+
+
+
+
+
Index: lams_tool_laqa/db/sql/all.sql
===================================================================
diff -u
--- lams_tool_laqa/db/sql/all.sql (revision 0)
+++ lams_tool_laqa/db/sql/all.sql (revision 16e844de3f7c34b44baee1b28e67e708f42d00bf)
@@ -0,0 +1,164 @@
+USE lams;
+
+DROP TABLE IF EXISTS lams.tool_laqa11_usr_resp;
+DROP TABLE IF EXISTS lams.tool_laqa11_que_usr;
+DROP TABLE IF EXISTS lams.tool_laqa11_que_content;
+DROP TABLE IF EXISTS lams.tool_laqa11_session;
+DROP TABLE IF EXISTS lams.tool_laqa11_content;
+
+
+CREATE TABLE lams.tl_laqa11_content (
+ qa_content_id BIGINT(20) NOT NULL
+ , title VARCHAR(100) DEFAULT 'Questions and Answers'
+ , instructions VARCHAR(255) DEFAULT 'Please, take a minute to answer the following questions.'
+ , creation_date DATE
+ , update_date DATE
+ , define_later TINYINT(1) NOT NULL DEFAULT 0
+ , username_visible TINYINT(1) NOT NULL DEFAULT 0
+ , report_title VARCHAR(100) DEFAULT 'Report'
+ , created_by BIGINT(20) NOT NULL DEFAULT 0
+ , synch_in_monitor TINYINT(1) NOT NULL DEFAULT 0
+ , offline_instructions VARCHAR(255) DEFAULT 'Please, take a minute to fill in offline instructions.'
+ , online_instructions VARCHAR(255) DEFAULT 'Please, take a minute to fill in online instructions.'
+ , PRIMARY KEY (qa_content_id)
+)TYPE=InnoDB;
+
+CREATE TABLE lams.tl_laqa11_session (
+ qa_session_id BIGINT(20) NOT NULL
+ , session_start_date DATE
+ , session_end_date DATE
+ , session_status VARCHAR(100)
+ , qa_content_id BIGINT(20) NOT NULL
+ , PRIMARY KEY (qa_session_id)
+ , INDEX (qa_content_id)
+ , CONSTRAINT FK_tool_lasr11_qa_session_1 FOREIGN KEY (qa_content_id)
+ REFERENCES lams.tl_laqa11_content (qa_content_id)
+)TYPE=InnoDB;
+
+CREATE TABLE lams.tl_laqa11_que_content (
+ qa_que_content_id BIGINT(20) NOT NULL
+ , question VARCHAR(255)
+ , display_order INT(5)
+ , qa_content_id BIGINT(20)
+ , PRIMARY KEY (qa_que_content_id)
+ , INDEX (qa_content_id)
+ , CONSTRAINT FK_tool_lasr11_qa_que_content_1 FOREIGN KEY (qa_content_id)
+ REFERENCES lams.tl_laqa11_content (qa_content_id)
+)TYPE=InnoDB;
+
+CREATE TABLE lams.tl_laqa11_que_usr (
+ que_usr_id BIGINT(20) NOT NULL
+ , username VARCHAR(100)
+ , qa_session_id BIGINT(20) NOT NULL
+ , qa_que_content_id BIGINT(20) NOT NULL
+ , fullname VARCHAR(100)
+ , PRIMARY KEY (que_usr_id)
+ , INDEX (qa_session_id)
+ , CONSTRAINT FK_tool_lasr11_qa_que_usr_1 FOREIGN KEY (qa_session_id)
+ REFERENCES lams.tl_laqa11_session (qa_session_id)
+ , INDEX (qa_que_content_id)
+ , CONSTRAINT FK_tool_lasr11_qa_que_usr_2 FOREIGN KEY (qa_que_content_id)
+ REFERENCES lams.tl_laqa11_que_content (qa_que_content_id)
+)TYPE=InnoDB;
+
+CREATE TABLE lams.tl_laqa11_usr_resp (
+ response_id BIGINT(20) NOT NULL
+ , answer VARCHAR(255)
+ , attempt_time DATE
+ , que_usr_id BIGINT(20)
+ , qa_que_content_id BIGINT(20) NOT NULL
+ , PRIMARY KEY (response_id)
+ , INDEX (que_usr_id)
+ , CONSTRAINT FK_tool_lasr11_qa_usr_resp_1 FOREIGN KEY (que_usr_id)
+ REFERENCES lams.tl_laqa11_que_usr (que_usr_id)
+ , INDEX (qa_que_content_id)
+ , CONSTRAINT FK_tool_lasr11_qa_usr_resp_3 FOREIGN KEY (qa_que_content_id)
+ REFERENCES lams.tl_laqa11_que_content (qa_que_content_id)
+)TYPE=InnoDB;
+
+
+
+INSERT INTO tl_laqa11_content (qa_content_id,
+ define_later,
+ username_visible,
+ synch_in_monitor)
+VALUES (10,
+ 1,
+ 1,
+ 1);
+
+
+
+-- test data for content questions table
+INSERT INTO tl_laqa11_que_content (qa_que_content_id,
+ question,
+ display_order,
+ qa_content_id) VALUES (20,'What is your name?',1,10);
+
+
+INSERT INTO tl_laqa11_que_content (qa_que_content_id,
+ question,
+ display_order,
+ qa_content_id) VALUES (21,'What is your favorite color?',2,10);
+
+
+INSERT INTO tl_laqa11_que_content (qa_que_content_id,
+ question,
+ display_order,
+ qa_content_id) VALUES (22,'Where were you born?',3,10);
+
+
+
+
+--test data for session table
+INSERT INTO tl_laqa11_session (qa_session_id,
+ session_start_date,
+ session_end_date,
+ qa_content_id)
+VALUES (101,
+ '2004-11-12T12:34:10',
+ '2005-12-12T12:14:10',
+ 10);
+
+
+
+
+
+--test data for user table
+INSERT INTO tl_laqa11_que_usr (que_usr_id,
+ username,
+ qa_session_id,
+ qa_que_content_id,
+ fullname)
+VALUES (500,'ozgurd',101, 20,'Ozgur Demirtas');
+
+
+INSERT INTO tl_laqa11_que_usr (que_usr_id,
+ username,
+ qa_session_id,
+ qa_que_content_id,
+ fullname)
+VALUES (600,'admin',101, 20,'Mr Admin');
+
+
+--test date for user responses table
+INSERT INTO tl_laqa11_usr_resp (response_id,
+ answer,
+ attempt_time,
+ que_usr_id,
+ qa_que_content_id)
+VALUES (5000,'my name is michael','2004-11-12T12:34:10',500,20);
+
+
+INSERT INTO tl_laqa11_usr_resp (response_id,
+ answer,
+ attempt_time,
+ que_usr_id,
+ qa_que_content_id)
+VALUES (5001,'my favorite color is blue','2004-12-12T12:34:10',500,21);
+
+
+
+
+
+
Index: lams_tool_laqa/db/sql/create_lams_tool_qa.sql
===================================================================
diff -u
--- lams_tool_laqa/db/sql/create_lams_tool_qa.sql (revision 0)
+++ lams_tool_laqa/db/sql/create_lams_tool_qa.sql (revision 16e844de3f7c34b44baee1b28e67e708f42d00bf)
@@ -0,0 +1,72 @@
+CREATE TABLE lams.tl_laqa11_content (
+ qa_content_id BIGINT(20) NOT NULL
+ , title VARCHAR(100) DEFAULT 'Questions and Answers'
+ , instructions VARCHAR(255) DEFAULT 'Please, take a minute to answer the following questions.'
+ , creation_date VARCHAR(100)
+ , update_date DATETIME
+ , questions_sequenced TINYINT(1) NOT NULL
+ , username_visible TINYINT(1) NOT NULL DEFAULT 0
+ , monitoring_report_title VARCHAR(100) DEFAULT 'Combined Learner Results'
+ , report_title VARCHAR(100) DEFAULT 'Report'
+ , created_by BIGINT(20) NOT NULL DEFAULT 0
+ , run_offline TINYINT(1) DEFAULT 0
+ , define_later TINYINT(1) NOT NULL DEFAULT 0
+ , synch_in_monitor TINYINT(1) NOT NULL DEFAULT 0
+ , offline_instructions VARCHAR(255) DEFAULT 'Please, take a minute to fill in offline instructions.'
+ , online_instructions VARCHAR(255) DEFAULT 'Please, take a minute to fill in online instructions.'
+ , end_learning_message VARCHAR(150) DEFAULT 'Thank you for taking this activity!'
+ , qa_session_id BIGINT(20) NOT NULL
+ , content_locked TINYINT(1) DEFAULT 0
+ , PRIMARY KEY (qa_content_id)
+)TYPE=InnoDB;
+
+CREATE TABLE lams.tl_laqa11_session (
+ qa_session_id BIGINT(20) NOT NULL
+ , session_start_date DATETIME
+ , session_end_date DATETIME
+ , session_status VARCHAR(100)
+ , qa_content_id BIGINT(20) NOT NULL
+ , PRIMARY KEY (qa_session_id)
+ , INDEX (qa_content_id)
+ , CONSTRAINT FK_tl_laqa11_session_1 FOREIGN KEY (qa_content_id)
+ REFERENCES lams.tl_laqa11_content (qa_content_id)
+)TYPE=InnoDB;
+
+CREATE TABLE lams.tl_laqa11_que_usr (
+ que_usr_id BIGINT(20) NOT NULL
+ , username VARCHAR(100)
+ , qa_session_id BIGINT(20) NOT NULL
+ , fullname VARCHAR(100)
+ , PRIMARY KEY (que_usr_id)
+ , INDEX (qa_session_id)
+ , CONSTRAINT FK_tl_laqa11_que_usr_2 FOREIGN KEY (qa_session_id)
+ REFERENCES lams.tl_laqa11_session (qa_session_id)
+)TYPE=InnoDB;
+
+CREATE TABLE lams.tl_laqa11_que_content (
+ qa_que_content_id BIGINT(20) NOT NULL
+ , question VARCHAR(255)
+ , display_order INT(5)
+ , qa_content_id BIGINT(20) NOT NULL
+ , PRIMARY KEY (qa_que_content_id)
+ , INDEX (qa_content_id)
+ , CONSTRAINT FK_tl_laqa11_que_content_1 FOREIGN KEY (qa_content_id)
+ REFERENCES lams.tl_laqa11_content (qa_content_id)
+)TYPE=InnoDB;
+
+CREATE TABLE lams.tl_laqa11_usr_resp (
+ response_id BIGINT(20) NOT NULL
+ , hidden TINYINT(1) DEFAULT 0
+ , answer VARCHAR(255)
+ , attempt_time DATETIME
+ , que_usr_id BIGINT(20) NOT NULL
+ , qa_que_content_id BIGINT(20) NOT NULL
+ , PRIMARY KEY (response_id)
+ , INDEX (qa_que_content_id)
+ , CONSTRAINT FK_tl_laqa11_usr_resp_2 FOREIGN KEY (qa_que_content_id)
+ REFERENCES lams.tl_laqa11_que_content (qa_que_content_id)
+ , INDEX (que_usr_id)
+ , CONSTRAINT FK_tl_laqa11_usr_resp_3 FOREIGN KEY (que_usr_id)
+ REFERENCES lams.tl_laqa11_que_usr (que_usr_id)
+)TYPE=InnoDB;
+
Index: lams_tool_laqa/db/sql/drop_lams_tool_qa.sql
===================================================================
diff -u
--- lams_tool_laqa/db/sql/drop_lams_tool_qa.sql (revision 0)
+++ lams_tool_laqa/db/sql/drop_lams_tool_qa.sql (revision 16e844de3f7c34b44baee1b28e67e708f42d00bf)
@@ -0,0 +1,7 @@
+
+DROP TABLE IF EXISTS lams.tl_laqa11_usr_resp;
+DROP TABLE IF EXISTS lams.tl_laqa11_que_usr;
+DROP TABLE IF EXISTS lams.tl_laqa11_que_content;
+DROP TABLE IF EXISTS lams.tl_laqa11_session;
+DROP TABLE IF EXISTS lams.tl_laqa11_content;
+
Index: lams_tool_laqa/db/sql/insert_tool_qa_data.sql
===================================================================
diff -u
--- lams_tool_laqa/db/sql/insert_tool_qa_data.sql (revision 0)
+++ lams_tool_laqa/db/sql/insert_tool_qa_data.sql (revision 16e844de3f7c34b44baee1b28e67e708f42d00bf)
@@ -0,0 +1,20 @@
+
+-- test data for content table
+-- test data for content table
+INSERT INTO tl_laqa11_content (qa_content_id,
+ creation_date
+ )
+VALUES (10,
+ NOW());
+
+
+
+-- test data for content questions table
+INSERT INTO tl_laqa11_que_content (qa_que_content_id,
+ question,
+ display_order,
+ qa_content_id) VALUES (20,'What is the capital of Uruguay?',1,10);
+
+
+
+
Index: lams_tool_laqa/db/sql/original-insert_tool_qa_data.sql
===================================================================
diff -u
--- lams_tool_laqa/db/sql/original-insert_tool_qa_data.sql (revision 0)
+++ lams_tool_laqa/db/sql/original-insert_tool_qa_data.sql (revision 16e844de3f7c34b44baee1b28e67e708f42d00bf)
@@ -0,0 +1,86 @@
+
+-- test data for content table
+-- test data for content table
+INSERT INTO tl_laqa11_content (qa_content_id,
+ define_later,
+ questions_sequenced,
+ username_visible,
+ synch_in_monitor,
+ force_offline,
+ creation_date
+ )
+VALUES (10,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ NOW());
+
+
+
+-- test data for content questions table
+INSERT INTO tl_laqa11_que_content (qa_que_content_id,
+ question,
+ display_order,
+ qa_content_id) VALUES (20,'What is the capital of Uruguay?',1,10);
+
+
+INSERT INTO tl_laqa11_que_content (qa_que_content_id,
+ question,
+ display_order,
+ qa_content_id) VALUES (21,'What is your favorite color?',2,10);
+
+
+INSERT INTO tl_laqa11_que_content (qa_que_content_id,
+ question,
+ display_order,
+ qa_content_id) VALUES (22,'Where were you born?',3,10);
+
+
+
+
+--test data for session table
+INSERT INTO tl_laqa11_session (qa_session_id,
+ session_start_date,
+ session_end_date,
+ qa_content_id)
+VALUES (101,
+ '2004-11-12T12:34:10',
+ '2005-12-12T12:14:10',
+ 10);
+
+
+INSERT INTO tl_laqa11_que_usr (que_usr_id,
+ username,
+ qa_session_id,
+ qa_que_content_id,
+ fullname)
+VALUES (500,'ozgurd',101, 20,'Ozgur Demirtas');
+
+
+INSERT INTO tl_laqa11_que_usr (que_usr_id,
+ username,
+ qa_session_id,
+ qa_que_content_id,
+ fullname)
+VALUES (600,'admin',101, 20,'Mr Admin');
+
+
+--test date for user responses table
+INSERT INTO tl_laqa11_usr_resp (response_id,
+ answer,
+ attempt_time,
+ que_usr_id,
+ qa_que_content_id)
+VALUES (5000,'my name is michael','2004-11-12T12:34:10',500,20);
+
+
+INSERT INTO tl_laqa11_usr_resp (response_id,
+ answer,
+ attempt_time,
+ que_usr_id,
+ qa_que_content_id)
+VALUES (5001,'my favorite color is blue','2004-12-12T12:34:10',500,21);
+
+
Index: lams_tool_laqa/ext-lib/j2ee.jar
===================================================================
diff -u
Binary files differ
Index: lams_tool_laqa/ext-lib/log4j-1.2.9.jar
===================================================================
diff -u
Binary files differ
Index: lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/Nullable.java
===================================================================
diff -u
--- lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/Nullable.java (revision 0)
+++ lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/Nullable.java (revision 16e844de3f7c34b44baee1b28e67e708f42d00bf)
@@ -0,0 +1,39 @@
+/*
+ *Copyright (C) 2005 LAMS Foundation (http://lamsfoundation.org)
+ *
+ *This program is free software; you can redistribute it and/or modify
+ *it under the terms of the GNU General Public License as published by
+ *the Free Software Foundation; either version 2 of the License, or
+ *(at your option) any later version.
+ *
+ *This program is distributed in the hope that it will be useful,
+ *but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ *GNU General Public License for more details.
+ *
+ *You should have received a copy of the GNU General Public License
+ *along with this program; if not, write to the Free Software
+ *Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
+ *USA
+ *
+ *http://www.gnu.org/licenses/gpl.txt
+ */
+package org.lamsfoundation.lams.tool.qa;
+
+
+/**
+ * Null Object pattern. This interface is defined to avoid the use of NULL.
+ * The domain object that allows NULL as return value should implement this
+ * interface.
+ *
+ * @author ozgurd
+ *
+ */
+public interface Nullable
+{
+ /**
+ * contract to indicate whether current object is null.
+ * @return
+ */
+ public boolean isNull();
+}
Index: lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/QaAppConstants.java
===================================================================
diff -u
--- lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/QaAppConstants.java (revision 0)
+++ lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/QaAppConstants.java (revision 16e844de3f7c34b44baee1b28e67e708f42d00bf)
@@ -0,0 +1,243 @@
+/**
+ * Created on 20/04/2005
+ *
+ * TODO To change the template for this generated file go to
+ * Window - Preferences - Java - Code Style - Code Templates
+ */
+package org.lamsfoundation.lams.tool.qa;
+
+/**
+ * @author ozgurd
+ *
+ * TODO: Check back the constants with "Attention"
+ * Holds constants used throughout the application
+ *
+ */
+public interface QaAppConstants {
+ /**
+ * Currently we are hardcoding the default content id.
+ * This will be replaced when the deploy logic automatically assigns a default content id in the deploy script.
+ */
+ public static final long DEFAULT_CONTENT_ID =10;
+ public static final long DEFAULT_QUE_CONTENT_ID =20;
+
+ /**
+ * temporarily refers to an existing content id for an incoming tool session id, won't need it in deployment environment
+ */
+ public static final long THE_MOCKED_CONTENT_ID =1803739427456570536L;
+ public static final String TOOL_SERVICE ="tool_service";
+ /**
+ * indicates which mode the tool runs under between Authoring, Learning, Monitoring
+ */
+ public static final String TARGET_MODE ="targetMode";
+ public static final String TARGET_MODE_AUTHORING ="Authoring";
+ public static final String TARGET_MODE_LEARNING ="Learning";
+ public static final String TARGET_MODE_MONITORING ="Monitoring";
+
+ public static final String AUTHORING_STARTER ="starter";
+ public static final String LEARNING_STARTER ="learningStarter";
+ public static final String MONITORING_STARTER ="monitoringStarter";
+
+ /**
+ * Mock constants below are temporary until the tool gets a User object from the container.
+ */
+ public static final Integer MOCK_USER_ID = new Integer(111);
+ public static final String MOCK_USER_NAME ="Ozgur";
+ public static final String MOCK_USER_LASTNAME ="Demirtas";
+ public static final String MOCK_LOGIN_NAME ="ozgur";
+
+ /**
+ * refers to number of questions presented initially, we have a single record for default content
+ */
+ public static final Long INITIAL_QUESTION_COUNT =new Long(1);
+
+ /**
+ * Struts level constants
+ */
+ public static final String LOAD ="load";
+ public static final String LOAD_QUESTIONS ="load";
+ public static final String LOAD_STARTER ="starter";
+ public static final String AUTHORING_BASIC ="authoringBasic";
+ public static final boolean MODE_OPTIONAL = false;
+ public static final String DISABLE_TOOL ="disabled";
+ public static final String IS_DEFINE_LATER ="isDefineLater";
+
+ /**
+ * authoring mode controllers
+ */
+ public static final String IS_ADD_QUESTION ="isAddQuestion";
+ public static final String IS_REMOVE_QUESTION ="isRemoveQuestion";
+ public static final String IS_REMOVE_CONTENT ="isRemoveContent";
+
+ /**
+ * tab controllers, constants for authoring page html tabs, used within jsp
+ */
+ public static final String CHOICE ="choice";
+ public static final String CHOICE_TYPE_BASIC ="choiceTypeBasic";
+ public static final String CHOICE_TYPE_ADVANCED ="choiceTypeAdvanced";
+ public static final String CHOICE_TYPE_INSTRUCTIONS ="choiceTypeInstructions";
+
+
+ /**
+ * authoring mode constants
+ */
+ public static final String MAP_QUESTION_CONTENT ="mapQuestionContent";
+ public static final String DEFAULT_QUESTION_CONTENT ="defaultQuestionContent";
+ public static final String TITLE ="title";
+ public static final String INSTRUCTIONS ="instructions";
+ public static final String CREATION_DATE ="creationDate";
+ public static final String USERNAME_VISIBLE ="usernameVisible";
+ public static final String ONLINE_INSTRUCTIONS ="onlineInstructions";
+ public static final String OFFLINE_INSTRUCTIONS ="offlineInstructions";
+ public static final String END_LEARNING_MESSSAGE ="endLearningMessage";
+ public static final String CONTENT_LOCKED ="contentLocked";
+ public static final String ON ="ON";
+ public static final String OFF ="OFF";
+ public static final String IS_USERNAME_VISIBLE_MONITORING ="isUsernameVisibleMonitoring";
+ public static final String IS_SYNCH_INMONITOR_MONITORING ="isSynchInMonitorMonitoring";
+ public static final String IS_QUESTIONS_SEQUENCED_MONITORING ="isQuestionsSequencedMonitoring";
+ public static final String USER_ID ="userId";
+
+
+ /**
+ * the author's current content id
+ */
+ public static final String TOOL_CONTENT_ID ="toolContentId";
+
+ /**
+ * the learner or monitoring environment provides toolSessionId
+ */
+ public static final String TOOL_SESSION_ID ="toolSessionId";
+ public final long ONE_DAY =60 * 60 * 1000 * 24;
+ public final static String NOT_ATTEMPTED ="NOT_ATTEMPTED";
+ public final static String INCOMPLETE ="INCOMPLETE";
+ public static final String COMPLETED ="COMPLETED";
+
+ public static final String MAP_TOOL_SESSIONS ="mapToolSessions";
+ public static final String RESPONSE_INDEX ="responseIndex";
+ public static final Integer MAX_TOOL_SESSION_COUNT =new Integer(500);
+ public static final String IS_TOOL_SESSION_CHANGED ="isToolSessionChanged";
+ public static final String USER_EXCEPTION_WRONG_FORMAT ="userExceptionWrongFormat";
+ public static final String USER_EXCEPTION_UNCOMPATIBLE_IDS ="userExceptionUncompatibleIds";
+ public static final String USER_EXCEPTION_NUMBERFORMAT ="userExceptionNumberFormat";
+ public static final String USER_EXCEPTION_CONTENT_DOESNOTEXIST ="userExceptionContentDoesNotExist";
+ public static final String USER_EXCEPTION_TOOLSESSION_DOESNOTEXIST ="userExceptionToolSessionDoesNotExist";
+ public static final String USER_EXCEPTION_CONTENTID_REQUIRED ="userExceptionContentIdRequired";
+ public static final String USER_EXCEPTION_TOOLSESSIONID_REQUIRED ="userExceptionToolSessionIdRequired";
+ public static final String USER_EXCEPTION_DEFAULTCONTENT_NOT_AVAILABLE ="userExceptionDefaultContentNotAvailable";
+ public static final String USER_EXCEPTION_DEFAULTQUESTIONCONTENT_NOT_AVAILABLE ="userExceptionDefaultQuestionContentNotAvailable";
+ public static final String USER_EXCEPTION_USERID_NOTAVAILABLE ="userExceptionUserIdNotAvailable";
+ public static final String USER_EXCEPTION_USERID_NOTNUMERIC ="userExceptionUserIdNotNumeric";
+ public static final String USER_EXCEPTION_ONLYCONTENT_ANDNOSESSIONS ="userExceptionOnlyContentAndNoSessions";
+ public static final String USER_EXCEPTION_USERID_EXISTING ="userExceptionUserIdExisting";
+ public static final String USER_EXCEPTION_MONITORINGTAB_CONTENTID_REQUIRED ="userExceptionMonitoringTabContentIdRequired";
+
+
+ /**
+ * user actions
+ */
+ public static final String ADD_NEW_QUESTION ="addNewQuestion";
+ public static final String REMOVE_QUESTION ="removeQuestion";
+ public static final String REMOVE_ALL_CONTENT ="removeAllContent";
+ public static final String SUBMIT_ALL_CONTENT ="submitAllContent";
+ public static final String SUBMIT_TAB_DONE ="submitTabDone";
+
+ public static final String OPTION_OFF ="false";
+
+ //LEARNER mode contants
+ public static final String MAP_QUESTION_CONTENT_LEARNER ="mapQuestionContentLearner";
+ public static final String CURRENT_QUESTION_INDEX ="currentQuestionIndex";
+ public static final String TOTAL_QUESTION_COUNT ="totalQuestionCount";
+ public static final String MAP_ANSWERS ="mapAnswers";
+ public static final String CURRENT_ANSWER ="currentAnswer";
+ public static final String USER_FEEDBACK ="userFeedback";
+ public static final String REPORT_TITLE ="reportTitle";
+ public static final String MONITORING_REPORT_TITLE ="monitoringReportTitle";
+ public static final String REPORT_TITLE_LEARNER ="reportTitleLearner";
+ public static final String END_LEARNING_MESSAGE ="endLearningMessage";
+ public static final String IS_TOOL_ACTIVITY_OFFLINE ="isToolActivityOnline";
+ public static final String IS_USERNAME_VISIBLE ="isUsernameVisible";
+ public static final String IS_ALL_SESSIONS_COMPLETED ="isAllSessionsCompleted";
+ public static final String CHECK_ALL_SESSIONS_COMPLETED ="checkAllSessionsCompleted";
+ public static final String FROM_TOOL_CONTENT_ID ="fromToolContentId";
+ public static final String TO_TOOL_CONTENT_ID ="toToolContentId";
+ public static final String LEARNER_REPORT ="learnerReport";
+ public static final String MAP_USER_RESPONSES ="mapUserResponses";
+ public static final String MAP_MAIN_REPORT ="mapMainReport";
+ public static final String MAP_STATS ="mapStats";
+
+
+ /**
+ * Monitoring Mode constants
+ */
+ public static final String REPORT_TITLE_MONITOR ="reportTitleMonitor";
+ public static final String MONITOR_USER_ID ="userId";
+ public static final String MONITORING_REPORT ="monitoringReport";
+ public static final String MONITORING_ERROR ="monitoringError";
+ public static final String MAP_MONITORING_QUESTIONS ="mapMonitoringQuestions";
+ public static final String SUMMARY_TOOL_SESSIONS ="summaryToolSessions";
+ public static final String CURRENT_MONITORED_TOOL_SESSION ="currentMonitoredToolSession";
+ public static final String CHOICE_MONITORING ="choiceMonitoring";
+ public static final String CHOICE_TYPE_MONITORING_SUMMARY ="choiceTypeMonitoringSummary";
+ public static final String CHOICE_TYPE_MONITORING_INSTRUCTIONS ="choiceTypeMonitoringInstructions";
+ public static final String CHOICE_TYPE_MONITORING_EDITACTIVITY ="choiceTypeMonitoringEditActivity";
+ public static final String CHOICE_TYPE_MONITORING_STATS ="choiceTypeMonitoringStats";
+ public static final String MONITORING_INSTRUCTIONS_VISITED ="monitoringInstructionsVisited";
+ public static final String MONITORING_EDITACTIVITY_VISITED ="monitoringEditActivityVisited";
+ public static final String MONITORING_STATS_VISITED ="monitoringStatsVisited";
+ public static final String DATAMAP_EDITABLE ="dataMapEditable";
+ public static final String DATAMAP_EDITABLE_RESPONSE_ID ="dataMapEditableResponseId";
+ public static final String DATAMAP_HIDDEN_RESPONSE_ID ="dataMapHiddenResponseId";
+ public static final String MONITORED_CONTENT_ID ="monitoredContentId";
+ public static final String START_MONITORING_SUMMARY_REQUEST ="startMonitoringSummaryRequest";
+ public static final String STOP_RENDERING_QUESTIONS ="stopRenderingQuestions";
+ public static final String EDITACTIVITY_EDITMODE ="editActivityEditMode";
+ public static final String FORM_INDEX ="formIndex";
+ public static final String RENDER_MONITORING_EDITACTIVITY ="renderMonitoringEditActivity";
+ public static final String NO_AVAILABLE_SESSIONS ="noAvailableSessions";
+ public static final String INITIAL_MONITORING_TOOL_CONTENT_ID ="initialMonitoringToolContentId";
+ public static final String IS_MONITORING_DEFINE_LATER ="isMonitoringDefineLater";
+ public static final String NO_TOOL_SESSIONS_AVAILABLE ="noToolSessionAvailable";
+
+ public static final String MONITORED_OFFLINE_INSTRUCTIONS ="monitoredOfflineInstructions";
+ public static final String MONITORED_ONLINE_INSTRUCTIONS ="monitoredOnlineInstructions";
+ public static final String MONITORING_INSTRUCTIONS_UPDATE_MESSAGE ="monitoringInstructionsUpdateMessage";
+
+ /**
+ * Monitor and Learning common constants - used in jsp reporting
+ */
+ public static final String FULLNAME ="fullName";
+ public static final String ANSWER ="answer";
+ public static final String ATIME ="aTime";
+ public static final String RESPONSE_ID ="responseId";
+ public static final String RESPONSE_HIDDEN ="responseHidden";
+ public static final String CURRENTLEARNER_FULLNAME ="currentLearnerFullname";
+ public static final String ATTR_USERDATA ="qa_user";
+ /**
+ * following tell whether author prefers to have the questions listed all in one page or listed sequentially. The default is all in one page.
+ */
+ public static final String QUESTION_LISTING_MODE ="questionListingMode";
+ public static final String QUESTION_LISTING_MODE_SEQUENTIAL ="questionListingModeSequential";
+ public static final String QUESTION_LISTING_MODE_COMBINED ="questionListingModeCombined";
+
+ public static final String FEEDBACK_TYPE_SEQUENTIAL ="You will be presented a total of : ";
+ public static final String FEEDBACK_TYPE_COMBINED ="You are being presented a total of : ";
+ public static final String QUESTIONS =" questions.";
+ /**
+ * refers to current tool user whether an author or a learner
+ */
+ public static final String TOOL_USER ="toolUser";
+ /**
+ * these indicate current user's reporting data
+ */
+ public static final String CURRENT_TOOL_USER_FULLNAME ="currentToolUserFullname";
+ public static final String CURRENT_TOOL_USER_ATTEMPTTIME ="currentToolUserAttemptTime";
+ public static final String CURRENT_TOOL_USER_ANSWER ="currentToolUserAnswer";
+
+ /**
+ * constants redundant for the moment
+ */
+ public static final String DISPLAY_QUESTIONS ="display";
+ public static final String SUBMIT_QUESTIONS ="submit";
+ public static final String VIEW_INDIVIDUAL_SUMMARY ="view";
+}
Index: lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/QaApplicationException.java
===================================================================
diff -u
--- lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/QaApplicationException.java (revision 0)
+++ lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/QaApplicationException.java (revision 16e844de3f7c34b44baee1b28e67e708f42d00bf)
@@ -0,0 +1,71 @@
+/*
+ *Copyright (C) 2005 LAMS Foundation (http://lamsfoundation.org)
+ *
+ *This program is free software; you can redistribute it and/or modify
+ *it under the terms of the GNU General Public License as published by
+ *the Free Software Foundation; either version 2 of the License, or
+ *(at your option) any later version.
+ *
+ *This program is distributed in the hope that it will be useful,
+ *but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ *GNU General Public License for more details.
+ *
+ *You should have received a copy of the GNU General Public License
+ *along with this program; if not, write to the Free Software
+ *Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
+ *USA
+ *
+ *http://www.gnu.org/licenses/gpl.txt
+ */
+package org.lamsfoundation.lams.tool.qa;
+
+
+/**
+ *
This exception wraps all basic exception occured in the qa tool. It is
+ * not suppose to be try and catched in any level. The struts should be taking
+ * care of handling this exception.
+ *
+ * @author ozgurd
+ *
+ */
+public class QaApplicationException extends RuntimeException
+{
+ /**
+ * Default Constructor
+ */
+ public QaApplicationException()
+ {
+ super();
+ }
+
+ /**
+ * Constructor for customized error message
+ * @param message
+ */
+ public QaApplicationException(String message)
+ {
+ super(message);
+ }
+
+ /**
+ * Constructor for wrapping the throwable object
+ * @param cause
+ */
+ public QaApplicationException(Throwable cause)
+ {
+ super(cause);
+ }
+
+ /**
+ * Constructor for wrapping both the customized error message and
+ * throwable exception object.
+ * @param message
+ * @param cause
+ */
+ public QaApplicationException(String message, Throwable cause)
+ {
+ super(message, cause);
+ }
+
+}
Index: lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/QaComparator.java
===================================================================
diff -u
--- lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/QaComparator.java (revision 0)
+++ lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/QaComparator.java (revision 16e844de3f7c34b44baee1b28e67e708f42d00bf)
@@ -0,0 +1,43 @@
+/*
+ * Created on 20/04/2005
+ *
+ * TODO To change the template for this generated file go to
+ * Window - Preferences - Java - Code Style - Code Templates
+ */
+package org.lamsfoundation.lams.tool.qa;
+
+import java.io.Serializable;
+import java.util.Comparator;
+
+import org.apache.log4j.Logger;
+
+/**
+ * @author ozgurd
+ *
+ * TODO To change the template for this generated type comment go to
+ * Window - Preferences - Java - Code Style - Code Templates
+ */
+
+/**
+ * A comparator implementation that can be used as a constructor to collections.
+ * The TreeMap in the web layer makes use of it.
+ *
+ */
+public class QaComparator implements Comparator, Serializable {
+ static Logger logger = Logger.getLogger(QaComparator.class.getName());
+
+ public int compare(Object o1, Object o2) {
+ String s1 = (String)o1;
+ String s2 = (String)o2;
+
+ int key1=new Long(s1).intValue();
+ int key2=new Long(s2).intValue();
+ //logger.debug(logger + " " + this.getClass().getName() + "comparing key1 and key2:" + key1 + " and " + key2);
+ return key1 - key2;
+ }
+
+ public boolean equals(Object o) {
+ String s = (String)o;
+ return compare(this, o)==0;
+ }
+}
Index: lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/QaConstants.java
===================================================================
diff -u
--- lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/QaConstants.java (revision 0)
+++ lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/QaConstants.java (revision 16e844de3f7c34b44baee1b28e67e708f42d00bf)
@@ -0,0 +1,59 @@
+/*
+ *Copyright (C) 2005 LAMS Foundation (http://lamsfoundation.org)
+ *
+ *This program is free software; you can redistribute it and/or modify
+ *it under the terms of the GNU General Public License as published by
+ *the Free Software Foundation; either version 2 of the License, or
+ *(at your option) any later version.
+ *
+ *This program is distributed in the hope that it will be useful,
+ *but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ *GNU General Public License for more details.
+ *
+ *You should have received a copy of the GNU General Public License
+ *along with this program; if not, write to the Free Software
+ *Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
+ *USA
+ *
+ *http://www.gnu.org/licenses/gpl.txt
+ */
+package org.lamsfoundation.lams.tool.qa;
+
+
+/**
+ * This is a constant utility class that defines all constants that needs to be
+ * shared around the qa tool.
+ *
+ * @author ozgurd
+ *
+ */
+
+/**
+ * This class could be redundant soon and be replaced by QaAppConstants.
+ * Defines application level constants
+ */
+public class QaConstants
+{
+ /**
+ * Private Construtor to avoid instantiation.
+ */
+ private QaConstants(){}
+
+ /*Currently we are hardcoDing the default content id.
+ * This will be replaced when the deploy logic automatically assigns a default content id in the deploy script.
+ */
+ public static final long DEFAULT_CONTENT_ID = 10;
+
+ public static final int NOT_SHOWN = -1;
+ public static final String OPEN_RESPONSE = "Open response";
+
+ //-------------------Question Type------------------------//
+ /*
+ public static final String SIMPLE_CHOICE="simpleChoice";
+ public static final String MULTIPLE_CHOICE="choiceMultiple";
+ public static final String TEXT_ENTRY="textEntry";
+ */
+ public static final int NOT_SHOWN_CANDIDATE_ANSWER_ORDER = -1;
+
+}
Index: lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/QaContent.hbm.xml
===================================================================
diff -u
--- lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/QaContent.hbm.xml (revision 0)
+++ lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/QaContent.hbm.xml (revision 16e844de3f7c34b44baee1b28e67e708f42d00bf)
@@ -0,0 +1,229 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Index: lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/QaContent.java
===================================================================
diff -u
--- lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/QaContent.java (revision 0)
+++ lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/QaContent.java (revision 16e844de3f7c34b44baee1b28e67e708f42d00bf)
@@ -0,0 +1,484 @@
+package org.lamsfoundation.lams.tool.qa;
+import java.io.Serializable;
+import java.util.Date;
+import java.util.Iterator;
+import java.util.Set;
+import java.util.TreeSet;
+
+import org.apache.commons.lang.builder.EqualsBuilder;
+import org.apache.commons.lang.builder.HashCodeBuilder;
+import org.apache.commons.lang.builder.ToStringBuilder;
+import org.apache.log4j.Logger;
+import org.lamsfoundation.lams.tool.qa.QaQueContent;
+
+
+/**
+ * @author ozgurd
+ *
+ * TODO To change the template for this generated type comment go to
+ * Window - Preferences - Java - Code Style - Code Templates
+ */
+
+/**
+ * QaContent Value Object
+ * The value object that maps to our model database table: tl_laqa11_content
+ * The relevant hibernate mapping resides in: QaContent.hbm.xml
+ *
+ * Holds content representation for the tool.
+ * Default content is made available to the tool by the database.
+ */
+public class QaContent implements Serializable {
+ static Logger logger = Logger.getLogger(QaContent.class.getName());
+
+ /** identifier field */
+ private Long qaContentId;
+
+ /** nullable persistent field */
+ private String title;
+
+ /** nullable persistent field */
+ private String instructions;
+
+ /** nullable persistent field */
+ private String reportTitle;
+
+ /** nullable persistent field */
+ private String monitoringReportTitle;
+
+ /** nullable persistent field */
+ private String offlineInstructions;
+
+ /** nullable persistent field */
+ private String onlineInstructions;
+
+ /** nullable persistent field */
+ private long createdBy;
+
+ /** nullable persistent field */
+ private boolean defineLater;
+
+ /** nullable persistent field */
+ private boolean runOffline;
+
+ private boolean questionsSequenced;
+
+ /** nullable persistent field */
+ private boolean usernameVisible;
+
+ /** nullable persistent field */
+ private boolean synchInMonitor;
+
+ /** nullable persistent field */
+ private boolean contentLocked;
+
+ /** nullable persistent field */
+ private String endLearningMessage;
+
+ /** nullable persistent field */
+ private String creationDate;
+
+ /** nullable persistent field */
+ private Date updateDate;
+
+ /** persistent field */
+ private Set qaQueContents;
+
+ /** persistent field */
+ private Set qaSessions;
+
+
+ /** default constructor */
+ public QaContent()
+ {
+ logger.debug(logger + " " + this.getClass().getName() + "in constructor: QaContent()");
+ }
+
+
+ /** full constructor */
+ public QaContent(Long qaContentId,
+ String title,
+ String instructions,
+ String reportTitle,
+ String monitoringReportTitle,
+ String offlineInstructions,
+ String onlineInstructions,
+ String endLearningMessage,
+ long createdBy,
+ boolean defineLater,
+ boolean runOffline,
+ boolean questionsSequenced,
+ boolean usernameVisible,
+ boolean synchInMonitor,
+ boolean contentLocked,
+ String creationDate,
+ Date updateDate,
+ Set qaQueContents,
+ Set qaSessions)
+ {
+ this.qaContentId = qaContentId;
+ this.title = title;
+ this.instructions = instructions;
+ this.reportTitle = reportTitle;
+ this.monitoringReportTitle=monitoringReportTitle;
+ this.offlineInstructions = offlineInstructions;
+ this.onlineInstructions = onlineInstructions;
+ this.endLearningMessage = endLearningMessage;
+ this.createdBy = createdBy;
+ this.defineLater = defineLater;
+ this.runOffline = runOffline;
+ this.questionsSequenced = questionsSequenced;
+ this.usernameVisible = usernameVisible;
+ this.synchInMonitor = synchInMonitor;
+ this.contentLocked =contentLocked;
+ this.creationDate = creationDate;
+ this.updateDate = updateDate;
+ this.qaQueContents = qaQueContents;
+ this.qaSessions = qaSessions;
+ logger.debug(logger + " " + this.getClass().getName() + "in full constructor: QaContent()");
+ }
+
+ /**
+ * Copy Construtor to create a new qa content instance. Note that we
+ * don't copy the qa session data here because the qa session
+ * will be created after we copied tool content.
+ * @param qa the original qa content.
+ * @param newContentId the new qa content id.
+ * @return the new qa content object.
+ */
+ public static QaContent newInstance(QaContent qa,
+ Long newContentId)
+ {
+ QaContent newContent = new QaContent(newContentId,
+ qa.getTitle(),
+ qa.getInstructions(),
+ qa.getReportTitle(),
+ qa.getMonitoringReportTitle(),
+ qa.getOfflineInstructions(),
+ qa.getOnlineInstructions(),
+ qa.getEndLearningMessage(),
+ qa.getCreatedBy(),
+ qa.isDefineLater(),
+ qa.isRunOffline(),
+ qa.isQuestionsSequenced(),
+ qa.isUsernameVisible(),
+ qa.isSynchInMonitor(),
+ qa.isContentLocked(),
+ qa.getCreationDate(),
+ qa.getUpdateDate(),
+ new TreeSet(),
+ new TreeSet());
+ logger.debug(logger + " " + "QaContent" + " " + "before doing deepCopyQaQueContent");
+ newContent.setQaQueContents(qa.deepCopyQaQueContent(newContent));
+ logger.debug(logger + " " + "QaContent" + " " + "after doing deepCopyQaQueContent");
+ return newContent;
+ }
+
+
+ //part of the contract: make sure that this works!
+ public Set deepCopyQaQueContent(QaContent newQaContent)
+ {
+ logger.debug(logger + " " + "QaContent" + " " + "start of deepCopyQaQueContent");
+ Set newQaQueContent = new TreeSet();
+ for (Iterator i = this.getQaQueContents().iterator(); i.hasNext();)
+ {
+ QaQueContent queContent = (QaQueContent) i.next();
+ newQaQueContent.add(QaQueContent.newInstance(queContent,
+ newQaContent,
+ null));
+ }
+ logger.debug(logger + " " + "QaContent" + " " + "returning newQaQueContent: " + newQaQueContent);
+ return newQaQueContent;
+ }
+
+
+
+
+ public Set deepCopyQaSession(QaContent newQaSession)
+ {
+ return new TreeSet();
+ }
+
+
+ public Set getQaQueContents()
+ {
+ if (this.qaQueContents == null)
+ setQaQueContents(new TreeSet());
+ return this.qaQueContents;
+ }
+
+ public void setQaQueContents(Set qaQueContents)
+ {
+ this.qaQueContents = qaQueContents;
+ }
+
+ public Set getQaSessions()
+ {
+ if (this.qaSessions == null)
+ setQaSessions(new TreeSet());
+ return this.qaSessions;
+ }
+
+ public void setQaSessions(Set qaSessions)
+ {
+ this.qaSessions = qaSessions;
+ }
+
+
+ /**
+ * @return Returns the qaContentId.
+ */
+ public Long getQaContentId() {
+ return qaContentId;
+ }
+ /**
+ * @param qaContentId The qaContentId to set.
+ */
+ public void setQaContentId(Long qaContentId) {
+ this.qaContentId = qaContentId;
+ }
+ /**
+ * @return Returns the title.
+ */
+ public String getTitle() {
+ return title;
+ }
+ /**
+ * @param title The title to set.
+ */
+ public void setTitle(String title) {
+ this.title = title;
+ }
+
+
+ public String toString()
+ {
+ return new ToStringBuilder(this).append("qaContentId:",
+ getQaContentId())
+ .append("qa title:", getTitle())
+ .append("qa instructions:",
+ getInstructions())
+ .append("date created:",
+ getCreationDate())
+ .append("update date:",
+ getUpdateDate())
+ .append("creator user id",
+ getCreatedBy())
+ .append("username_visible:", isUsernameVisible())
+ .append("defineLater", isDefineLater())
+ .append("offline_instructions:", getOfflineInstructions())
+ .append("online_instructions:", getOnlineInstructions())
+ .append("report_title: ", getReportTitle())
+ .append("synch_in_monitor: ", isSynchInMonitor())
+ .toString();
+ }
+
+
+
+ /**
+ * Since the survey content id is assigned variable, we can use content id
+ * to ensure two survey objects are equal.
+ * @see java.lang.Object#equals(java.lang.Object)
+ */
+ public boolean equals(Object other)
+ {
+ if (!(other instanceof QaContent))
+ return false;
+ QaContent castOther = (QaContent) other;
+ return new EqualsBuilder().append(this.getQaContentId(),
+ castOther.getQaContentId())
+ .isEquals();
+ }
+
+ /**
+ * Since the survey content id is assigned variable, we can use content id
+ * to ensure two survey objects are equal.
+ * @see java.lang.Object#hashCode()
+ */
+ public int hashCode()
+ {
+ return new HashCodeBuilder().append(getQaContentId()).toHashCode();
+ }
+
+
+ /**
+ * @return Returns the createdBy.
+ */
+ public long getCreatedBy() {
+ return createdBy;
+ }
+ /**
+ * @param createdBy The createdBy to set.
+ */
+ public void setCreatedBy(long createdBy) {
+ this.createdBy = createdBy;
+ }
+ /**
+ * @return Returns the creationDate.
+ */
+ public String getCreationDate() {
+ return creationDate;
+ }
+ /**
+ * @param creationDate The creationDate to set.
+ */
+ public void setCreationDate(String creationDate) {
+ this.creationDate = creationDate;
+ }
+ /**
+ * @return Returns the defineLater.
+ */
+ public boolean isDefineLater() {
+ return defineLater;
+ }
+ /**
+ * @param defineLater The defineLater to set.
+ */
+ public void setDefineLater(boolean defineLater) {
+ this.defineLater = defineLater;
+ }
+ /**
+ * @return Returns the instructions.
+ */
+ public String getInstructions() {
+ return instructions;
+ }
+ /**
+ * @param instructions The instructions to set.
+ */
+ public void setInstructions(String instructions) {
+ this.instructions = instructions;
+ }
+ /**
+ * @return Returns the offlineInstructions.
+ */
+ public String getOfflineInstructions() {
+ return offlineInstructions;
+ }
+ /**
+ * @param offlineInstructions The offlineInstructions to set.
+ */
+ public void setOfflineInstructions(String offlineInstructions) {
+ this.offlineInstructions = offlineInstructions;
+ }
+ /**
+ * @return Returns the onlineInstructions.
+ */
+ public String getOnlineInstructions() {
+ return onlineInstructions;
+ }
+ /**
+ * @param onlineInstructions The onlineInstructions to set.
+ */
+ public void setOnlineInstructions(String onlineInstructions) {
+ this.onlineInstructions = onlineInstructions;
+ }
+ /**
+ * @return Returns the reportTitle.
+ */
+ public String getReportTitle() {
+ return reportTitle;
+ }
+ /**
+ * @param reportTitle The reportTitle to set.
+ */
+ public void setReportTitle(String reportTitle) {
+ this.reportTitle = reportTitle;
+ }
+ /**
+ * @return Returns the synchInMonitor.
+ */
+ public boolean isSynchInMonitor() {
+ return synchInMonitor;
+ }
+ /**
+ * @param synchInMonitor The synchInMonitor to set.
+ */
+ public void setSynchInMonitor(boolean synchInMonitor) {
+ this.synchInMonitor = synchInMonitor;
+ }
+ /**
+ * @return Returns the updateDate.
+ */
+ public Date getUpdateDate() {
+ return updateDate;
+ }
+ /**
+ * @param updateDate The updateDate to set.
+ */
+ public void setUpdateDate(Date updateDate) {
+ this.updateDate = updateDate;
+ }
+ /**
+ * @return Returns the usernameVisible.
+ */
+ public boolean isUsernameVisible() {
+ return usernameVisible;
+ }
+ /**
+ * @param usernameVisible The usernameVisible to set.
+ */
+ public void setUsernameVisible(boolean usernameVisible) {
+ this.usernameVisible = usernameVisible;
+ }
+
+ /**
+ * @return Returns the questionsSequenced.
+ */
+ public boolean isQuestionsSequenced() {
+ return questionsSequenced;
+ }
+ /**
+ * @param questionsSequenced The questionsSequenced to set.
+ */
+ public void setQuestionsSequenced(boolean questionsSequenced) {
+ this.questionsSequenced = questionsSequenced;
+ }
+ /**
+ * @return Returns the endLearningMessage.
+ */
+ public String getEndLearningMessage() {
+ return endLearningMessage;
+ }
+ /**
+ * @param endLearningMessage The endLearningMessage to set.
+ */
+ public void setEndLearningMessage(String endLearningMessage) {
+ this.endLearningMessage = endLearningMessage;
+ }
+ /**
+ * @return Returns the runOffline.
+ */
+ public boolean isRunOffline() {
+ return runOffline;
+ }
+ /**
+ * @param runOffline The runOffline to set.
+ */
+ public void setRunOffline(boolean runOffline) {
+ this.runOffline = runOffline;
+ }
+ /**
+ * @return Returns the monitoringReportTitle.
+ */
+ public String getMonitoringReportTitle() {
+ return monitoringReportTitle;
+ }
+ /**
+ * @param monitoringReportTitle The monitoringReportTitle to set.
+ */
+ public void setMonitoringReportTitle(String monitoringReportTitle) {
+ this.monitoringReportTitle = monitoringReportTitle;
+ }
+ /**
+ * @return Returns the contentLocked.
+ */
+ public boolean isContentLocked() {
+ return contentLocked;
+ }
+ /**
+ * @param contentLocked The contentLocked to set.
+ */
+ public void setContentLocked(boolean contentLocked) {
+ this.contentLocked = contentLocked;
+ }
+}
Index: lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/QaQueContent.hbm.xml
===================================================================
diff -u
--- lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/QaQueContent.hbm.xml (revision 0)
+++ lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/QaQueContent.hbm.xml (revision 16e844de3f7c34b44baee1b28e67e708f42d00bf)
@@ -0,0 +1,81 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Index: lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/QaQueContent.java
===================================================================
diff -u
--- lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/QaQueContent.java (revision 0)
+++ lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/QaQueContent.java (revision 16e844de3f7c34b44baee1b28e67e708f42d00bf)
@@ -0,0 +1,345 @@
+/*
+ *Copyright (C) 2005 LAMS Foundation (http://lamsfoundation.org)
+ *
+ *This program is free software; you can redistribute it and/or modify
+ *it under the terms of the GNU General Public License as published by
+ *the Free Software Foundation; either version 2 of the License, or
+ *(at your option) any later version.
+ *
+ *This program is distributed in the hope that it will be useful,
+ *but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ *GNU General Public License for more details.
+ *
+ *You should have received a copy of the GNU General Public License
+ *along with this program; if not, write to the Free Software
+ *Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
+ *USA
+ *
+ *http://www.gnu.org/licenses/gpl.txt
+ */
+package org.lamsfoundation.lams.tool.qa;
+
+import java.io.Serializable;
+import java.util.Iterator;
+import java.util.Set;
+import java.util.TreeSet;
+
+import org.apache.commons.lang.builder.EqualsBuilder;
+import org.apache.commons.lang.builder.HashCodeBuilder;
+import org.apache.commons.lang.builder.ToStringBuilder;
+import org.apache.log4j.Logger;
+
+/**
+ *
+ * @author ozgurd
+ *
+ * TODO To change the template for this generated type comment go to
+ * Window - Preferences - Java - Code Style - Code Templates
+ */
+
+/**
+ * QaQueContent Value Object
+ * The value object that maps to our model database table: tl_laqa11_que_content
+ * The relevant hibernate mapping resides in: QaQueContent.hbm.xml
+ *
+ * Holds question content within a particular content
+ */
+public class QaQueContent implements Serializable,Comparable, Nullable
+{
+ static Logger logger = Logger.getLogger(QaQueContent.class.getName());
+
+ /** identifier field */
+ private Long qaQueContentId;
+
+ /** nullable persistent field */
+ private String question;
+
+ /** nullable persistent field */
+ private int displayOrder;
+
+
+ /** nullable persistent field */
+ private org.lamsfoundation.lams.tool.qa.QaContent qaContent;
+
+ /** persistent field */
+ private Set qaUsrResps;
+
+ /** persistent field */
+ private Set qaQueUsers;
+
+ /** Struts form convenient field */
+ private String[] userResponses = {};
+
+ /** Struts form convenient field */
+ private String otherResponse;
+
+ /** nullable persistent field */
+ private boolean isOptional;
+
+
+ /** default constructor */
+ public QaQueContent()
+ {
+ logger.debug(logger + " " + this.getClass().getName() + "in constructor: QaQueContent()");
+ }
+
+ /** full constructor */
+ public QaQueContent(String question,
+ int displayOrder,
+ org.lamsfoundation.lams.tool.qa.QaContent qaContent,
+ Set qaQueUsers,
+ Set qaUsrResps)
+ {
+ this.question = question;
+ this.displayOrder = displayOrder;
+ this.qaContent = qaContent;
+ this.qaQueUsers=qaQueUsers;
+ this.qaUsrResps=qaUsrResps;
+ }
+
+ public QaQueContent(String question,
+ int displayOrder,
+ Set qaQueUsers,
+ Set qaUsrResps)
+{
+ this.question = question;
+ this.displayOrder = displayOrder;
+ this.qaQueUsers=qaQueUsers;
+ this.qaUsrResps=qaUsrResps;
+ }
+
+
+ /** minimal constructor */
+ public QaQueContent(Set qaQueUsers,
+ Set qaUsrResps)
+ {
+ this.qaQueUsers = qaQueUsers;
+ this.qaUsrResps = qaUsrResps;
+ }
+
+
+ /**
+ * Copy constructor
+ * @param queContent the original qa question content
+ * @return the new qa question content object
+ */
+ //part of the contract: make sure that this works!
+ public static QaQueContent newInstance(QaQueContent queContent,
+ QaContent newQaContent,
+ QaQueContent parentQuestion)
+ {
+ QaQueContent newQueContent = new QaQueContent(queContent.getQuestion(),
+ queContent.getDisplayOrder(),
+ newQaContent,
+ new TreeSet(),
+ new TreeSet());
+ logger.debug(logger + " " + "QaQueContent" + " " + "returning newQueContent: " + newQueContent);
+ return newQueContent;
+ }
+
+
+ public String toString() {
+ return new ToStringBuilder(this)
+ .append("qaQueContentId: ", getQaQueContentId())
+ .append("question: ", getQuestion())
+ .append("displayOrder: ", getDisplayOrder())
+ .toString();
+ }
+
+ public boolean equals(Object other) {
+ if ( !(other instanceof QaQueContent) ) return false;
+ QaQueContent castOther = (QaQueContent) other;
+ return new EqualsBuilder()
+ .append(this.getQaQueContentId(), castOther.getQaQueContentId())
+ .isEquals();
+ }
+
+ public int hashCode() {
+ return new HashCodeBuilder()
+ .append(getQaQueContentId())
+ .toHashCode();
+ }
+
+
+ /**
+ * @return Returns the displayOrder.
+ */
+ public int getDisplayOrder() {
+ return displayOrder;
+ }
+ /**
+ * @param displayOrder The displayOrder to set.
+ */
+ public void setDisplayOrder(int displayOrder) {
+ this.displayOrder = displayOrder;
+ }
+ /**
+ * @return Returns the qaContent.
+ */
+ public org.lamsfoundation.lams.tool.qa.QaContent getQaContent() {
+ return qaContent;
+ }
+ /**
+ * @param qaContent The qaContent to set.
+ */
+ public void setQaContent(org.lamsfoundation.lams.tool.qa.QaContent qaContent) {
+ this.qaContent = qaContent;
+ }
+ /**
+ * @return Returns the qaQueContentId.
+ */
+ public Long getQaQueContentId() {
+ return qaQueContentId;
+ }
+ /**
+ * @param qaQueContentId The qaQueContentId to set.
+ */
+ public void setQaQueContentId(Long qaQueContentId) {
+ this.qaQueContentId = qaQueContentId;
+ }
+ /**
+ * @return Returns the qaQueUsers.
+ */
+ public Set getQaQueUsers() {
+ if (this.qaQueUsers == null)
+ setQaQueUsers(new TreeSet());
+ return qaQueUsers;
+ }
+ /**
+ * @param qaQueUsers The qaQueUsers to set.
+ */
+ public void setQaQueUsers(Set qaQueUsers) {
+ this.qaQueUsers = qaQueUsers;
+ }
+ /**
+ * @return Returns the qaUsrResps.
+ */
+ public Set getQaUsrResps() {
+ if (this.qaUsrResps == null)
+ setQaUsrResps(new TreeSet());
+ return qaUsrResps;
+ }
+ /**
+ * @param qaUsrResps The qaUsrResps to set.
+ */
+ public void setQaUsrResps(Set qaUsrResps) {
+ this.qaUsrResps = qaUsrResps;
+ }
+ /**
+ * @return Returns the question.
+ */
+ public String getQuestion() {
+ return question;
+ }
+ /**
+ * @param question The question to set.
+ */
+ public void setQuestion(String question) {
+ this.question = question;
+ }
+
+
+ public String[] getUserResponses()
+ {
+ return userResponses;
+ }
+
+ /**
+ * @param userResponse The userResponse to set.
+ */
+ public void setUserResponses(String[] userResponse)
+ {
+ this.userResponses = userResponse;
+ }
+
+ /**
+ * @return Returns the otherResponse.
+ */
+ public String getOtherResponse()
+ {
+ return otherResponse == null ? null : otherResponse.trim();
+ }
+
+ /**
+ * @param otherResponse The otherResponse to set.
+ */
+ public void setOtherResponse(String otherResponse)
+ {
+ this.otherResponse = otherResponse;
+ }
+
+
+ /**
+ * @hibernate.property column="isOptional" length="1"
+ *
+ */
+ public boolean getIsOptional()
+ {
+ return this.isOptional;
+ }
+
+ public void setIsOptional(boolean isOptional)
+ {
+ this.isOptional = isOptional;
+ }
+
+
+ /**
+ * Validate whether there is a response available for current question.
+ * This method only validate struts convient field at the moment.
+ * @return whether the resonse is available or not.
+ */
+ private boolean isResponseAvailable()
+ {
+ if (this.getUserResponses().length == 0
+ && this.getOtherResponse() == null)
+ return false;
+ return this.getUserResponses().length != 0
+ || !this.getOtherResponse().equals("");
+
+ }
+
+ public void setUpOtherResponse(String username)
+ {
+ for (Iterator i = this.getQaQueUsers().iterator(); i.hasNext();)
+ {
+ QaQueUsr qUser = (QaQueUsr) i.next();
+
+ if ((qUser.getUsername().trim()).equals(username))
+ this.setOtherResponse(qUser.getOtherResponse());
+ }
+ }
+
+
+ /**
+ * Convenient method to check out the response for other field.
+ * @return true if other response field is not null and is not equals to
+ * empty String
+ */
+ public boolean isOtherResponseAvailable()
+ {
+ if (this.otherResponse != null && !this.otherResponse.equals(""))
+ return true;
+ return false;
+ }
+
+ public boolean isNull()
+ {
+ return false;
+ }
+
+ public int compareTo(Object o)
+ {
+ QaQueContent queContent = (QaQueContent) o;
+
+ //if the object does not exist yet, then just return any one of 0, -1, 1. Should not make a difference.
+ if (qaQueContentId == null)
+ return 1;
+ else
+ return (int) (qaQueContentId.longValue() - queContent.qaQueContentId.longValue());
+
+ }
+
+
+}
Index: lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/QaQueUsr.hbm.xml
===================================================================
diff -u
--- lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/QaQueUsr.hbm.xml (revision 0)
+++ lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/QaQueUsr.hbm.xml (revision 16e844de3f7c34b44baee1b28e67e708f42d00bf)
@@ -0,0 +1,76 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Index: lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/QaQueUsr.java
===================================================================
diff -u
--- lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/QaQueUsr.java (revision 0)
+++ lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/QaQueUsr.java (revision 16e844de3f7c34b44baee1b28e67e708f42d00bf)
@@ -0,0 +1,470 @@
+/*
+ *Copyright (C) 2005 LAMS Foundation (http://lamsfoundation.org)
+ *
+ *This program is free software; you can redistribute it and/or modify
+ *it under the terms of the GNU General Public License as published by
+ *the Free Software Foundation; either version 2 of the License, or
+ *(at your option) any later version.
+ *
+ *This program is distributed in the hope that it will be useful,
+ *but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ *GNU General Public License for more details.
+ *
+ *You should have received a copy of the GNU General Public License
+ *along with this program; if not, write to the Free Software
+ *Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
+ *USA
+ *
+ *http://www.gnu.org/licenses/gpl.txt
+ */
+package org.lamsfoundation.lams.tool.qa;
+
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Set;
+import java.util.TreeSet;
+
+import org.apache.commons.lang.builder.EqualsBuilder;
+import org.apache.commons.lang.builder.HashCodeBuilder;
+import org.apache.commons.lang.builder.ToStringBuilder;
+import org.apache.log4j.Logger;
+/**
+ *
+ * @author ozgurd
+ *
+ * TODO To change the template for this generated type comment go to
+ * Window - Preferences - Java - Code Style - Code Templates
+ */
+
+/**
+ *
+ * QaQueUsr Value Object
+ * The value object that maps to our model database table: tl_laqa11_que_usr
+ * The relevant hibernate mapping resides in: QaQueUsr.hbm.xml
+ *
+ * Represents tool users.
+ */
+public class QaQueUsr implements Serializable, Comparable, Nullable
+{
+ static Logger logger = Logger.getLogger(QaQueUsr.class.getName());
+
+ /** identifier field */
+ private Long queUsrId;
+
+ /** nullable persistent field */
+ private String username;
+
+ /** nullable persistent field */
+ private String fullname;
+
+ /** persistent field */
+ private QaSession qaSession;
+
+ /** persistent field */
+ private Long qaSessionId;
+
+ /** persistent field */
+ private QaQueContent qaQueContent;
+
+ /** persistent field */
+ private Set qaUsrResps; //surveyUsrResps
+
+ public QaQueUsr()
+ {
+ logger.debug(logger + " " + this.getClass().getName() + "in constructor: QaQueUsr()");
+ }
+
+
+
+ /** full constructor */
+ public QaQueUsr(Long queUsrId,
+ String username,
+ String fullname,
+ QaQueContent qaQueContent,
+ QaSession qaSession,
+ Set qaUsrResps)
+
+ {
+ this.queUsrId = queUsrId;
+ this.username = username;
+ this.fullname = fullname;
+ this.qaQueContent = qaQueContent;
+ this.qaSession = qaSession;
+ this.qaUsrResps =qaUsrResps;
+ }
+
+ /** minimal constructor */
+ public QaQueUsr(QaQueContent qaQueContent,
+ QaSession qaSession,
+ Set qaUsrResps)
+
+ {
+ this.qaQueContent = qaQueContent;
+ this.qaSession = qaSession;
+ this.qaUsrResps =qaUsrResps;
+ }
+
+
+ public QaQueUsr(Long queUsrId,
+ String username,
+ String fullname,
+ QaQueContent qaQueContent,
+ QaSession qaSession)
+ {
+ this.queUsrId = queUsrId;
+ this.username = username;
+ this.fullname = fullname;
+ this.qaQueContent = qaQueContent;
+ this.qaSession = qaSession;
+ }
+
+
+
+ public QaQueUsr(String username,
+ String fullname,
+ QaQueContent qaQueContent,
+ QaSession qaSession,
+ Set qaUsrResps)
+
+ {
+ this.username = username;
+ this.fullname = fullname;
+ this.qaQueContent = qaQueContent;
+ this.qaSession = qaSession;
+ this.qaUsrResps =qaUsrResps;
+ }
+
+
+
+ //implement this, double check this, what is it for?
+ /**
+ * Copy construtor; We copy all data except the hibernate id field.
+ * @param queUsr the original survey question user object.
+ * @return the survey question user object.
+ */
+ public QaQueUsr newInstance(QaQueUsr queUsr)
+ {
+ return new QaQueUsr(queUsr.getQueUsrId(),
+ queUsr.getUsername(),
+ queUsr.getFullname(),
+ queUsr.getQaQueContent(),
+ queUsr.getQaSession(),
+ queUsr.getQaUsrResps());
+ }
+
+
+ /**
+ * @return Returns the fullname.
+ */
+ public String getFullname() {
+ return fullname;
+ }
+ /**
+ * @param fullName The fullName to set.
+ */
+ public void setFullname(String fullname) {
+ this.fullname = fullname;
+ }
+ /**
+ * @return Returns the qaQueContent.
+ */
+ public QaQueContent getQaQueContent() {
+ return qaQueContent;
+ }
+ /**
+ * @param qaQueContent The qaQueContent to set.
+ */
+ public void setQaQueContent(QaQueContent qaQueContent) {
+ this.qaQueContent = qaQueContent;
+ }
+ /**
+ * @return Returns the qaSession.
+ */
+ public QaSession getQaSession() {
+ return qaSession;
+ }
+ /**
+ * @param qaSession The qaSession to set.
+ */
+ public void setQaSession(QaSession qaSession) {
+ this.qaSession = qaSession;
+ }
+ /**
+ * @return Returns the qaUsrResps.
+ */
+ public Set getQaUsrResps()
+ {
+ if (this.qaUsrResps == null)
+ setQaUsrResps(new TreeSet());
+ return this.qaUsrResps;
+ }
+ /**
+ * @param qaUsrResps The qaUsrResps to set.
+ */
+ public void setQaUsrResps(Set qaUsrResps) {
+ this.qaUsrResps = qaUsrResps;
+ }
+ /**
+ * @return Returns the queUsrId.
+ */
+ public Long getQueUsrId() {
+ return queUsrId;
+ }
+ /**
+ * @param queUsrId The queUsrId to set.
+ */
+ public void setQueUsrId(Long queUsrId) {
+ this.queUsrId = queUsrId;
+ }
+ /**
+ * @return Returns the username.
+ */
+ public String getUsername() {
+ return username;
+ }
+ /**
+ * @param username The username to set.
+ */
+ public void setUsername(String username) {
+ this.username = username;
+ }
+
+
+ public String toString()
+ {
+ return new ToStringBuilder(this).append("queUsrId", getQueUsrId())
+ .append("username",getUsername())
+ .append("full name",getFullname())
+ .toString();
+ }
+
+
+ public boolean equals(Object other)
+ {
+ if (!(other instanceof QaQueUsr))
+ return false;
+ QaQueUsr castOther = (QaQueUsr) other;
+ return new EqualsBuilder().append(this.getQueUsrId(),castOther.getQueUsrId())
+ //.append(this.getUserId(),castOther.getUserId())
+ //.append(this.getQaQueContent(),castOther.getQaQueContent())
+ .isEquals();
+ }
+
+ public int hashCode()
+ {
+ return new HashCodeBuilder().append(getQueUsrId())
+ //.append(getUserId())
+ .toHashCode();
+ }
+
+
+
+ //---------------------------------------------------------------------
+ // Convenient Service Methods
+ //---------------------------------------------------------------------
+ /**
+ * Check up question responsed by current user against a list user responses.
+ * Return true if
+ * @param responses
+ * @return the validation result
+ */
+ public boolean checkUpQueUsrHas(List responses)
+ {
+ if (responses == null)
+ throw new IllegalArgumentException("Invalid responses from "
+ + this.getFullname() + ": Can't validate null responses"
+ + "against current survey questions");
+
+ //make defensive copy to avoid list mutation outside this class.
+ ArrayList resps = new ArrayList(responses);
+
+ for (Iterator i = resps.iterator(); i.hasNext();)
+ {
+ QaUsrResp resp = (QaUsrResp) i.next();
+ if (doesQueUserHas(resp))
+ return true;
+ }
+ return false;
+ }
+
+
+
+ /**
+ * The helper function to validate the availability of a user response for
+ * this question user.
+ * The condition to return true is:
+ *
the requested response has a reference to a question user object
+ * and reference id is the same as current question user object.
+ *
+ * @param response the user response
+ * @return the validation result
+ */
+ public boolean doesQueUserHas(QaUsrResp response)
+ {
+ if (response.getQaQueUser() == null)
+ throw new IllegalArgumentException("Invalid response :"
+ + " Can't validate the availability"
+ + " of a response without the reference to a user");
+
+ if(response.getQaQueUser().getQueUsrId()==null||this.getQueUsrId()==null)
+ return false;
+
+ if (this.getQueUsrId().equals(response.getQaQueUser().getQueUsrId()))
+ return true;
+ return false;
+ }
+
+ /**
+ * @param responses
+ * @param responseSet
+ */
+ public void removeResponseBy(ArrayList responses)
+ {
+ Set responseSet = new TreeSet(this.getQaUsrResps());
+ //remove responses no longer exist.
+ for(Iterator i = responseSet.iterator();i.hasNext();)
+ {
+ QaUsrResp resp = (QaUsrResp) i.next();
+ if(!resp.doesRespExistIn(responses))
+ this.getQaUsrResps().remove(resp);
+ }
+ }
+
+
+ /**
+ * Update the user responses of this question user object against a list of
+ * new user responses.
+ * @param responses
+ */
+ public void updateQueUsr(List responses)
+ {
+ if (responses == null)
+ throw new IllegalArgumentException("Invalid responses from "
+ + this.getFullname() + ": Can't update null responses"
+ + "against current survey questions");
+
+ //make defensive copy to avoid list mutation outside this class.
+ ArrayList resps = new ArrayList(responses);
+ //clean up all the existing reponses
+ removeResponseBy(resps);
+ addNewResponsesBy(resps);
+ updateExistingResp(resps);
+ }
+
+ /**
+ * @param resps
+ * @param responseList
+ */
+ public void addNewResponsesBy(ArrayList resps)
+ {
+ ArrayList responseList = new ArrayList(this.getQaUsrResps());
+ //add all associated new responses into the current question user.
+ for (Iterator i = resps.iterator(); i.hasNext();)
+ {
+ QaUsrResp resp = (QaUsrResp) i.next();
+ if (!resp.doesRespExistIn(responseList)&&doesQueUserHas(resp))
+ addUserResponse(resp);
+ }
+ }
+
+ /**
+ * @param responses
+ * @param responseSet
+ */
+ public void updateExistingResp(ArrayList responses)
+ {
+ //update existing responses
+ for(Iterator i = this.getQaUsrResps().iterator();i.hasNext();)
+ {
+ QaUsrResp resp = (QaUsrResp) i.next();
+ if(resp.doesRespExistIn(responses))
+ resp.updateResponseBy(responses);
+ }
+ }
+
+ /**
+ * @param resp
+ */
+ public void addUserResponse(QaUsrResp resp)
+ {
+ if (resp != null && !resp.isResponseValid())
+ throw new IllegalArgumentException("Invalid response for update ");
+
+ this.getQaUsrResps().add(resp);
+ }
+
+
+ /**
+ * Get a list of user response Strings that are correspondent to the
+ * authored defined candidate answers. Currently, we include the free
+ * text answer to this category as well.
+ *
+ * @return the list of String user responses
+ */
+ public List getPredefinedResponse()
+ {
+ LinkedList responses = new LinkedList();
+
+ for(Iterator i = this.getQaUsrResps().iterator();i.hasNext();)
+ {
+ QaUsrResp res = (QaUsrResp)i.next();
+ if(res.isPredefinedResponse())
+ {
+ responses.add(res.getAnswer());
+ }
+ }
+ return responses;
+ }
+
+
+ public String getOtherResponse()
+ {
+ for(Iterator i = this.getQaUsrResps().iterator();i.hasNext();)
+ {
+ QaUsrResp res = (QaUsrResp)i.next();
+ if(!res.isPredefinedResponse())
+ return res.getAnswer();
+ }
+
+ return "";
+ }
+
+ public int compareTo(Object o)
+ {
+
+ QaQueUsr qUser = (QaQueUsr) o;
+ /*
+ if (this.qaQueContent == null
+ && qUser.getQaQueContent() == null)
+ return String.CASE_INSENSITIVE_ORDER.compare(username,
+ qUser.username);
+ if (this.qaQueContent == null)
+ return 1;
+ if (qUser.getQaQueContent() == null)
+ return -1;
+ */
+ return this.getQaQueContent().compareTo(qUser.getQaQueContent());
+ }
+
+ public boolean isNull()
+ {
+ return false;
+ }
+
+ /**
+ * @return Returns the qaSessionId.
+ */
+ public Long getQaSessionId() {
+ return qaSessionId;
+ }
+ /**
+ * @param qaSessionId The qaSessionId to set.
+ */
+ public void setQaSessionId(Long qaSessionId) {
+ this.qaSessionId = qaSessionId;
+ }
+}
Index: lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/QaResources.properties
===================================================================
diff -u
--- lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/QaResources.properties (revision 0)
+++ lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/QaResources.properties (revision 16e844de3f7c34b44baee1b28e67e708f42d00bf)
@@ -0,0 +1,100 @@
+# Project lams_tool_qa
+#Authoring mode resources
+label.authoring.qa =Questions and Answers
+label.authoring.title =Title
+label.authoring.instructions =Instructions
+
+button.basic =Basic
+button.uploadFile =Upload Package
+button.preview =Preview
+button.advanced =Advanced
+button.instructions =Instructions
+button.done =Done
+tool.icon.name =Q/A
+button.addNewQuestion =+
+button.removeQuestion =-
+button.removeAllContent =Remove Content
+button.submitAllContent =Submit
+button.done =Done
+button.getNextQuestion =Next
+button.getPreviousQuestion =Previous
+
+label.report.title =Report Title
+label.monitoringReport.title =Monitoring Report Title
+label.report.endLearningMessage =End of Activity Message
+label.question1 =Question 1
+radiobox.defineLater =Define Later
+radiobox.synchInMonitor =Sync in Monitor
+radiobox.forceOffline =Force Offline
+radiobox.usernameVisible =Username Visible
+radiobox.questionsSequenced =Questions Sequenced
+label.offlineInstructions =Offline Instructions
+label.onlineInstructions =Online Instructions
+option.on =ON
+option.off =OFF
+feedback =Please address the following issues before submit.
+error.title =The field "Title" is mandatory.
+error.instructions =The field "Instructions" is mandatory.
+error.reportTitle =The field "Report Title (Advanced)" is mandatory.
+error.defaultquestion.empty =The first question can not be empty.
+submit.successful =The content has been created successfully.
+
+error.content.locked =The content has been locked since it is being used by one mor more learners. The modification of the content is not allowed.
+error.content.inUse =The modification of the content is not allowed since one or more students has attempted the activity.
+error.content.beingModified =The content creation is not allowed since the same content is being modified.
+error.content.unstableState =The content is in an unstable state since it has been left editable while monitored. Please use this screen to redefine the content.
+error.defaultContent.notAvailable =Tool Activity Error! Can't continue The the default content for the Tool Activity has not been set up.
+error.defaultQuestionContent.notAvailable =Tool Activity Error! Can't continue The the default question content for the Tool Activity has not been set up.
+
+#Learning mode resources
+label.learning.qa =Answers for Q/A
+label.question =Question
+label.answers =Answers:
+button.endLearning =Finish
+label.learning.user =User
+label.learning.attemptTime =Attempt Date/Time
+label.learning.response =Response
+label.learning.forceOfflineMessage =The activity Q/A is setup to be carried out offline. Plase see your instructor.
+error.defineLater =Sorry, this activity's content is not ready yet. Please wait for your teacher to make the content ready.
+error.toolSessionId.required =Tool Activity Error! Can't continue URL is not complete. The Tool Activity requires a toolSession id.
+error.contentId.required =Tool Activity Error! Can't continue URL is not complete. The Tool Activity requires a content id.
+error.authoringUser.notAvailable =Tool Activity Error! Can't continue. Tool Activity expects a user id.
The expected format is either : TOOLURL?userId=A&toolContentId=B or TOOLURL?userId=A
+error.userId.notNumeric =Tool Activity Error! Can't continue. The user id passed to the Tool Activity must be numerical.
+error.userId.existing =Tool Activity Error! Can't continue. The user id passed to the Tool Activity refers to a student that has already used the activity. Each learner activity should be associated with a unique userId.
+
+#Monitoring mode resources
+button.startLesson =Start Lesson
+button.deleteLesson =Delete Lesson
+button.contributeLesson =Contribute -> Report
+button.forceComplete =Force Complete
+error.synchInMonitor =The report is available only after all the students finish their activities Some of the students has not completed the activity yet. Those students may be forced to complete.
+error.monitorReportTitle =The field "Monitor Report Title (Advanced)" is mandatory.
+error.noStudentActivity =Sorry, the report can not be generated. No student has attempted the activity yet.
+error.contentAndToolSession.notCompatible =Tool Activity Error! Can't continue. The content id and tool session(s) passed to the tool activity are not compatible with each other. The Tool Activity expects that each of the passed tool sessions refer to the same passed content id.
+error.toolSessions.wrongFormat =Tool Activity Error! Can't continue. No valid tool sessions has been passed to the Tool Activity. The expected format is: TOOLURL?toolContentId=A&toolSessionId1=B&toolSessionId2=C&toolSessionId3=D&...
+error.numberFormatException =Tool Activity Error! Can't continue. The content id and tool session id(s) passed to the Tool Activity must be numerical.
+error.contentId.numberFormatException =Tool Activity Error! Can't continue. The content id passed to the Tool Activity must be numerical.
+error.sessionId.numberFormatException =Tool Activity Error! Can't continue. The toolSession id passed to the Tool Activity must be numerical.
+error.content.doesNotExist =Tool Activity Error! Can't continue. The content id passed to the Tool Activity does not refer to an existing content.
+error.toolSessions.doesNotExist =Tool Activity Error! Can't continue. One of the toolsession ids passed to the Tool Activity does not refer to an existing tool session.
+error.content.onlyContentAndNoSessions =A report can not be generated since no tool sessions has been passed to the Tool Activity.
+error.tab.contentId.required =Sorry, the screen is not available. The Tool Activity requires a content id.
+monitoring.feedback.instructionUpdate =The content has been updated successfully.
+
+group.label =Group
+button.summary =Summary
+button.editActivity =Edit Activity
+button.stats =Stats
+label.edit =Edit
+label.update =Update
+label.hide =Hide
+label.unHide =UnHide
+label.hidden =Hidden
+label.stats.totalLearners =Total count of learners:
+label.stats.allGroups =All Groups:
+label.stats.totalAllGroups =Total count of all learners:
+
+#=========================Error Messages===========================#
+error.system.qa=A system exception has occured. Please contact Lams International technical support at 95806666. The error to report is\: {0}
+
+
Index: lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/QaSession.hbm.xml
===================================================================
diff -u
--- lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/QaSession.hbm.xml (revision 0)
+++ lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/QaSession.hbm.xml (revision 16e844de3f7c34b44baee1b28e67e708f42d00bf)
@@ -0,0 +1,95 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Index: lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/QaSession.java
===================================================================
diff -u
--- lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/QaSession.java (revision 0)
+++ lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/QaSession.java (revision 16e844de3f7c34b44baee1b28e67e708f42d00bf)
@@ -0,0 +1,361 @@
+/*
+ *Copyright (C) 2005 LAMS Foundation (http://lamsfoundation.org)
+ *
+ *This program is free software; you can redistribute it and/or modify
+ *it under the terms of the GNU General Public License as published by
+ *the Free Software Foundation; either version 2 of the License, or
+ *(at your option) any later version.
+ *
+ *This program is distributed in the hope that it will be useful,
+ *but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ *GNU General Public License for more details.
+ *
+ *You should have received a copy of the GNU General Public License
+ *along with this program; if not, write to the Free Software
+ *Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
+ *USA
+ *
+ *http://www.gnu.org/licenses/gpl.txt
+ */
+package org.lamsfoundation.lams.tool.qa;
+
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Set;
+import java.util.TreeSet;
+
+import org.apache.commons.lang.builder.EqualsBuilder;
+import org.apache.commons.lang.builder.HashCodeBuilder;
+import org.apache.commons.lang.builder.ToStringBuilder;
+import org.apache.log4j.Logger;
+
+
+/**
+ * QaSession Value Object
+ * The value object that maps to our model database table: tl_laqa11_session
+ * The relevant hibernate mapping resides in: QaSession.hbm.xml
+ *
+ * Holds tool sessions
+ */
+public class QaSession implements Serializable,Comparable, Nullable
+{
+ static Logger logger = Logger.getLogger(QaSession.class.getName());
+
+ public final static String INCOMPLETE = "INCOMPLETE";
+
+ public static final String COMPLETED = "COMPLETED";
+
+ /** identifier field */
+ private Long qaSessionId;
+
+ /** nullable persistent field */
+ private Date session_start_date;
+
+ /** nullable persistent field */
+ private Date session_end_date;
+
+ /** nullable persistent field */
+ private String session_status;
+
+ /** persistent field */
+ private QaContent qaContent;
+
+ /** persistent field */
+ private Set qaQueUsers;
+
+ private Long qaContentId;
+
+
+
+ /** full constructor */
+ public QaSession(Long qaSessionId,
+ Date session_start_date,
+ Date session_end_date,
+ String session_status,
+ QaContent qaContent,
+ Set qaQueUsers)
+ {
+ this.qaSessionId = qaSessionId;
+ this.session_start_date = session_start_date;
+ this.session_end_date = session_end_date;
+ this.session_status = session_status;
+ this.qaContent = qaContent;
+ this.qaQueUsers = qaQueUsers;
+ logger.debug(logger + " " + this.getClass().getName() + "in full constructor: QaSession()");
+ }
+
+ /** default constructor */
+ public QaSession()
+ {
+ logger.debug(logger + " " + this.getClass().getName() + "in constructor: QaSession()");
+ }
+
+ /**
+ * Construtor for initializing survey session.
+ * @param sessionStartDate
+ * @param sessionStatus
+ * @param surveyContent
+ * @param surveyQueUsrs
+ */
+ public QaSession(Long qaSessionId,
+ Date session_start_date,
+ String session_status,
+ QaContent qaContent,
+ Set qaQueUsers)
+ {
+ this(qaSessionId,session_start_date,null,session_status,qaContent,qaQueUsers);
+ }
+
+ /**
+ * @hibernate.id
+ * generator-class="assigned"
+ * type="java.lang.Long"
+ * column="survey_session_id"
+ *
+ */
+ public Long getQaSessionId()
+ {
+ return this.qaSessionId;
+ }
+
+ public void setQaSessionId(Long qaSessionId)
+ {
+ this.qaSessionId = qaSessionId;
+ }
+
+ /**
+ * @hibernate.property
+ * column="session_start_date"
+ * length="10"
+ *
+ */
+ public Date getSession_start_date()
+ {
+ return this.session_start_date;
+ }
+
+ public void setSession_start_date(Date session_start_date)
+ {
+ this.session_start_date = session_start_date;
+ }
+
+ /**
+ * @hibernate.property
+ * column="session_end_date"
+ * length="10"
+ *
+ */
+ public Date getSession_end_date()
+ {
+ return this.session_end_date;
+ }
+
+ public void setSession_end_date(Date session_end_date)
+ {
+ this.session_end_date = session_end_date;
+ }
+
+
+ /**
+ * @hibernate.property column="session_status" length="128"
+ * @return Returns the sessionStatus.
+ */
+ public String getSession_status()
+ {
+ return session_status;
+ }
+ /**
+ * @param sessionStatus The sessionStatus to set.
+ */
+ public void setSession_status(String session_status)
+ {
+ this.session_status = session_status;
+ }
+
+ /**
+ * @hibernate.many-to-one
+ * not-null="true"
+ * @hibernate.column name="survey_content_id"
+ *
+ */
+ public QaContent getQaContent()
+ {
+ return this.qaContent;
+ }
+
+ public void setQaContent(QaContent qaContent)
+ {
+ this.qaContent = qaContent;
+ }
+
+ /**
+ * @hibernate.set lazy="false" inverse="true" cascade="all-delete-orphan"
+ * @hibernate.collection-key column="survey_session_id"
+ * @hibernate.collection-one-to-many
+ * class="org.lamsfoundation.lams.tool.survey.SurveyQueUsr"
+ *
+ */
+ public Set getQaQueUsers()
+ {
+ if (this.qaQueUsers == null)
+ setQaQueUsers(new TreeSet());
+ return this.qaQueUsers;
+ }
+
+
+
+ public void setQaQueUsers(Set qaQueUsers)
+ {
+ this.qaQueUsers = qaQueUsers;
+ }
+
+
+ //---------------------------------------------------------------------
+ // Domain Service Methods
+ //---------------------------------------------------------------------
+ /**
+ *
+ * @param responses
+ */
+
+
+ public void removeQueUsersBy(List responses)
+ {
+ //make a copy of que user to avoid concurrent modification exception
+ Set queUserSet = new TreeSet(this.getQaQueUsers());
+
+ /*
+ for (Iterator i = queUserSet.iterator(); i.hasNext();)
+ {
+ SurveyQueUsr curUser = (SurveyQueUsr) i.next();
+ //remove question user object if no new response has reference
+ //to it.
+ if (!curUser.checkUpQueUsrHas(responses))
+ this.getSurveyQueUsrs().remove(curUser);
+ }
+ */
+ }
+
+
+
+ /**
+ *
+ * @param responses
+ */
+
+
+ public void updateQueUsersBy(List responses)
+ {
+ for (Iterator i = this.getQaQueUsers().iterator(); i.hasNext();)
+ {
+ /*
+ SurveyQueUsr curUser = (SurveyQueUsr) i.next();
+ if (curUser.checkUpQueUsrHas(responses))
+ curUser.updateQueUsr(responses);
+ */
+ }
+ }
+
+ /**
+ * @param responses
+ */
+
+ public void addNewQueUsersBy(List responses)
+ {
+ //make a defensive a copy to avoid mutation from outside.
+ ArrayList resps = new ArrayList(responses);
+ for(Iterator i = resps.iterator();i.hasNext();)
+ {
+ /*
+ SurveyUsrResp response = (SurveyUsrResp)i.next();
+ SurveyQueUsr queUser = response.getSurveyQueUsr();
+ if(!isQueUsrExist(queUser))
+ this.getSurveyQueUsrs().add(queUser);
+ */
+ }
+ }
+
+
+ /**
+ * @param queUser
+ * @return
+ */
+
+ /*
+ private boolean isQueUsrExist(SurveyQueUsr queUser)
+ {
+ for(Iterator i = this.getSurveyQueUsrs().iterator();i.hasNext();)
+ {
+
+ SurveyQueUsr curUser = (SurveyQueUsr)i.next();
+ if(curUser.getSurveyQueContent().equals(queUser.getSurveyQueContent()))
+ return true;
+ }
+ return false;
+ }
+ */
+
+ public String toString()
+ {
+ return new ToStringBuilder(this).append("qaSessionId",getQaSessionId())
+ .append("session start date",getSession_start_date())
+ .append("session end date",getSession_end_date())
+ .append("session status",getSession_status())
+ .toString();
+ }
+
+
+
+ public boolean equals(Object other)
+ {
+ if (!(other instanceof QaSession))
+ return false;
+
+ QaSession castOther = (QaSession) other;
+ return new EqualsBuilder().append(this.getQaSessionId(),
+ castOther.getQaSessionId())
+ .isEquals();
+
+ }
+
+ public int hashCode()
+ {
+ return new HashCodeBuilder().
+ append(getQaSessionId()).
+ toHashCode();
+
+ }
+
+
+ public int compareTo(Object o)
+ {
+ QaSession qaSession = (QaSession) o;
+ return (int) (qaSessionId.longValue() - qaSession.qaSessionId.longValue());
+ }
+
+ /**
+ * This object should not be null.
+ * @see org.lamsfoundation.lams.tool.survey.Nullable#isNull()
+ */
+ public boolean isNull()
+ {
+ return false;
+ }
+
+ /**
+ * @return Returns the qaContentId.
+ */
+ public Long getQaContentId() {
+ return qaContentId;
+ }
+ /**
+ * @param qaContentId The qaContentId to set.
+ */
+ public void setQaContentId(Long qaContentId) {
+ this.qaContentId = qaContentId;
+ }
+}
Index: lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/QaStringComparator.java
===================================================================
diff -u
--- lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/QaStringComparator.java (revision 0)
+++ lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/QaStringComparator.java (revision 16e844de3f7c34b44baee1b28e67e708f42d00bf)
@@ -0,0 +1,40 @@
+/*
+ * Created on 20/04/2005
+ *
+ * TODO To change the template for this generated file go to
+ * Window - Preferences - Java - Code Style - Code Templates
+ */
+package org.lamsfoundation.lams.tool.qa;
+
+import java.io.Serializable;
+import java.util.Comparator;
+
+import org.apache.log4j.Logger;
+
+/**
+ * @author ozgurd
+ *
+ * TODO To change the template for this generated type comment go to
+ * Window - Preferences - Java - Code Style - Code Templates
+ */
+
+/**
+ * A comparator implementation that can be used as a constructor to collections.
+ * The TreeMap in the web layer makes use of it.
+ *
+ */
+public class QaStringComparator implements Comparator, Serializable {
+ static Logger logger = Logger.getLogger(QaStringComparator.class.getName());
+
+ public int compare(Object o1, Object o2) {
+ String s1 = (String)o1;
+ String s2 = (String)o2;
+
+ return s1.compareTo(s2);
+ }
+
+ public boolean equals(Object o) {
+ String s = (String)o;
+ return compare(this, o)==0;
+ }
+}
Index: lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/QaUsrResp.hbm.xml
===================================================================
diff -u
--- lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/QaUsrResp.hbm.xml (revision 0)
+++ lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/QaUsrResp.hbm.xml (revision 16e844de3f7c34b44baee1b28e67e708f42d00bf)
@@ -0,0 +1,98 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Index: lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/QaUsrResp.java
===================================================================
diff -u
--- lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/QaUsrResp.java (revision 0)
+++ lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/QaUsrResp.java (revision 16e844de3f7c34b44baee1b28e67e708f42d00bf)
@@ -0,0 +1,316 @@
+package org.lamsfoundation.lams.tool.qa;
+
+import java.io.Serializable;
+import java.util.Date;
+import java.util.Iterator;
+import java.util.List;
+
+import org.apache.commons.lang.builder.EqualsBuilder;
+import org.apache.commons.lang.builder.HashCodeBuilder;
+import org.apache.commons.lang.builder.ToStringBuilder;
+import org.lamsfoundation.lams.tool.qa.QaQueContent;
+
+
+/**
+ * QaUsrResp Value Object
+ * The value object that maps to our model database table: tl_laqa11_usr_resp
+ * The relevant hibernate mapping resides in: QaQueResp.hbm.xml
+ *
+ * Holds user responses to questions
+ */
+
+public class QaUsrResp implements Serializable, Comparable {
+
+ /** identifier field */
+ private Long responseId;
+
+ /** nullable persistent field */
+ private String answer;
+
+ /** nullable persistent field */
+ private boolean hidden;
+
+ /** nullable persistent field */
+ private Date attemptTime;
+
+ /** nullable persistent field */
+ private QaQueContent qaQueContent;
+
+ /** nullable persistent field */
+ private Long qaQueContentId; //added to enable deletion by the resp dao
+
+ /** nullable persistent field */
+ private Long queUsrId; //added to enable deletion by the resp dao
+
+ /** nullable persistent field */
+ private QaQueUsr qaQueUser;
+
+ /** full constructor */
+ public QaUsrResp(Long responseId,
+ String answer,
+ boolean hidden,
+ Date attemptTime,
+ QaQueContent qaQueContent,
+ QaQueUsr qaQueUser) {
+ this.responseId =responseId;
+ this.answer = answer;
+ this.hidden = hidden;
+ this.attemptTime = attemptTime;
+ this.qaQueContent = qaQueContent;
+ this.qaQueUser = qaQueUser;
+ }
+
+ public QaUsrResp(String answer,
+ boolean hidden,
+ Date attemptTime,
+ QaQueContent qaQueContent,
+ QaQueUsr qaQueUser) {
+ this.answer = answer;
+ this.hidden = hidden;
+ this.attemptTime = attemptTime;
+ this.qaQueContent = qaQueContent;
+ this.qaQueUser = qaQueUser;
+ }
+
+
+ public QaUsrResp(String answer,
+ Date attemptTime,
+ QaQueContent question)
+ {
+ this.answer = answer;
+ this.attemptTime = attemptTime;
+ this.qaQueContent = question;
+ }
+
+ /** default constructor */
+ public QaUsrResp(){}
+
+ /**
+ * Copy construtor. Delegate to full construtor to achieve the object
+ * creation.
+ * @param response the original survey user response
+ * @return the new qa user response cloned from original object
+ */
+ public static QaUsrResp newInstance(QaUsrResp response)
+ {
+ return new QaUsrResp(response.getResponseId(),
+ response.getAnswer(),
+ response.isHidden(),
+ response.getAttemptTime(),
+ response.getQaQueContent(),
+ response.qaQueUser);
+ }
+
+
+
+ public String toString() {
+ return new ToStringBuilder(this)
+ .append("responseId: ", getResponseId())
+ .append("answer:", getAnswer())
+ .append("attempt time: ", getAttemptTime())
+ .toString();
+ }
+
+ public boolean equals(Object other) {
+ if ( !(other instanceof QaUsrResp) ) return false;
+ QaUsrResp castOther = (QaUsrResp) other;
+ return new EqualsBuilder()
+ .append(this.getResponseId(), castOther.getResponseId())
+ .isEquals();
+ }
+
+ public int hashCode() {
+ return new HashCodeBuilder()
+ .append(getResponseId())
+ .toHashCode();
+ }
+
+ /**
+ * @return Returns the answer.
+ */
+ public String getAnswer() {
+ return answer;
+ }
+ /**
+ * @param answer The answer to set.
+ */
+ public void setAnswer(String answer) {
+ this.answer = answer;
+ }
+ /**
+ * @return Returns the attemptTime.
+ */
+ public Date getAttemptTime() {
+ return attemptTime;
+ }
+ /**
+ * @param attemptTime The attemptTime to set.
+ */
+ public void setAttemptTime(Date attemptTime) {
+ this.attemptTime = attemptTime;
+ }
+ /**
+ * @return Returns the qaQueContent.
+ */
+ public QaQueContent getQaQueContent() {
+ return qaQueContent;
+ }
+ /**
+ * @param qaQueContent The qaQueContent to set.
+ */
+ public void setQaQueContent(QaQueContent qaQueContent) {
+ this.qaQueContent = qaQueContent;
+ }
+ /**
+ * @return Returns the qaQueUsr.
+ */
+ public QaQueUsr getQaQueUser() {
+ return qaQueUser;
+ }
+ /**
+ * @param qaQueUsr The qaQueUsr to set.
+ */
+ public void setQaQueUser(QaQueUsr qaQueUser) {
+ this.qaQueUser = qaQueUser;
+ }
+ /**
+ * @return Returns the responseId.
+ */
+ public Long getResponseId() {
+ return responseId;
+ }
+ /**
+ * @param responseId The responseId to set.
+ */
+ public void setResponseId(Long responseId) {
+ this.responseId = responseId;
+ }
+
+
+ /**
+ * @param responses
+ * @return
+ */
+ public boolean doesRespExistIn(List responses)
+ {
+ for(Iterator i = responses.iterator();i.hasNext();)
+ {
+ QaUsrResp resp = (QaUsrResp)i.next();
+ if((resp.getAnswer().trim()).equals(this.getAnswer().trim())
+ &&resp.getQaQueUser().getQueUsrId()==this.getQaQueUser().getQueUsrId())
+ return true;
+ }
+ return false;
+ }
+
+
+ /**
+ * @param responses
+ */
+ public void updateResponseBy(List responses)
+ {
+ for(Iterator i = responses.iterator();i.hasNext();)
+ {
+ QaUsrResp resp = (QaUsrResp)i.next();
+ if(resp.getQaQueUser().getQueUsrId()==this.getQaQueUser().getQueUsrId())
+// && resp.getQaAnsContent().getDisplayOrder()==this.getQaAnsContent().getDisplayOrder())
+ this.updateResponse(resp);
+
+ }
+ }
+
+ /**
+ * The response is not valid if it doesn't have a reference to question
+ * object and question user object.
+ * @param resp the response to be validated
+ * @return the validation result.
+ */
+ public boolean isResponseValid()
+ {
+ return this.getQaQueUser()!=null && this.getQaQueContent()!=null;
+ // &&this.getQaAnsContent()!=null;
+ }
+
+
+ /**
+ * Update current object according to the new response object.
+ * @param resp
+ */
+ public void updateResponse(QaUsrResp resp)
+ {
+ if(!resp.isResponseValid())
+ throw new IllegalArgumentException("Invalid response for update ");
+
+ this.setAnswer(resp.getAnswer());
+ this.setAttemptTime(resp.getAttemptTime());
+ this.setQaQueContent(resp.getQaQueContent());
+
+ this.setQaQueUser(resp.getQaQueUser());
+
+ }
+
+
+ /**
+ * Validate whether the current response is correspondent to an author
+ * defined answer.
+ *
+ * @return boolean value
+ */
+ public boolean isPredefinedResponse()
+ {
+ //may need to add more logic here
+ return false;
+ }
+
+
+ public int compareTo(Object o)
+ {
+ QaUsrResp response = (QaUsrResp) o;
+
+ if (responseId == null)
+ return -1;
+ if (response.responseId == null)
+ return 1;
+
+ return (int) (responseId.longValue() - response.responseId.longValue());
+ }
+
+
+
+ /**
+ * @return Returns the qaQueContentId.
+ */
+ public Long getQaQueContentId() {
+ return qaQueContentId;
+ }
+ /**
+ * @param qaQueContentId The qaQueContentId to set.
+ */
+ public void setQaQueContentId(Long qaQueContentId) {
+ this.qaQueContentId = qaQueContentId;
+ }
+ /**
+ * @return Returns the queUsrId.
+ */
+ public Long getQueUsrId() {
+ return queUsrId;
+ }
+ /**
+ * @param queUsrId The queUsrId to set.
+ */
+ public void setQueUsrId(Long queUsrId) {
+ this.queUsrId = queUsrId;
+ }
+ /**
+ * @return Returns the hidden.
+ */
+ public boolean isHidden() {
+ return hidden;
+ }
+ /**
+ * @param hidden The hidden to set.
+ */
+ public void setHidden(boolean hidden) {
+ this.hidden = hidden;
+ }
+}
Index: lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/QaUtils.java
===================================================================
diff -u
--- lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/QaUtils.java (revision 0)
+++ lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/QaUtils.java (revision 16e844de3f7c34b44baee1b28e67e708f42d00bf)
@@ -0,0 +1,333 @@
+/*
+ * Created on 21/04/2005
+ *
+ * TODO To change the template for this generated file go to
+ * Window - Preferences - Java - Code Style - Code Templates
+ */
+package org.lamsfoundation.lams.tool.qa;
+
+import java.security.Principal;
+import java.util.Random;
+
+import javax.servlet.http.HttpServletRequest;
+
+import org.apache.log4j.Logger;
+import org.lamsfoundation.lams.tool.qa.service.IQaService;
+import org.lamsfoundation.lams.tool.qa.web.QaAuthoringForm;
+import org.lamsfoundation.lams.usermanagement.User;
+
+/**
+ *
+ *
+ * The session attributes ATTR_USERDATA and TOOL_USER refer to the same User object.
+ * TOOL_USER is the one we consistently use across the application to obtain current user data.
+ *
+ * Verify the assumption:
+ * We make the assumption that the obtained User object will habe a userId property ready in it.
+ * We use the same userId property as the user table key when we are saving learner responses and associated user data.
+ * *
+ */
+/**
+ * @author ozgurd
+ *
+ * TODO To change the template for this generated type comment go to
+ * Window - Preferences - Java - Code Style - Code Templates
+ */
+
+/**
+ * Common utility functions live here.
+ */
+public abstract class QaUtils implements QaAppConstants {
+
+ static Logger logger = Logger.getLogger(QaUtils.class.getName());
+
+ public static IQaService getToolService(HttpServletRequest request)
+ {
+ IQaService qaService=(IQaService)request.getSession().getAttribute(TOOL_SERVICE);
+ return qaService;
+ }
+
+
+ /**
+ * generateId()
+ * return long
+ * IMPORTANT: The way we obtain either content id or tool session id must be modified
+ * so that we only use lams common to get these ids. This functionality is not
+ * available yet in the lams common as of 21/04/2005.
+ */
+ public static long generateId()
+ {
+ Random generator = new Random();
+ long longId=generator.nextLong();
+ if (longId < 0) longId=longId * (-1) ;
+ return longId;
+ }
+
+ /**
+ * helps create a mock user object in development time.
+ * static long generateIntegerId()
+ * @return long
+ */
+ public static int generateIntegerId()
+ {
+ Random generator = new Random();
+ int intId=generator.nextInt();
+ if (intId < 0) intId=intId * (-1) ;
+ return intId;
+ }
+
+
+
+ /**
+ * cleanupSession(TreeMap mapQuestionContent, HttpServletRequest request)
+ * return void
+ * cleans up the session of the content details
+ */
+
+ public static void cleanupSession(HttpServletRequest request)
+ {
+ //remove session attributes in Authoring mode
+ request.getSession().removeAttribute(DEFAULT_QUESTION_CONTENT);
+ request.getSession().removeAttribute(MAP_QUESTION_CONTENT);
+ request.getSession().removeAttribute(CHOICE);
+ request.getSession().removeAttribute(IS_DEFINE_LATER);
+ request.getSession().removeAttribute(DISABLE_TOOL);
+ request.getSession().removeAttribute(CHOICE_TYPE_BASIC);
+ request.getSession().removeAttribute(CHOICE_TYPE_ADVANCED);
+ request.getSession().removeAttribute(CHOICE_TYPE_INSTRUCTIONS);
+ request.getSession().removeAttribute(REPORT_TITLE);
+ request.getSession().removeAttribute(INSTRUCTIONS);
+ request.getSession().removeAttribute(TITLE);
+ request.getSession().removeAttribute(CONTENT_LOCKED);
+
+
+ //remove session attributes in Learner mode
+ request.getSession().removeAttribute(MAP_ANSWERS);
+ request.getSession().removeAttribute(MAP_QUESTION_CONTENT_LEARNER);
+ request.getSession().removeAttribute(CURRENT_QUESTION_INDEX);
+ request.getSession().removeAttribute(TOTAL_QUESTION_COUNT);
+ request.getSession().removeAttribute(CURRENT_ANSWER);
+ request.getSession().removeAttribute(USER_FEEDBACK);
+ request.getSession().removeAttribute(TOOL_SESSION_ID);
+ request.getSession().removeAttribute(QUESTION_LISTING_MODE);
+ request.getSession().removeAttribute(QUESTION_LISTING_MODE_SEQUENTIAL);
+ request.getSession().removeAttribute(QUESTION_LISTING_MODE_COMBINED);
+ request.getSession().removeAttribute(MAP_USER_RESPONSES);
+ request.getSession().removeAttribute(MAP_MAIN_REPORT);
+ request.getSession().removeAttribute(REPORT_TITLE_LEARNER);
+ request.getSession().removeAttribute(END_LEARNING_MESSAGE);
+ request.getSession().removeAttribute(IS_TOOL_ACTIVITY_OFFLINE);
+
+ //remove session attributes in Monitoring mode
+ request.getSession().removeAttribute(MAP_TOOL_SESSIONS);
+ request.getSession().removeAttribute(MAP_MONITORING_QUESTIONS);
+
+ //remove session attributes used commonly
+ request.getSession().removeAttribute(IS_USERNAME_VISIBLE);
+ request.getSession().removeAttribute(REPORT_TITLE_MONITOR);
+ request.getSession().removeAttribute(IS_ALL_SESSIONS_COMPLETED);
+ request.getSession().removeAttribute(CHECK_ALL_SESSIONS_COMPLETED);
+ request.getSession().removeAttribute(TOOL_CONTENT_ID);
+ request.getSession().removeAttribute(ATTR_USERDATA);
+ request.getSession().removeAttribute(TOOL_USER);
+ request.getSession().removeAttribute(TOOL_SERVICE);
+ request.getSession().removeAttribute(TARGET_MODE);
+
+ request.getSession().removeAttribute(CURRENT_TOOL_USER_FULLNAME);
+ request.getSession().removeAttribute(CURRENT_TOOL_USER_ATTEMPTTIME);
+ request.getSession().removeAttribute(CURRENT_TOOL_USER_ANSWER);
+ }
+
+ public static void setDefaultSessionAttributes(HttpServletRequest request, QaContent defaultQaContent, QaAuthoringForm qaAuthoringForm)
+ {
+ //should never be null anyway as default content MUST exist in the db
+ if (defaultQaContent != null)
+ {
+ qaAuthoringForm.setTitle(defaultQaContent.getTitle());
+ qaAuthoringForm.setInstructions(defaultQaContent.getInstructions());
+ qaAuthoringForm.setReportTitle(defaultQaContent.getReportTitle());
+ qaAuthoringForm.setEndLearningMessage(defaultQaContent.getEndLearningMessage());
+ qaAuthoringForm.setOnlineInstructions(defaultQaContent.getOnlineInstructions());
+ qaAuthoringForm.setOfflineInstructions(defaultQaContent.getOfflineInstructions());
+ qaAuthoringForm.setMonitoringReportTitle(defaultQaContent.getMonitoringReportTitle());
+
+ request.getSession().setAttribute(TITLE,qaAuthoringForm.getTitle());
+ request.getSession().setAttribute(INSTRUCTIONS,qaAuthoringForm.getInstructions());
+ }
+
+ }
+
+
+ /**
+ * Helper method to retrieve the user data. We always load up from http
+ * session first to optimize the performance. If no session cache available,
+ * we load it from data source.
+ * @param request A standard Servlet HttpServletRequest class.
+ * @param surveyService the service facade of qa tool
+ * @return the user data value object
+ */
+ public static User getUserData(HttpServletRequest request,IQaService qaService) throws QaApplicationException
+ {
+ User userCompleteData = (User) request.getSession().getAttribute(ATTR_USERDATA);
+ logger.debug(logger + " " + "QaUtils" + "retrieving userCompleteData: " + userCompleteData);
+ /**
+ * if no session cache available, retrieve it from data source
+ */
+ if (userCompleteData == null)
+ {
+ /**
+ * WebUtil.getUsername(request,DEVELOPMENT_FLAG) returns the current learner's username based on
+ * user principals defined in the container. If no username is defined in the container, we get a RunTimeException.
+ */
+
+ /**
+ * pass testing flag as false to obtain user principal
+ */
+ try
+ {
+ String userName=getUsername(request,false);
+ userCompleteData = qaService.getCurrentUserData(userName);
+ }
+ catch(QaApplicationException e)
+ {
+ logger.debug(logger + " " + "QaUtils" + " Exception occured: Tool expects the current user is an authenticated user and he has a security principal defined. Can't continue!: " + e);
+ throw new QaApplicationException("Exception occured: " +
+ "Tool expects the current user is an authenticated user and he has a security principal defined. Can't continue!");
+ }
+
+ logger.debug(logger + " " + "QaUtils" + "retrieving userCompleteData from service: " + userCompleteData);
+ //this can be redundant as we keep the User data in TOOL_USER
+ request.getSession().setAttribute(ATTR_USERDATA, userCompleteData);
+ }
+ return userCompleteData;
+ }
+
+ public static int getCurrentUserId(HttpServletRequest request) throws QaApplicationException
+ {
+ User user=(User) request.getSession().getAttribute(TOOL_USER);
+ logger.debug(logger + " " + "QaUtils" + " Current user is: " + user + " with id: " + user.getUserId());
+ return user.getUserId().intValue();
+ }
+
+
+ /**
+ * Modified to throw QaApplicationException insteadof RuntimeException
+ * String getUsername(HttpServletRequest req,boolean isTesting) throws RuntimeException
+ * is normally lives in package org.lamsfoundation.lams.util. It generates Runtime exception when the user principal
+ * is not found. We find this not too usefulespeciaaly in teh development time. Below is a local and modified version
+ * of this function.
+ *
+ * @return username from principal object
+ */
+ public static String getUsername(HttpServletRequest req,boolean isTesting) throws QaApplicationException
+ {
+ if(isTesting)
+ return "test";
+
+ Principal principal = req.getUserPrincipal();
+ if (principal == null)
+ {
+ throw new QaApplicationException("Trying to get username but principal object missing. Request is "
+ + req.toString());
+ }
+
+ String username = principal.getName();
+ if (username == null)
+ {
+ throw new QaApplicationException("Name missing from principal object. Request is "
+ + req.toString()
+ + " Principal object is "
+ + principal.toString());
+ }
+ return username;
+ }
+
+
+ /**
+ * This method exists temporarily until we have the user data is passed properly from teh container to the tool
+ * createMockUser()
+ * @return User
+ */
+ public static User createMockUser()
+ {
+ logger.debug(logger + " " + "QaUtils" + " request for new new mock user");
+ int randomUserId=generateIntegerId();
+ User mockUser=new User();
+ mockUser.setUserId(new Integer(randomUserId));
+ mockUser.setFirstName(MOCK_USER_NAME + randomUserId);
+ mockUser.setLastName(MOCK_USER_LASTNAME + randomUserId);
+ mockUser.setLogin(MOCK_LOGIN_NAME + randomUserId); //we assume login and username refers to the same property
+ logger.debug(logger + " " + "QaUtils" + " created mockuser: " + mockUser);
+ return mockUser;
+ }
+
+
+ public static User createAuthoringUser(Integer userId)
+ {
+ User user=new User();
+ user.setUserId(userId);
+ return user;
+ }
+
+ public static User createUser(Integer userId)
+ {
+ User user=new User();
+ user.setUserId(userId);
+
+ int randomUserId=generateIntegerId();
+ user.setFirstName(MOCK_USER_NAME + randomUserId);
+ user.setLastName(MOCK_USER_LASTNAME + randomUserId);
+ user.setLogin(MOCK_LOGIN_NAME + randomUserId);
+ return user;
+ }
+
+ public static boolean getDefineLaterStatus()
+ {
+ return false;
+ }
+
+
+ /**
+ * existsContent(long toolContentId)
+ * @param long toolContentId
+ * @return boolean
+ * determine whether a specific toolContentId exists in the db
+ */
+ public static boolean existsContent(long toolContentId, HttpServletRequest request)
+ {
+ /**
+ * retrive the service
+ */
+ IQaService qaService =QaUtils.getToolService(request);
+
+ QaContent qaContent=qaService.loadQa(toolContentId);
+ logger.debug(logger + " " + "QaUtils " + "retrieving qaContent: " + qaContent);
+ if (qaContent == null)
+ return false;
+
+ return true;
+ }
+
+ /**
+ * it is expected that the tool session id already exists in the tool sessions table
+ * existsSession(long toolSessionId)
+ * @param toolSessionId
+ * @return boolean
+ */
+ public static boolean existsSession(long toolSessionId, HttpServletRequest request)
+ {
+ /**
+ * get the service
+ */
+ IQaService qaService =QaUtils.getToolService(request);
+ QaSession qaSession=qaService.retrieveQaSessionOrNullById(toolSessionId);
+
+ logger.debug(logger + " " + " QaUtils " + "retrieving qaSession: " + qaSession);
+
+ if (qaSession == null)
+ return false;
+
+ return true;
+ }
+
+}
Index: lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/dao/IQaContentDAO.java
===================================================================
diff -u
--- lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/dao/IQaContentDAO.java (revision 0)
+++ lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/dao/IQaContentDAO.java (revision 16e844de3f7c34b44baee1b28e67e708f42d00bf)
@@ -0,0 +1,65 @@
+/*
+ *Copyright (C) 2005 LAMS Foundation (http://lamsfoundation.org)
+ *
+ *This program is free software; you can redistribute it and/or modify
+ *it under the terms of the GNU General Public License as published by
+ *the Free Software Foundation; either version 2 of the License, or
+ *(at your option) any later version.
+ *
+ *This program is distributed in the hope that it will be useful,
+ *but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ *GNU General Public License for more details.
+ *
+ *You should have received a copy of the GNU General Public License
+ *along with this program; if not, write to the Free Software
+ *Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
+ *USA
+ *
+ *http://www.gnu.org/licenses/gpl.txt
+ */
+package org.lamsfoundation.lams.tool.qa.dao;
+
+import org.lamsfoundation.lams.tool.qa.QaContent;
+
+
+
+
+/**
+ *
+ * @author ozgurd
+ *
+ */
+public interface IQaContentDAO
+{
+ public QaContent getQaById(long qaId);
+
+ /**
+ *
+ * return null if not found
+ */
+ public QaContent loadQaById(long qaId);
+
+ /**
+ * returns qa content
+ * getQaBySession(Long sessionId)
+ * @param sessionId
+ * @return QaContent
+ */
+ public QaContent getQaBySession(Long sessionId);
+
+ public void saveQa(QaContent qa);
+
+ public void updateQa(QaContent qa);
+
+ public void removeQa(Long qaContentId);
+
+ public void deleteQa(QaContent qa);
+
+ public void removeQaById(Long qaId);
+
+ public void removeAllQaSession(QaContent content);
+
+ public int countUserResponsed(QaContent content);
+
+}
Index: lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/dao/IQaQueContentDAO.java
===================================================================
diff -u
--- lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/dao/IQaQueContentDAO.java (revision 0)
+++ lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/dao/IQaQueContentDAO.java (revision 16e844de3f7c34b44baee1b28e67e708f42d00bf)
@@ -0,0 +1,39 @@
+/*
+ *Copyright (C) 2005 LAMS Foundation (http://lamsfoundation.org)
+ *
+ *This program is free software; you can redistribute it and/or modify
+ *it under the terms of the GNU General Public License as published by
+ *the Free Software Foundation; either version 2 of the License, or
+ *(at your option) any later version.
+ *
+ *This program is distributed in the hope that it will be useful,
+ *but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ *GNU General Public License for more details.
+ *
+ *You should have received a copy of the GNU General Public License
+ *along with this program; if not, write to the Free Software
+ *Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
+ *USA
+ *
+ *http://www.gnu.org/licenses/gpl.txt
+ */
+package org.lamsfoundation.lams.tool.qa.dao;
+
+import org.lamsfoundation.lams.tool.qa.QaQueContent;
+
+
+/**
+ *
+ * @author ozgurd
+ *
+ */
+public interface IQaQueContentDAO
+{
+ public QaQueContent getQaQueById(long qaQueContentId);
+
+ public void createQueContent(QaQueContent queContent);
+
+ public void removeQueContent(long qaQueContentId);
+
+}
Index: lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/dao/IQaQueUsrDAO.java
===================================================================
diff -u
--- lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/dao/IQaQueUsrDAO.java (revision 0)
+++ lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/dao/IQaQueUsrDAO.java (revision 16e844de3f7c34b44baee1b28e67e708f42d00bf)
@@ -0,0 +1,43 @@
+/*
+ *Copyright (C) 2005 LAMS Foundation (http://lamsfoundation.org)
+ *
+ *This program is free software; you can redistribute it and/or modify
+ *it under the terms of the GNU General Public License as published by
+ *the Free Software Foundation; either version 2 of the License, or
+ *(at your option) any later version.
+ *
+ *This program is distributed in the hope that it will be useful,
+ *but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ *GNU General Public License for more details.
+ *
+ *You should have received a copy of the GNU General Public License
+ *along with this program; if not, write to the Free Software
+ *Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
+ *USA
+ *
+ *http://www.gnu.org/licenses/gpl.txt
+ */
+package org.lamsfoundation.lams.tool.qa.dao;
+
+import org.lamsfoundation.lams.tool.qa.QaQueUsr;
+import org.lamsfoundation.lams.tool.qa.QaSession;
+
+
+/**
+ *
+ * @author ozgurd
+ *
+ */
+public interface IQaQueUsrDAO
+{
+ public QaQueUsr getQaQueUsrById(long qaQueUsrId);
+
+ public QaQueUsr loadQaQueUsrById(long qaQueUsrId);
+
+ public void createUsr(QaQueUsr usr);
+
+ public void deleteQaQueUsr(QaQueUsr qaQueUsr);
+
+ public int countSessionUser(QaSession qaSession);
+}
Index: lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/dao/IQaSessionDAO.java
===================================================================
diff -u
--- lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/dao/IQaSessionDAO.java (revision 0)
+++ lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/dao/IQaSessionDAO.java (revision 16e844de3f7c34b44baee1b28e67e708f42d00bf)
@@ -0,0 +1,51 @@
+/*
+ *Copyright (C) 2005 LAMS Foundation (http://lamsfoundation.org)
+ *
+ *This program is free software; you can redistribute it and/or modify
+ *it under the terms of the GNU General Public License as published by
+ *the Free Software Foundation; either version 2 of the License, or
+ *(at your option) any later version.
+ *
+ *This program is distributed in the hope that it will be useful,
+ *but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ *GNU General Public License for more details.
+ *
+ *You should have received a copy of the GNU General Public License
+ *along with this program; if not, write to the Free Software
+ *Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
+ *USA
+ *
+ *http://www.gnu.org/licenses/gpl.txt
+ */
+package org.lamsfoundation.lams.tool.qa.dao;
+
+import org.lamsfoundation.lams.tool.qa.QaContent;
+import org.lamsfoundation.lams.tool.qa.QaSession;
+
+
+/**
+ *
+ * @author ozgurd
+ */
+public interface IQaSessionDAO
+{
+ public int countIncompleteSession(QaContent qa);
+
+ public QaSession getQaSessionById(long qaSessionId);
+
+ public QaSession getQaSessionOrNullById(long qaSessionId);
+
+ public int studentActivityOccurred(QaContent qa);
+
+ public void CreateQaSession(QaSession session);
+
+ public void UpdateQaSession(QaSession session);
+
+ public void deleteQaSession(QaSession session);
+}
+
+
+
+
+
Index: lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/dao/IQaUsrRespDAO.java
===================================================================
diff -u
--- lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/dao/IQaUsrRespDAO.java (revision 0)
+++ lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/dao/IQaUsrRespDAO.java (revision 16e844de3f7c34b44baee1b28e67e708f42d00bf)
@@ -0,0 +1,46 @@
+/*
+ *Copyright (C) 2005 LAMS Foundation (http://lamsfoundation.org)
+ *
+ *This program is free software; you can redistribute it and/or modify
+ *it under the terms of the GNU General Public License as published by
+ *the Free Software Foundation; either version 2 of the License, or
+ *(at your option) any later version.
+ *
+ *This program is distributed in the hope that it will be useful,
+ *but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ *GNU General Public License for more details.
+ *
+ *You should have received a copy of the GNU General Public License
+ *along with this program; if not, write to the Free Software
+ *Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
+ *USA
+ *
+ *http://www.gnu.org/licenses/gpl.txt
+ */
+package org.lamsfoundation.lams.tool.qa.dao;
+
+import org.lamsfoundation.lams.tool.qa.QaUsrResp;
+
+
+/**
+ *
+ * @author ozgurd
+ *
+ */
+public interface IQaUsrRespDAO
+{
+ public void saveUserResponse(QaUsrResp resp);
+
+ public void updateUserResponse(QaUsrResp resp);
+
+ public void createUserResponse(QaUsrResp resp);
+
+ public void removeUserResponse(QaUsrResp resp);
+
+ public void removeUserResponseByQaQueId(Long qaQueId);
+
+ public QaUsrResp retrieveQaUsrResp(long responseId);
+}
+
+
Index: lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/dao/hibernate/QaContentDAO.java
===================================================================
diff -u
--- lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/dao/hibernate/QaContentDAO.java (revision 0)
+++ lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/dao/hibernate/QaContentDAO.java (revision 16e844de3f7c34b44baee1b28e67e708f42d00bf)
@@ -0,0 +1,137 @@
+/*
+ * Created on 15/03/2005
+ *
+ * TODO To change the template for this generated file go to
+ * Window - Preferences - Java - Code Style - Code Templates
+ */
+package org.lamsfoundation.lams.tool.qa.dao.hibernate;
+
+import net.sf.hibernate.Hibernate;
+import net.sf.hibernate.HibernateException;
+import net.sf.hibernate.Session;
+
+import org.apache.log4j.Logger;
+import org.lamsfoundation.lams.tool.qa.QaContent;
+import org.lamsfoundation.lams.tool.qa.dao.IQaContentDAO;
+import org.springframework.orm.hibernate.HibernateCallback;
+import org.springframework.orm.hibernate.support.HibernateDaoSupport;
+
+
+/**
+ * @author ozgurd
+ *
+ * TODO To change the template for this generated type comment go to
+ * Window - Preferences - Java - Code Style - Code Templates
+ */
+
+public class QaContentDAO extends HibernateDaoSupport implements IQaContentDAO {
+ static Logger logger = Logger.getLogger(QaContentDAO.class.getName());
+
+ private static final String LOAD_QA_BY_SESSION = "select qa from QaContent qa left join fetch "
+ + "qa.qaSessions session where session.qaSessionId=:sessionId";
+
+
+ private static final String COUNT_USER_RESPONSED = "select distinct u.userId from QaQueUsr u left join fetch"
+ + " u.qaQueContent as ques where ques.qaContent = :qa group by u.userId";
+
+
+ public QaContentDAO() {}
+
+ public QaContent getQaById(long qaId)
+ {
+ return (QaContent) this.getHibernateTemplate()
+ .load(QaContent.class, new Long(qaId));
+ }
+
+ /**
+ *
+ * return null if not found
+ */
+ public QaContent loadQaById(long qaId)
+ {
+ logger.debug(logger + " " + this.getClass().getName() + " " + "loadQaById called with: " + qaId);
+ return (QaContent) this.getHibernateTemplate().get(QaContent.class, new Long(qaId));
+ }
+
+
+
+ public void updateQa(QaContent qa)
+ {
+ this.getHibernateTemplate().update(qa);
+ }
+
+
+
+ public QaContent getQaBySession(final Long sessionId)
+ {
+ return (QaContent) getHibernateTemplate().execute(new HibernateCallback()
+ {
+
+ public Object doInHibernate(Session session) throws HibernateException
+ {
+ return session.createQuery(LOAD_QA_BY_SESSION)
+ .setLong("sessionId",
+ sessionId.longValue())
+ .uniqueResult();
+ }
+ });
+ }
+
+ public void saveQa(QaContent qa)
+ {
+ this.getHibernateTemplate().save(qa);
+ }
+
+ public void createQa(QaContent qa)
+ {
+ this.getHibernateTemplate().save(qa);
+ }
+
+ public void UpdateQa(QaContent qa)
+ {
+ this.getHibernateTemplate().update(qa);
+ }
+
+ public int countUserResponsed(QaContent qa)
+ {
+ return (getHibernateTemplate().findByNamedParam(COUNT_USER_RESPONSED,
+ "qa",
+ qa)).size();
+ }
+
+
+
+ /** GETS CALLED BY CONTRACT
+ */
+ public void removeAllQaSession(QaContent qaContent){
+ logger.debug(logger + " " + this.getClass().getName() + " " + "before removing all sessions: ");
+ this.getHibernateTemplate().deleteAll(qaContent.getQaSessions());
+ }
+
+ public void removeQa(Long qaId)
+ {
+ String query = "from qa in class org.lamsfoundation.lams.tool.qa.QaContent"
+ + " where qa.qaContentId = ?";
+ this.getHibernateTemplate().delete(query,qaId,Hibernate.LONG);
+ }
+
+ public void deleteQa(QaContent qaContent)
+ {
+ this.getHibernateTemplate().delete(qaContent);
+ }
+
+ public void removeQaById(Long qaId)
+ {
+ String query = "from qa in class org.lamsfoundation.lams.tool.qa.QaContent"
+ + " where qa.qaContentId = ?";
+ this.getHibernateTemplate().delete(query,qaId,Hibernate.LONG);
+ }
+
+
+ public void flush()
+ {
+ this.getHibernateTemplate().flush();
+ }
+
+
+}
\ No newline at end of file
Index: lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/dao/hibernate/QaQueContentDAO.java
===================================================================
diff -u
--- lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/dao/hibernate/QaQueContentDAO.java (revision 0)
+++ lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/dao/hibernate/QaQueContentDAO.java (revision 16e844de3f7c34b44baee1b28e67e708f42d00bf)
@@ -0,0 +1,42 @@
+/*
+ * Created on 15/03/2005
+ *
+ * TODO To change the template for this generated file go to
+ * Window - Preferences - Java - Code Style - Code Templates
+ */
+package org.lamsfoundation.lams.tool.qa.dao.hibernate;
+
+import org.apache.log4j.Logger;
+import org.lamsfoundation.lams.tool.qa.QaQueContent;
+import org.lamsfoundation.lams.tool.qa.dao.IQaQueContentDAO;
+import org.springframework.orm.hibernate.support.HibernateDaoSupport;
+
+
+
+
+/**
+ * @author ozgurd
+ *
+ * TODO To change the template for this generated type comment go to
+ * Window - Preferences - Java - Code Style - Code Templates
+ */
+
+public class QaQueContentDAO extends HibernateDaoSupport implements IQaQueContentDAO {
+ static Logger logger = Logger.getLogger(QaQueContentDAO.class.getName());
+
+ public QaQueContent getQaQueById(long qaQueContentId)
+ {
+ return (QaQueContent) this.getHibernateTemplate().load(QaQueContent.class, new Long(qaQueContentId));
+ }
+
+ public void createQueContent(QaQueContent queContent)
+ {
+ this.getHibernateTemplate().save(queContent);
+ }
+
+ public void removeQueContent(long qaQueContentId)
+ {
+ QaQueContent qaQueContent= (QaQueContent) this.getHibernateTemplate().load(QaQueContent.class, new Long(qaQueContentId));
+ this.getHibernateTemplate().delete(qaQueContent);
+ }
+}
\ No newline at end of file
Index: lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/dao/hibernate/QaQueUsrDAO.java
===================================================================
diff -u
--- lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/dao/hibernate/QaQueUsrDAO.java (revision 0)
+++ lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/dao/hibernate/QaQueUsrDAO.java (revision 16e844de3f7c34b44baee1b28e67e708f42d00bf)
@@ -0,0 +1,60 @@
+/*
+ * Created on 15/03/2005
+ *
+ * TODO To change the template for this generated file go to
+ * Window - Preferences - Java - Code Style - Code Templates
+ */
+package org.lamsfoundation.lams.tool.qa.dao.hibernate;
+
+import org.apache.log4j.Logger;
+import org.lamsfoundation.lams.tool.qa.QaQueUsr;
+import org.lamsfoundation.lams.tool.qa.QaSession;
+import org.lamsfoundation.lams.tool.qa.dao.IQaQueUsrDAO;
+import org.springframework.orm.hibernate.support.HibernateDaoSupport;
+
+
+
+
+/**
+ * @author ozgurd
+ *
+ * TODO To change the template for this generated type comment go to
+ * Window - Preferences - Java - Code Style - Code Templates
+ */
+
+public class QaQueUsrDAO extends HibernateDaoSupport implements IQaQueUsrDAO {
+ static Logger logger = Logger.getLogger(QaQueUsrDAO.class.getName());
+
+ private static final String COUNT_SESSION_USER = "select qaQueUsr.queUsrId from QaQueUsr qaQueUsr where qaQueUsr.qaSessionId= :qaSession";
+
+
+ public int countSessionUser(QaSession qaSession)
+ {
+ return (getHibernateTemplate().findByNamedParam(COUNT_SESSION_USER,
+ "qaSession",
+ qaSession)).size();
+ }
+
+
+ public QaQueUsr getQaQueUsrById(long qaQueUsrId)
+ {
+ return (QaQueUsr) this.getHibernateTemplate().load(QaQueUsr.class, new Long(qaQueUsrId));
+ }
+
+ public QaQueUsr loadQaQueUsrById(long qaQueUsrId)
+ {
+ return (QaQueUsr) this.getHibernateTemplate().get(QaQueUsr.class, new Long(qaQueUsrId));
+ }
+
+ public void createUsr(QaQueUsr usr)
+ {
+ this.getHibernateTemplate().save(usr);
+ }
+
+ public void deleteQaQueUsr(QaQueUsr qaQueUsr)
+ {
+ this.getHibernateTemplate().delete(qaQueUsr);
+ }
+
+
+}
\ No newline at end of file
Index: lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/dao/hibernate/QaSessionDAO.java
===================================================================
diff -u
--- lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/dao/hibernate/QaSessionDAO.java (revision 0)
+++ lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/dao/hibernate/QaSessionDAO.java (revision 16e844de3f7c34b44baee1b28e67e708f42d00bf)
@@ -0,0 +1,93 @@
+/*
+ *Copyright (C) 2005 LAMS Foundation (http://lamsfoundation.org)
+ *
+ *This program is free software; you can redistribute it and/or modify
+ *it under the terms of the GNU General Public License as published by
+ *the Free Software Foundation; either version 2 of the License, or
+ *(at your option) any later version.
+ *
+ *This program is distributed in the hope that it will be useful,
+ *but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ *GNU General Public License for more details.
+ *
+ *You should have received a copy of the GNU General Public License
+ *along with this program; if not, write to the Free Software
+ *Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
+ *USA
+ *
+ *http://www.gnu.org/licenses/gpl.txt
+ */
+package org.lamsfoundation.lams.tool.qa.dao.hibernate;
+
+import org.lamsfoundation.lams.tool.qa.QaContent;
+import org.lamsfoundation.lams.tool.qa.QaSession;
+import org.lamsfoundation.lams.tool.qa.dao.IQaSessionDAO;
+import org.springframework.orm.hibernate.support.HibernateDaoSupport;
+
+
+
+/**
+ * @author ozgurd
+ *
+ */
+public class QaSessionDAO extends HibernateDaoSupport implements
+ IQaSessionDAO
+{
+ private static final String COUNT_SESSION_INCOMPLITE = "select qaSession.session_status from QaSession qaSession where qaSession.session_status='INCOMPLETE' and qaSession.qaContentId = :qa";
+ private static final String COUNT_SESSION_ACTIVITY = "select qaSession.session_status from QaSession qaSession where qaSession.qaContentId = :qa";
+
+
+ public int countIncompleteSession(QaContent qa)
+ {
+ return (getHibernateTemplate().findByNamedParam(COUNT_SESSION_INCOMPLITE,
+ "qa",
+ qa)).size();
+ }
+
+ public int studentActivityOccurred(QaContent qa)
+ {
+ return (getHibernateTemplate().findByNamedParam(COUNT_SESSION_ACTIVITY,
+ "qa",
+ qa)).size();
+ }
+
+
+ /**
+ * @see org.lamsfoundation.lams.tool.survey.dao.interfaces.ISurveySessionDAO#getSurveySessionById(long)
+ */
+ public QaSession getQaSessionById(long qaSessionId)
+ {
+ return (QaSession)this.getHibernateTemplate().load(QaSession.class,new Long(qaSessionId));
+ }
+
+ public QaSession getQaSessionOrNullById(long qaSessionId)
+ {
+ return (QaSession)this.getHibernateTemplate().get(QaSession.class,new Long(qaSessionId));
+ }
+
+ /**
+ * @see org.lamsfoundation.lams.tool.survey.dao.interfaces.ISurveySessionDAO#CreateSurveySession(com.lamsinternational.tool.survey.domain.SurveySession)
+ */
+ public void CreateQaSession(QaSession session)
+ {
+ this.getHibernateTemplate().save(session);
+ }
+
+ /**
+ * @see org.lamsfoundation.lams.tool.survey.dao.interfaces.ISurveySessionDAO#UpdateSurveySession(com.lamsinternational.tool.survey.domain.SurveySession)
+ */
+ public void UpdateQaSession(QaSession session)
+ {
+ this.getHibernateTemplate().update(session);
+ }
+
+ /**
+ * @see org.lamsfoundation.lams.tool.survey.dao.interfaces.ISurveySessionDAO#deleteSurveySession(com.lamsinternational.tool.survey.domain.SurveySession)
+ */
+ public void deleteQaSession(QaSession qaSession)
+ {
+ this.getHibernateTemplate().delete(qaSession);
+ }
+
+}
Index: lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/dao/hibernate/QaUsrRespDAO.java
===================================================================
diff -u
--- lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/dao/hibernate/QaUsrRespDAO.java (revision 0)
+++ lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/dao/hibernate/QaUsrRespDAO.java (revision 16e844de3f7c34b44baee1b28e67e708f42d00bf)
@@ -0,0 +1,89 @@
+/*
+ *Copyright (C) 2005 LAMS Foundation (http://lamsfoundation.org)
+ *
+ *This program is free software; you can redistribute it and/or modify
+ *it under the terms of the GNU General Public License as published by
+ *the Free Software Foundation; either version 2 of the License, or
+ *(at your option) any later version.
+ *
+ *This program is distributed in the hope that it will be useful,
+ *but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ *GNU General Public License for more details.
+ *
+ *You should have received a copy of the GNU General Public License
+ *along with this program; if not, write to the Free Software
+ *Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
+ *USA
+ *
+ *http://www.gnu.org/licenses/gpl.txt
+ */
+package org.lamsfoundation.lams.tool.qa.dao.hibernate;
+
+import net.sf.hibernate.Hibernate;
+
+import org.lamsfoundation.lams.tool.qa.QaContent;
+import org.lamsfoundation.lams.tool.qa.QaQueUsr;
+import org.lamsfoundation.lams.tool.qa.QaUsrResp;
+import org.lamsfoundation.lams.tool.qa.dao.IQaUsrRespDAO;
+import org.springframework.orm.hibernate.support.HibernateDaoSupport;
+
+
+/**
+ *
+ * @author ozgurd
+ *
+ */
+public class QaUsrRespDAO extends HibernateDaoSupport implements IQaUsrRespDAO
+{
+
+ public QaQueUsr getUserById(long userId)
+ {
+ return (QaQueUsr)this.getHibernateTemplate().load(QaQueUsr.class,new Long(userId));
+
+ }
+
+ public void createUserResponse(QaUsrResp qaUsrResp)
+ {
+ this.getHibernateTemplate().save(qaUsrResp);
+ }
+
+ public QaUsrResp retrieveQaUsrResp(long responseId)
+ {
+ logger.debug(logger + " " + this.getClass().getName() + " " + "retrieveUserResponse called with: " + responseId);
+ return (QaUsrResp) this.getHibernateTemplate().get(QaUsrResp.class, new Long(responseId));
+ }
+
+
+ /**
+ * @see org.lamsfoundation.lams.tool.qa.dao.interfaces.IQaUsrRespDAO#saveUserResponse(com.lamsinternational.tool.qa.domain.QaUsrResp)
+ */
+ public void saveUserResponse(QaUsrResp resp)
+ {
+ this.getHibernateTemplate().save(resp);
+ }
+
+ /**
+ * @see org.lamsfoundation.lams.tool.qa.dao.IQaUsrRespDAO#updateUserResponse(org.lamsfoundation.lams.tool.qa.QaUsrResp)
+ */
+ public void updateUserResponse(QaUsrResp resp)
+ {
+ this.getHibernateTemplate().update(resp);
+ }
+
+ public void removeUserResponse(QaUsrResp resp)
+ {
+ this.getHibernateTemplate().delete(resp);
+ }
+
+
+ public void removeUserResponseByQaQueId(Long qaQueId)
+ {
+ String query = "from resp in class org.lamsfoundation.lams.tool.qa.QaUsrResp"
+ + " where resp.qaQueContentId = ?";
+ this.getHibernateTemplate().delete(query,qaQueId,Hibernate.LONG);
+ }
+
+}
+
+
Index: lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/dbConnection.properties
===================================================================
diff -u
--- lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/dbConnection.properties (revision 0)
+++ lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/dbConnection.properties (revision 16e844de3f7c34b44baee1b28e67e708f42d00bf)
@@ -0,0 +1,19 @@
+# Properties file with Hibernate-related settings.
+# Applied by PropertyPlaceholderConfigurer from "dbConnection.xml".
+# Targetted at system administrators, to avoid touching the context XML files.
+
+#jdbc configuration
+jdbc.driverClassName=org.gjt.mm.mysql.Driver
+jdbc.url=jdbc:mysql://localhost/lams
+jdbc.username=root
+jdbc.password=root
+
+#Hibernate configuration
+hibernate.show_sql=true
+hibernate.dialect=net.sf.hibernate.dialect.MySQLDialect
+
+#Connection Pooling configuration
+hibernate.c3p0.minPoolSize=5
+hibernate.c3p0.maxPoolSize=20
+hibernate.c3p0.timeout=1800
+hibernate.c3p0.max_statement=50
\ No newline at end of file
Index: lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/log4j.properties
===================================================================
diff -u
--- lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/log4j.properties (revision 0)
+++ lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/log4j.properties (revision 16e844de3f7c34b44baee1b28e67e708f42d00bf)
@@ -0,0 +1,12 @@
+# Set the root logger to the DEBUG level and FA as a FileAppender
+#log4j.rootLogger=DEBUG, FA
+
+# Set FA to be a FileAppender.
+#log4j.appender.FA=org.apache.log4j.FileAppender
+
+# Set the filename and layout for FA to use
+#log4j.appender.FA.file=AppLogger.log
+#log4j.appender.FA.MaxFileSize=100MB
+#log4j.appender.FA.append=true
+#log4j.appender.FA.layout=org.apache.log4j.PatternLayout
+#log4j.appender.FA.layout.ConversionPattern=Date=%d{MMM dd yyyy} at Time=%d{HH:mm:ss} %-5p : %m %n
Index: lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/qaApplicationContext.xml
===================================================================
diff -u
--- lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/qaApplicationContext.xml (revision 0)
+++ lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/qaApplicationContext.xml (revision 16e844de3f7c34b44baee1b28e67e708f42d00bf)
@@ -0,0 +1,177 @@
+
+
+
+
+
+
+
+
+
+
+
+
+ /WEB-INF/dbConnection.properties
+
+
+
+
+
+
+
+ ${jdbc.driverClassName}
+ ${jdbc.url}
+ ${jdbc.username}
+ ${jdbc.password}
+
+
+
+
+
+
+
+
+ /WEB-INF/QaContent.hbm.xml
+ /WEB-INF/QaSession.hbm.xml
+ /WEB-INF/QaQueContent.hbm.xml
+ /WEB-INF/QaQueUsr.hbm.xml
+ /WEB-INF/QaUsrResp.hbm.xml
+
+
+
+
+ ${hibernate.dialect}
+ ${hibernate.show_sql}
+ ${hibernate.c3p0.minPoolSize}
+ ${hibernate.c3p0.maxPoolSize}
+ ${hibernate.c3p0.timeout}
+ ${hibernate.c3p0.max_statement}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ PROPAGATION_REQUIRED,-QaApplicationException
+ PROPAGATION_REQUIRED,-QaApplicationException
+ PROPAGATION_REQUIRED, -QaApplicationException
+ PROPAGATION_REQUIRED,-QaApplicationException
+ PROPAGATION_REQUIRED,readOnly,-QacpApplicationException
+ PROPAGATION_REQUIRED,-QaApplicationException
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ PROPAGATION_REQUIRED,-QaApplicationException
+
+
+
+
+
+
+
+
+
Index: lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/service/IQaService.java
===================================================================
diff -u
--- lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/service/IQaService.java (revision 0)
+++ lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/service/IQaService.java (revision 16e844de3f7c34b44baee1b28e67e708f42d00bf)
@@ -0,0 +1,184 @@
+/*
+ *Copyright (C) 2005 LAMS Foundation (http://lamsfoundation.org)
+ *
+ *This program is free software; you can redistribute it and/or modify
+ *it under the terms of the GNU General Public License as published by
+ *the Free Software Foundation; either version 2 of the License, or
+ *(at your option) any later version.
+ *
+ *This program is distributed in the hope that it will be useful,
+ *but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ *GNU General Public License for more details.
+ *
+ *You should have received a copy of the GNU General Public License
+ *along with this program; if not, write to the Free Software
+ *Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
+ *USA
+ *
+ *http://www.gnu.org/licenses/gpl.txt
+ */
+package org.lamsfoundation.lams.tool.qa.service;
+
+import org.lamsfoundation.lams.tool.qa.QaContent;
+import org.lamsfoundation.lams.tool.qa.QaQueContent;
+import org.lamsfoundation.lams.tool.qa.QaQueUsr;
+import org.lamsfoundation.lams.tool.qa.QaSession;
+import org.lamsfoundation.lams.tool.qa.QaUsrResp;
+import org.lamsfoundation.lams.usermanagement.User;
+
+
+/**
+ * This interface define the contract that all Survey service provider must
+ * follow.
+ *
+ * @author ozgurd
+ */
+public interface IQaService
+{
+ /**
+ * Return the qa object according to the requested content id.
+ * @param toolContentId the tool content id
+ * @return the qa object
+ */
+
+ public QaContent retrieveQa(long toolContentId);
+
+
+ /**
+ * Return the qa object according to the requested content id.
+ * @param toolContentId the tool content id
+ * @return the qa object or null
+ */
+
+ public QaContent loadQa(long toolContentId);
+
+
+
+ /**
+ * Return the question content object according to the requested question content id.
+ * @param qaQueContentId qa question content id
+ * @return the qa question object
+ */
+ public QaQueContent retrieveQaQue(long qaQueContentId);
+
+ public QaQueUsr loadQaQueUsr(Long userId);
+
+ public void createQaQue(QaQueContent qaQueContent);
+
+ public void createQaUsrResp(QaUsrResp qaUsrResp);
+
+ public QaUsrResp retrieveQaUsrResp(long responseId);
+
+ public void updateQaUsrResp(QaUsrResp qaUsrResp);
+
+
+ /**
+ * Return the qa session object according to the requested session id.
+ * @param qaSessionId qa session id
+ * @return the qa session object
+ */
+ public QaSession retrieveQaSession(long qaSessionId);
+
+ public QaSession retrieveQaSessionOrNullById(long qaSessionId);
+
+ public void createQaSession(QaSession qaSession);
+
+ public void createQaQueUsr(QaQueUsr qaQueUsr);
+
+ public void updateQaSession(QaSession qaSession);
+
+
+ /**
+ * Return the qa que user object according to the requested usr id.
+ * @param qaQaUsrId qa usr id
+ * @return the qa que usr object
+ */
+ public QaQueUsr retrieveQaQueUsr(long qaQaUsrId);
+
+ public void updateQa(QaContent qa);
+
+ public void createQa(QaContent qa);
+
+ public void deleteQa(QaContent qa);
+
+ public void deleteUsrRespByQueId(Long qaQueId);
+
+ public void deleteQaById(Long qaId);
+
+ public void deleteQaQueUsr(QaQueUsr qaQueUsr);
+
+ public void removeUserResponse(QaUsrResp resp);
+
+ public User getCurrentUserData(String username);
+
+ /**
+ *
+ * copyToolContent(Long fromContentId, Long toContentId)
+ * should ideally should not be part this interface as it is
+ * already part of the interface ToolSessionManager. It is here for development purposes.
+ * return void
+ * @param fromContentId
+ * @param toContentId
+ */
+ public void copyToolContent(Long fromContentId, Long toContentId);
+
+ public void setAsDefineLater(Long toolContentId);
+
+ public void unsetAsDefineLater(Long toolContentId);
+
+ public void setAsRunOffline(Long toolContentId);
+
+ /**
+ * TO BE DEFINED AS PART OF MAIN TOOL API
+ * updates user's tool session status from INCOMPLETE to COMPLETED
+ * @param userId
+ */
+ public void setAsForceComplete(Long userId);
+
+ /**
+ * TO BE DEFINED AS PART OF MAIN TOOL API
+ * @param toolSessionId
+ */
+ public void setAsForceCompleteSession(Long toolSessionId);
+
+ public boolean studentActivityOccurred(QaContent qa);
+
+ public boolean studentActivityOccurredGlobal(QaContent qaContent);
+
+
+ /**
+ * removeToolContent(Long toolContentId) should ideally should not be part this interface as it is
+ * already part of the interface ToolSessionManager. It is here for development purposes.
+ * return void
+ * @param toolContentId
+ */
+ public void removeToolContent(Long toolContentId);
+
+
+ /**
+ * createToolSession(Long toolSessionId, Long toolContentId) should ideally should not be part this interface as it is
+ * already part of the interface ToolSessionManager. It is here for development purposes.
+ *
+ * It is also defined here since in development we want to be able call it directly from our web-layer
+ * instead of it being called by the container.
+ * @param toolSessionId
+ * @param toolContentId
+ */
+ public void createToolSession(Long toolSessionId, Long toolContentId);
+
+ /**
+ * leaveToolSession(Long toolSessionId, User learner) should ideally should not be part this interface as it is
+ * already part of the interface ToolSessionManager. It is here for development purposes.
+ *
+ * It is also defined here since in development we want to be able call it directly from our web-layer
+ * instead of it being called by the container.
+ * @param toolSessionId
+ * @param toolContentId
+ */
+ public String leaveToolSession(Long toolSessionId, User learner);
+
+ public int countSessionUser(QaSession qaSession);
+
+}
+
Index: lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/service/QaServicePOJO.java
===================================================================
diff -u
--- lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/service/QaServicePOJO.java (revision 0)
+++ lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/service/QaServicePOJO.java (revision 16e844de3f7c34b44baee1b28e67e708f42d00bf)
@@ -0,0 +1,1096 @@
+/*
+ *Copyright (C) 2005 LAMS Foundation (http://lamsfoundation.org)
+ *
+ *This program is free software; you can redistribute it and/or modify
+ *it under the terms of the GNU General Public License as published by
+ *the Free Software Foundation; either version 2 of the License, or
+ *(at your option) any later version.
+ *
+ *This program is distributed in the hope that it will be useful,
+ *but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ *GNU General Public License for more details.
+ *
+ *You should have received a copy of the GNU General Public License
+ *along with this program; if not, write to the Free Software
+ *Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
+ *USA
+ *
+ *http://www.gnu.org/licenses/gpl.txt
+ */
+package org.lamsfoundation.lams.tool.qa.service;
+import java.util.Date;
+import java.util.Iterator;
+import java.util.List;
+import java.util.TreeSet;
+
+import org.apache.log4j.Logger;
+import org.lamsfoundation.lams.lesson.Lesson;
+import org.lamsfoundation.lams.tool.ToolContentManager;
+import org.lamsfoundation.lams.tool.ToolSessionExportOutputData;
+import org.lamsfoundation.lams.tool.ToolSessionManager;
+import org.lamsfoundation.lams.tool.qa.QaApplicationException;
+import org.lamsfoundation.lams.tool.qa.QaContent;
+import org.lamsfoundation.lams.tool.qa.QaQueContent;
+import org.lamsfoundation.lams.tool.qa.QaQueUsr;
+import org.lamsfoundation.lams.tool.qa.QaSession;
+import org.lamsfoundation.lams.tool.qa.QaUsrResp;
+import org.lamsfoundation.lams.tool.qa.dao.IQaContentDAO;
+import org.lamsfoundation.lams.tool.qa.dao.IQaQueContentDAO;
+import org.lamsfoundation.lams.tool.qa.dao.IQaQueUsrDAO;
+import org.lamsfoundation.lams.tool.qa.dao.IQaSessionDAO;
+import org.lamsfoundation.lams.tool.qa.dao.IQaUsrRespDAO;
+import org.lamsfoundation.lams.tool.qa.web.QaMonitoringAction;
+import org.lamsfoundation.lams.tool.service.ILamsToolService;
+import org.lamsfoundation.lams.usermanagement.User;
+import org.lamsfoundation.lams.usermanagement.service.IUserManagementService;
+import org.springframework.dao.DataAccessException;
+
+
+
+/**
+ * The POJO implementation of Survey service. All business logics of survey tool
+ * are implemented in this class. It translate the request from presentation
+ * layer and perform approporiate database operation.
+ *
+ * Two construtors are provided in this class. The constuctor with Hibernate
+ * session object allows survey tool to handle long run application transaction.
+ * The developer can store Hibernate session in http session and pass across
+ * different http request. This implementation also make the testing out side
+ * JBoss container much easier.
+ *
+ * Every method is implemented as a Hibernate session transaction. It open an
+ * new persistent session or connect to existing persistent session in the
+ * begining and it close or disconnect to the persistent session in the end.
+ *
+ * @author ozgurd
+ *
+ */
+
+public class QaServicePOJO implements
+ IQaService, ToolContentManager, ToolSessionManager
+
+{
+
+ private IQaContentDAO qaDAO;
+ private IQaQueContentDAO qaQueContentDAO;
+ private IQaSessionDAO qaSessionDAO;
+ private IQaQueUsrDAO qaQueUsrDAO;
+ private IQaUsrRespDAO qaUsrRespDAO;
+
+ private IUserManagementService userManagementService;
+ private ILamsToolService toolService;
+
+ static Logger logger = Logger.getLogger(QaMonitoringAction.class.getName());
+
+
+ public QaServicePOJO(){}
+
+ public void setQaDAO(IQaContentDAO qaDAO)
+ {
+ this.qaDAO = qaDAO;
+ }
+
+ public void setQaQueContentDAO(IQaQueContentDAO qaQueContentDAO)
+ {
+ this.qaQueContentDAO = qaQueContentDAO;
+ }
+
+ public void setQaSessionDAO(IQaSessionDAO qaSessionDAO)
+ {
+ this.qaSessionDAO = qaSessionDAO;
+ }
+
+ public void setQaQueUsrDAO(IQaQueUsrDAO qaQueUsrDAO)
+ {
+ this.qaQueUsrDAO = qaQueUsrDAO;
+ }
+
+ public void setQaUsrRespDAO(IQaUsrRespDAO qaUsrRespDAO)
+ {
+ this.qaUsrRespDAO = qaUsrRespDAO;
+ }
+
+
+ public void setUserManagementService(IUserManagementService userManagementService)
+ {
+ this.userManagementService = userManagementService;
+ }
+
+ public void setToolService(ILamsToolService toolService)
+ {
+ this.toolService = toolService;
+ }
+
+
+ public void createQa(QaContent qaContent)
+ {
+ try
+ {
+ qaDAO.saveQa(qaContent);
+ }
+ catch (DataAccessException e)
+ {
+ throw new QaApplicationException("Exception occured when lams is loading qa content: "
+ + e.getMessage(),
+ e);
+ }
+ }
+
+
+ public QaContent retrieveQa(long toolContentId)
+ {
+ try
+ {
+ return qaDAO.getQaById(toolContentId);
+ }
+ catch (DataAccessException e)
+ {
+ throw new QaApplicationException("Exception occured when lams is loading qa content: "
+ + e.getMessage(),
+ e);
+ }
+ }
+
+ /**
+ * same as retrieveQa(long toolContentId) except that returns null if not found
+ */
+ public QaContent loadQa(long toolContentId)
+ {
+ try
+ {
+ return qaDAO.loadQaById(toolContentId);
+ }
+ catch (DataAccessException e)
+ {
+ throw new QaApplicationException("Exception occured when lams is loading qa content: "
+ + e.getMessage(),
+ e);
+ }
+ }
+
+
+
+ public void createQaQue(QaQueContent qaQueContent)
+ {
+ try
+ {
+ qaQueContentDAO.createQueContent(qaQueContent);
+ }
+ catch (DataAccessException e)
+ {
+ throw new QaApplicationException("Exception occured when lams is creating qa content: "
+ + e.getMessage(),
+ e);
+ }
+ }
+
+ public void createQaSession(QaSession qaSession)
+ {
+ try
+ {
+ qaSessionDAO.CreateQaSession(qaSession);
+ }
+ catch (DataAccessException e)
+ {
+ throw new QaApplicationException("Exception occured when lams is creating qa session: "
+ + e.getMessage(),
+ e);
+ }
+ }
+
+ public void createQaQueUsr(QaQueUsr qaQueUsr)
+ {
+ try
+ {
+ qaQueUsrDAO.createUsr(qaQueUsr);
+ }
+ catch (DataAccessException e)
+ {
+ throw new QaApplicationException("Exception occured when lams is creating qa QueUsr: "
+ + e.getMessage(),
+ e);
+ }
+ }
+
+
+ public QaQueUsr loadQaQueUsr(Long userId)
+ {
+ try
+ {
+ QaQueUsr qaQueUsr=qaQueUsrDAO.loadQaQueUsrById(userId.longValue());
+ return qaQueUsr;
+ }
+ catch (DataAccessException e)
+ {
+ throw new QaApplicationException("Exception occured when lams is loading qa QueUsr: "
+ + e.getMessage(),
+ e);
+ }
+ }
+
+
+ public void createQaUsrResp(QaUsrResp qaUsrResp)
+ {
+ try
+ {
+ qaUsrRespDAO.createUserResponse(qaUsrResp);
+ }
+ catch (DataAccessException e)
+ {
+ throw new QaApplicationException("Exception occured when lams is creating qa UsrResp: "
+ + e.getMessage(),
+ e);
+ }
+ }
+
+
+ public QaUsrResp retrieveQaUsrResp(long responseId)
+ {
+ try
+ {
+ QaUsrResp qaUsrResp=qaUsrRespDAO.retrieveQaUsrResp(responseId);
+ return qaUsrResp;
+ }
+ catch (DataAccessException e)
+ {
+ throw new QaApplicationException("Exception occured when lams is loading qa qaUsrResp: "
+ + e.getMessage(),
+ e);
+ }
+
+ }
+
+ public void updateQaUsrResp(QaUsrResp qaUsrResp)
+ {
+ try
+ {
+ qaUsrRespDAO.updateUserResponse(qaUsrResp);
+ }
+ catch (DataAccessException e)
+ {
+ throw new QaApplicationException("Exception occured when lams is updating qa UsrResp: "
+ + e.getMessage(),
+ e);
+ }
+ }
+
+
+
+ public QaQueContent retrieveQaQue(long qaQueContentId)
+ {
+ try
+ {
+ return qaQueContentDAO.getQaQueById(qaQueContentId);
+ }
+ catch (DataAccessException e)
+ {
+ throw new QaApplicationException("Exception occured when lams is loading qa question content: "
+ + e.getMessage(),
+ e);
+ }
+ }
+
+
+ public QaSession retrieveQaSession(long qaSessionId)
+ {
+ try
+ {
+ return qaSessionDAO.getQaSessionById(qaSessionId);
+ }
+ catch (DataAccessException e)
+ {
+ throw new QaApplicationException("Exception occured when lams is loading qa session : "
+ + e.getMessage(),
+ e);
+ }
+ }
+
+
+
+ public QaSession retrieveQaSessionOrNullById(long qaSessionId)
+ {
+ try
+ {
+ return qaSessionDAO.getQaSessionOrNullById(qaSessionId);
+ }
+ catch (DataAccessException e)
+ {
+ throw new QaApplicationException("Exception occured when lams is loading qa session : "
+ + e.getMessage(),
+ e);
+ }
+ }
+
+
+
+
+ public QaContent retrieveQaBySession(long qaSessionId)
+ {
+ try
+ {
+ return qaDAO.getQaBySession(new Long(qaSessionId));
+ }
+ catch (DataAccessException e)
+ {
+ throw new QaApplicationException("Exception occured when lams is loading qa: "
+ + e.getMessage(),
+ e);
+ }
+ }
+
+
+ public void updateQa(QaContent qa)
+ {
+ try
+ {
+ qaDAO.updateQa(qa);
+ }
+ catch(DataAccessException e)
+ {
+ throw new QaApplicationException("Exception occured when lams is updating"
+ + " the qa content: "
+ + e.getMessage(),e);
+ }
+ }
+
+
+ public void updateQaSession(QaSession qaSession)
+ {
+ try
+ {
+ logger.debug(logger + " " + this.getClass().getName() + "before updateQaSession: " + qaSession);
+ qaSessionDAO.UpdateQaSession(qaSession);
+ }
+ catch (DataAccessException e)
+ {
+ throw new QaApplicationException("Exception occured when lams is updating qa session : "
+ + e.getMessage(),
+ e);
+ }
+ }
+
+
+ public void deleteQa(QaContent qa)
+ {
+ try
+ {
+ qaDAO.deleteQa(qa);
+ }
+ catch(DataAccessException e)
+ {
+ throw new QaApplicationException("Exception occured when lams is deleting"
+ + " the qa content: "
+ + e.getMessage(),e);
+ }
+ }
+
+ public void deleteQaById(Long qaId)
+ {
+ try
+ {
+ qaDAO.removeQaById(qaId);
+ }
+ catch(DataAccessException e)
+ {
+ throw new QaApplicationException("Exception occured when lams is deleting"
+ + " the qa content: "
+ + e.getMessage(),e);
+ }
+ }
+
+
+ public void removeUserResponse(QaUsrResp resp)
+ {
+ try
+ {
+ qaUsrRespDAO.removeUserResponse(resp);
+ }
+ catch(DataAccessException e)
+ {
+ throw new QaApplicationException("Exception occured when lams is deleting"
+ + " the resp: "
+ + e.getMessage(),e);
+ }
+ }
+
+
+ public void deleteUsrRespByQueId(Long qaQueId)
+ {
+ try
+ {
+ qaUsrRespDAO.removeUserResponseByQaQueId(qaQueId);
+ }
+ catch(DataAccessException e)
+ {
+ throw new QaApplicationException("Exception occured when lams is deleting"
+ + " the resp: "
+ + e.getMessage(),e);
+ }
+ }
+
+ public void deleteQaQueUsr(QaQueUsr qaQueUsr)
+ {
+ try
+ {
+ qaQueUsrDAO.deleteQaQueUsr(qaQueUsr);
+ }
+ catch(DataAccessException e)
+ {
+ throw new QaApplicationException("Exception occured when lams is deleting"
+ + " the user: "
+ + e.getMessage(),e);
+ }
+ }
+
+
+
+ public int countTotalNumberOfUserResponsed(QaContent qa)
+ {
+ try
+ {
+ return qaDAO.countUserResponsed(qa);
+ }
+ catch (DataAccessException e)
+ {
+ throw new QaApplicationException("Exception occured in [countTotalNumberOfUserResponsed]: "
+ + e.getMessage(),
+ e);
+ }
+ }
+
+
+ public User getCurrentUserData(String username) throws QaApplicationException
+ {
+ try
+ {
+ logger.debug(logger + " " + this.getClass().getName() + "getCurrentUserData: " + username);
+ /**
+ * this will return null if the username not found
+ */
+ User user=userManagementService.getUserByLogin(username);
+ if (user == null)
+ {
+ logger.debug(logger + " " + this.getClass().getName() + "No user with the username: "+ username + " exists.");
+ throw new QaApplicationException("No user with that username exists.");
+ }
+ return user;
+ }
+ catch (DataAccessException e)
+ {
+ throw new QaApplicationException("Unable to find current user information"
+ + " Root Cause: ["
+ + e.getMessage() + "]",
+ e);
+ }
+ }
+
+
+ public Lesson getCurrentLesson(long lessonId)
+ {
+ try
+ {
+ //this is a mock implementation to make the project compile and
+ //work. When the Lesson service is ready, we need to switch to
+ //real service implmenation.
+ return new Lesson();
+ //return lsDAO.find(lsessionId);
+ }
+ catch (DataAccessException e)
+ {
+ throw new QaApplicationException("Exception occured when lams is loading"
+ + " learning session:"
+ + e.getMessage(),
+ e);
+ }
+ }
+
+
+ /**
+ * Persistent user response into database.
+ * @see com.webmcq.ld.tool.survey.ISurveyService#saveUserResponses(java.util.List,
+ * long, long)
+ */
+ public void saveUserResponses(List responses, long toolSessionId, User user)
+ {
+ try
+ {
+ QaSession curSession = qaSessionDAO.getQaSessionById(toolSessionId);
+
+ curSession.setSession_status(QaSession.INCOMPLETE);
+ //remove the question user no longer exist
+ curSession.removeQueUsersBy(responses);
+ //update the existing question user.
+ curSession.updateQueUsersBy(responses);
+ //add new question users
+ curSession.addNewQueUsersBy(responses);
+ //persist the updates
+ qaSessionDAO.UpdateQaSession(curSession);
+
+ }
+ catch (DataAccessException e)
+ {
+ throw new QaApplicationException("Exception occured when lams is saving"
+ + " user responses: "
+ + e.getMessage(),
+ e);
+ }
+ }
+
+
+ public int getQaClassSize(Long qaContentId)
+ {
+ //pre-condition validation
+ if (qaContentId == null)
+ throw new QaApplicationException("We can't calculate number"
+ + "of potential qa learner with null qa content id.");
+/**
+ try
+ {
+ return toolService.getAllPotentialLearners(surveyContentId.longValue())
+ .size();
+ }
+ catch (LamsToolServiceException e)
+ {
+ throw new SurveyApplicationException("Exception occured when lams is caculating"
+ + " potential survey learners: "
+ + e.getMessage(),
+ e);
+ }
+*/
+ //TODO need to change to above implementation once it is done.
+ return 10;
+ }
+
+
+
+ // public QaSession retrieveQaSession(long toolSessionId){}
+
+
+ public void saveQaContent(QaContent qa)
+ {
+ try
+ {
+ qaDAO.saveQa(qa);
+ }
+ catch (DataAccessException e)
+ {
+ throw new QaApplicationException("Exception occured when lams is saving"
+ + " the qa content: "
+ + e.getMessage(),e);
+ }
+ }
+
+ public QaQueUsr retrieveQaQueUsr(long qaQaQueUsrId)
+ {
+ try
+ {
+ return qaQueUsrDAO.getQaQueUsrById(qaQaQueUsrId);
+ }
+ catch (DataAccessException e)
+ {
+ throw new QaApplicationException("Exception occured when lams is loading qa que usr: "
+ + e.getMessage(),
+ e);
+ }
+
+ }
+
+
+ public int countSessionUser(QaSession qaSession)
+ {
+ try
+ {
+ return qaQueUsrDAO.countSessionUser(qaSession);
+ }
+ catch (DataAccessException e)
+ {
+ throw new QaApplicationException("Exception occured when lams is counting users in the session "
+ + e.getMessage(),
+ e);
+ }
+ }
+
+
+ /**
+ * checks the paramter content in the user responses table
+ * @param qa
+ * @return
+ * @throws QaApplicationException
+ */
+ public boolean studentActivityOccurredGlobal(QaContent qaContent) throws QaApplicationException
+ {
+ logger.debug(logger + " " + this.getClass().getName() + "using qaContent: " + qaContent);
+ Iterator questionIterator=qaContent.getQaQueContents().iterator();
+ while (questionIterator.hasNext())
+ {
+ QaQueContent qaQueContent=(QaQueContent)questionIterator.next();
+ logger.debug(logger + " " + this.getClass().getName() + "iterated question : " + qaQueContent);
+ Iterator responsesIterator=qaQueContent.getQaUsrResps().iterator();
+ while (responsesIterator.hasNext())
+ {
+ logger.debug(logger + " " + this.getClass().getName() + "there is at least one response");
+ /**
+ * proved the fact that there is at least one response for this content.
+ */
+ return true;
+ }
+ }
+ logger.debug(logger + " " + this.getClass().getName() + "there is no response for this content");
+ return false;
+ }
+
+
+ public int countIncompleteSession(QaContent qa) throws QaApplicationException
+ {
+ logger.debug(logger + " " + this.getClass().getName() + " " + "start of countIncompleteSession: " + qa);
+ logger.debug(logger + " " + this.getClass().getName() + " " + "QaContentId: " + qa.getQaContentId());
+ int countIncompleteSession=qaSessionDAO.countIncompleteSession(qa);
+ logger.debug(logger + " " + this.getClass().getName() + " " + "countIncompleteSession: " + countIncompleteSession);
+ return countIncompleteSession;
+ }
+
+ /**
+ * checks the parameter content in the tool sessions table
+ *
+ * find out if any student has ever used (logged in through the url and replied) to this content
+ * return true even if you have only one content passed as parameter referenced in the tool sessions table
+ * @param qa
+ * @return boolean
+ * @throws QaApplicationException
+ */
+ public boolean studentActivityOccurred(QaContent qa) throws QaApplicationException
+ {
+ logger.debug(logger + " " + this.getClass().getName() + " " + "start of studentActivityOccurred: " + qa);
+ logger.debug(logger + " " + this.getClass().getName() + " " + "QaContentId: " + qa.getQaContentId());
+ int countStudentActivity=qaSessionDAO.studentActivityOccurred(qa);
+ logger.debug(logger + " " + this.getClass().getName() + " " + "countIncompleteSession: " + countStudentActivity);
+ if (countStudentActivity > 0)
+ return true;
+ return false;
+ }
+
+
+ /**
+ * TESTED
+ * gets called ONLY when a lesson is being created in monitoring mode.
+ * Should create the new content(toContent) based on what the author has created her content with. In q/a tool's case
+ * that is content + question's content but not user responses. The deep copy should go only as far as
+ * default content (or author created content) already goes.
+ * ToolContentManager CONTRACT
+ *
+ *
+ * similar to public void removeToolContent(Long toolContentId)
+ * gets called by Container+Flash
+ *
+ */
+ public void copyToolContent(Long fromContentId, Long toContentId) throws QaApplicationException
+ {
+ logger.debug(logger + " " + this.getClass().getName() + " " + "start of copyToolContent with ids: " + fromContentId + " and " + toContentId);
+
+ if (fromContentId == null || toContentId == null)
+ throw new QaApplicationException("Failed to copy content"
+ + " based on null toolSessionId or null toolContentId");
+ try
+ {
+ QaContent fromContent = qaDAO.loadQaById(fromContentId.longValue());
+ if (fromContent == null)
+ {
+ logger.debug(logger + " " + this.getClass().getName() + " " + "WARNING!, retrieved fromContent is null: ");
+ throw new QaApplicationException("WARNING! Fail to create fromContent. Can't continue!");
+ }
+ else
+ {
+ logger.debug(logger + " " + this.getClass().getName() + " " + "retrieved fromContent: " + fromContent);
+ QaContent toContent = QaContent.newInstance(fromContent,toContentId);
+ if (toContent == null)
+ {
+ logger.debug(logger + " " + this.getClass().getName() + " " + "WARNING!, retrieved fromContent is null: ");
+ throw new QaApplicationException("WARNING! Fail to create toContent. Can't continue!");
+ }
+ else
+ {
+ logger.debug(logger + " " + this.getClass().getName() + " " + "retrieved toContent: " + toContent);
+ qaDAO.saveQa(toContent);
+ logger.debug(logger + " " + this.getClass().getName() + " " + "toContent has been saved successfully: " + toContent);
+ }
+ }
+ logger.debug(logger + " " + this.getClass().getName() + " " + "end of copyToolContent with ids: " + fromContentId + " and " + toContentId);
+ }
+ catch (DataAccessException e)
+ {
+ throw new QaApplicationException("Exception occured when lams is copying content between content ids: fromContentId: " + fromContentId +
+ " and " + toContentId
+ + e.getMessage(),e);
+ }
+ }
+
+
+
+ /**
+ * TO BE DEFINED-FUTURE API
+ *
+ * update the tool session status to COMPLETE for this tool session
+ * IMPLEMENT THIS!!!! Is this from ToolContentManager???
+ *
+
+ * @param Long toolSessionId
+ */
+ public void setAsForceCompleteSession(Long toolSessionId) throws QaApplicationException
+ {
+ logger.debug(logger + " " + this.getClass().getName() + " " + " request for setAsForceCompleteSession has come for toolSessionId: " + toolSessionId);
+
+ QaSession qaSession=retrieveQaSessionOrNullById(toolSessionId.longValue());
+ logger.debug(logger + " " + this.getClass().getName() + " " + " retrieved qaSession is : " + qaSession);
+ qaSession.setSession_status(QaSession.COMPLETED);
+ logger.debug(logger + " " + this.getClass().getName() + " " + " updated qaSession to COMPLETED : ");
+ updateQaSession(qaSession);
+ logger.debug(logger + " " + this.getClass().getName() + " " + " updated qaSession to COMPLETED in the db : ");
+ }
+
+
+ /**
+ * TO BE DEFINED
+ * TESTED
+ * update the tool session status to COMPLETE for this user
+ * IMPLEMENT THIS!!!! Is this from ToolContentManager???
+ *
+
+ * @param userId
+ */
+ public void setAsForceComplete(Long userId) throws QaApplicationException
+ {
+ logger.debug(logger + " " + this.getClass().getName() + " " + " request for setAsForceComplete has come for userId: " + userId);
+ QaQueUsr qaQueUsr=loadQaQueUsr(userId);
+
+ if (qaQueUsr != null)
+ {
+ logger.debug(logger + " " + this.getClass().getName() + " " + " retrieved qaQueUsr : " + qaQueUsr);
+ logger.debug(logger + " " + this.getClass().getName() + " " + " retrieved qaQueUsr has the tool session : " + qaQueUsr.getQaSession());
+ QaSession qaSession=qaQueUsr.getQaSession();
+ if (qaSession != null)
+ {
+ Long usersToolSessionId=qaSession.getQaSessionId();
+ logger.debug(logger + " " + this.getClass().getName() + " " + " retrieved tool session has tool session id : " + usersToolSessionId);
+
+ qaSession=retrieveQaSessionOrNullById(usersToolSessionId.longValue());
+ logger.debug(logger + " " + this.getClass().getName() + " " + " retrieved qaSession is : " + qaSession);
+ qaSession.setSession_status(QaSession.COMPLETED);
+ logger.debug(logger + " " + this.getClass().getName() + " " + " updated qaSession to COMPLETED : ");
+ updateQaSession(qaSession);
+ logger.debug(logger + " " + this.getClass().getName() + " " + " updated qaSession to COMPLETED in the db : ");
+ QaContent qaContent=qaSession.getQaContent();
+ logger.debug(logger + " " + this.getClass().getName() + " " + " qaSession uses qaContent : " + qaContent);
+ logger.debug(logger + " " + this.getClass().getName() + " " + " qaSession uses qaContentId : " + qaContent.getQaContentId());
+
+ /**
+ * if all the sessions of this content is COMPLETED, unlock the content
+ *
+ */
+ int countIncompleteSession=countIncompleteSession(qaContent);
+ logger.debug(logger + " " + this.getClass().getName() + " " + " qaSession countIncompleteSession : " + countIncompleteSession);
+
+ if (countIncompleteSession == 0)
+ {
+ qaContent.setContentLocked(false);
+ updateQa(qaContent);
+ logger.debug(logger + " " + this.getClass().getName() + " " + " qaContent has been updated for contentLocked" + qaContent);
+ }
+ }
+ else
+ {
+ logger.debug(logger + " " + this.getClass().getName() + " " + " WARNING!!!: retrieved qaSession is null.");
+ throw new QaApplicationException("Fail to setAsForceComplete"
+ + " based on null qaSession.");
+ }
+ }
+ else
+ {
+ logger.debug(logger + " " + this.getClass().getName() + " " + " WARNING!!!: retrieved qaQueUsr is null.");
+ throw new QaApplicationException("Fail to setAsForceComplete"
+ + " based on null qaQueUsr.");
+ }
+ }
+
+
+ public void unsetAsDefineLater(Long toolContentId) throws QaApplicationException
+ {
+ logger.debug(logger + " " + this.getClass().getName() + " " + " request for unsetAsDefineLater with toolContentId: " + toolContentId);
+ if (toolContentId == null)
+ {
+ logger.debug(logger + " " + this.getClass().getName() + " " + " WARNING!!!: retrieved toolContentId is null.");
+ throw new QaApplicationException("Fail to setAsDefineLater"
+ + " based on null toolContentId.");
+ }
+ QaContent qaContent = qaDAO.loadQaById(toolContentId.longValue());
+ if (qaContent == null)
+ {
+ logger.debug(logger + " " + this.getClass().getName() + " " + " WARNING!!!: retrieved qaContent is null.");
+ throw new QaApplicationException("Fail to unsetAsDefineLater"
+ + " based on null qaContent.");
+ }
+ qaContent.setDefineLater(false);
+ updateQa(qaContent);
+ logger.debug(logger + " " + this.getClass().getName() + " " + " qaContent has been updated for unsetAsDefineLater: " + qaContent);
+ }
+
+ /**
+ * TESTED
+ * set the defineLater to true on this content
+ *
+ * @param toolContentId
+ * return void
+ */
+ public void setAsDefineLater(Long toolContentId) throws QaApplicationException
+ {
+ logger.debug(logger + " " + this.getClass().getName() + " " + " request for setAsDefineLater with toolContentId: " + toolContentId);
+ if (toolContentId == null)
+ {
+ logger.debug(logger + " " + this.getClass().getName() + " " + " WARNING!!!: retrieved toolContentId is null.");
+ throw new QaApplicationException("Fail to setAsDefineLater"
+ + " based on null toolContentId.");
+ }
+ QaContent qaContent = qaDAO.loadQaById(toolContentId.longValue());
+ if (qaContent == null)
+ {
+ logger.debug(logger + " " + this.getClass().getName() + " " + " WARNING!!!: retrieved qaContent is null.");
+ throw new QaApplicationException("Fail to setAsDefineLater"
+ + " based on null qaContent.");
+ }
+ qaContent.setDefineLater(true);
+ updateQa(qaContent);
+ logger.debug(logger + " " + this.getClass().getName() + " " + " qaContent has been updated for defineLater: " + qaContent);
+ }
+
+ /**
+ * TESTED
+ * set the runOffline to true on this content
+ *
+ * @param toolContentId
+ * return void
+ */
+ public void setAsRunOffline(Long toolContentId) throws QaApplicationException
+ {
+ logger.debug(logger + " " + this.getClass().getName() + " " + " request for setAsRunOffline with toolContentId:" + toolContentId);
+ if (toolContentId == null)
+ {
+ logger.debug(logger + " " + this.getClass().getName() + " " + " WARNING!!!: retrieved toolContentId is null.");
+ throw new QaApplicationException("Fail to setAsRunOffline"
+ + " based on null toolContentId.");
+ }
+ QaContent qaContent = qaDAO.loadQaById(toolContentId.longValue());
+ if (qaContent == null)
+ {
+ logger.debug(logger + " " + this.getClass().getName() + " " + " WARNING!!!: retrieved qaContent is null.");
+ throw new QaApplicationException("Fail to setAsRunOffline"
+ + " based on null qaContent.");
+ }
+ qaContent.setRunOffline(true);
+ updateQa(qaContent);
+ logger.debug(logger + " " + this.getClass().getName() + " " + " qaContent has been updated for RunOffline: " + qaContent);
+ }
+
+
+
+ /**
+ * TESTED
+ * gets automatically called only in monitoring mode when the author chooses to delete a lesson.
+ *
+ * The idea is to remove content + its relevant sessions + in q/a tools's case the question's content from the db.
+ * ToolContentManager CONTRACT
+ * this gets called automatically by Flash when a deletion is detected in the tool interface.
+ */
+ public void removeToolContent(Long toolContentId)
+ {
+ logger.debug(logger + " " + this.getClass().getName() + " " + "start of removeToolContent with toolContentId: " + toolContentId);
+
+ QaContent qaContent = qaDAO.loadQaById(toolContentId.longValue());
+ logger.debug(logger + " " + this.getClass().getName() + "retrieving qaContent: " + qaContent);
+
+ if (qaContent != null)
+ {
+ Iterator sessionIterator=qaContent.getQaSessions().iterator();
+ while (sessionIterator.hasNext())
+ {
+ QaSession qaSession=(QaSession)sessionIterator.next();
+ logger.debug(logger + " " + this.getClass().getName() + "iterated qaSession : " + qaSession);
+
+ Iterator sessionUsersIterator=qaSession.getQaQueUsers().iterator();
+ while (sessionUsersIterator.hasNext())
+ {
+ QaQueUsr qaQueUsr=(QaQueUsr) sessionUsersIterator.next();
+ logger.debug(logger + " " + this.getClass().getName() + "iterated qaQueUsr : " + qaQueUsr);
+
+ Iterator sessionUsersResponsesIterator=qaQueUsr.getQaUsrResps().iterator();
+ while (sessionUsersResponsesIterator.hasNext())
+ {
+ QaUsrResp qaUsrResp=(QaUsrResp)sessionUsersResponsesIterator.next();
+ logger.debug(logger + " " + this.getClass().getName() + "iterated qaUsrResp : " + qaUsrResp);
+ removeUserResponse(qaUsrResp);
+ logger.debug(logger + " " + this.getClass().getName() + "removed qaUsrResp : " + qaUsrResp);
+ }
+ }
+ }
+
+ logger.debug(logger + " " + this.getClass().getName() + " " + "removed all existing responses of toolContent with toolContentId:" +
+ toolContentId);
+ qaDAO.removeQa(toolContentId);
+ logger.debug(logger + " " + this.getClass().getName() + " " + "removed qaContent:" + qaContent);
+ }
+ }
+
+ /**
+ * it is possible that the tool session id already exists in the tool sessions table
+ * as the users from the same session are involved.
+ * existsSession(long toolSessionId)
+ * @param toolSessionId
+ * @return boolean
+ */
+ protected boolean existsSession(long toolSessionId)
+ {
+ QaSession qaSession=retrieveQaSessionOrNullById(toolSessionId);
+
+ if (qaSession == null)
+ {
+ logger.debug(logger + " " + this.getClass().getName() + "qaSession does not exist yet: " + toolSessionId);
+ return false;
+ }
+ else
+ {
+ logger.debug(logger + " " + this.getClass().getName() + "retrieving an existing qaSession: " + qaSession + " " + toolSessionId);
+ }
+ return true;
+ }
+
+ /**
+ * TESTED
+ * ToolSessionManager CONTRACT : creates a tool session with the incoming toolSessionId in the tool session table
+ *
+ * gets called only in the Learner mode.
+ * All the learners in the same group have the same toolSessionId.
+ *
+ */
+ public void createToolSession(Long toolSessionId, Long toolContentId) throws QaApplicationException
+ {
+ logger.debug(logger + " " + this.getClass().getName() + " " + "start of createToolSession with ids: " + toolSessionId + " and " + toolContentId);
+ if (toolSessionId == null || toolContentId == null)
+ throw new QaApplicationException("Fail to create a qa session"
+ + " based on null toolSessionId or toolContentId");
+
+ logger.debug("Start to create qa session based on toolSessionId["
+ + toolSessionId.longValue() + "] and toolContentId["
+ + toolContentId.longValue() + "]");
+ try
+ {
+ QaContent qaContent = qaDAO.loadQaById(toolContentId.longValue());
+ logger.debug(logger + " " + this.getClass().getName() + " " + "created qaContent: " + qaContent);
+
+ if (qaContent == null)
+ {
+ logger.debug(logger + " " + this.getClass().getName() + " " + "WARNING!!: qaContent is null! . " +
+ "We can't create a new tool session based on a null qa content. Can't continue!");
+ throw new QaApplicationException("WARNING! Fail to create tool session since there is no content with toolContentId:" + toolContentId);
+ }
+
+
+ /**
+ * create a new a new tool session if it does not already exist in the tool session table
+ */
+ if (!existsSession(toolSessionId.longValue()))
+ {
+ QaSession qaSession = new QaSession(toolSessionId,
+ new Date(System.currentTimeMillis()),
+ QaSession.INCOMPLETE,
+ qaContent,
+ new TreeSet());
+
+ logger.debug(logger + " " + this.getClass().getName() + " " + "created qaSession: " + qaSession);
+ qaSessionDAO.CreateQaSession(qaSession);
+ logger.debug(logger + " " + this.getClass().getName() + " " + "created qaSession in the db: " + qaSession);
+ }
+ }
+ catch (DataAccessException e)
+ {
+ throw new QaApplicationException("Exception occured when lams is creating"
+ + " a qa Session: "
+ + e.getMessage(),e);
+ }
+
+ }
+
+
+ /**FIX THIS ONE!!!!
+ * TO BE TESTED
+ * ToolSessionManager CONTRACT
+ * gets called only in the Learner mode.
+ *
+ * Call controller service to complete the qa session
+ * @see org.lamsfoundation.lams.tool.ToolSessionManager#leaveToolSession(java.lang.Long)
+ */
+ public String leaveToolSession(Long toolSessionId,User learner) throws QaApplicationException
+ {
+ logger.debug(logger + " " + this.getClass().getName() + " " + "start of leaveToolSession with toolSessionId:" + toolSessionId);
+ logger.debug(logger + " " + this.getClass().getName() + " " + "start of leaveToolSession with learner:" + learner);
+ try
+ {
+ /*
+ String nextUrl=learnerService.completeToolSession(toolSessionId,learner);
+ logger.debug(logger + " " + this.getClass().getName() + " " + "nextUrl: " + nextUrl);
+ return nextUrl;
+ */
+ return "completionUrl";
+ }
+ catch(DataAccessException e)
+ {
+ throw new QaApplicationException("Exception occured when user is leaving tool session: "
+ + e.getMessage(),e);
+ }
+
+ }
+
+ /**
+ * ToolSessionManager CONTRACT
+ *
+ */
+ public ToolSessionExportOutputData exportToolSession(Long toolSessionId)
+ {
+ // TODO Auto-generated method stub
+ throw new UnsupportedOperationException("not yet implemented");
+ }
+
+ /**
+ * ToolSessionManager CONTRACT
+ *
+ */
+ public ToolSessionExportOutputData exportToolSession(List toolSessionIds)
+ {
+ // TODO Auto-generated method stub
+ throw new UnsupportedOperationException("not yet implemented");
+ }
+
+ /**
+ * @return Returns the qaDAO.
+ */
+ public IQaContentDAO getQaDAO() {
+ return qaDAO;
+ }
+ /**
+ * @return Returns the qaSessionDAO.
+ */
+ public IQaSessionDAO getQaSessionDAO() {
+ return qaSessionDAO;
+ }
+ /**
+ * @return Returns the qaUsrRespDAO.
+ */
+ public IQaUsrRespDAO getQaUsrRespDAO() {
+ return qaUsrRespDAO;
+ }
+
+
+ public void buildLearnerReport()
+ {
+
+ }
+
+}
Index: lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/service/QaServiceProxy.java
===================================================================
diff -u
--- lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/service/QaServiceProxy.java (revision 0)
+++ lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/service/QaServiceProxy.java (revision 16e844de3f7c34b44baee1b28e67e708f42d00bf)
@@ -0,0 +1,72 @@
+/*
+ *Copyright (C) 2005 LAMS Foundation (http://lamsfoundation.org)
+ *
+ *This program is free software; you can redistribute it and/or modify
+ *it under the terms of the GNU General Public License as published by
+ *the Free Software Foundation; either version 2 of the License, or
+ *(at your option) any later version.
+ *
+ *This program is distributed in the hope that it will be useful,
+ *but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ *GNU General Public License for more details.
+ *
+ *You should have received a copy of the GNU General Public License
+ *along with this program; if not, write to the Free Software
+ *Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
+ *USA
+ *
+ *http://www.gnu.org/licenses/gpl.txt
+ */
+package org.lamsfoundation.lams.tool.qa.service;
+
+import javax.servlet.ServletContext;
+import org.lamsfoundation.lams.tool.ToolContentManager;
+import org.lamsfoundation.lams.tool.ToolSessionManager;
+import org.springframework.web.context.WebApplicationContext;
+import org.springframework.web.context.support.WebApplicationContextUtils;
+
+
+
+
+/**
+ *
This class act as the proxy between web layer and service layer. It is
+ * designed to decouple the presentation logic and business logic completely.
+ * In this way, the presentation tier will no longer be aware of the changes in
+ * service layer. Therefore we can feel free to switch the business logic
+ * implementation.
+ *
+ */
+public class QaServiceProxy
+{
+ //private IQaService lnkIQaService;
+ /**
+ * Return the survey domain service object. It will delegate to the Spring
+ * helper method to retrieve the proper bean from Spring bean factory.
+ * @param servletContext the servletContext for current application
+ * @return survey service object.
+ */
+ public static final IQaService getQaService(ServletContext servletContext)
+ {
+ return (IQaService)getQaDomainService(servletContext);
+ }
+
+ public static final ToolSessionManager getQaSessionManager(ServletContext servletContext)
+ {
+ return (ToolSessionManager)getQaDomainService(servletContext);
+ }
+
+ public static final ToolContentManager getQaContentManager(ServletContext servletContext)
+ {
+ return (ToolContentManager)getQaDomainService(servletContext);
+ }
+
+
+ private static Object getQaDomainService(ServletContext servletContext)
+ {
+ WebApplicationContext wac = WebApplicationContextUtils.getRequiredWebApplicationContext(servletContext);
+ return wac.getBean("qaService");
+ }
+
+
+}
\ No newline at end of file
Index: lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/AuthoringUtil.java
===================================================================
diff -u
--- lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/AuthoringUtil.java (revision 0)
+++ lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/AuthoringUtil.java (revision 16e844de3f7c34b44baee1b28e67e708f42d00bf)
@@ -0,0 +1,477 @@
+/*
+ * Created on 16/05/2005
+ *
+ * TODO To change the template for this generated file go to
+ * Window - Preferences - Java - Code Style - Code Templates
+ */
+package org.lamsfoundation.lams.tool.qa.web;
+
+import java.util.Date;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.TreeMap;
+import java.util.TreeSet;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import org.lamsfoundation.lams.usermanagement.User;
+
+import org.apache.log4j.Logger;
+import org.apache.struts.action.ActionForm;
+import org.apache.struts.action.ActionMapping;
+import org.lamsfoundation.lams.tool.qa.QaAppConstants;
+import org.lamsfoundation.lams.tool.qa.QaComparator;
+import org.lamsfoundation.lams.tool.qa.QaContent;
+import org.lamsfoundation.lams.tool.qa.QaQueContent;
+import org.lamsfoundation.lams.tool.qa.QaUtils;
+import org.lamsfoundation.lams.tool.qa.service.IQaService;
+
+/**
+ *
+ * Keeps all operations needed for Authoring mode.
+ * @author ozgurd
+ *
+ */
+public class AuthoringUtil implements QaAppConstants{
+ static Logger logger = Logger.getLogger(AuthoringUtil.class.getName());
+
+ /**
+ * reconstructQuestionContentMapForAdd(TreeMap mapQuestionContent, HttpServletRequest request)
+ * return void
+ * adds a new entry to the Map
+ */
+ protected void reconstructQuestionContentMapForAdd(Map mapQuestionContent, HttpServletRequest request)
+ {
+ logger.debug(logger + " " + this.getClass().getName() + "pre-add Map content: " + mapQuestionContent);
+ logger.debug(logger + " " + this.getClass().getName() + "pre-add Map size: " + mapQuestionContent.size());
+
+ //repopulate the Map
+ repopulateMap(mapQuestionContent, request);
+
+ mapQuestionContent.put(new Long(mapQuestionContent.size()+1).toString(), "");
+ request.getSession().setAttribute("mapQuestionContent", mapQuestionContent);
+
+ logger.debug(logger + " " + this.getClass().getName() + "post-add Map is: " + mapQuestionContent);
+ logger.debug(logger + " " + this.getClass().getName() + "post-add count " + mapQuestionContent.size());
+ }
+
+
+ /**
+ * reconstructQuestionContentMapForRemove(TreeMap mapQuestionContent, HttpServletRequest request)
+ * return void
+ * deletes the requested entry from the Map
+ */
+ protected void reconstructQuestionContentMapForRemove(Map mapQuestionContent, HttpServletRequest request, QaAuthoringForm qaAuthoringForm)
+ {
+ String questionIndex =qaAuthoringForm.getQuestionIndex();
+ logger.debug(logger + " " + this.getClass().getName() + "pre-delete map content: " + mapQuestionContent);
+ logger.debug(logger + " " + this.getClass().getName() + "questionIndex: " + questionIndex);
+
+ long longQuestionIndex= new Long(questionIndex).longValue();
+
+ logger.debug(logger + " " + this.getClass().getName() + "pre-delete count: " + mapQuestionContent.size());
+
+ //repopulate the Map
+ repopulateMap(mapQuestionContent, request);
+ logger.debug(logger + " " + this.getClass().getName() + "after repopulateMap");
+ logger.debug(logger + " " + this.getClass().getName() + "questionIndex: " + questionIndex);
+
+ mapQuestionContent.remove(new Long(longQuestionIndex).toString());
+ logger.debug(logger + " " + this.getClass().getName() + "removed the question content with index: " + longQuestionIndex);
+ request.getSession().setAttribute("mapQuestionContent", mapQuestionContent);
+
+ logger.debug(logger + " " + this.getClass().getName() + "post-delete count " + mapQuestionContent.size());
+ logger.debug(logger + " " + this.getClass().getName() + "post-delete map content: " + mapQuestionContent);
+ }
+
+
+ /**
+ * reconstructQuestionContentMapForSubmit(TreeMap mapQuestionContent, HttpServletRequest request)
+ * return void
+ * re-organizes the Map by removing empty entries from the user and creates the final Map ready for service layer
+ */
+ protected void reconstructQuestionContentMapForSubmit(Map mapQuestionContent, HttpServletRequest request)
+ {
+ logger.debug(logger + " " + this.getClass().getName() + "pre-submit Map:" + mapQuestionContent);
+ logger.debug(logger + " " + this.getClass().getName() + "pre-submit Map size :" + mapQuestionContent.size());
+
+ //repopulate the Map
+ repopulateMap(mapQuestionContent, request);
+ Map mapFinalQuestionContent = new TreeMap(new QaComparator());
+
+ Iterator itMap = mapQuestionContent.entrySet().iterator();
+ while (itMap.hasNext()) {
+ Map.Entry pairs = (Map.Entry)itMap.next();
+ if ((pairs.getValue() != null) && (!pairs.getValue().equals("")))
+ {
+ mapFinalQuestionContent.put(pairs.getKey(), pairs.getValue());
+ logger.debug(logger + " " + this.getClass().getName() + "Adding the pair: " + pairs.getKey() + " = " + pairs.getValue());
+ }
+ }
+
+ mapQuestionContent=(TreeMap)mapFinalQuestionContent;
+ request.getSession().setAttribute("mapQuestionContent", mapQuestionContent);
+ logger.debug(logger + " " + this.getClass().getName() + "post-submit Map:" + mapQuestionContent);
+ }
+
+
+ /**
+ * repopulateMap(TreeMap mapQuestionContent, HttpServletRequest request)
+ * return void
+ * repopulates the user entries into the Map
+ */
+ protected void repopulateMap(Map mapQuestionContent, HttpServletRequest request)
+ {
+ logger.debug(logger + " " + this.getClass().getName() + "queIndex: " + request.getSession().getAttribute("queIndex"));
+ long queIndex= new Long(request.getSession().getAttribute("queIndex").toString()).longValue();
+ logger.debug(logger + " " + this.getClass().getName() + "queIndex: " + queIndex);
+
+ //if there is data in the Map remaining from previous session remove those
+ mapQuestionContent.clear();
+ logger.debug(logger + " " + this.getClass().getName() + "Map got initialized: " + mapQuestionContent);
+
+
+ for (long i=0; i < queIndex ; i++)
+ {
+ String candidateQuestionEntry =request.getParameter("questionContent" + i);
+ if (i==0)
+ {
+ request.getSession().setAttribute("defaultQuestionContent", candidateQuestionEntry);
+ logger.debug(logger + " " + this.getClass().getName() + "defaultQuestionContent set to: " + candidateQuestionEntry);
+ }
+ if ((candidateQuestionEntry != null) && (candidateQuestionEntry.length() > 0))
+ {
+ logger.debug(logger + " " + this.getClass().getName() + "using key: " + i);
+ mapQuestionContent.put(new Long(i+1).toString(), candidateQuestionEntry);
+ logger.debug(logger + " " + this.getClass().getName() + "added new entry: ");
+ }
+ }
+ }
+
+
+ /**
+ * findSelectedTab(ActionMapping mapping,
+ ActionForm form,
+ HttpServletRequest request,
+ HttpServletResponse response)
+ *
+ * @param mapping
+ * @param form
+ * @param request
+ * @param response
+ *
+ * determines which tab in the UI is the active one
+ */
+ protected void findSelectedTab(ActionMapping mapping,
+ ActionForm form,
+ HttpServletRequest request,
+ HttpServletResponse response)
+ {
+ QaAuthoringForm qaAuthoringForm = (QaAuthoringForm) form;
+ String choiceBasic=qaAuthoringForm.getChoiceBasic();
+ String choiceAdvanced=qaAuthoringForm.getChoiceAdvanced();
+ String choiceInstructions=qaAuthoringForm.getChoiceInstructions();
+
+ //make the Basic tab the default one
+ request.getSession().setAttribute(CHOICE,CHOICE_TYPE_BASIC);
+
+ if (choiceBasic != null)
+ {
+ logger.debug(logger + " " + this.getClass().getName() + "CHOICE_TYPE_BASIC");
+ request.getSession().setAttribute(CHOICE,CHOICE_TYPE_BASIC);
+ }
+ else if (choiceAdvanced != null)
+ {
+ logger.debug(logger + " " + this.getClass().getName() + "CHOICE_TYPE_ADVANCED");
+ request.getSession().setAttribute(CHOICE,CHOICE_TYPE_ADVANCED);
+ }
+ else if (choiceInstructions != null)
+ {
+ logger.debug(logger + " " + this.getClass().getName() + "CHOICE_TYPE_INSTRUCTIONS");
+ request.getSession().setAttribute(CHOICE,CHOICE_TYPE_INSTRUCTIONS);
+ }
+
+ logger.debug(logger + " " + this.getClass().getName() + "CHOICE is:" + request.getSession().getAttribute(CHOICE));
+ //reset tab controllers
+ qaAuthoringForm.choiceBasic=null;
+ qaAuthoringForm.choiceAdvanced=null;
+ qaAuthoringForm.choiceInstructions=null;
+
+
+ /**
+ * if the presentation is for monitoring EditActivity screen, keep preserving request scope START_MONITORING_SUMMARY_REQUEST
+ */
+ Boolean renderMonitoringEditActivity=(Boolean)request.getSession().getAttribute(RENDER_MONITORING_EDITACTIVITY);
+ if ((renderMonitoringEditActivity != null) && (renderMonitoringEditActivity.booleanValue()))
+ {
+ request.setAttribute(FORM_INDEX, "1");
+ request.setAttribute(START_MONITORING_SUMMARY_REQUEST, new Boolean(true));
+ }
+ else
+ {
+ request.setAttribute(FORM_INDEX, "0");
+ request.setAttribute(START_MONITORING_SUMMARY_REQUEST, new Boolean(false));
+ }
+
+ logger.debug(logger + " " + this.getClass().getName() + "QaCTION, START_MONITORING_SUMMARY_REQUEST: " +
+ request.getAttribute(START_MONITORING_SUMMARY_REQUEST));
+
+ logger.debug(logger + " " + this.getClass().getName() + "formIndex:" + request.getAttribute(FORM_INDEX));
+
+ request.getSession().setAttribute(EDITACTIVITY_EDITMODE, new Boolean(false));
+ if (qaAuthoringForm.getEdit() != null)
+ {
+ logger.debug(logger + " " + this.getClass().getName() + "request for editActivity - editmode");
+ IQaService qaService =QaUtils.getToolService(request);
+ Long monitoredContentId=(Long)request.getSession().getAttribute(MONITORED_CONTENT_ID);
+ logger.debug(logger + " " + this.getClass().getName() + "MONITORED_CONTENT_ID: " + monitoredContentId);
+ qaService.setAsDefineLater(monitoredContentId);
+ logger.debug(logger + " " + this.getClass().getName() + "MONITORED_CONTENT_ID has been marked as defineLater: ");
+ request.getSession().setAttribute(EDITACTIVITY_EDITMODE, new Boolean(true));
+ }
+ else
+ {
+ request.getSession().setAttribute(TITLE,qaAuthoringForm.getTitle());
+ request.getSession().setAttribute(INSTRUCTIONS,qaAuthoringForm.getInstructions());
+ }
+ }
+
+
+ /**
+ * createContent(TreeMap mapQuestionContent)
+ * return QaContent
+ * At this stage, the Map is available from the presentaion layer and can be passed to services layer for persistance.
+ * We are making the content and question contents persistent.
+ * Id generation is "CURRENTLY" based on java.util.Random
+ */
+ protected QaContent createContent(Map mapQuestionContent, HttpServletRequest request, QaAuthoringForm qaAuthoringForm)
+ {
+ //get the service
+ IQaService qaService =QaUtils.getToolService(request);
+
+ //the tool content id is passed from the container to the tool and placed into session in the QaStarterAction
+ String toolContentId=(String)request.getSession().getAttribute(TOOL_CONTENT_ID);
+ if ((toolContentId != null) && (!toolContentId.equals("")))
+ {
+ logger.debug(logger + " " + this.getClass().getName() + "passed TOOL_CONTENT_ID : " + new Long(toolContentId));
+ //delete the existing content in the database before applying new content
+ qaService.deleteQaById(new Long(toolContentId));
+ logger.debug(logger + " " + this.getClass().getName() + "post-deletion existing content");
+ }
+ logger.debug(logger + " " + this.getClass().getName() + "using TOOL_CONTENT_ID: " + toolContentId);
+ request.getSession().setAttribute(TOOL_CONTENT_ID,toolContentId);
+
+ boolean isQuestionsSequenced=false;
+ boolean isSynchInMonitor=false;
+ boolean isUsernameVisible=false;
+ String reportTitle="";
+ String monitoringReportTitle="";
+ String offlineInstructions="";
+ String onlineInstructions="";
+ String endLearningMessage="";
+ String creationDate="";
+
+ Boolean isQuestionsSequencedBoolean=new Boolean(false);
+ Boolean isSynchInMonitorBoolean=new Boolean(false);
+ Boolean isUsernameVisibleBoolean=new Boolean(false);
+
+ Boolean renderMonitoringEditActivity=(Boolean)request.getSession().getAttribute(RENDER_MONITORING_EDITACTIVITY);
+ if ((renderMonitoringEditActivity != null) && (renderMonitoringEditActivity.booleanValue()))
+ {
+ logger.debug(logger + " " + this.getClass().getName() + "getting booleans based on editActivity");
+ isQuestionsSequencedBoolean=(Boolean)request.getSession().getAttribute(IS_QUESTIONS_SEQUENCED_MONITORING);
+ isSynchInMonitorBoolean=(Boolean)request.getSession().getAttribute(IS_SYNCH_INMONITOR_MONITORING);
+ isUsernameVisibleBoolean=(Boolean)request.getSession().getAttribute(IS_USERNAME_VISIBLE_MONITORING);
+ reportTitle=(String)request.getSession().getAttribute(REPORT_TITLE);
+ monitoringReportTitle=(String)request.getSession().getAttribute(MONITORING_REPORT_TITLE);
+ offlineInstructions=(String)request.getSession().getAttribute(OFFLINE_INSTRUCTIONS);
+ onlineInstructions=(String)request.getSession().getAttribute(ONLINE_INSTRUCTIONS);
+ endLearningMessage=(String)request.getSession().getAttribute(END_LEARNING_MESSSAGE);
+ endLearningMessage=(String)request.getSession().getAttribute(END_LEARNING_MESSSAGE);
+
+ if (isQuestionsSequencedBoolean != null)
+ isQuestionsSequenced=isQuestionsSequencedBoolean.booleanValue();
+
+ if (isSynchInMonitorBoolean != null)
+ isSynchInMonitor=isSynchInMonitorBoolean.booleanValue();
+
+ if (isUsernameVisibleBoolean != null)
+ isUsernameVisible=isUsernameVisibleBoolean.booleanValue();
+ }
+ else
+ {
+ logger.debug(logger + " " + this.getClass().getName() + "getting booleans based on normal flow: ");
+ logger.debug(logger + " " + this.getClass().getName() + "isQuestionsSequenced: " + qaAuthoringForm.getQuestionsSequenced());
+ if (qaAuthoringForm.getQuestionsSequenced().equalsIgnoreCase(ON))
+ isQuestionsSequenced=true;
+
+ logger.debug(logger + " " + this.getClass().getName() + "isSynchInMonitor: " + qaAuthoringForm.getSynchInMonitor());
+ if (qaAuthoringForm.getSynchInMonitor().equalsIgnoreCase(ON))
+ isSynchInMonitor=true;
+
+
+ logger.debug(logger + " " + this.getClass().getName() + "isUsernameVisible: " + qaAuthoringForm.getUsernameVisible());
+ if (qaAuthoringForm.getUsernameVisible().equalsIgnoreCase(ON))
+ isUsernameVisible=true;
+
+ reportTitle=qaAuthoringForm.getReportTitle();
+ monitoringReportTitle=qaAuthoringForm.getMonitoringReportTitle();
+ offlineInstructions=qaAuthoringForm.getOnlineInstructions();
+ onlineInstructions=qaAuthoringForm.getOfflineInstructions();
+ endLearningMessage=qaAuthoringForm.getEndLearningMessage();
+ }
+ creationDate=(String)request.getSession().getAttribute(CREATION_DATE);
+ if (creationDate == null)
+ creationDate=new Date(System.currentTimeMillis()).toString();
+
+
+ //obtain user object from the session
+ User toolUser=(User)request.getSession().getAttribute(TOOL_USER);
+ logger.debug(logger + " " + this.getClass().getName() + "retrieving toolUser: " + toolUser);
+ logger.debug(logger + " " + this.getClass().getName() + "retrieving toolUser userId: " + toolUser.getUserId());
+ String fullName= toolUser.getFirstName() + " " + toolUser.getLastName();
+ logger.debug(logger + " " + this.getClass().getName() + "retrieving toolUser fullname: " + fullName);
+ long userId=toolUser.getUserId().longValue();
+
+ //create a new qa content and leave the default content intact
+ QaContent qa = new QaContent();
+ qa.setQaContentId(new Long(toolContentId));
+ qa.setTitle(qaAuthoringForm.getTitle());
+ qa.setInstructions(qaAuthoringForm.getInstructions());
+ qa.setCreationDate(creationDate); //preserve this from the db
+ qa.setUpdateDate(new Date(System.currentTimeMillis())); //keep updating this one
+ qa.setCreatedBy(userId); //make sure we are setting the userId from the User object above
+ qa.setUsernameVisible(isUsernameVisible);
+ qa.setQuestionsSequenced(isQuestionsSequenced); //the default question listing in learner mode will be all in the same page
+ qa.setSynchInMonitor(isSynchInMonitor);
+ qa.setOnlineInstructions(onlineInstructions);
+ qa.setOfflineInstructions(offlineInstructions);
+ qa.setEndLearningMessage(endLearningMessage);
+ qa.setReportTitle(reportTitle);
+ qa.setMonitoringReportTitle(monitoringReportTitle);
+ qa.setQaQueContents(new TreeSet());
+ qa.setQaSessions(new TreeSet());
+ logger.debug(logger + " " + this.getClass().getName() + "qa content :" + qa);
+
+ //create the content in the db
+ qaService.createQa(qa);
+ logger.debug(logger + " " + this.getClass().getName() + "qa created with content id: " + toolContentId);
+
+ return qa;
+ }
+
+
+ /**
+ * createQuestionContent(TreeMap mapQuestionContent, HttpServletRequest request)
+ * return void
+ *
+ * persist the questions in the Map the user has submitted
+ */
+ protected void createQuestionContent(Map mapQuestionContent, HttpServletRequest request, QaContent qaContent)
+ {
+ IQaService qaService =QaUtils.getToolService(request);
+
+ Iterator itMap = mapQuestionContent.entrySet().iterator();
+ int diplayOrder=0;
+ while (itMap.hasNext())
+ {
+ Map.Entry pairs = (Map.Entry)itMap.next();
+ logger.debug(logger + " " + this.getClass().getName() + "Using the pair: " + pairs.getKey() + " = " + pairs.getValue());
+
+ //make sure question entered is NOT blank
+ if (pairs.getValue().toString().length() != 0)
+ {
+ QaQueContent queContent= new QaQueContent(pairs.getValue().toString(),
+ ++diplayOrder,
+ qaContent,
+ null,
+ null);
+
+ logger.debug(logger + " " + this.getClass().getName() + " queContent: " + queContent);
+ qaService.createQaQue(queContent);
+ logger.debug(logger + " " + this.getClass().getName() + "a qaQueContent created:");
+ }
+ }
+ logger.debug(logger + " " + this.getClass().getName() + "all questions in the Map persisted:");
+ }
+
+
+
+ /** remove existing content data from the db
+ *
+ * qaService.removeToolContent(Long toolContentId) gets automatically called only in monitoring mode when
+ * the author chooses to delete a lesson.
+ *
+ * In here we act as another client of this contact method since we want to clear q/a tool's content tables based on
+ * author's UI interactions. We are removing content + question's content + relavant tool sessions from the db.
+ *
+ * removeAllDBContent(TreeMap mapQuestionContent, HttpServletRequest request)
+ * return void
+ * removes content for a specific content Id
+ */
+ protected void removeAllDBContent(HttpServletRequest request)
+ {
+ IQaService qaService =QaUtils.getToolService(request);
+ logger.debug(logger + " " + this.getClass().getName() + "retrieve qaService: " + qaService);
+ String toolContentId=null;
+
+ if (request.getSession().getAttribute(TOOL_CONTENT_ID) != null)
+ toolContentId=(String)(request.getSession().getAttribute(TOOL_CONTENT_ID));
+
+ if ((toolContentId != null) && (!toolContentId.equals("")))
+ {
+ logger.debug(logger + " " + this.getClass().getName() + "simulate container behaviour by calling: removeToolContent with: " + new Long(toolContentId));
+ /**
+ * we are calling removeToolContent to clear content tables although this method normally
+ * gets called only in the monitoring mode automatically by the core.
+ *
+ * Having this method here also makes sure that this contract has implemented and tested properly.
+ */
+ qaService.removeToolContent(new Long(toolContentId));
+ logger.debug(logger + " " + this.getClass().getName() + "simulated container behaviour by calling: removeToolContent with: " + toolContentId);
+ logger.debug(logger + " " + this.getClass().getName() + "removed content from database for content id:" + toolContentId);
+ }
+ }
+
+ /**
+ * Normally, a request to set runOffline property of the content comes directly from container through the property inspector.
+ * What we do below is simulate that for development purposes.
+ * @param request
+ */
+
+ public void simulatePropertyInspector_RunOffline(HttpServletRequest request)
+ {
+ IQaService qaService =QaUtils.getToolService(request);
+ logger.debug(logger + " " + this.getClass().getName() + "retrieve qaService: " + qaService);
+
+ String toolContentId=(String)request.getSession().getAttribute(TOOL_CONTENT_ID);
+ if ((toolContentId != null) && (!toolContentId.equals("")))
+ {
+ logger.debug(logger + " " + this.getClass().getName() + "passed TOOL_CONTENT_ID : " + new Long(toolContentId));
+ qaService.setAsRunOffline(new Long(toolContentId));
+ logger.debug(logger + " " + this.getClass().getName() + "post-RunAsOffline");
+ }
+ logger.debug(logger + " " + this.getClass().getName() + "end of simulating RunOffline on content id: " + toolContentId);
+ }
+
+ /**
+ * Normally, a request to set defineLaterproperty of the content comes directly from container through the property inspector.
+ * What we do below is simulate that for development purposes.
+ * @param request
+ */
+ public void simulatePropertyInspector_setAsDefineLater(HttpServletRequest request)
+ {
+ IQaService qaService =QaUtils.getToolService(request);
+ logger.debug(logger + " " + this.getClass().getName() + "retrieve qaService: " + qaService);
+
+ String toolContentId=(String)request.getSession().getAttribute(TOOL_CONTENT_ID);
+ if ((toolContentId != null) && (!toolContentId.equals("")))
+ {
+ logger.debug(logger + " " + this.getClass().getName() + "passed TOOL_CONTENT_ID : " + new Long(toolContentId));
+ qaService.setAsDefineLater(new Long(toolContentId));
+ logger.debug(logger + " " + this.getClass().getName() + "post-setAsDefineLater");
+ }
+ logger.debug(logger + " " + this.getClass().getName() + "end of simulating setAsDefineLater on content id: " + toolContentId);
+ }
+
+}
Index: lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/LearningUtil.java
===================================================================
diff -u
--- lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/LearningUtil.java (revision 0)
+++ lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/LearningUtil.java (revision 16e844de3f7c34b44baee1b28e67e708f42d00bf)
@@ -0,0 +1,594 @@
+/**
+ *
+ * Keeps all operations needed for Learning mode.
+ * @author ozgurd
+ *
+ */
+package org.lamsfoundation.lams.tool.qa.web;
+
+import java.util.Date;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Set;
+import java.util.TreeMap;
+import java.util.TreeSet;
+
+import javax.servlet.http.HttpServletRequest;
+import org.lamsfoundation.lams.usermanagement.User;
+
+import org.apache.log4j.Logger;
+import org.lamsfoundation.lams.tool.qa.QaAppConstants;
+import org.lamsfoundation.lams.tool.qa.QaComparator;
+import org.lamsfoundation.lams.tool.qa.QaContent;
+import org.lamsfoundation.lams.tool.qa.QaQueContent;
+import org.lamsfoundation.lams.tool.qa.QaQueUsr;
+import org.lamsfoundation.lams.tool.qa.QaSession;
+import org.lamsfoundation.lams.tool.qa.QaStringComparator;
+import org.lamsfoundation.lams.tool.qa.QaUsrResp;
+import org.lamsfoundation.lams.tool.qa.QaUtils;
+import org.lamsfoundation.lams.tool.qa.service.IQaService;
+
+/**
+ *
+ * Keeps all operations needed for Learning mode.
+ * @author ozgurd
+ *
+ */
+public class LearningUtil implements QaAppConstants{
+ static Logger logger = Logger.getLogger(LearningUtil.class.getName());
+
+ /**
+ * NEVER USED: redundant method.
+ * @param request
+ */
+ protected void deleteSessionUsersAndResponses(HttpServletRequest request)
+ {
+ IQaService qaService =QaUtils.getToolService(request);
+ /**
+ * retrive contentId from the http session
+ */
+ logger.debug(logger + " " + this.getClass().getName() + "attempt retrieving toolContentId: " + request.getSession().getAttribute(TOOL_CONTENT_ID));
+ Long toolContentId=(Long)request.getSession().getAttribute(TOOL_CONTENT_ID);
+ QaContent qaContent=qaService.retrieveQa(toolContentId.longValue());
+
+ logger.debug(logger + " " + this.getClass().getName() + "retrieving qaContent: " + qaContent);
+ Iterator sessionIterator=qaContent.getQaSessions().iterator();
+ while (sessionIterator.hasNext())
+ {
+ QaSession qaSession=(QaSession)sessionIterator.next();
+ logger.debug(logger + " " + this.getClass().getName() + "iterated qaSession : " + qaSession);
+
+ Iterator sessionUsersIterator=qaSession.getQaQueUsers().iterator();
+ while (sessionUsersIterator.hasNext())
+ {
+ QaQueUsr qaQueUsr=(QaQueUsr) sessionUsersIterator.next();
+ logger.debug(logger + " " + this.getClass().getName() + "iterated qaQueUsr : " + qaQueUsr);
+
+ Iterator sessionUsersResponsesIterator=qaQueUsr.getQaUsrResps().iterator();
+ while (sessionUsersResponsesIterator.hasNext())
+ {
+ QaUsrResp qaUsrResp=(QaUsrResp)sessionUsersResponsesIterator.next();
+ logger.debug(logger + " " + this.getClass().getName() + "iterated qaUsrResp : " + qaUsrResp);
+ qaService.removeUserResponse(qaUsrResp);
+ logger.debug(logger + " " + this.getClass().getName() + "removed qaUsrResp : " + qaUsrResp);
+ }
+ }
+ }
+ logger.debug(logger + " " + this.getClass().getName() + "end of deleteSessionUsersAndResponses()");
+ }
+
+
+ /**
+ * NEVER USED: redundant method.
+ * deletes the user of a particular question content and her responses
+ * deleteExistingUsersAndResponses(HttpServletRequest request)
+ *
+ * return void
+ * @param request
+ */
+ protected void deleteExistingUsersAndResponses(HttpServletRequest request)
+ {
+ IQaService qaService =QaUtils.getToolService(request);
+ /**
+ * retrive contentId from the http session
+ */
+ logger.debug(logger + " " + this.getClass().getName() + "attempt retrieving toolContentId: " + request.getSession().getAttribute(TOOL_CONTENT_ID));
+ Long toolContentId=(Long)request.getSession().getAttribute(TOOL_CONTENT_ID);
+ QaContent qaContent=qaService.retrieveQa(toolContentId.longValue());
+
+ logger.debug(logger + " " + this.getClass().getName() + "retrieving qaContent: " + qaContent);
+
+ /**
+ * get iterator of questions collection
+ */
+ Iterator contentIterator=qaContent.getQaQueContents().iterator();
+ while (contentIterator.hasNext())
+ {
+ QaQueContent qaQueContent=(QaQueContent)contentIterator.next();
+ logger.debug(logger + " " + this.getClass().getName() + "retrieving qaQueContent: " + qaQueContent);
+ if (qaQueContent != null)
+ {
+ Set qaQueUsers=qaQueContent.getQaQueUsers();
+ logger.debug(logger + " " + this.getClass().getName() + "qaQueUsers size: " + qaQueUsers.size());
+ /**
+ * iterate users and delete them
+ */
+ Iterator usersIterator=qaQueUsers.iterator();
+ while (usersIterator.hasNext())
+ {
+ QaQueUsr qaQueUsr=(QaQueUsr) usersIterator.next();
+ logger.debug(logger + " " + this.getClass().getName() + "retrieving qaQueUsr: " + qaQueUsr);
+ if (qaQueUsr != null)
+ {
+ Set qaUsrResps=qaQueUsr.getQaUsrResps();
+ logger.debug(logger + " " + this.getClass().getName() + "retrieving user's all responses : " + qaUsrResps);
+ Iterator responsesIterator=qaUsrResps.iterator();
+ while (responsesIterator.hasNext())
+ {
+ QaUsrResp qaUsrResp=(QaUsrResp)responsesIterator.next();
+ if (qaUsrResp != null)
+ {
+ logger.debug(logger + " " + this.getClass().getName() + "retrieving qaUsrResp: " + qaUsrResp);
+ qaService.removeUserResponse(qaUsrResp);
+ logger.debug(logger + " " + this.getClass().getName() + "removed qaUsrResp with id:" + qaUsrResp.getResponseId());
+ }
+ }
+ qaService.deleteQaQueUsr(qaQueUsr);
+ logger.debug(logger + " " + this.getClass().getName() + "deleted user: " + qaQueUsr);
+ }
+ }
+ }
+ }
+ logger.debug(logger + " " + this.getClass().getName() + "end of deleteExistingUsersAndResponses()");
+ }
+
+
+ /**
+ * createUsersAndResponses(Map mapAnswers, HttpServletRequest request)
+ * create users of the responses
+ * @param mapAnswers, request
+ * return void
+ *
+ */
+ protected void createUsersAndResponses(Map mapAnswers, HttpServletRequest request)
+ {
+ IQaService qaService =QaUtils.getToolService(request);
+ logger.debug(logger + " " + this.getClass().getName() + "createUsers-retrieving qaService: " + qaService);
+
+ User toolUser=(User)request.getSession().getAttribute(TOOL_USER);
+ logger.debug(logger + " " + this.getClass().getName() + "retrieving toolUser: " + toolUser);
+ logger.debug(logger + " " + this.getClass().getName() + "retrieving toolUser userId: " + toolUser.getUserId());
+ logger.debug(logger + " " + this.getClass().getName() + "retrieving toolUser username: " + toolUser.getLogin());
+ /**
+ * !!double check this!!
+ */
+ String userName=toolUser.getLogin();
+ String fullName= toolUser.getFirstName() + " " + toolUser.getLastName();
+ logger.debug(logger + " " + this.getClass().getName() + "retrieving toolUser fullname: " + fullName);
+
+ Long userId=new Long(toolUser.getUserId().longValue());
+
+ /**
+ * retrive contentId from the http session
+ */
+ logger.debug(logger + " " + this.getClass().getName() + "createUsers-attempt retrieving toolContentId: " + request.getSession().getAttribute(TOOL_CONTENT_ID));
+ Long toolContentId=(Long)request.getSession().getAttribute(TOOL_CONTENT_ID);
+ /**
+ * obtain QaContent to be used in creating QaQueUsr
+ */
+ QaContent qaContent=qaService.retrieveQa(toolContentId.longValue());
+ logger.debug(logger + " " + this.getClass().getName() + "createUsers-retrieving qaContent: " + qaContent);
+
+ /**
+ * get QaSession to be used in creating QaQueUsr
+ */
+ Long toolSessionId=(Long)request.getSession().getAttribute(TOOL_SESSION_ID);
+ logger.debug(logger + " " + this.getClass().getName() + "createUsers-retrieving toolSessionId: " + toolSessionId);
+ QaSession qaSession = qaService.retrieveQaSessionOrNullById(toolSessionId.longValue());
+ logger.debug(logger + " " + this.getClass().getName() + "createUsers-retrieving qaSession: " + qaSession);
+
+ Iterator contentIterator=qaContent.getQaQueContents().iterator();
+ logger.debug(logger + " " + this.getClass().getName() + "createUsers-attempt iteration questions");
+
+ QaQueUsr qaQueUsr= new QaQueUsr(userId,
+ userName,
+ fullName,
+ null,
+ qaSession,
+ new TreeSet());
+
+ logger.debug(logger + " " + this.getClass().getName() + "createUsers-qaQueUsr: " + qaQueUsr);
+ if (qaQueUsr != null)
+ {
+ qaService.createQaQueUsr(qaQueUsr);
+ logger.debug(logger + " " + this.getClass().getName() + "createUsers-qaQueUsr created in the db: " + qaQueUsr);
+ }
+
+
+ while (contentIterator.hasNext())
+ {
+ QaQueContent qaQueContent=(QaQueContent)contentIterator.next();
+ if (qaQueContent != null)
+ {
+ /**
+ * get the question
+ */
+ String question=qaQueContent.getQuestion();
+ /**
+ * get the question's display order
+ */
+ String displayOrder=new Long(qaQueContent.getDisplayOrder()).toString();
+
+ /**
+ * get the answer from the map of that displayOrder
+ */
+ String answer=(String)mapAnswers.get(displayOrder);
+
+ logger.debug(logger + " " + this.getClass().getName() + "iterationg question-answers: displayOrder: " + displayOrder +
+ " question: " + question + " answer: " + answer);
+
+
+ QaUsrResp qaUsrResp= new QaUsrResp(answer,false,
+ new Date(System.currentTimeMillis()),
+ qaQueContent,
+ qaQueUsr);
+
+ logger.debug(logger + " " + this.getClass().getName() + "iterationg qaUsrResp: " + qaUsrResp);
+ if (qaUsrResp != null)
+ {
+ qaService.createQaUsrResp(qaUsrResp);
+ logger.debug(logger + " " + this.getClass().getName() + "created qaUsrResp in the db");
+ }
+
+ }
+ }
+ logger.debug(logger + " " + this.getClass().getName() + "both users and their responses created in the db");
+ }
+
+
+ /**
+ * creates a data structure to hold learner report data
+ * buidLearnerReport(HttpServletRequest request, Map mapQuestions, Map mapAnswers)
+ *
+ * calls processUserResponses() to do some of the work
+ * @param HttpServletRequest request, Map mapQuestions, Map mapAnswers
+ * return void
+ *
+ */
+ protected void buidLearnerReport(HttpServletRequest request, int toolSessionIdCounter)
+ {
+ IQaService qaService =QaUtils.getToolService(request);
+
+ /**
+ * find out the current tool session
+ */
+ Long toolSessionId=(Long) request.getSession().getAttribute(TOOL_SESSION_ID);
+ logger.debug(logger + " " + this.getClass().getName() + "processUserResponses using toolSessionId: " + toolSessionId);
+
+ /**
+ * holds all the tool sessions passed in from the url
+ * used in monitoring mode
+ */
+ Map mapToolSessions=(Map)request.getSession().getAttribute(MAP_TOOL_SESSIONS);
+ logger.debug(logger + " " + this.getClass().getName() + "retrieving MAP_TOOL_SESSIONS from the session: " + mapToolSessions);
+
+
+ /**
+ * keys of the Map refers to questions and values refers to user info and their entries
+ * used in learning mode
+ */
+ Map mapMainReport= new TreeMap(new QaStringComparator());
+ logger.debug(logger + " " + this.getClass().getName() + "mapMainReport created with QaStringComparator");
+
+ Long toolContentId=(Long) request.getSession().getAttribute(TOOL_CONTENT_ID);
+ logger.debug(logger + " " + this.getClass().getName() + "current toolContentId: " + toolContentId);
+ QaContent qaContent=qaService.loadQa(toolContentId.longValue());
+ logger.debug(logger + " " + this.getClass().getName() + "retrieve qaContent: " + qaContent);
+
+ Iterator contentIterator=qaContent.getQaQueContents().iterator();
+ logger.debug(logger + " " + this.getClass().getName() + "content iteration count: " + qaContent.getQaQueContents().size());
+
+ int questionIndex=0;
+ /**
+ * used to iterate responses to questions within the tool sessions in the jsp level in the monitoring mode
+ */
+ Map mapQuestions= new TreeMap(new QaStringComparator());
+ logger.debug(logger + " " + this.getClass().getName() + "mapQuestions created with QaStringComparator");
+
+ /**
+ * used to iterate questions within the tool sessions in the jsp level in the monitoring mode
+ */
+ Map mapMonitoringQuestions= new TreeMap(new QaStringComparator());
+ logger.debug(logger + " " + this.getClass().getName() + "mapMonitoringQuestions created with QaStringComparator");
+
+ while (contentIterator.hasNext())
+ {
+ QaQueContent qaQueContent=(QaQueContent)contentIterator.next();
+ logger.debug(logger + " " + this.getClass().getName() + "retrieve qaQueContent: " + qaQueContent);
+ if (qaQueContent != null)
+ {
+ /**
+ * obtain All responses from ALL users to this question
+ */
+ Set qaUsrResps=qaQueContent.getQaUsrResps();
+ logger.debug(logger + " " + this.getClass().getName() + "the set of user responses qaUsrResps: " + qaUsrResps);
+
+ /**
+ * deal with all responses
+ */
+ questionIndex=questionIndex+1;
+ logger.debug(logger + " " + this.getClass().getName() + "current questionIndex: " + questionIndex);
+
+ String targetMode=(String )request.getSession().getAttribute(TARGET_MODE);
+ logger.debug(logger + " " + this.getClass().getName() + "TARGET_MODE: " + targetMode);
+
+ logger.debug(logger + " " + this.getClass().getName() + "buidLearnerReport for TARGET_MODE: " + targetMode);
+ if (targetMode.equalsIgnoreCase(TARGET_MODE_MONITORING))
+ {
+ Map mapUserResponses=processUserResponses(request, qaUsrResps, questionIndex, new TreeMap());
+ /**
+ * Map mapQuestions for holding the question index /responses pair
+ */
+ mapQuestions.put(new Integer(questionIndex).toString(),mapUserResponses);
+ logger.debug(logger + " " + this.getClass().getName() + "getting mapQuestions: " + mapQuestions);
+ /**
+ * Map mapQuestions for holding the questions themselves
+ */
+ mapMonitoringQuestions.put(new Integer(questionIndex).toString(),qaQueContent.getQuestion());
+ logger.debug(logger + " " + this.getClass().getName() + "getting mapMonitoringQuestions: " + mapMonitoringQuestions);
+ request.getSession().setAttribute(MAP_MONITORING_QUESTIONS,mapMonitoringQuestions);
+
+ mapToolSessions.put(toolSessionId.toString(), mapQuestions);
+ logger.debug(logger + " " + this.getClass().getName() + "mapToolSessionsupdated: " + mapToolSessions);
+ request.getSession().setAttribute(MAP_TOOL_SESSIONS,mapToolSessions);
+ logger.debug(logger + " " + this.getClass().getName() + "MAP_TOOL_SESSIONS in session updated: " + mapToolSessions);
+ }
+ else
+ {
+ Map mapUserResponses= new TreeMap(new QaComparator());
+ mapUserResponses=processUserResponses(request, qaUsrResps, questionIndex, mapUserResponses);
+ mapMainReport.put(qaQueContent.getQuestion(), mapUserResponses);
+ }
+ }
+ }
+ logger.debug(logger + " " + this.getClass().getName() + "mapMainReport: " + mapMainReport);
+ request.getSession().setAttribute(MAP_MAIN_REPORT, mapMainReport);
+ }
+
+
+
+
+ /**
+ * This method prepares the report to eb presented in both leraning and monitoring mode.
+ * In learning mode in places the curresnt user's data in the first row.
+ * In monitoring mode, it just presents data as it reads into the Map as usual.
+ *
+ *
+ * Reporting in Learning mode is different than reporting in monitoring mode in two main respects:
+ * 1- Use of username visible applies only to learning mode
+ * 2- Placing the current user's name first in the generated list only applies to learning mode
+ *
+ * prepares ALL responses to a particular question and
+ * makes it available to the UI.
+ * processUserResponses(Set qaUsrResps)
+ * return void
+ * @param qaUsrResps
+ */
+ protected Map processUserResponses(HttpServletRequest request, Set qaUsrResps, int questionIndex, Map mapUserResponses)
+ {
+ logger.debug(logger + " " + this.getClass().getName() + "will be processing user responses: ");
+
+ /**
+ * find out the current tool session
+ */
+ Long toolSessionId=(Long) request.getSession().getAttribute(TOOL_SESSION_ID);
+ logger.debug(logger + " " + this.getClass().getName() + "processUserResponses using toolSessionId: " + toolSessionId);
+
+
+ /**
+ * find out the tool's mode. We produce different reports for learning and monitoring
+ */
+ String targetMode=(String )request.getSession().getAttribute(TARGET_MODE);
+ logger.debug(logger + " " + this.getClass().getName() + "TARGET_MODE: " + targetMode);
+
+ if (targetMode.equalsIgnoreCase(TARGET_MODE_MONITORING))
+ {
+ logger.debug(logger + " " + this.getClass().getName() + "processUserResponses for TARGET_MODE: " + targetMode);
+
+ if (qaUsrResps.isEmpty())
+ logger.debug(logger + " " + this.getClass().getName() + "the set of user responses for a particular question is empty.");
+
+ Iterator itResps=qaUsrResps.iterator();
+ /**
+ * obtain each response and the user that replied with that response
+ */
+ int responseIndex=0;
+ while (itResps.hasNext())
+ {
+ QaUsrResp qaUsrResp=(QaUsrResp)itResps.next();
+ logger.debug(logger + " " + this.getClass().getName() + "using qaUsrResp: " + qaUsrResp + " with responseIndex: " + responseIndex);
+ /**
+ * Don't include the blank answers in the report. Make sure it is the requirement.
+ */
+ if ((qaUsrResp != null) && (qaUsrResp.getAnswer() != null) && (!qaUsrResp.getAnswer().equals("")))
+ {
+ logger.debug(logger + " " + this.getClass().getName() + "iterated qaUsrResp:" + qaUsrResp);
+ logger.debug(logger + " " + this.getClass().getName() + "isResponseHidden: " + qaUsrResp.isHidden());
+ QaQueUsr qaQueUsr=qaUsrResp.getQaQueUser();
+ //find out what you need to display: fullname or login (userName)?
+ logger.debug(logger + " " + this.getClass().getName() + "iterated qaQueUsr fullName:" + qaQueUsr.getFullname());
+ logger.debug(logger + " " + this.getClass().getName() + "iterated qaQueUsr userName:" + qaQueUsr.getUsername());
+ logger.debug(logger + " " + this.getClass().getName() + "iterated qaQueUsr userName:" + qaQueUsr.getQaSession());
+ logger.debug(logger + " " + this.getClass().getName() + "using responseIndex: " + responseIndex);
+
+ QaSession qaSession=qaQueUsr.getQaSession();
+ if (toolSessionId.equals(qaSession.getQaSessionId()))
+ {
+ responseIndex=responseIndex+1;
+ logger.debug(logger + " " + this.getClass().getName() + "responseIndex incremented to: " + responseIndex);
+ mapUserResponses.put(new Integer(responseIndex).toString(), qaQueUsr.getFullname() + " " + qaUsrResp.getAttemptTime() + " " + qaUsrResp.getAnswer());
+ logger.debug(logger + " " + this.getClass().getName() + "setting attemptTime: " + "aTime" + questionIndex +""+ responseIndex + "---------" + qaUsrResp.getAttemptTime());
+ logger.debug(logger + " " + this.getClass().getName() + "setting final monitoring report data with:" + toolSessionId + " " + questionIndex + " " + responseIndex);
+
+ request.getSession().setAttribute(FULLNAME + toolSessionId + "" + questionIndex +""+ responseIndex, qaQueUsr.getFullname());
+ request.getSession().setAttribute(ANSWER + toolSessionId + "" + questionIndex +""+ responseIndex, qaUsrResp.getAnswer());
+ request.getSession().setAttribute(ATIME + toolSessionId + "" + questionIndex +""+ responseIndex, qaUsrResp.getAttemptTime());
+ request.getSession().setAttribute(RESPONSE_ID + toolSessionId + "" + questionIndex +""+ responseIndex, qaUsrResp.getResponseId());
+
+ boolean isResponseHidden=qaUsrResp.isHidden();
+ logger.debug(logger + " " + this.getClass().getName() + "isResponseHidden: " + isResponseHidden);
+ request.getSession().setAttribute(RESPONSE_HIDDEN + toolSessionId + "" + questionIndex +""+ responseIndex, new Boolean(isResponseHidden));
+ }
+ }
+ }
+
+ }
+ else if (targetMode.equalsIgnoreCase(TARGET_MODE_LEARNING))
+ {
+ logger.debug(logger + " " + this.getClass().getName() + "processUserResponses for TARGET_MODE: " + targetMode);
+ /**
+ * find out whos is the current user. Important to know for reporting responses in learning mode
+ */
+ User toolUser=(User)request.getSession().getAttribute(TOOL_USER);
+ logger.debug(logger + " " + this.getClass().getName() + "retrieving toolUser: " + toolUser + " userName: " + toolUser.getLogin());
+ /**
+ * !!double check if String userName=toolUser.getLogin();
+ */
+
+ /**
+ * see whether you have to report only the current learner's name and make invisible all the other learner's names in the report.
+ * A boolean true isUsernameVisible indicates that all user names to be displayed.
+ * Only applies to learning mode.
+ */
+ Boolean isUsernameVisible=(Boolean)request.getSession().getAttribute(IS_USERNAME_VISIBLE);
+ logger.debug(logger + " " + this.getClass().getName() + "IS_USERNAME_VISIBLE: " + isUsernameVisible);
+
+
+ if (qaUsrResps.isEmpty())
+ logger.debug(logger + " " + this.getClass().getName() + "the set of user responses for a particular question is empty.");
+
+ Iterator itResps=qaUsrResps.iterator();
+ /**
+ * obtain each response and the user that replied with that response
+ */
+ int responseIndex=0;
+ while (itResps.hasNext())
+ {
+ QaUsrResp qaUsrResp=(QaUsrResp)itResps.next();
+ logger.debug(logger + " " + this.getClass().getName() + "using qaUsrResp: " + qaUsrResp + " with responseIndex: " + responseIndex);
+ /**
+ * Don't include the blank answers in the report. Make sure it is the requirement.
+ */
+ if ((qaUsrResp != null) && (!qaUsrResp.isHidden()) && (qaUsrResp.getAnswer() != null) && (!qaUsrResp.getAnswer().equals("")))
+ {
+ logger.debug(logger + " " + this.getClass().getName() + "iterated qaUsrResp:" + qaUsrResp);
+ QaQueUsr qaQueUsr=qaUsrResp.getQaQueUser();
+ //find out what you need to display: fullname or login (userName)?
+ logger.debug(logger + " " + this.getClass().getName() + "iterated qaQueUsr fullName:" + qaQueUsr.getFullname());
+ logger.debug(logger + " " + this.getClass().getName() + "iterated qaQueUsr userName:" + qaQueUsr.getUsername());
+ logger.debug(logger + " " + this.getClass().getName() + "iterated qaQueUsr userName:" + qaQueUsr.getQaSession());
+ logger.debug(logger + " " + this.getClass().getName() + "using responseIndex: " + responseIndex);
+
+ /**
+ * find out if the current tool user's login(userName) is the same as the iterated user's userName.
+ * If there is a match we need to display that person first in the report
+ * !!do this when User objkect issue is resolved!!!
+ */
+
+ /**
+ * these are all the other users. See if we have the permission to display their names.
+ * if we are permitted, get ready to display all available information
+ */
+
+ /**
+ * get user's tool session
+ */
+ QaSession qaSession=qaQueUsr.getQaSession();
+ logger.debug(logger + " " + this.getClass().getName() + "iterated qaQueUsr userName:" + qaSession.getQaSessionId());
+ logger.debug(logger + " " + this.getClass().getName() + "incoming toolSessionId versus user's toolSessionId:" + toolSessionId + " versus " + qaSession.getQaSessionId());
+
+ logger.debug(logger + " " + this.getClass().getName() + "toolSessionId versus iterated session id: " + toolSessionId + "--" + qaSession.getQaSessionId());
+ logger.debug(logger + " " + this.getClass().getName() + "learner report includes only those responses in the same tool session: " + toolSessionId);
+ if (toolSessionId.equals(qaSession.getQaSessionId()))
+ {
+
+ responseIndex=responseIndex+1;
+ logger.debug(logger + " " + this.getClass().getName() + "responseIndex incremented to: " + responseIndex);
+ if (isUsernameVisible.booleanValue())
+ {
+ logger.debug(logger + " " + this.getClass().getName() + "IS_USERNAME_VISIBLE:" + isUsernameVisible.booleanValue());
+ mapUserResponses.put(new Integer(responseIndex).toString(), qaQueUsr.getFullname() + " " + qaUsrResp.getAttemptTime() + " " + qaUsrResp.getAnswer());
+ logger.debug(logger + " " + this.getClass().getName() + "Building request level response data with: " +
+ "fullname" + questionIndex +""+ responseIndex);
+ request.getSession().setAttribute(FULLNAME + questionIndex +""+ responseIndex, qaQueUsr.getFullname());
+
+ }
+ else /** we won't display the usernames of these users*/
+ {
+ logger.debug(logger + " " + this.getClass().getName() + "IS_USERNAME_VISIBLE:" + isUsernameVisible.booleanValue());
+ mapUserResponses.put(new Integer(responseIndex).toString(), " " + qaUsrResp.getAttemptTime() + " " + qaUsrResp.getAnswer());
+ logger.debug(logger + " " + this.getClass().getName() + "Building request level response data with: " +
+ "aTime" + questionIndex +""+ responseIndex);
+ }
+ /**
+ * place these whether username visible or not
+ */
+
+ logger.debug(logger + " " + this.getClass().getName() + "setting attemptTime: " + "aTime" + questionIndex +""+ responseIndex + "---------" + qaUsrResp.getAttemptTime());
+
+ request.getSession().setAttribute(ANSWER + questionIndex +""+ responseIndex, qaUsrResp.getAnswer());
+ request.getSession().setAttribute(ATIME + questionIndex +""+ responseIndex, qaUsrResp.getAttemptTime());
+
+ if (qaQueUsr.getUsername().equalsIgnoreCase(toolUser.getLogin()))
+ {
+ request.getSession().setAttribute(FULLNAME + questionIndex +""+ responseIndex, qaQueUsr.getFullname());
+ logger.debug(logger + " " + this.getClass().getName() + "include fullName for current learner: " + "fullName" + questionIndex +""+ responseIndex + "---" + qaQueUsr.getFullname());
+ logger.debug(logger + " " + this.getClass().getName() + "current learner:" + qaQueUsr.getUsername());
+ request.getSession().setAttribute(CURRENTLEARNER_FULLNAME , qaQueUsr.getFullname());
+ logger.debug(logger + " " + this.getClass().getName() + "current learner fullname:" + qaQueUsr.getFullname());
+ }
+ }
+ }
+ }
+ }
+ logger.debug(logger + " " + this.getClass().getName() + "Learner report MAP_USER_RESPONSES: " + mapUserResponses);
+ return mapUserResponses;
+ }
+
+
+ /**
+ * feedBackAnswersProgress(HttpServletRequest request, int currentQuestionIndex)
+ * give user feedback on the remaining questions
+ * @param qaLearningForm
+ * return void
+ */
+ protected void feedBackAnswersProgress(HttpServletRequest request, int currentQuestionIndex)
+ {
+ String totalQuestionCount=(String)request.getSession().getAttribute(TOTAL_QUESTION_COUNT);
+ logger.debug(logger + " " + this.getClass().getName() + "totalQuestionCount: " + totalQuestionCount);
+ int remainingQuestionCount=new Long(totalQuestionCount).intValue() - currentQuestionIndex +1;
+ logger.debug(logger + " " + this.getClass().getName() + "remainingQuestionCount: " + remainingQuestionCount);
+ String userFeedback="";
+ if (remainingQuestionCount != 0)
+ userFeedback= "Remaining question count: " + remainingQuestionCount;
+ else
+ userFeedback= "End of the questions.";
+
+ request.getSession().setAttribute(USER_FEEDBACK, userFeedback);
+ }
+
+ public void lockContent(HttpServletRequest request)
+ {
+ IQaService qaService =QaUtils.getToolService(request);
+ Long toolContentId=(Long) request.getSession().getAttribute(TOOL_CONTENT_ID);
+ logger.debug(logger + " " + this.getClass().getName() + "current toolContentId: " + toolContentId);
+ QaContent qaContent=qaService.loadQa(toolContentId.longValue());
+ logger.debug(logger + " " + this.getClass().getName() + "retrieve qaContent: " + qaContent);
+
+ qaContent.setContentLocked(true);
+ logger.debug(logger + " " + this.getClass().getName() + " " + "content with id : " + toolContentId + "has been marked LOCKED");
+ qaService.updateQa(qaContent);
+ logger.debug(logger + " " + this.getClass().getName() + " " + "content with id : " + toolContentId + "has been marked LOCKED and updated in the db");
+ }
+
+}
Index: lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/MonitoringUtil.java
===================================================================
diff -u
--- lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/MonitoringUtil.java (revision 0)
+++ lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/MonitoringUtil.java (revision 16e844de3f7c34b44baee1b28e67e708f42d00bf)
@@ -0,0 +1,290 @@
+/**
+ *
+ * Keeps all operations needed for Learning mode.
+ * @author ozgurd
+ *
+ */
+package org.lamsfoundation.lams.tool.qa.web;
+
+import java.util.Iterator;
+
+import javax.servlet.http.HttpServletRequest;
+
+import org.apache.log4j.Logger;
+import org.apache.struts.action.ActionForm;
+import org.lamsfoundation.lams.tool.qa.QaAppConstants;
+import org.lamsfoundation.lams.tool.qa.QaApplicationException;
+import org.lamsfoundation.lams.tool.qa.QaContent;
+import org.lamsfoundation.lams.tool.qa.QaSession;
+import org.lamsfoundation.lams.tool.qa.QaUsrResp;
+import org.lamsfoundation.lams.tool.qa.QaUtils;
+import org.lamsfoundation.lams.tool.qa.service.IQaService;
+
+/**
+ *
+ * Keeps all operations needed for Monitoring mode.
+ * @author ozgurd
+ *
+ */
+public class MonitoringUtil implements QaAppConstants{
+ static Logger logger = Logger.getLogger(MonitoringUtil.class.getName());
+
+ /**
+ * determine whether all the tool sessions for a particular content has been COMPLETED
+ * @param toolContentId
+ * @return
+ */
+
+ public boolean isSessionsSync(HttpServletRequest request, long toolContentId)
+ {
+ logger.debug(logger + " " + this.getClass().getName() + " " + "start of isSessionsSync with toolContentId: " + toolContentId);
+ IQaService qaService =QaUtils.getToolService(request);
+
+ QaContent qaContent =qaService.loadQa(toolContentId);
+ logger.debug(logger + " " + this.getClass().getName() + "retrieving qaContent: " + qaContent);
+
+ /**
+ * iterate all the tool sessions, if even one session is INCOMPLETE, the functions returns false
+ */
+ if (qaContent != null)
+ {
+ Iterator sessionIterator=qaContent.getQaSessions().iterator();
+ while (sessionIterator.hasNext())
+ {
+ QaSession qaSession=(QaSession)sessionIterator.next();
+ logger.debug(logger + " " + this.getClass().getName() + "iterated qaSession : " + qaSession);
+ if (qaSession.getSession_status().equalsIgnoreCase(QaSession.INCOMPLETE))
+ return false;
+ }
+ }
+
+ return true;
+ }
+
+ public void cleanupMonitoringSession(HttpServletRequest request)
+ {
+ request.getSession().removeAttribute(MAP_TOOL_SESSIONS);
+ request.getSession().removeAttribute(MAP_MONITORING_QUESTIONS);
+ request.getSession().removeAttribute(CURRENT_MONITORED_TOOL_SESSION);
+ request.getSession().removeAttribute(MAP_USER_RESPONSES);
+ request.getSession().removeAttribute(DATAMAP_EDITABLE);
+ request.getSession().removeAttribute(CHOICE_MONITORING);
+ request.getSession().removeAttribute(DATAMAP_EDITABLE_RESPONSE_ID);
+ request.getSession().removeAttribute(DATAMAP_HIDDEN_RESPONSE_ID);
+
+ //remove session attributes used commonly
+ request.getSession().removeAttribute(IS_USERNAME_VISIBLE);
+ request.getSession().removeAttribute(REPORT_TITLE_MONITOR);
+ request.getSession().removeAttribute(IS_ALL_SESSIONS_COMPLETED);
+ request.getSession().removeAttribute(CHECK_ALL_SESSIONS_COMPLETED);
+ request.getSession().removeAttribute(TOOL_CONTENT_ID);
+ request.getSession().removeAttribute(ATTR_USERDATA);
+ request.getSession().removeAttribute(TOOL_USER);
+ request.getSession().removeAttribute(TOOL_SERVICE);
+ request.getSession().removeAttribute(TARGET_MODE);
+ }
+
+
+ public void startLesson(QaMonitoringForm qaMonitoringForm, HttpServletRequest request)
+ {
+ IQaService qaService=QaUtils.getToolService(request);
+
+ String strFromToolContentId="";
+ String strToToolContentId="";
+
+ qaMonitoringForm.resetUserAction();
+ /**
+ * In deployment, we won't be passing FROM_TOOL_CONTENT_ID, TO_TOOL_CONTENT_ID and TOOL_SESSION_ID from url
+ * the Monitoring Service bean calls:
+ * copyToolContent(Long fromContentId, Long toContentId)
+ */
+ strFromToolContentId=request.getParameter(FROM_TOOL_CONTENT_ID);
+ logger.debug(logger + " " + " startLesson" + "FROM_TOOL_CONTENT_ID: " + strFromToolContentId);
+ if (strFromToolContentId == null)
+ {
+ throw new QaApplicationException("Exception occured: " +
+ "Tool expects a legitimate FROM_TOOL_CONTENT_ID from the container. Can't continue!");
+ }
+
+ strToToolContentId=request.getParameter(TO_TOOL_CONTENT_ID);
+ logger.debug(logger + " " + " startLesson" + "TO_TOOL_CONTENT_ID: " + strToToolContentId);
+ if (strToToolContentId == null)
+ {
+ throw new QaApplicationException("Exception occured: " +
+ "Tool expects a legitimate TO_TOOL_CONTENT_ID from the container. Can't continue!");
+ }
+ qaService.copyToolContent(new Long(strFromToolContentId), new Long(strToToolContentId));
+
+ /** calls to these two methods will be made from Monitoring Service bean optionally depending on
+ * the the tool is setup for DefineLater and (or) RunOffline
+ */
+
+ /**
+ * TESTED to work
+ * qaService.setAsDefineLater(new Long(strToToolContentId));
+ qaService.setAsRunOffline(new Long(strToToolContentId));
+ *
+ */
+ qaMonitoringForm.resetUserAction();
+ }
+
+
+ public void deleteLesson(QaMonitoringForm qaMonitoringForm, HttpServletRequest request)
+ {
+ IQaService qaService=QaUtils.getToolService(request);
+
+ String strFromToolContentId="";
+ String strToToolContentId="";
+
+ qaMonitoringForm.resetUserAction();
+
+ /**
+ * TESTED to work
+ */
+ strToToolContentId=request.getParameter(TO_TOOL_CONTENT_ID);
+ logger.debug(logger + " " + this.getClass().getName() + "TO_TOOL_CONTENT_ID: " + strToToolContentId);
+ if (strToToolContentId == null)
+ {
+ throw new QaApplicationException("Exception occured: " +
+ "Tool expects a legitimate TO_TOOL_CONTENT_ID from the container. Can't continue!");
+ }
+ qaService.removeToolContent(new Long(strToToolContentId));
+ qaMonitoringForm.resetUserAction();
+ }
+
+
+ public void forceComplete(QaMonitoringForm qaMonitoringForm, HttpServletRequest request)
+ {
+ IQaService qaService=QaUtils.getToolService(request);
+ /**
+ * Parameter: userId
+ */
+ qaMonitoringForm.resetUserAction();
+ logger.debug(logger + " " + this.getClass().getName() + "request for forceComplete");
+ String userId=request.getParameter(MONITOR_USER_ID);
+ logger.debug(logger + " " + this.getClass().getName() + "MONITOR_USER_ID: " + userId);
+ qaService.setAsForceComplete(new Long(userId));
+ logger.debug(logger + " " + this.getClass().getName() + "end of setAsForceComplete with userId: " + userId);
+ }
+
+
+ public boolean isDefaultMonitoringScreen(QaMonitoringForm qaMonitoringForm)
+ {
+ if ((qaMonitoringForm.getSummary() == null) &&
+ (qaMonitoringForm.getInstructions() == null) &&
+ (qaMonitoringForm.getEditActivity() == null) &&
+ (qaMonitoringForm.getStats() == null))
+ {
+ qaMonitoringForm.setSummary("summary");
+ return true;
+ }
+ return false;
+ }
+
+
+ /**
+ * findSelectedMonitoringTab(ActionForm form,
+ * HttpServletRequest request)
+ * return void
+ * determines which monitoring tabs is the active one.
+ *
+ */
+ public void findSelectedMonitoringTab(ActionForm form,
+ HttpServletRequest request)
+ {
+ QaMonitoringForm qaMonitoringForm = (QaMonitoringForm) form;
+ String choiceTypeMonitoringSummary=qaMonitoringForm.getSummary();
+ String choiceTypeMonitoringInstructions=qaMonitoringForm.getInstructions();
+ String choiceTypeMonitoringEditActivity=qaMonitoringForm.getEditActivity();
+ String choiceTypeMonitoringStats=qaMonitoringForm.getStats();
+
+ /**make the Summary tab the default one */
+ request.getSession().setAttribute(CHOICE_MONITORING,CHOICE_TYPE_MONITORING_SUMMARY);
+
+ if (choiceTypeMonitoringSummary != null)
+ {
+ logger.debug(logger + " " + this.getClass().getName() + "CHOICE_TYPE_MONITORING_SUMMARY");
+ request.getSession().setAttribute(CHOICE_MONITORING,CHOICE_TYPE_MONITORING_SUMMARY);
+ }
+ else if ((choiceTypeMonitoringInstructions != null) || (qaMonitoringForm.getSubmitMonitoringInstructions() != null))
+ {
+ logger.debug(logger + " " + this.getClass().getName() + "CHOICE_TYPE_MONITORING_INSTRUCTIONS");
+ request.getSession().setAttribute(CHOICE_MONITORING,CHOICE_TYPE_MONITORING_INSTRUCTIONS);
+ }
+ else if (choiceTypeMonitoringEditActivity != null)
+ {
+ logger.debug(logger + " " + this.getClass().getName() + "CHOICE_TYPE_MONITORING_EDITACTIVITY");
+ request.getSession().setAttribute(CHOICE_MONITORING,CHOICE_TYPE_MONITORING_EDITACTIVITY);
+ }
+ else if (choiceTypeMonitoringStats != null)
+ {
+ logger.debug(logger + " " + this.getClass().getName() + "CHOICE_TYPE_MONITORING_STATS");
+ request.getSession().setAttribute(CHOICE_MONITORING,CHOICE_TYPE_MONITORING_STATS);
+ }
+ logger.debug(logger + " " + this.getClass().getName() + "CHOICE_MONITORING is:" + request.getSession().getAttribute(CHOICE_MONITORING));
+
+ /** reset tab controllers */
+ qaMonitoringForm.setSummary(null);
+ qaMonitoringForm.setInstructions(null);
+ qaMonitoringForm.setEditActivity(null);
+ qaMonitoringForm.setStats(null);
+ }
+
+ public boolean isNonDefaultScreensVisited(HttpServletRequest request)
+ {
+ Boolean monitoringInstructionsVisited = (Boolean) request.getSession().getAttribute(MONITORING_INSTRUCTIONS_VISITED);
+ Boolean monitoringEditActivityVisited = (Boolean) request.getSession().getAttribute(MONITORING_EDITACTIVITY_VISITED);
+ Boolean monitoringStatsVisited = (Boolean) request.getSession().getAttribute(MONITORING_STATS_VISITED);
+
+ logger.debug(logger + " " + this.getClass().getName() + "isNonDefaultScreensVisited:" + monitoringInstructionsVisited
+ + " " + monitoringEditActivityVisited + " " + monitoringStatsVisited);
+
+ if ((monitoringInstructionsVisited != null) && (monitoringInstructionsVisited.booleanValue()))
+ return true;
+
+ if ((monitoringEditActivityVisited != null) && (monitoringEditActivityVisited.booleanValue()))
+ return true;
+
+ if ((monitoringStatsVisited != null) && (monitoringStatsVisited.booleanValue()))
+ return true;
+
+ return false;
+ }
+
+ public void updateResponse(HttpServletRequest request, String responseId, String updatedResponse)
+ {
+ IQaService qaService=QaUtils.getToolService(request);
+
+ logger.debug(logger + " " + this.getClass().getName() + "load response with responseId: " + new Long(responseId).longValue());
+ QaUsrResp qaUsrResp=qaService.retrieveQaUsrResp(new Long(responseId).longValue());
+ logger.debug(logger + " " + this.getClass().getName() + "loaded user response: " + qaUsrResp);
+ qaUsrResp.setAnswer(updatedResponse);
+ qaService.updateQaUsrResp(qaUsrResp);
+ logger.debug(logger + " " + this.getClass().getName() + "updated user response in the db: " + qaUsrResp);
+ }
+
+ public void hideResponse(HttpServletRequest request, String responseId)
+ {
+ IQaService qaService=QaUtils.getToolService(request);
+
+ logger.debug(logger + " " + this.getClass().getName() + "load response with responseId for hiding: " + new Long(responseId).longValue());
+ QaUsrResp qaUsrResp=qaService.retrieveQaUsrResp(new Long(responseId).longValue());
+ logger.debug(logger + " " + this.getClass().getName() + "loaded user response: " + qaUsrResp);
+ qaUsrResp.setHidden(true);
+ qaService.updateQaUsrResp(qaUsrResp);
+ logger.debug(logger + " " + this.getClass().getName() + "updated user response in the db: " + qaUsrResp);
+ }
+
+
+ public void unHideResponse(HttpServletRequest request, String responseId)
+ {
+ IQaService qaService=QaUtils.getToolService(request);
+
+ logger.debug(logger + " " + this.getClass().getName() + "load response with responseId for un-hiding: " + new Long(responseId).longValue());
+ QaUsrResp qaUsrResp=qaService.retrieveQaUsrResp(new Long(responseId).longValue());
+ logger.debug(logger + " " + this.getClass().getName() + "loaded user response: " + qaUsrResp);
+ qaUsrResp.setHidden(false);
+ qaService.updateQaUsrResp(qaUsrResp);
+ logger.debug(logger + " " + this.getClass().getName() + "updated user response in the db: " + qaUsrResp);
+ }
+}
Index: lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/QAction.java
===================================================================
diff -u
--- lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/QAction.java (revision 0)
+++ lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/QAction.java (revision 16e844de3f7c34b44baee1b28e67e708f42d00bf)
@@ -0,0 +1,664 @@
+/*
+ *Copyright (C) 2005 LAMS Foundation (http://lamsfoundation.org)
+ *
+ *This program is free software; you can redistribute it and/or modify
+ *it under the terms of the GNU General Public License as published by
+ *the Free Software Foundation; either version 2 of the License, or
+ *(at your option) any later version.
+ *
+ *This program is distributed in the hope that it will be useful,
+ *but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ *GNU General Public License for more details.
+ *
+ *You should have received a copy of the GNU General Public License
+ *along with this program; if not, write to the Free Software
+ *Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
+ *USA
+ *
+ *http://www.gnu.org/licenses/gpl.txt
+ */
+package org.lamsfoundation.lams.tool.qa.web;
+
+import java.io.IOException;
+import java.util.Date;
+import java.util.Map;
+
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.log4j.Logger;
+import org.apache.struts.Globals;
+import org.apache.struts.action.ActionForm;
+import org.apache.struts.action.ActionForward;
+import org.apache.struts.action.ActionMapping;
+import org.apache.struts.action.ActionMessage;
+import org.apache.struts.action.ActionMessages;
+import org.apache.struts.actions.DispatchAction;
+import org.lamsfoundation.lams.tool.qa.QaAppConstants;
+import org.lamsfoundation.lams.tool.qa.QaContent;
+import org.lamsfoundation.lams.tool.qa.QaSession;
+import org.lamsfoundation.lams.tool.qa.QaUtils;
+import org.lamsfoundation.lams.tool.qa.service.IQaService;
+import org.lamsfoundation.lams.usermanagement.User;
+
+/**
+ *
+ * monitoring to support modification and hiding of user responses
+ *
+ */
+/**
+ *
+ * once lams_learning is erady and appContext file is src/ then FINISH toool session will work.
+ *
+ */
+/**
+ *
+ * content_locked is done
+ */
+/**
+ *
+ * done: removed styling, except error messages and table centering
+ *
+ */
+/**
+ * The tool's Spring configuration file: qaCompactApplicationContext.xml
+ * Main service bean of the tool is: org.lamsfoundation.lams.tool.qa.service.QaServicePOJO
+ *
+ * done: config file is read from classpath
+ */
+
+
+/**
+ *
+ * the tool's web.xml will be modified to have classpath to learning service.
+ * This is how the tool gets the definition of "learnerService"
+ */
+/**
+ *
+ * when to reset define later and synchin monitor etc..
+ *
+ */
+
+/** make sure the tool gets called on:
+ * setAsForceComplete(Long userId) throws QaApplicationException
+ */
+
+
+/**
+ *
+ * User Issue:
+ * Right now:
+ * 1- the tool gets the request object from the container.
+ * 2- Principal principal = req.getUserPrincipal();
+ * 3- String username = principal.getName();
+ * 4- User userCompleteData = qaService.getCurrentUserData(userName);
+ * 5- write back userCompleteData.getUserId()
+ */
+
+
+/**
+ *
+ * JBoss Issue:
+ * Currently getUserPrincipal() returns null and ServletRequest.isUserInRole() always returns false on unsecured pages,
+ * even after the user has been authenticated.
+ * http://jira.jboss.com/jira/browse/JBWEB-19
+ */
+
+/**
+ * TO DO: definelater to be created completely at monitor time?
+ * populating User id from the tool url.
+ *
+ */
+
+/**
+ * eliminate the calls to:
+ * authoringUtil.simulatePropertyInspector_RunOffline(request);
+ * authoringUtil.simulatePropertyInspector_setAsDefineLater(request);
+ */
+
+
+/**
+ *
+ * @author ozgurd
+ *
+ * TOOL PARAMETERS: ?? (toolAccessMode) ??
+ * Authoring environment: toolContentId
+ * Learning environment: toolSessionId + toolContentId
+ * Monitoring environment: toolContentId / Contribute tab:toolSessionId(s)
+ *
+ *
+ */
+
+/**
+ * Note: the tool must support deletion of an existing content from within the authoring environment.
+ * The current support for this is by implementing the tool contract : removeToolContent(Long toolContentId)
+ */
+
+
+/**
+ *
+ * We have had to simulate container bahaviour in development stage by calling
+ * createToolSession and leaveToolSession from the web layer. These will go once the tool is
+ * in deployment environment.
+ *
+ *
+ * CHECK: leaveToolSession and relavent LearnerService may need to be defined in the spring config file.
+ *
+ */
+
+
+/**
+ *
+ * GROUPING SUPPORT: Find out what to do.
+ */
+
+/**
+ *
+ * take force_offline and define_later outside of the tool
+ */
+
+/**
+ *
Action class that controls the logic of tool behavior.
+ *
+ *
Note that Struts action class only has the responsibility to navigate
+ * page flow. All database operation should go to service layer and data
+ * transformation from domain model to struts form bean should go to form
+ * bean class. This ensure clean and maintainable code.
+ *
+ *
+ * SystemException is thrown whenever an known error condition is
+ * identified. No system exception error handling code should appear in the
+ * Struts action class as all of them are handled in
+ * CustomStrutsExceptionHandler.
+ *
+ * @author ozgurd
+ * ----------------XDoclet Tags--------------------
+ * ----------------XDoclet Tags--------------------
+ */
+public class QAction extends DispatchAction implements QaAppConstants
+{
+ static Logger logger = Logger.getLogger(QAction.class.getName());
+
+ public static Integer READABLE_TOOL_SESSION_COUNT = new Integer(1);
+
+ /**
+ *
Struts dispatch method.
+ *
+ *
It is assuming that progress engine should pass in the tool access
+ * mode and the tool session id as http parameters.
+ *
+ * @param mapping An ActionMapping class that will be used by the Action class to tell
+ * the ActionServlet where to send the end-user.
+ *
+ * @param form The ActionForm class that will contain any data submitted
+ * by the end-user via a form.
+ * @param request A standard Servlet HttpServletRequest class.
+ * @param response A standard Servlet HttpServletResponse class.
+ * @return An ActionForward class that will be returned to the ActionServlet indicating where
+ * the user is to go next.
+ * @throws IOException
+ * @throws ServletException
+ * @throws QaApplicationException the known runtime exception
+ *
+ */
+
+ /**
+ * loadQ(ActionMapping mapping,
+ ActionForm form,
+ HttpServletRequest request,
+ HttpServletResponse response) throws IOException,
+ ServletException
+
+ * return ActionForward
+ * main content/question content management and workflow logic
+ *
+ * if the passed toolContentId exists in the db, we need to get the relevant data into the Map
+ * if not, create the default Map
+ */
+
+ public ActionForward loadQ(ActionMapping mapping,
+ ActionForm form,
+ HttpServletRequest request,
+ HttpServletResponse response) throws IOException,
+ ServletException
+ {
+
+ AuthoringUtil authoringUtil= new AuthoringUtil();
+
+ /**
+ * find out which tab is the active one.
+ */
+ authoringUtil.findSelectedTab(mapping,
+ form,
+ request,
+ response);
+
+ QaAuthoringForm qaAuthoringForm = (QaAuthoringForm) form;
+ logger.debug(logger + " " + this.getClass().getName() + "loadQ: form read: " + qaAuthoringForm);
+
+
+ /**
+ * the status of define later is determined from the property inspector and
+ * by now, we know whether it is on or off
+ *
+ * enable-disable tool html elements based on "define later" status
+ */
+ boolean defineLaterStatus=QaUtils.getDefineLaterStatus();
+
+ Boolean defineLater=new Boolean(defineLaterStatus);
+ logger.debug(logger + " " + this.getClass().getName() + "defineLater: " + defineLater);
+ if (defineLater.equals(new Boolean(false)))
+ {
+ request.getSession().setAttribute(IS_DEFINE_LATER,"false");
+ request.getSession().setAttribute(DISABLE_TOOL,"");
+ }
+ else
+ {
+ request.getSession().setAttribute(IS_DEFINE_LATER,"true");
+ request.getSession().setAttribute(DISABLE_TOOL,"disabled");
+ }
+
+ //retrieve the default question content map
+ Map mapQuestionContent=(Map)request.getSession().getAttribute(MAP_QUESTION_CONTENT);
+ logger.debug(logger + " " + this.getClass().getName() + "MAP_QUESTION_CONTENT:" + request.getSession().getAttribute(MAP_QUESTION_CONTENT));
+
+ String userAction="";
+ if (qaAuthoringForm.getAddContent() != null)
+ {
+ userAction=ADD_NEW_QUESTION;
+ }
+ else if (qaAuthoringForm.getRemoveContent() != null)
+ {
+ userAction=REMOVE_QUESTION;
+ }
+ else if (qaAuthoringForm.getRemoveAllContent() != null)
+ {
+ userAction=REMOVE_ALL_CONTENT;
+ }
+ else if (qaAuthoringForm.getSubmitTabDone() != null)
+ {
+ userAction=SUBMIT_TAB_DONE;
+ }
+ else if (qaAuthoringForm.getSubmitAllContent() != null)
+ {
+ userAction=SUBMIT_ALL_CONTENT;
+ }
+ logger.debug(logger + " " + this.getClass().getName() + "user action is: " + userAction);
+
+ //add a new question to Map
+ if (userAction.equalsIgnoreCase(ADD_NEW_QUESTION))
+ {
+ request.getSession().setAttribute(EDITACTIVITY_EDITMODE, new Boolean(true));
+ authoringUtil.reconstructQuestionContentMapForAdd(mapQuestionContent, request);
+ }//delete a question
+ else if (userAction.equalsIgnoreCase(REMOVE_QUESTION))
+ {
+ request.getSession().setAttribute(EDITACTIVITY_EDITMODE, new Boolean(true));
+ authoringUtil.reconstructQuestionContentMapForRemove(mapQuestionContent, request, qaAuthoringForm);
+ } //remove selected content
+ else if (userAction.equalsIgnoreCase(REMOVE_ALL_CONTENT))
+ {
+ authoringUtil.removeAllDBContent(request);
+ QaUtils.cleanupSession(request);
+ //reset all user actions
+ qaAuthoringForm.resetUserAction();
+ return (mapping.findForward(LOAD_STARTER));
+ }
+ else if (userAction.equalsIgnoreCase(SUBMIT_TAB_DONE))
+ {
+ logger.debug(logger + " " + this.getClass().getName() + "user is done with this tab.");
+ //reset all user actions
+ qaAuthoringForm.resetUserAction();
+ return (mapping.findForward(LOAD_QUESTIONS));
+ }//submit questions contained in the Map
+ else if (userAction.equalsIgnoreCase(SUBMIT_ALL_CONTENT))
+ {
+ ActionMessages errors= new ActionMessages();
+
+ /**
+ * full form validation should be performed only in standard authoring mode, but not in monitoring EditActivity
+ */
+
+ if ((qaAuthoringForm.getTitle() == null) || (qaAuthoringForm.getTitle().length() == 0))
+ {
+ errors.add(Globals.ERROR_KEY,new ActionMessage("error.title"));
+ logger.debug(logger + " " + this.getClass().getName() + "add title to ActionMessages:");
+ }
+
+ if ((qaAuthoringForm.getInstructions() == null) || (qaAuthoringForm.getInstructions().length() == 0))
+ {
+ errors.add(Globals.ERROR_KEY, new ActionMessage("error.instructions"));
+ logger.debug(logger + " " + this.getClass().getName() + "add instructions to ActionMessages: ");
+ }
+
+ /**
+ * enforce that the first (default) question entry is not empty
+ */
+ String defaultQuestionEntry =request.getParameter("questionContent0");
+ if ((defaultQuestionEntry == null) || (defaultQuestionEntry.length() == 0))
+ {
+ errors.add(Globals.ERROR_KEY, new ActionMessage("error.defaultquestion.empty"));
+ logger.debug(logger + " " + this.getClass().getName() + "add error.defaultquestion.empty to ActionMessages: ");
+ }
+
+ Boolean renderMonitoringEditActivity=(Boolean)request.getSession().getAttribute(RENDER_MONITORING_EDITACTIVITY);
+ if ((renderMonitoringEditActivity != null) && (!renderMonitoringEditActivity.booleanValue()))
+ {
+
+ if ((qaAuthoringForm.getReportTitle() == null) || (qaAuthoringForm.getReportTitle().length() == 0))
+ {
+ errors.add(Globals.ERROR_KEY, new ActionMessage("error.reportTitle"));
+ logger.debug(logger + " " + this.getClass().getName() + "add reportTitle to ActionMessages: ");
+ }
+
+ if ((qaAuthoringForm.getMonitoringReportTitle() == null) || (qaAuthoringForm.getMonitoringReportTitle().length() == 0))
+ {
+ errors.add(Globals.ERROR_KEY, new ActionMessage("error.monitorReportTitle"));
+ logger.debug(logger + " " + this.getClass().getName() + "add monitorReportTitle to ActionMessages: ");
+ }
+ }
+ /**
+ * end of error validation
+ */
+
+ saveErrors(request,errors);
+ if (errors.size() > 0)
+ {
+ logger.debug(logger + " " + this.getClass().getName() + "returning back to from to fix errors:");
+ request.getSession().setAttribute(EDITACTIVITY_EDITMODE, new Boolean(true));
+ return (mapping.findForward(LOAD_QUESTIONS));
+ }
+
+ /**
+ * look after defineLater flag
+ */
+ IQaService qaService =QaUtils.getToolService(request);
+ Long monitoredContentId=(Long)request.getSession().getAttribute(MONITORED_CONTENT_ID);
+ logger.debug(logger + " " + this.getClass().getName() + "MONITORED_CONTENT_ID: " + monitoredContentId);
+ if (monitoredContentId != null)
+ {
+ qaService.unsetAsDefineLater(monitoredContentId);
+ logger.debug(logger + " " + this.getClass().getName() + "MONITORED_CONTENT_ID has been unset as defineLater: ");
+ }
+
+ authoringUtil.reconstructQuestionContentMapForSubmit(mapQuestionContent, request);
+ //delete existing content from the database
+ authoringUtil.removeAllDBContent(request);
+ //create-recreate the content in the db
+ QaContent qaContent=authoringUtil.createContent(mapQuestionContent, request, qaAuthoringForm);
+ authoringUtil.createQuestionContent(mapQuestionContent, request, qaContent);
+
+ //giving the user a feedback
+ errors.clear();
+ errors.add(Globals.ERROR_KEY, new ActionMessage("submit.successful"));
+ logger.debug(logger + " " + this.getClass().getName() + "submit successful: ");
+ saveErrors(request,errors);
+ }
+ else
+ {
+ logger.debug(logger + " " + this.getClass().getName() + "Warning!: Uncatered-for user action: " + userAction);
+ }
+
+ //reset all user actions
+ qaAuthoringForm.resetUserAction();
+
+ /*
+ ToolAccessMode mode = WebUtil.readToolAccessModeParam(request, WebUtil.PARAM_MODE,MODE_OPTIONAL);
+ logger.debug(logger + " " + this.getClass().getName() + "retrieving mode: " + mode);
+ */
+
+ return (mapping.findForward(LOAD_QUESTIONS));
+ }
+
+
+ /**
+ * This method manages the presentation Map for the learner mode.
+ * The dispatch method to decide which view should be shown to the user.
+ * The deicision is based on tool access mode and tool session status.
+ * The tool access mode is lams concept and should comes from progress
+ * engine, whereas tool session status is tool's own session state
+ * concept and should be loaded from database and setup by
+ * loadQuestionnaire.
+ *
+ * @param mapping An ActionMapping class that will be used by the Action class to tell
+ * the ActionServlet where to send the end-user.
+ *
+ * @param form The ActionForm class that will contain any data submitted
+ * by the end-user via a form.
+ * @param request A standard Servlet HttpServletRequest class.
+ * @param response A standard Servlet HttpServletResponse class.
+ * @return An ActionForward class that will be returned to the ActionServlet indicating where
+ * the user is to go next.
+ * @throws IOException
+ * @throws ServletException
+ */
+ public ActionForward displayQ(ActionMapping mapping,
+ ActionForm form,
+ HttpServletRequest request,
+ HttpServletResponse response) throws IOException,
+ ServletException
+ {
+ /**
+ * if the content is not ready yet, don't even proceed.
+ * check the define later status
+ */
+ Boolean defineLater=(Boolean)request.getSession().getAttribute(IS_DEFINE_LATER);
+ logger.debug(logger + " " + this.getClass().getName() + "learning-defineLater: " + defineLater);
+ if (defineLater.booleanValue() == true)
+ {
+ persistError(request,"error.defineLater");
+ return (mapping.findForward(LOAD));
+ }
+
+ LearningUtil learningUtil= new LearningUtil();
+ QaLearningForm qaLearningForm = (QaLearningForm) form;
+
+ //retrieve the default question content map
+ Map mapQuestions=(Map)request.getSession().getAttribute(MAP_QUESTION_CONTENT_LEARNER);
+ logger.debug(logger + " " + this.getClass().getName() + "MAP_QUESTION_CONTENT_LEARNER:" + request.getSession().getAttribute(MAP_QUESTION_CONTENT_LEARNER));
+
+ //retrieve the answers Map
+ Map mapAnswers=(Map)request.getSession().getAttribute(MAP_ANSWERS);
+ logger.debug(logger + " " + this.getClass().getName() + "MAP_ANSWERS:" + mapAnswers);
+
+ //obtain author's question listing preference
+ String questionListingMode=(String) request.getSession().getAttribute(QUESTION_LISTING_MODE);
+ //maintain Map either based on sequential listing or based on combined listing
+ if (questionListingMode.equalsIgnoreCase(QUESTION_LISTING_MODE_SEQUENTIAL))
+ {
+ logger.debug(logger + " " + this.getClass().getName() + "QUESTION_LISTING_MODE_SEQUENTIAL");
+
+ int currentQuestionIndex=new Long(qaLearningForm.getCurrentQuestionIndex()).intValue();
+ logger.debug(logger + " " + this.getClass().getName() + "currentQuestionIndex is: " + currentQuestionIndex);
+ logger.debug(logger + " " + this.getClass().getName() + "getting answer for question: " + currentQuestionIndex + "as: " + qaLearningForm.getAnswer());
+ logger.debug(logger + " " + this.getClass().getName() + "mapAnswers size:" + mapAnswers.size());
+
+ if (mapAnswers.size() >= currentQuestionIndex)
+ {
+ logger.debug(logger + " " + this.getClass().getName() + "mapAnswers size:" + mapAnswers.size() + " and currentQuestionIndex: " + currentQuestionIndex);
+ mapAnswers.remove(new Long(currentQuestionIndex).toString());
+ }
+ logger.debug(logger + " " + this.getClass().getName() + "before adding to mapAnswers: " + mapAnswers);
+ mapAnswers.put(new Long(currentQuestionIndex).toString(), qaLearningForm.getAnswer());
+ logger.debug(logger + " " + this.getClass().getName() + "adding new answer:" + qaLearningForm.getAnswer() + " to mapAnswers.");
+
+ if (qaLearningForm.getGetNextQuestion() != null)
+ currentQuestionIndex++;
+ else if (qaLearningForm.getGetPreviousQuestion() != null)
+ currentQuestionIndex--;
+
+ request.getSession().setAttribute(CURRENT_ANSWER, mapAnswers.get(new Long(currentQuestionIndex).toString()));
+ logger.debug(logger + " " + this.getClass().getName() + "currentQuestionIndex will be: " + currentQuestionIndex);
+ request.getSession().setAttribute(CURRENT_QUESTION_INDEX, new Long(currentQuestionIndex));
+ learningUtil.feedBackAnswersProgress(request,currentQuestionIndex);
+ qaLearningForm.resetUserActions(); /**resets all except submitAnswersContent */
+ }
+ else
+ {
+ logger.debug(logger + " " + this.getClass().getName() + "QUESTION_LISTING_MODE_COMBINED");
+ for (int questionIndex=INITIAL_QUESTION_COUNT.intValue(); questionIndex<= mapQuestions.size(); questionIndex++ )
+ {
+ String answer=request.getParameter("answer" + questionIndex);
+ logger.debug(logger + " " + this.getClass().getName() + " answer for question " + questionIndex + " is:" + answer);
+ mapAnswers.put(new Long(questionIndex).toString(), answer);
+ }
+ }
+
+ /**
+ * At this point the Map holding learner responses is ready. So place that into the session.
+ */
+ request.getSession().setAttribute(MAP_ANSWERS, mapAnswers);
+
+ /**
+ * Learner submits the responses to the questions.
+ */
+ if (qaLearningForm.getSubmitAnswersContent() != null)
+ {
+ logger.debug(logger + " " + this.getClass().getName() + "submit the responses: " + mapAnswers);
+ //recreate the users and responses
+ learningUtil.createUsersAndResponses(mapAnswers, request);
+ //reset all user actions
+ qaLearningForm.resetUserActions();
+ //also reset this button
+ qaLearningForm.setSubmitAnswersContent(null);
+ //start generating a report for the Learner
+ learningUtil.buidLearnerReport(request,1);
+
+ learningUtil.lockContent(request);
+ logger.debug(logger + " " + this.getClass().getName() + "content has been locked");
+ return (mapping.findForward(LEARNER_REPORT));
+ }
+ /**
+ * Simulate learner leaving the current tool session. This will normally gets called by the container by
+ * leaveToolSession(toolSessionId, user)
+ */
+ else if (qaLearningForm.getEndLearning() != null)
+ {
+ /**
+ * The learner is done with the tool session. The tool needs to clean-up.
+ */
+
+ Long toolSessionId=(Long)request.getSession().getAttribute(TOOL_SESSION_ID);
+ User user=(User)request.getSession().getAttribute(TOOL_USER);
+ logger.debug(logger + " " + this.getClass().getName() + "Simulating container behaviour by calling " +
+ "leaveToolSession() with toolSessionId: " + toolSessionId + " and " +
+ "user: " + user);
+
+ /**
+ * mark the tool session as COMPLETE
+ */
+ IQaService qaService =QaUtils.getToolService(request);
+ QaSession qaSession=qaService.retrieveQaSessionOrNullById(toolSessionId.longValue());
+ qaSession.setSession_end_date(new Date(System.currentTimeMillis()));
+ qaSession.setSession_status(COMPLETED);
+ qaService.updateQaSession(qaSession);
+ logger.debug(logger + " " + this.getClass().getName() + "tool session has been marked COMPLETE: " + qaSession);
+ /*
+ ILearnerService learnerService =LearnerServiceProxy.getLearnerService(getServlet().getServletContext());
+ logger.debug(logger + " " + this.getClass().getName() + "learnerService: " + learnerService);
+ learnerService.completeToolSession(toolSessionId, user);
+ logger.debug(logger + " " + this.getClass().getName() + "completeToolSession on learnerService has finished: ");
+ */
+ }
+
+ /**
+ * Also cleanup session attributes
+ */
+ QaUtils.cleanupSession(request);
+
+ //reset all user actions
+ qaLearningForm.resetUserActions();
+
+ return (mapping.findForward(LOAD));
+ }
+
+
+ /**
+ * used to load Monitoring tabs back once the controller moves to Edit Activity.
+ * @param mapping
+ * @param form
+ * @param request
+ * @param response
+ * @return
+ * @throws IOException
+ * @throws ServletException
+ */
+ public ActionForward loadMonitoring(ActionMapping mapping,
+ ActionForm form,
+ HttpServletRequest request,
+ HttpServletResponse response) throws IOException,
+ ServletException
+ {
+ QaAuthoringForm qaAuthoringForm = (QaAuthoringForm) form;
+
+ if (qaAuthoringForm.getSummaryMonitoring() != null)
+ {
+ logger.debug(logger + " " + this.getClass().getName() + "request for getSummaryMonitoring, start proxying...");
+ logger.debug(logger + " " + this.getClass().getName() + "NO_AVAILABLE_SESSIONS: " +
+ request.getSession().getAttribute(NO_AVAILABLE_SESSIONS));
+
+ Boolean noAvailableSessions=(Boolean)request.getSession().getAttribute(NO_AVAILABLE_SESSIONS);
+ logger.debug(logger + " " + this.getClass().getName() + "NO_AVAILABLE_SESSIONS: " +noAvailableSessions);
+ qaAuthoringForm.resetUserAction();
+ if ((noAvailableSessions != null) && (noAvailableSessions.booleanValue()))
+ {
+ persistError(request,"error.noStudentActivity");
+ request.setAttribute(START_MONITORING_SUMMARY_REQUEST, new Boolean(true));
+ request.setAttribute(STOP_RENDERING_QUESTIONS, new Boolean(true));
+ return (mapping.findForward(LOAD));
+ }
+ else
+ {
+ logger.debug(logger + " " + this.getClass().getName() + "NO_AVAILABLE_SESSIONS: " +false);
+ QaMonitoringAction qaMonitoringAction=new QaMonitoringAction();
+ QaMonitoringForm qaMonitoringForm=new QaMonitoringForm();
+ return qaMonitoringAction.generateToolSessionDataMap(mapping,qaMonitoringForm,request,response);
+ }
+ }
+ else if (qaAuthoringForm.getInstructionsMonitoring() != null)
+ {
+ logger.debug(logger + " " + this.getClass().getName() + "QAction- request for getInstructionsMonitoring()");
+ qaAuthoringForm.resetUserAction();
+ QaMonitoringAction qaMonitoringAction=new QaMonitoringAction();
+ QaMonitoringForm qaMonitoringForm=new QaMonitoringForm();
+ qaMonitoringForm.setInstructions("instructions");
+ return qaMonitoringAction.generateToolSessionDataMap(mapping,qaMonitoringForm,request,response);
+ }
+ else if (qaAuthoringForm.getEditActivityMonitoring() != null)
+ {
+ logger.debug(logger + " " + this.getClass().getName() + "QAction-request for getEditActivityMonitoring()");
+ QaStarterAction qaStarterAction = new QaStarterAction();
+ logger.debug(logger + " " + this.getClass().getName() + "forward to Authoring Basic tab ");
+ ActionForward actionForward=qaStarterAction.startMonitoringSummary(mapping, qaAuthoringForm, request, response);
+ logger.debug(logger + " " + this.getClass().getName() + "actionForward: " + actionForward);
+ qaAuthoringForm.resetUserAction();
+ return (actionForward);
+ }
+ else if (qaAuthoringForm.getStatsMonitoring() != null)
+ {
+ logger.debug(logger + " " + this.getClass().getName() + "TO BE FIXED request for getStatsMonitoring()");
+ qaAuthoringForm.resetUserAction();
+ QaMonitoringAction qaMonitoringAction=new QaMonitoringAction();
+ QaMonitoringForm qaMonitoringForm=new QaMonitoringForm();
+ qaMonitoringForm.setStats("stats");
+ return qaMonitoringAction.generateToolSessionDataMap(mapping,qaMonitoringForm,request,response);
+ }
+
+ return null;
+ }
+
+ /**
+ * persists error messages to request scope
+ * @param request
+ * @param message
+ */
+ public void persistError(HttpServletRequest request, String message)
+ {
+ ActionMessages errors= new ActionMessages();
+ errors.add(Globals.ERROR_KEY, new ActionMessage(message));
+ logger.debug(logger + " " + this.getClass().getName() + "add " + message +" to ActionMessages:");
+ saveErrors(request,errors);
+ }
+}
Index: lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/QaAuthoringForm.java
===================================================================
diff -u
--- lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/QaAuthoringForm.java (revision 0)
+++ lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/QaAuthoringForm.java (revision 16e844de3f7c34b44baee1b28e67e708f42d00bf)
@@ -0,0 +1,451 @@
+/*
+ * ozgurd
+ * Created on 26/04/2005
+ *
+ * TODO To change the template for this generated file go to
+ * Window - Preferences - Java - Code Style - Code Templates
+ */
+package org.lamsfoundation.lams.tool.qa.web;
+
+/**
+ * ActionForm for the Authoring environment
+ */
+import org.apache.log4j.Logger;
+import org.apache.struts.action.ActionForm;
+import org.lamsfoundation.lams.tool.qa.QaAppConstants;
+
+/**
+ * @author ozgurd
+ *
+ * TODO To change the template for this generated type comment go to
+ * Window - Preferences - Java - Code Style - Code Templates
+ */
+public class QaAuthoringForm extends ActionForm implements QaAppConstants {
+ static Logger logger = Logger.getLogger(QaAuthoringForm.class.getName());
+
+ //controllers
+ protected String addContent;
+ protected String removeContent;
+ protected String removeAllContent;
+ protected String submitAllContent;
+ protected String submitTabDone;
+
+ //tab controller, these may go away once the Flash wraps the jsp
+ protected String choice;
+ protected String choiceBasic;
+ protected String choiceAdvanced;
+ protected String choiceInstructions;
+
+ //basic content
+ protected String title;
+ protected String instructions;
+ protected String questionIndex;
+ protected String isRemoveContent;
+ protected String toolContentId;
+ //instructions content
+ protected String onlineInstructions;
+ protected String offlineInstructions;
+ //advanced content
+ protected String synchInMonitor;
+ protected String reportTitle;
+ protected String monitoringReportTitle;
+ protected String endLearningMessage;
+ protected String usernameVisible;
+ protected String questionsSequenced;
+
+ //proxy controllers for Monitoring tabs
+ protected String summaryMonitoring;
+ protected String instructionsMonitoring;
+ protected String editActivityMonitoring;
+ protected String statsMonitoring;
+
+ protected String edit;
+
+ public void resetUserAction()
+ {
+ this.addContent=null;
+ this.removeContent=null;
+ this.removeAllContent=null;
+ this.submitAllContent=null;
+ this.submitTabDone=null;
+
+ this.summaryMonitoring=null;
+ this.instructionsMonitoring=null;
+ this.editActivityMonitoring=null;
+ this.statsMonitoring=null;
+ this.edit=null;
+ }
+
+ public void reset()
+ {
+ this.addContent=null;
+ this.removeContent=null;
+ this.removeAllContent=null;
+ this.submitAllContent=null;
+ this.submitTabDone=null;
+
+ this.choice=null;
+ this.choiceBasic=null;
+ this.choiceAdvanced=null;
+ this.choiceInstructions=null;
+
+ this.title=null;
+ this.instructions=null;
+ this.questionIndex=null;
+ this.isRemoveContent=null;
+ this.toolContentId=null;
+
+ this.onlineInstructions=null;
+ this.offlineInstructions=null;
+
+ this.endLearningMessage=null;
+ this.synchInMonitor=null;
+ this.reportTitle=null;
+ this.monitoringReportTitle=null;
+ this.questionsSequenced=null;
+
+ this.summaryMonitoring=null;
+ this.instructionsMonitoring=null;
+ this.editActivityMonitoring=null;
+ this.statsMonitoring=null;
+ this.edit=null;
+ }
+
+ public void resetRadioBoxes()
+ {
+ this.synchInMonitor =OPTION_OFF;
+ this.usernameVisible =OPTION_OFF;
+ this.questionsSequenced =OPTION_OFF;
+ logger.debug(logger + " " + this.getClass().getName() + "resetting RadioBoxes to: " + this.getSynchInMonitor());
+ }
+
+
+ /**
+ * @return Returns the isRemoveContent.
+ */
+ public String getIsRemoveContent() {
+ return isRemoveContent;
+ }
+ /**
+ * @param isRemoveContent The isRemoveContent to set.
+ */
+ public void setIsRemoveContent(String isRemoveContent) {
+ this.isRemoveContent = isRemoveContent;
+ }
+ /**
+ * @return Returns the questionIndex.
+ */
+ public String getQuestionIndex() {
+ return questionIndex;
+ }
+ /**
+ * @param questionIndex The questionIndex to set.
+ */
+ public void setQuestionIndex(String questionIndex) {
+ this.questionIndex = questionIndex;
+ }
+
+ /**
+ * @return Returns the addContent.
+ */
+ public String getAddContent() {
+ return addContent;
+ }
+ /**
+ * @param addContent The addContent to set.
+ */
+ public void setAddContent(String addContent) {
+ this.addContent = addContent;
+ }
+ /**
+ * @return Returns the removeContent.
+ */
+ public String getRemoveContent() {
+ return removeContent;
+ }
+ /**
+ * @param removeContent The removeContent to set.
+ */
+ public void setRemoveContent(String removeContent) {
+ this.removeContent = removeContent;
+ }
+ /**
+ * @return Returns the removeAllContent.
+ */
+ public String getRemoveAllContent() {
+ return removeAllContent;
+ }
+ /**
+ * @param removeAllContent The removeAllContent to set.
+ */
+ public void setRemoveAllContent(String removeAllContent) {
+ this.removeAllContent = removeAllContent;
+ }
+ /**
+ * @return Returns the submitAllContent.
+ */
+ public String getSubmitAllContent() {
+ return submitAllContent;
+ }
+ /**
+ * @param submitAllContent The submitAllContent to set.
+ */
+ public void setSubmitAllContent(String submitAllContent) {
+ this.submitAllContent = submitAllContent;
+ }
+ /**
+ * @return Returns the instructions.
+ */
+ public String getInstructions() {
+ return instructions;
+ }
+ /**
+ * @param instructions The instructions to set.
+ */
+ public void setInstructions(String instructions) {
+ this.instructions = instructions;
+ }
+ /**
+ * @return Returns the title.
+ */
+ public String getTitle() {
+ return title;
+ }
+ /**
+ * @param title The title to set.
+ */
+ public void setTitle(String title) {
+ this.title = title;
+ }
+ /**
+ * @return Returns the toolContentId.
+ */
+ public String getToolContentId() {
+ return toolContentId;
+ }
+ /**
+ * @param toolContentId The toolContentId to set.
+ */
+ public void setToolContentId(String toolContentId) {
+ this.toolContentId = toolContentId;
+ }
+ /**
+ * @return Returns the offlineInstructions.
+ */
+ public String getOfflineInstructions() {
+ return offlineInstructions;
+ }
+ /**
+ * @param offlineInstructions The offlineInstructions to set.
+ */
+ public void setOfflineInstructions(String offlineInstructions) {
+ this.offlineInstructions = offlineInstructions;
+ }
+ /**
+ * @return Returns the onlineInstructions.
+ */
+ public String getOnlineInstructions() {
+ return onlineInstructions;
+ }
+ /**
+ * @param onlineInstructions The onlineInstructions to set.
+ */
+ public void setOnlineInstructions(String onlineInstructions) {
+ this.onlineInstructions = onlineInstructions;
+ }
+
+ /**
+ * @return Returns the syncInMonitor.
+ */
+ public String getSynchInMonitor() {
+ return synchInMonitor;
+ }
+ /**
+ * @param syncInMonitor The syncInMonitor to set.
+ */
+ public void setSynchInMonitor(String synchInMonitor) {
+ this.synchInMonitor = synchInMonitor;
+ }
+
+ /**
+ * @return Returns the choiceAdvanced.
+ */
+ public String getChoiceAdvanced() {
+ return choiceAdvanced;
+ }
+ /**
+ * @param choiceAdvanced The choiceAdvanced to set.
+ */
+ public void setChoiceAdvanced(String choiceAdvanced) {
+ this.choiceAdvanced = choiceAdvanced;
+ }
+ /**
+ * @return Returns the choiceBasic.
+ */
+ public String getChoiceBasic() {
+ return choiceBasic;
+ }
+ /**
+ * @param choiceBasic The choiceBasic to set.
+ */
+ public void setChoiceBasic(String choiceBasic) {
+ this.choiceBasic = choiceBasic;
+ }
+ /**
+ * @return Returns the choiceInstructions.
+ */
+ public String getChoiceInstructions() {
+ return choiceInstructions;
+ }
+ /**
+ * @param choiceInstructions The choiceInstructions to set.
+ */
+ public void setChoiceInstructions(String choiceInstructions) {
+ this.choiceInstructions = choiceInstructions;
+ }
+ /**
+ * @return Returns the choice.
+ */
+ public String getChoice() {
+ return choice;
+ }
+ /**
+ * @param choice The choice to set.
+ */
+ public void setChoice(String choice) {
+ this.choice = choice;
+ }
+ /**
+ * @return Returns the reportTitle.
+ */
+ public String getReportTitle() {
+ return reportTitle;
+ }
+ /**
+ * @param reportTitle The reportTitle to set.
+ */
+ public void setReportTitle(String reportTitle) {
+ this.reportTitle = reportTitle;
+ }
+ /**
+ * @return Returns the usernameVisible.
+ */
+ public String getUsernameVisible() {
+ return usernameVisible;
+ }
+ /**
+ * @param usernameVisible The usernameVisible to set.
+ */
+ public void setUsernameVisible(String usernameVisible) {
+ this.usernameVisible = usernameVisible;
+ }
+ /**
+ * @return Returns the submitTabDone.
+ */
+ public String getSubmitTabDone() {
+ return submitTabDone;
+ }
+ /**
+ * @param submitTabDone The submitTabDone to set.
+ */
+ public void setSubmitTabDone(String submitTabDone) {
+ this.submitTabDone = submitTabDone;
+ }
+
+ /**
+ * @return Returns the questionsSequenced.
+ */
+ public String getQuestionsSequenced() {
+ return questionsSequenced;
+ }
+ /**
+ * @param questionsSequenced The questionsSequenced to set.
+ */
+ public void setQuestionsSequenced(String questionsSequenced) {
+ this.questionsSequenced = questionsSequenced;
+ }
+ /**
+ * @return Returns the endLearningMessage.
+ */
+ public String getEndLearningMessage() {
+ return endLearningMessage;
+ }
+ /**
+ * @param endLearningMessage The endLearningMessage to set.
+ */
+ public void setEndLearningMessage(String endLearningMessage) {
+ this.endLearningMessage = endLearningMessage;
+ }
+ /**
+ * @return Returns the monitoringReportTitle.
+ */
+ public String getMonitoringReportTitle() {
+ return monitoringReportTitle;
+ }
+ /**
+ * @param monitoringReportTitle The monitoringReportTitle to set.
+ */
+ public void setMonitoringReportTitle(String monitoringReportTitle) {
+ this.monitoringReportTitle = monitoringReportTitle;
+ }
+ /**
+ * @return Returns the editActivityMonitoring.
+ */
+ public String getEditActivityMonitoring() {
+ return editActivityMonitoring;
+ }
+ /**
+ * @param editActivityMonitoring The editActivityMonitoring to set.
+ */
+ public void setEditActivityMonitoring(String editActivityMonitoring) {
+ this.editActivityMonitoring = editActivityMonitoring;
+ }
+ /**
+ * @return Returns the instructionsMonitoring.
+ */
+ public String getInstructionsMonitoring() {
+ return instructionsMonitoring;
+ }
+ /**
+ * @param instructionsMonitoring The instructionsMonitoring to set.
+ */
+ public void setInstructionsMonitoring(String instructionsMonitoring) {
+ this.instructionsMonitoring = instructionsMonitoring;
+ }
+ /**
+ * @return Returns the statsMonitoring.
+ */
+ public String getStatsMonitoring() {
+ return statsMonitoring;
+ }
+ /**
+ * @param statsMonitoring The statsMonitoring to set.
+ */
+ public void setStatsMonitoring(String statsMonitoring) {
+ this.statsMonitoring = statsMonitoring;
+ }
+ /**
+ * @return Returns the summaryMonitoring.
+ */
+ public String getSummaryMonitoring() {
+ return summaryMonitoring;
+ }
+ /**
+ * @param summaryMonitoring The summaryMonitoring to set.
+ */
+ public void setSummaryMonitoring(String summaryMonitoring) {
+ this.summaryMonitoring = summaryMonitoring;
+ }
+ /**
+ * @return Returns the edit.
+ */
+ public String getEdit() {
+ return edit;
+ }
+ /**
+ * @param edit The edit to set.
+ */
+ public void setEdit(String edit) {
+ this.edit = edit;
+ }
+}
Index: lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/QaEmptyForm.java
===================================================================
diff -u
--- lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/QaEmptyForm.java (revision 0)
+++ lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/QaEmptyForm.java (revision 16e844de3f7c34b44baee1b28e67e708f42d00bf)
@@ -0,0 +1,22 @@
+/*
+ * ozgurd
+ * Created on 26/04/2005
+ *
+ * TODO To change the template for this generated file go to
+ * Window - Preferences - Java - Code Style - Code Templates
+ */
+package org.lamsfoundation.lams.tool.qa.web;
+
+/**
+ * ActionForm for the Learning environment
+ */
+import org.apache.struts.action.ActionForm;
+
+/**
+ * @author ozgurd
+ *
+ * TODO To change the template for this generated type comment go to
+ * Window - Preferences - Java - Code Style - Code Templates
+ */
+public class QaEmptyForm extends ActionForm {
+}
Index: lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/QaLearningForm.java
===================================================================
diff -u
--- lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/QaLearningForm.java (revision 0)
+++ lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/QaLearningForm.java (revision 16e844de3f7c34b44baee1b28e67e708f42d00bf)
@@ -0,0 +1,120 @@
+/*
+ * ozgurd
+ * Created on 26/04/2005
+ *
+ * TODO To change the template for this generated file go to
+ * Window - Preferences - Java - Code Style - Code Templates
+ */
+package org.lamsfoundation.lams.tool.qa.web;
+
+/**
+ * ActionForm for the Learning environment
+ */
+import org.apache.log4j.Logger;
+import org.apache.struts.action.ActionForm;
+import org.lamsfoundation.lams.tool.qa.QaAppConstants;
+
+/**
+ * @author ozgurd
+ *
+ * TODO To change the template for this generated type comment go to
+ * Window - Preferences - Java - Code Style - Code Templates
+ */
+public class QaLearningForm extends ActionForm implements QaAppConstants {
+ static Logger logger = Logger.getLogger(QaLearningForm.class.getName());
+ protected String answer;
+ protected String currentQuestionIndex;
+ //controller
+ protected String submitAnswersContent;
+ protected String getNextQuestion;
+ protected String getPreviousQuestion;
+ protected String endLearning;
+
+
+ /**
+ * reset user actions in learning mode
+ * @param qaAuthoringForm
+ * return void
+ */
+
+ protected void resetUserActions()
+ {
+ this.getNextQuestion=null;
+ this.getPreviousQuestion=null;
+ this.endLearning=null;
+ }
+
+
+ /**
+ * @return Returns the currentQuestionIndex.
+ */
+ public String getCurrentQuestionIndex() {
+ return currentQuestionIndex;
+ }
+ /**
+ * @param currentQuestionIndex The currentQuestionIndex to set.
+ */
+ public void setCurrentQuestionIndex(String currentQuestionIndex) {
+ this.currentQuestionIndex = currentQuestionIndex;
+ }
+ /**
+ * @return Returns the answer.
+ */
+ public String getAnswer() {
+ return answer;
+ }
+ /**
+ * @param answer The answer to set.
+ */
+ public void setAnswer(String answer) {
+ this.answer = answer;
+ }
+ /**
+ * @return Returns the getNextQuestion.
+ */
+ public String getGetNextQuestion() {
+ return getNextQuestion;
+ }
+ /**
+ * @param getNextQuestion The getNextQuestion to set.
+ */
+ public void setGetNextQuestion(String getNextQuestion) {
+ this.getNextQuestion = getNextQuestion;
+ }
+ /**
+ * @return Returns the getPreviousQuestion.
+ */
+ public String getGetPreviousQuestion() {
+ return getPreviousQuestion;
+ }
+ /**
+ * @param getPreviousQuestion The getPreviousQuestion to set.
+ */
+ public void setGetPreviousQuestion(String getPreviousQuestion) {
+ this.getPreviousQuestion = getPreviousQuestion;
+ }
+ /**
+ * @return Returns the submitAnswersContent.
+ */
+ public String getSubmitAnswersContent() {
+ return submitAnswersContent;
+ }
+ /**
+ * @param submitAnswersContent The submitAnswersContent to set.
+ */
+ public void setSubmitAnswersContent(String submitAnswersContent) {
+ this.submitAnswersContent = submitAnswersContent;
+ }
+ /**
+ * @return Returns the endLearning.
+ */
+ public String getEndLearning() {
+ return endLearning;
+ }
+ /**
+ * @param endLearning The endLearning to set.
+ */
+ public void setEndLearning(String endLearning) {
+ this.endLearning = endLearning;
+ }
+ }
Index: lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/QaLearningStarterAction.java
===================================================================
diff -u
--- lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/QaLearningStarterAction.java (revision 0)
+++ lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/QaLearningStarterAction.java (revision 16e844de3f7c34b44baee1b28e67e708f42d00bf)
@@ -0,0 +1,329 @@
+/**
+ * Created on 8/03/2005
+ * initializes the tool's learning mode
+ */
+
+package org.lamsfoundation.lams.tool.qa.web;
+import java.io.IOException;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.TreeMap;
+
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import org.lamsfoundation.lams.usermanagement.User;
+
+import org.apache.log4j.Logger;
+import org.apache.struts.Globals;
+import org.apache.struts.action.Action;
+import org.apache.struts.action.ActionForm;
+import org.apache.struts.action.ActionForward;
+import org.apache.struts.action.ActionMapping;
+import org.apache.struts.action.ActionMessage;
+import org.apache.struts.action.ActionMessages;
+import org.lamsfoundation.lams.tool.qa.QaAppConstants;
+import org.lamsfoundation.lams.tool.qa.QaApplicationException;
+import org.lamsfoundation.lams.tool.qa.QaComparator;
+import org.lamsfoundation.lams.tool.qa.QaContent;
+import org.lamsfoundation.lams.tool.qa.QaQueContent;
+import org.lamsfoundation.lams.tool.qa.QaQueUsr;
+import org.lamsfoundation.lams.tool.qa.QaSession;
+import org.lamsfoundation.lams.tool.qa.QaUtils;
+import org.lamsfoundation.lams.tool.qa.service.IQaService;
+import org.lamsfoundation.lams.tool.qa.service.QaServiceProxy;
+
+/**
+ *
+ * @author ozgurd
+ *
+ * Learner mode takes in the parameters TOOL_SESSION_ID and TOOL_CONTENT_ID
+ *
+ * Make a note to change QaAppConstants.DEVELOPMENT_FLAG to false in deployment.
+ *
+ * This class is used to load the default content and initialize the presentation Map for Learner mode
+ *
+ * createToolSession will not be called once the tool is deployed.
+ *
+ * It is important that ALL the session attributes created in this action gets removed by: QaUtils.cleanupSession(request)
+ *
+ */
+
+/**
+ *
+ * verifies that the content id passed to the tool is numeric and does refer to an existing content.
+ *
+ */
+
+public class QaLearningStarterAction extends Action implements QaAppConstants {
+ static Logger logger = Logger.getLogger(QaLearningStarterAction.class.getName());
+
+ /**
+ * holds the question contents for a given tool session and relevant content
+ */
+ protected Map mapQuestions= new TreeMap(new QaComparator());
+ /**
+ * holds the answers
+ */
+ protected Map mapAnswers= new TreeMap(new QaComparator());
+
+ public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response)
+ throws IOException, ServletException, QaApplicationException {
+
+ QaLearningForm qaQaLearningForm = (QaLearningForm) form;
+
+ /**
+ * reset the question index to 1
+ */
+ request.getSession().setAttribute(CURRENT_QUESTION_INDEX, "1");
+ logger.debug(logger + " " + this.getClass().getName() + "CURRENT_QUESTION_INDEX: " + request.getSession().getAttribute(CURRENT_QUESTION_INDEX));
+
+ /**
+ * reset the current answer
+ */
+ request.getSession().setAttribute(CURRENT_ANSWER, "");
+
+ /**
+ * initialize available question display modes in the session
+ */
+ request.getSession().setAttribute(QUESTION_LISTING_MODE_SEQUENTIAL,QUESTION_LISTING_MODE_SEQUENTIAL);
+ request.getSession().setAttribute(QUESTION_LISTING_MODE_COMBINED, QUESTION_LISTING_MODE_COMBINED);
+
+ /**
+ * retrive the service
+ */
+ IQaService qaService = QaServiceProxy.getQaService(getServlet().getServletContext());
+ logger.debug(logger + " " + this.getClass().getName() + "retrieving qaService: " + qaService);
+ request.getSession().setAttribute(TOOL_SERVICE, qaService);
+
+ /**
+ * mark the http session as a learning activity
+ */
+ request.getSession().setAttribute(TARGET_MODE,TARGET_MODE_LEARNING);
+
+ /**
+ * obtain and setup the current user's data
+ */
+ String userId=request.getParameter(USER_ID);
+ if ((userId == null) || (userId.length()==0))
+ {
+ logger.debug(logger + " " + this.getClass().getName() + "error: The tool expects userId");
+ persistError(request,"error.authoringUser.notAvailable");
+ request.setAttribute(USER_EXCEPTION_USERID_NOTAVAILABLE, new Boolean(true));
+ logger.debug(logger + " " + this.getClass().getName() + "forwarding to: " + LOAD);
+ return (mapping.findForward(LOAD));
+ }
+
+ try
+ {
+ User user=QaUtils.createUser(new Integer(userId));
+ request.getSession().setAttribute(TOOL_USER, user);
+ }
+ catch(NumberFormatException e)
+ {
+ persistError(request,"error.userId.notNumeric");
+ request.setAttribute(USER_EXCEPTION_USERID_NOTNUMERIC, new Boolean(true));
+ logger.debug(logger + " " + this.getClass().getName() + "forwarding to: " + LOAD);
+ return (mapping.findForward(LOAD));
+ }
+ logger.debug(logger + " " + this.getClass().getName() + "TOOL_USER is:" + request.getSession().getAttribute(TOOL_USER));
+
+ /**
+ * verify that userID does not already exist in the db
+ */
+ QaQueUsr qaQueUsr=qaService.loadQaQueUsr(new Long(userId));
+ logger.debug(logger + " " + this.getClass().getName() + "QaQueUsr:" + qaQueUsr);
+ if (qaQueUsr != null)
+ {
+ persistError(request,"error.userId.existing");
+ request.setAttribute(USER_EXCEPTION_USERID_EXISTING, new Boolean(true));
+ logger.debug(logger + " " + this.getClass().getName() + "forwarding to: " + LOAD);
+ return (mapping.findForward(LOAD));
+ }
+
+ /**
+ * process incoming tool content id
+ */
+ String strToolContentId=request.getParameter(TOOL_CONTENT_ID);
+ long toolContentId=0;
+ if ((strToolContentId == null) || (strToolContentId.length() == 0))
+ {
+ persistError(request, "error.contentId.required");
+ request.setAttribute(USER_EXCEPTION_CONTENTID_REQUIRED, new Boolean(true));
+ logger.debug(logger + " " + this.getClass().getName() + "forwarding to: " + LOAD);
+ return (mapping.findForward(LOAD));
+ }
+ else
+ {
+ try
+ {
+ toolContentId=new Long(strToolContentId).longValue();
+ logger.debug(logger + " " + this.getClass().getName() + "passed TOOL_CONTENT_ID : " + new Long(toolContentId));
+ request.getSession().setAttribute(TOOL_CONTENT_ID,new Long(toolContentId));
+ }
+ catch(NumberFormatException e)
+ {
+ persistError(request, "error.contentId.numberFormatException");
+ request.setAttribute(USER_EXCEPTION_NUMBERFORMAT, new Boolean(true));
+ logger.debug(logger + " " + this.getClass().getName() + "forwarding to: " + LOAD);
+ return (mapping.findForward(LOAD));
+ }
+ }
+
+ if (!QaUtils.existsContent(toolContentId, request))
+ {
+ persistError(request, "error.content.doesNotExist");
+ request.setAttribute(USER_EXCEPTION_CONTENT_DOESNOTEXIST, new Boolean(true));
+ logger.debug(logger + " " + this.getClass().getName() + "forwarding to: " + LOAD);
+ return (mapping.findForward(LOAD));
+ }
+
+ QaContent qaContent=qaService.loadQa(toolContentId);
+ /**
+ * process incoming tool session id
+ * A toolSessionId must be passed to the tool from the container.
+ */
+ String strToolSessionId=request.getParameter(TOOL_SESSION_ID);
+ long toolSessionId=0;
+ if ((strToolSessionId == null) || (strToolSessionId.length() == 0))
+ {
+ persistError(request, "error.toolSessionId.required");
+ request.setAttribute(USER_EXCEPTION_TOOLSESSIONID_REQUIRED, new Boolean(true));
+ logger.debug(logger + " " + this.getClass().getName() + "forwarding to: " + LOAD);
+ return (mapping.findForward(LOAD));
+ }
+ else
+ {
+ try
+ {
+ toolSessionId=new Long(strToolSessionId).longValue();
+ logger.debug(logger + " " + this.getClass().getName() + "passed TOOL_SESSION_ID : " + new Long(toolSessionId));
+ request.getSession().setAttribute(TOOL_SESSION_ID,new Long(toolSessionId));
+ }
+ catch(NumberFormatException e)
+ {
+ persistError(request, "error.sessionId.numberFormatException");
+ logger.debug(logger + " " + this.getClass().getName() + "add error.sessionId.numberFormatException to ActionMessages: ");
+ request.setAttribute(USER_EXCEPTION_NUMBERFORMAT, new Boolean(true));
+ logger.debug(logger + " " + this.getClass().getName() + "forwarding to: " + LOAD);
+ return (mapping.findForward(LOAD));
+ }
+ }
+
+ /**
+ * By now, the passed tool session id MUST exist in the db through the calling of:
+ * public void createToolSession(Long toolSessionId, Long toolContentId) by the container.
+ *
+ * make sure this session exists in tool's session table by now.
+ */
+ if (!QaUtils.existsSession(toolSessionId, request))
+ {
+ Long currentToolContentId=(Long)request.getSession().getAttribute(TOOL_CONTENT_ID);
+ logger.debug(logger + " " + this.getClass().getName() + "Simulating container behaviour: calling createToolSession with toolSessionId : " +
+ new Long(toolSessionId) + " and toolContentId: " + currentToolContentId);
+ qaService.createToolSession(new Long(toolSessionId), currentToolContentId);
+ logger.debug(logger + " " + this.getClass().getName() + "Simulated container behaviour:");
+ }
+
+ /**
+ * by now, we made sure that the passed tool session id exists in the db as a new record
+ * Make sure we can retrieve it and relavent content
+ */
+
+ QaSession qaSession=qaService.retrieveQaSessionOrNullById(toolSessionId);
+ logger.debug(logger + " " + this.getClass().getName() + "retrieving qaSession: " + qaSession);
+ /**
+ * find out what content this tool session is referring to
+ * get the content for this tool session (many to one mapping)
+ */
+
+ /**
+ * Each passed tool session id points to a particular content. Many to one mapping.
+ */
+ qaContent=qaSession.getQaContent();
+ logger.debug(logger + " " + this.getClass().getName() + "using qaContent: " + qaContent);
+
+ /**
+ * The content we retrieved above must have been created before in Authoring time.
+ * And the passed tool session id already refers to it.
+ */
+
+ logger.debug(logger + " " + this.getClass().getName() + "REPORT_TITLE_LEARNER: " + qaContent.getReportTitle());
+ request.getSession().setAttribute(REPORT_TITLE_LEARNER,qaContent.getReportTitle());
+
+ request.getSession().setAttribute(END_LEARNING_MESSAGE,qaContent.getEndLearningMessage());
+ logger.debug(logger + " " + this.getClass().getName() + "END_LEARNING_MESSAGE: " + qaContent.getEndLearningMessage());
+
+ logger.debug(logger + " " + this.getClass().getName() + "IS_TOOL_ACTIVITY_OFFLINE: " + qaContent.isRunOffline());
+ request.getSession().setAttribute(IS_TOOL_ACTIVITY_OFFLINE, new Boolean(qaContent.isRunOffline()).toString());
+
+ logger.debug(logger + " " + this.getClass().getName() + "IS_USERNAME_VISIBLE: " + qaContent.isUsernameVisible());
+ request.getSession().setAttribute(IS_USERNAME_VISIBLE, new Boolean(qaContent.isUsernameVisible()));
+
+ logger.debug(logger + " " + this.getClass().getName() + "IS_DEFINE_LATER: " + qaContent.isDefineLater());
+ request.getSession().setAttribute(IS_DEFINE_LATER, new Boolean(qaContent.isDefineLater()));
+
+ /**
+ * convince jsp: Learning mode requires this setting for jsp to generate the user's report
+ */
+ request.getSession().setAttribute(CHECK_ALL_SESSIONS_COMPLETED, new Boolean(false));
+
+ logger.debug(logger + " " + this.getClass().getName() + "IS_QUESTIONS_SEQUENCED: " + qaContent.isQuestionsSequenced());
+ String feedBackType="";
+ if (qaContent.isQuestionsSequenced())
+ {
+ request.getSession().setAttribute(QUESTION_LISTING_MODE, QUESTION_LISTING_MODE_SEQUENTIAL);
+ feedBackType=FEEDBACK_TYPE_SEQUENTIAL;
+ }
+ else
+ {
+ request.getSession().setAttribute(QUESTION_LISTING_MODE, QUESTION_LISTING_MODE_COMBINED);
+ feedBackType=FEEDBACK_TYPE_COMBINED;
+ }
+ logger.debug(logger + " " + this.getClass().getName() + "QUESTION_LISTING_MODE: " + request.getSession().getAttribute(QUESTION_LISTING_MODE));
+
+ /**
+ * fetch question content from content
+ */
+ Iterator contentIterator=qaContent.getQaQueContents().iterator();
+ while (contentIterator.hasNext())
+ {
+ QaQueContent qaQueContent=(QaQueContent)contentIterator.next();
+ if (qaQueContent != null)
+ {
+ int displayOrder=qaQueContent.getDisplayOrder();
+ if (displayOrder != 0)
+ {
+ /**
+ * add the question to the questions Map in the displayOrder
+ */
+ mapQuestions.put(new Integer(displayOrder).toString(),qaQueContent.getQuestion());
+ }
+ }
+ }
+
+ request.getSession().setAttribute(MAP_ANSWERS, mapAnswers);
+ request.getSession().setAttribute(MAP_QUESTION_CONTENT_LEARNER, mapQuestions);
+ logger.debug(logger + " " + this.getClass().getName() + "qaContent has : " + mapQuestions.size() + " entries.");
+
+ request.getSession().setAttribute(TOTAL_QUESTION_COUNT, new Long(mapQuestions.size()).toString());
+ String userFeedback= feedBackType + request.getSession().getAttribute(TOTAL_QUESTION_COUNT) + QUESTIONS;
+ request.getSession().setAttribute(USER_FEEDBACK, userFeedback);
+
+ logger.debug(logger + " " + this.getClass().getName() + "forwarding to learning screen");
+ return (mapping.findForward(LOAD));
+ }
+
+ /**
+ * persists error messages to request scope
+ * @param request
+ * @param message
+ */
+ public void persistError(HttpServletRequest request, String message)
+ {
+ ActionMessages errors= new ActionMessages();
+ errors.add(Globals.ERROR_KEY, new ActionMessage(message));
+ logger.debug(logger + " " + this.getClass().getName() + "add " + message +" to ActionMessages:");
+ saveErrors(request,errors);
+ }
+}
Index: lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/QaMonitoringAction.java
===================================================================
diff -u
--- lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/QaMonitoringAction.java (revision 0)
+++ lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/QaMonitoringAction.java (revision 16e844de3f7c34b44baee1b28e67e708f42d00bf)
@@ -0,0 +1,719 @@
+/*
+ *Copyright (C) 2005 LAMS Foundation (http://lamsfoundation.org)
+ *
+ *This program is free software; you can redistribute it and/or modify
+ *it under the terms of the GNU General Public License as published by
+ *the Free Software Foundation; either version 2 of the License, or
+ *(at your option) any later version.
+ *
+ *This program is distributed in the hope that it will be useful,
+ *but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ *GNU General Public License for more details.
+ *
+ *You should have received a copy of the GNU General Public License
+ *along with this program; if not, write to the Free Software
+ *Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
+ *USA
+ *
+ *http://www.gnu.org/licenses/gpl.txt
+ */
+package org.lamsfoundation.lams.tool.qa.web;
+
+import java.io.IOException;
+import java.util.Map;
+import java.util.TreeMap;
+
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.log4j.Logger;
+import org.apache.struts.Globals;
+import org.apache.struts.action.ActionForm;
+import org.apache.struts.action.ActionForward;
+import org.apache.struts.action.ActionMapping;
+import org.apache.struts.action.ActionMessage;
+import org.apache.struts.action.ActionMessages;
+import org.apache.struts.actions.DispatchAction;
+import org.lamsfoundation.lams.tool.qa.QaAppConstants;
+import org.lamsfoundation.lams.tool.qa.QaApplicationException;
+import org.lamsfoundation.lams.tool.qa.QaContent;
+import org.lamsfoundation.lams.tool.qa.QaSession;
+import org.lamsfoundation.lams.tool.qa.QaStringComparator;
+import org.lamsfoundation.lams.tool.qa.QaUtils;
+import org.lamsfoundation.lams.tool.qa.service.IQaService;
+import org.lamsfoundation.lams.tool.qa.service.QaServiceProxy;
+
+public class QaMonitoringAction extends DispatchAction implements QaAppConstants
+{
+ static Logger logger = Logger.getLogger(QaMonitoringAction.class.getName());
+
+ public static String SELECTBOX_SELECTED_TOOL_SESSION ="selectBoxSelectedToolSession";
+ public static Integer READABLE_TOOL_SESSION_COUNT = new Integer(1);
+
+ public ActionForward generateToolSessionDataMap(ActionMapping mapping,
+ ActionForm form,
+ HttpServletRequest request,
+ HttpServletResponse response) throws IOException,
+ ServletException
+ {
+ QaMonitoringForm qaMonitoringForm = (QaMonitoringForm) form;
+ MonitoringUtil monitoringUtil = new MonitoringUtil();
+ logger.debug(logger + " " + this.getClass().getName() + "calling findSelectedMonitoringTab");
+ monitoringUtil.findSelectedMonitoringTab(form, request);
+ logger.debug(logger + " " + this.getClass().getName() + "called findSelectedMonitoringTab");
+
+ /**
+ * load the values for online and offline instructions
+ */
+ handleInstructionsScreen(mapping, form, request);
+ IQaService qaService =QaUtils.getToolService(request);
+ Long initialMonitoringContentId=(Long)request.getSession().getAttribute(INITIAL_MONITORING_TOOL_CONTENT_ID);
+ if (initialMonitoringContentId != null)
+ {
+ QaContent qaContent=qaService.retrieveQa(initialMonitoringContentId.longValue());
+ logger.debug(logger + " " + this.getClass().getName() + "qaContent: " + qaContent);
+ request.getSession().setAttribute(MONITORED_OFFLINE_INSTRUCTIONS, qaContent.getOfflineInstructions());
+ request.getSession().setAttribute(MONITORED_ONLINE_INSTRUCTIONS, qaContent.getOnlineInstructions());
+ logger.debug(logger + " " + this.getClass().getName() + "session updated with on/off instructions");
+ }
+
+
+ /**
+ * determine what screen(tab) to generate
+ */
+ String choiceMonitoring=(String)request.getSession().getAttribute(CHOICE_MONITORING);
+ logger.debug(logger + " " + this.getClass().getName() + "CHOICE_MONITORING: " + choiceMonitoring);
+
+ if (choiceMonitoring.equalsIgnoreCase(CHOICE_TYPE_MONITORING_SUMMARY))
+ {
+ logger.debug(logger + " " + this.getClass().getName() + "will generate summary screen");
+ return generateSummaryScreen(mapping, form, request, response);
+ }
+ else if (choiceMonitoring.equalsIgnoreCase(CHOICE_TYPE_MONITORING_INSTRUCTIONS))
+ {
+ logger.debug(logger + " " + this.getClass().getName() + "will generate instructions screen");
+ request.getSession().setAttribute(MONITORING_INSTRUCTIONS_VISITED, new Boolean(true));
+ return generateInstructionsScreen(mapping, form, request, response);
+ }
+ else if (choiceMonitoring.equalsIgnoreCase(CHOICE_TYPE_MONITORING_EDITACTIVITY))
+ {
+ logger.debug(logger + " " + this.getClass().getName() + "will generate editActivity screen");
+ request.getSession().setAttribute(MONITORING_EDITACTIVITY_VISITED, new Boolean(true));
+ return generateEditActivityScreen(mapping, form, request, response);
+ }
+ else if (choiceMonitoring.equalsIgnoreCase(CHOICE_TYPE_MONITORING_STATS))
+ {
+ logger.debug(logger + " " + this.getClass().getName() + "will generate stats screen");
+ request.getSession().setAttribute(MONITORING_STATS_VISITED, new Boolean(true));
+ return generateStatsScreen(mapping, form, request, response);
+ }
+
+ return null;
+ }
+
+
+ public ActionForward generateSummaryScreen(ActionMapping mapping,
+ ActionForm form,
+ HttpServletRequest request,
+ HttpServletResponse response) throws IOException,
+ ServletException
+ {
+ QaMonitoringForm qaMonitoringForm = (QaMonitoringForm) form;
+
+ Boolean noToolSessionsAvailable=(Boolean)request.getSession().getAttribute(NO_TOOL_SESSIONS_AVAILABLE);
+ if ((noToolSessionsAvailable !=null) && (noToolSessionsAvailable.booleanValue()))
+ {
+ qaMonitoringForm.resetUserAction();
+ logger.debug(logger + " " + this.getClass().getName() + "detected noToolSessionsAvailable:" + noToolSessionsAvailable);
+ persistError(request,"error.content.onlyContentAndNoSessions");
+ request.setAttribute(USER_EXCEPTION_ONLYCONTENT_ANDNOSESSIONS, new Boolean(true));
+ logger.debug(logger + " " + this.getClass().getName() + "forwarding to: " + MONITORING_REPORT);
+ return (mapping.findForward(MONITORING_REPORT));
+ }
+
+ MonitoringUtil monitoringUtil = new MonitoringUtil();
+ String responseId=qaMonitoringForm.getResponseId();
+ String hiddenResponseId=qaMonitoringForm.getHiddenResponseId();
+ String unHiddenResponseId=qaMonitoringForm.getUnHiddenResponseId();
+
+ if (qaMonitoringForm.getEditReport() != null)
+ {
+ logger.debug(logger + " " + this.getClass().getName() + "responseId for editReport" + responseId);
+ request.getSession().setAttribute(DATAMAP_EDITABLE_RESPONSE_ID, responseId);
+ }
+ else if (qaMonitoringForm.getUpdateReport() != null)
+ {
+ logger.debug(logger + " " + this.getClass().getName() + "request for responseUpdate with id: "
+ + request.getSession().getAttribute(DATAMAP_EDITABLE_RESPONSE_ID));
+ responseId=(String)request.getSession().getAttribute(DATAMAP_EDITABLE_RESPONSE_ID);
+ String updatedResponse=qaMonitoringForm.getUpdatedResponse();
+ monitoringUtil.updateResponse(request, responseId, updatedResponse);
+ request.getSession().setAttribute(DATAMAP_EDITABLE_RESPONSE_ID, "");
+ logger.debug(logger + " " + this.getClass().getName() + "end of updateResponse with: " + responseId + "-" + updatedResponse);
+ }
+
+ if (qaMonitoringForm.getHideReport() != null)
+ {
+ logger.debug(logger + " " + this.getClass().getName() + "hiddenResponseId for hideReport" + hiddenResponseId);
+ request.getSession().setAttribute(DATAMAP_HIDDEN_RESPONSE_ID, hiddenResponseId);
+ monitoringUtil.hideResponse(request, hiddenResponseId);
+ }
+
+ if (qaMonitoringForm.getUnhideReport() != null)
+ {
+ logger.debug(logger + " " + this.getClass().getName() + "hiddenResponseId for unHideReport" + unHiddenResponseId);
+ request.getSession().setAttribute(DATAMAP_HIDDEN_RESPONSE_ID, "");
+ monitoringUtil.unHideResponse(request, unHiddenResponseId);
+ }
+
+
+ logger.debug(logger + " " + this.getClass().getName() + "DATAMAP_EDITABLE_RESPONSE_ID: " +
+ request.getSession().getAttribute(DATAMAP_EDITABLE_RESPONSE_ID));
+
+ logger.debug(logger + " " + this.getClass().getName() + "DATAMAP_HIDDEN_RESPONSE_ID: " +
+ request.getSession().getAttribute(DATAMAP_HIDDEN_RESPONSE_ID));
+
+ qaMonitoringForm.setUpdatedResponse("");
+ logger.debug(logger + " " + this.getClass().getName() + "request for summary");
+
+ String isToolSessionChanged=request.getParameter(IS_TOOL_SESSION_CHANGED);
+ logger.debug(logger + " " + this.getClass().getName() + "IS_TOOL_SESSION_CHANGED - before loop: " + isToolSessionChanged);
+
+ /**
+ * sessionList holds all the toolSessionIds passed to summary page to be presented in a drop-down box.
+ */
+ Map sessionList = new TreeMap();
+ int SELECTION_CASE=0;
+
+ logger.debug(logger + " " + this.getClass().getName() + "isNonDefaultScreensVisited: " + monitoringUtil.isNonDefaultScreensVisited(request));
+
+
+ /**
+ * Following conditions test which entry has been selected in the monitoring mode-summary screen drop box.
+ * is Default page
+ */
+ String selectionCase=(String)request.getSession().getAttribute("selectionCase");
+ logger.debug(logger + " " + this.getClass().getName() + "current selectionCase: " + selectionCase);
+
+ boolean sessionListReadable=false;
+ if ((isToolSessionChanged == null) && !monitoringUtil.isNonDefaultScreensVisited(request))
+ {
+ logger.debug(logger + " " + this.getClass().getName() + "First case based on null. Gets rendered only once in http session life time");
+ logger.debug(logger + " " + this.getClass().getName() + "summary to use MAX_TOOL_SESSION_COUNT");
+ /**
+ * initialize sessionList with "All", which is the default option.
+ */
+ sessionList.put("All", "All");
+ READABLE_TOOL_SESSION_COUNT=MAX_TOOL_SESSION_COUNT;
+ SELECTION_CASE=1;
+ }
+ else if ((isToolSessionChanged == null) && monitoringUtil.isNonDefaultScreensVisited(request))
+ {
+ logger.debug(logger + " " + this.getClass().getName() + "Other tabs visited. Gets rendered for all tool sessions");
+ sessionList.put("All", "All");
+ READABLE_TOOL_SESSION_COUNT=MAX_TOOL_SESSION_COUNT;
+ SELECTION_CASE=2;
+ sessionListReadable=true;
+ }
+ else if ((isToolSessionChanged != null) && isToolSessionChanged.equalsIgnoreCase("1"))
+ {
+ String selectedToolSessionId=(String)request.getParameter("toolSessionId1");
+ logger.debug(logger + " " + this.getClass().getName() + "selectedToolSessionId" + selectedToolSessionId);
+ /**
+ * is "All" selected
+ */
+ if (selectedToolSessionId.equalsIgnoreCase("All"))
+ {
+ logger.debug(logger + " " + this.getClass().getName() + "Second case");
+ logger.debug(logger + " " + this.getClass().getName() + "summary to use MAX_TOOL_SESSION_COUNT");
+ /**
+ * initialize sessionList with "All", which is the default option.
+ */
+ sessionList.put("All", "All");
+ READABLE_TOOL_SESSION_COUNT=MAX_TOOL_SESSION_COUNT;
+ SELECTION_CASE=2;
+ sessionListReadable=true;
+ }
+ else
+ {
+ /**
+ * is a single session id selected
+ */
+ logger.debug(logger + " " + this.getClass().getName() + "Third case");
+ logger.debug(logger + " " + this.getClass().getName() + "selectedToolSessionId" + selectedToolSessionId);
+ READABLE_TOOL_SESSION_COUNT=new Integer(2);
+ SELECTION_CASE=3;
+ request.getSession().setAttribute(CURRENT_MONITORED_TOOL_SESSION,selectedToolSessionId);
+ logger.debug(logger + " " + this.getClass().getName() + "CURRENT_MONITORED_TOOL_SESSION " + selectedToolSessionId);
+ }
+ }
+ else if (isToolSessionChanged.equals("") && (selectionCase.equals("3")))
+ {
+ /**
+ * is a single session id selected
+ */
+ logger.debug(logger + " " + this.getClass().getName() + "case with single session and edit or update selected");
+ READABLE_TOOL_SESSION_COUNT=new Integer(2);
+ SELECTION_CASE=3;
+ }
+ else if (isToolSessionChanged.equals(""))
+ {
+ logger.debug(logger + " " + this.getClass().getName() + "All is selected");
+ sessionList.put("All", "All");
+ READABLE_TOOL_SESSION_COUNT=MAX_TOOL_SESSION_COUNT;
+ SELECTION_CASE=2;
+ sessionListReadable=true;
+ }
+ logger.debug(logger + " " + this.getClass().getName() + "SELECTION_CASE: " + SELECTION_CASE);
+
+ if ((qaMonitoringForm.getEditReport() == null) && (qaMonitoringForm.getUpdateReport() == null))
+ {
+ logger.debug(logger + " " + this.getClass().getName() + "no editReport or updateReport selected");
+ request.getSession().setAttribute(DATAMAP_EDITABLE_RESPONSE_ID, "");
+ request.getSession().setAttribute("selectionCase",new Long(SELECTION_CASE).toString());
+ }
+ qaMonitoringForm.resetUserAction();
+
+ /**
+ * holds all the toolSessionIds passed in the form toolSessionId1, toolSessionId2 etc.
+ */
+ Map mapToolSessions= new TreeMap(new QaStringComparator());
+ request.getSession().setAttribute(MAP_TOOL_SESSIONS,mapToolSessions);
+ logger.debug(logger + " " + this.getClass().getName() + "MAP_TOOL_SESSIONS placed into session");
+
+ Map mapUserResponses= new TreeMap(new QaStringComparator());
+ request.getSession().setAttribute(MAP_USER_RESPONSES,mapUserResponses);
+ logger.debug(logger + " " + this.getClass().getName() + "MAP_USER_RESPONSES placed into session");
+ logger.debug(logger + " " + this.getClass().getName() + "request for contributeLesson");
+ /**
+ * monitoring reads all the toolSessionsIds appended one after other until it finds a null one. The cap was limited to 500.
+ * This is the case all the tool sessions are using the same content.
+ *
+ * The final Map mapToolSessions holds the Map mapQuestions which in turn holds the Map mapUserResponses.
+ * The key of mapToolSessions: incremental numbers
+ * The key of mapQuestions: questions themselves
+ * The key of mapUserResponses: incremental numbers
+ *
+ */
+
+ IQaService qaService = QaUtils.getToolService(request);
+ logger.debug(logger + " " + this.getClass().getName() + "retrieving qaService: " + qaService);
+
+ if (qaService == null)
+ {
+ qaService = QaServiceProxy.getQaService(getServlet().getServletContext());
+ logger.debug(logger + " " + this.getClass().getName() + "retrieving qaService from proxy: " + qaService);
+ request.getSession().setAttribute(TOOL_SERVICE, qaService);
+ }
+
+ request.getSession().setAttribute(NO_AVAILABLE_SESSIONS,new Boolean(false));
+ logger.debug(logger + " " + this.getClass().getName() + "NO_AVAILABLE_SESSIONS: " + false);
+
+ /**
+ * monitoredToolSessionsCounter holds the total number of valid toolSessionIds passed to the monitoring url
+ */
+
+ logger.debug(logger + " " + this.getClass().getName() + "READABLE_TOOL_SESSION_COUNT: " + READABLE_TOOL_SESSION_COUNT);
+ int monitoredToolSessionsCounter=0;
+ for (int toolSessionIdCounter=1; toolSessionIdCounter < READABLE_TOOL_SESSION_COUNT.intValue(); toolSessionIdCounter++)
+ {
+ logger.debug(logger + " " + this.getClass().getName() + "toolSessionIdCounter: " + toolSessionIdCounter);
+ String strToolSessionId=request.getParameter(TOOL_SESSION_ID + toolSessionIdCounter);
+ logger.debug(logger + " " + this.getClass().getName() + "TOOL_SESSION_ID: " + strToolSessionId);
+
+ String strRetrievableToolSessionId="";
+ /**
+ * catering for un-formatted monitoring url
+ * Watch for case where the "All" is selected in the drop-down.
+ */
+ logger.debug(logger + " " + this.getClass().getName() + "SELECTION_CASE: " + SELECTION_CASE);
+ if ((strToolSessionId == null) && (SELECTION_CASE == 1))
+ {
+ logger.debug(logger + " " + this.getClass().getName() + "un-formatted monitoring url, exiting...");
+ break;
+ }
+ else if ((!sessionListReadable) && ((strToolSessionId == null) || (strToolSessionId.length() == 0)))
+ {
+ logger.debug(logger + " " + this.getClass().getName() + "un-formatted monitoring url, exiting...");
+ break;
+ }
+ else
+ {
+ if (sessionListReadable)
+ {
+ logger.debug(logger + " " + this.getClass().getName() + "sessionListReadable is true.");
+ logger.debug(logger + " " + this.getClass().getName() + "strToolSessionId is All: " + strToolSessionId);
+ sessionList=(Map)request.getSession().getAttribute(SUMMARY_TOOL_SESSIONS);
+ logger.debug(logger + " " + this.getClass().getName() + "toolSessionIdCounter: " + toolSessionIdCounter);
+ logger.debug(logger + " " + this.getClass().getName() + "sessionList size: " + sessionList.size());
+
+ if (toolSessionIdCounter==sessionList.size())
+ {
+ logger.debug(logger + " " + this.getClass().getName() + "sessionList size equals toolSessionIdCounter, exiting...");
+ break;
+ }
+
+ logger.debug(logger + " " + this.getClass().getName() + "sessionList: " + sessionList);
+ strToolSessionId=(String)sessionList.get("Group" + toolSessionIdCounter);
+ logger.debug(logger + " " + this.getClass().getName() + "strToolSessionId from sessionList: " + strToolSessionId);
+ }
+
+ strRetrievableToolSessionId=strToolSessionId;
+ logger.debug(logger + " " + this.getClass().getName() + "retrievableStrToolSessionId: " + strRetrievableToolSessionId);
+
+ QaSession qaSession=qaService.retrieveQaSessionOrNullById(new Long(strRetrievableToolSessionId).longValue());
+ logger.debug(logger + " " + this.getClass().getName() + "retrieving qaSession: " + qaSession);
+
+ if (qaSession !=null)
+ {
+ monitoredToolSessionsCounter++;
+ request.getSession().setAttribute(TOOL_SESSION_ID, new Long(strToolSessionId));
+ logger.debug(logger + " " + this.getClass().getName() + "TOOL_SESSION_ID in session");
+
+ if (READABLE_TOOL_SESSION_COUNT.equals(MAX_TOOL_SESSION_COUNT))
+ {
+ logger.debug(logger + " " + this.getClass().getName() + "default screen - READABLE_TOOL_SESSION_COUNT equals MAX_TOOL_SESSION_COUNT");
+ /**
+ * add the current toolSessionId to the arraylist for the drop-down box
+ */
+ sessionList.put("Group" + monitoredToolSessionsCounter, strToolSessionId);
+ logger.debug(logger + " " + this.getClass().getName() + "sessionList Map new entry, strToolSessionId added to the list: " + toolSessionIdCounter + "->" + strToolSessionId );
+ }
+
+ /**
+ * get to content from the tool session
+ */
+ QaContent qaContent=qaSession.getQaContent();
+ logger.debug(logger + " " + this.getClass().getName() + "using qaContent: " + qaContent);
+ logger.debug(logger + " " + this.getClass().getName() + "Monitor - contribute will be using TOOL_CONTENT_ID: " + qaContent.getQaContentId());
+
+ /**
+ * editActivity-defineLater screen depends on MONITORED_CONTENT_ID
+ */
+ request.getSession().setAttribute(MONITORED_CONTENT_ID,qaContent.getQaContentId());
+
+ /**
+ * place it into TOOL_CONTENT_ID session attribute since learningUtil.buidLearnerReport(request) depends on it
+ * to generate a report
+ */
+ request.getSession().setAttribute(TOOL_CONTENT_ID,qaContent.getQaContentId());
+
+ /**
+ * this is to convince jsp although usernameVisible applies only to learning mode
+ */
+ request.getSession().setAttribute(IS_USERNAME_VISIBLE, new Boolean(true));
+
+ logger.debug(logger + " " + this.getClass().getName() + "REPORT_TITLE_MONITOR: " + qaContent.getMonitoringReportTitle());
+ request.getSession().setAttribute(REPORT_TITLE_MONITOR,qaContent.getMonitoringReportTitle());
+
+
+ /**
+ * check if the author requires that the all tool sessions must be COMPLETED before the report in Monitoring
+ */
+ boolean isAllSessionsCompleted=monitoringUtil.isSessionsSync(request,qaContent.getQaContentId().longValue());
+ logger.debug(logger + " " + this.getClass().getName() + "Monitor - contribute will be using isAllSessionsCompleted: " + isAllSessionsCompleted);
+
+ logger.debug(logger + " " + this.getClass().getName() + "Monitor - contribute will be using isSynchInMonitor: " + qaContent.isSynchInMonitor());
+ /**
+ * if the author requires syncronization but not all the sessions are COMPLETED give an error
+ */
+ if (qaContent.isSynchInMonitor() && (!isAllSessionsCompleted))
+ {
+ request.getSession().setAttribute(CHECK_ALL_SESSIONS_COMPLETED, new Boolean(true));
+ request.getSession().setAttribute(IS_ALL_SESSIONS_COMPLETED, new Boolean(isAllSessionsCompleted));
+
+ ActionMessages errors= new ActionMessages();
+ errors.add(Globals.ERROR_KEY, new ActionMessage("error.synchInMonitor"));
+ logger.debug(logger + " " + this.getClass().getName() + "add synchInMonitor to ActionMessages: ");
+ saveErrors(request,errors);
+ }
+ else
+ {
+ request.getSession().setAttribute(CHECK_ALL_SESSIONS_COMPLETED, new Boolean(false));
+ }
+ logger.debug(logger + " " + this.getClass().getName() + "IS_ALL_SESSIONS_COMPLETED:" + request.getSession().getAttribute(IS_ALL_SESSIONS_COMPLETED));
+ logger.debug(logger + " " + this.getClass().getName() + "CHECK_ALL_SESSIONS_COMPLETED" + request.getSession().getAttribute(CHECK_ALL_SESSIONS_COMPLETED));
+
+ LearningUtil learningUtil= new LearningUtil();
+ /**
+ * generate a report for the Author/Teacher
+ */
+ logger.debug(logger + " " + this.getClass().getName() + "calling buidMonitoringReport with toolSessionIdCounter:" + toolSessionIdCounter);
+ learningUtil.buidLearnerReport(request, toolSessionIdCounter);
+ }
+ }
+ }
+
+ /**
+ * store the arrayList in the session
+ */
+ if (READABLE_TOOL_SESSION_COUNT.equals(MAX_TOOL_SESSION_COUNT))
+ {
+ logger.debug(logger + " " + this.getClass().getName() + "sessionList storable");
+ request.getSession().setAttribute(SUMMARY_TOOL_SESSIONS,sessionList);
+ logger.debug(logger + " " + this.getClass().getName() + "SUMMARY_TOOL_SESSIONS stored into the session:" + request.getSession().getAttribute(SUMMARY_TOOL_SESSIONS));
+ }
+
+ mapToolSessions=(Map)request.getSession().getAttribute(MAP_TOOL_SESSIONS);
+ logger.debug(logger + " " + this.getClass().getName() + "before forwarding MAP_TOOL_SESSIONS:" + mapToolSessions);
+
+ if (mapToolSessions.size() == 0)
+ {
+ request.getSession().setAttribute(NO_AVAILABLE_SESSIONS,new Boolean(true));
+ logger.debug(logger + " " + this.getClass().getName() + "NO_AVAILABLE_SESSIONS: " +true);
+ ActionMessages errors= new ActionMessages();
+ errors.add(Globals.ERROR_KEY, new ActionMessage("error.noStudentActivity"));
+ logger.debug(logger + " " + this.getClass().getName() + "add error.noStudentActivity to ActionMessages");
+ saveErrors(request,errors);
+ }
+
+ Boolean noAvailableSessions=(Boolean) request.getSession().getAttribute(NO_AVAILABLE_SESSIONS);
+ logger.debug(logger + " " + this.getClass().getName() + "before forwarding NO_AVAILABLE_SESSIONS:" + noAvailableSessions);
+
+ Map mapMonitoringQuestions=(Map)request.getSession().getAttribute(MAP_MONITORING_QUESTIONS);
+ logger.debug(logger + " " + this.getClass().getName() + "before forwarding MAP_MONITORING_QUESTIONS:" + mapMonitoringQuestions);
+
+ String targetMode=(String )request.getSession().getAttribute(TARGET_MODE);
+ logger.debug(logger + " " + this.getClass().getName() + "TARGET_MODE: " + targetMode);
+ return (mapping.findForward(MONITORING_REPORT));
+ }
+
+
+ public ActionForward generateInstructionsScreen(ActionMapping mapping,
+ ActionForm form,
+ HttpServletRequest request,
+ HttpServletResponse response) throws IOException,
+ ServletException
+ {
+ logger.debug(logger + " " + this.getClass().getName() + "will generateInstructionsScreen ");
+ QaMonitoringForm qaMonitoringForm = (QaMonitoringForm) form;
+
+ Long initialMonitoringContentId=(Long)request.getSession().getAttribute(INITIAL_MONITORING_TOOL_CONTENT_ID);
+ if (initialMonitoringContentId == null)
+ {
+ logger.debug(logger + " " + this.getClass().getName() + "missing content id:");
+ persistError(request,"error.tab.contentId.required");
+ request.setAttribute(USER_EXCEPTION_MONITORINGTAB_CONTENTID_REQUIRED, new Boolean(true));
+ logger.debug(logger + " " + this.getClass().getName() + "forwarding to: " + MONITORING_ERROR);
+ return (mapping.findForward(MONITORING_REPORT));
+ }
+
+ qaMonitoringForm.resetUserAction();
+ return (mapping.findForward(MONITORING_REPORT));
+ }
+
+
+ public ActionForward generateEditActivityScreen(ActionMapping mapping,
+ ActionForm form,
+ HttpServletRequest request,
+ HttpServletResponse response) throws IOException,
+ ServletException
+ {
+ QaMonitoringForm qaMonitoringForm = (QaMonitoringForm) form;
+
+ request.getSession().setAttribute(CONTENT_LOCKED, new Boolean(false));
+ IQaService qaService=(IQaService)request.getSession().getAttribute(TOOL_SERVICE);
+ logger.debug(logger + " " + this.getClass().getName() + "retrieving qaService: " + qaService);
+
+ Long toolContentId=(Long)request.getSession().getAttribute(INITIAL_MONITORING_TOOL_CONTENT_ID);
+ logger.debug(logger + " " + this.getClass().getName() + "toolContentId: " + toolContentId);
+
+ if (toolContentId == null)
+ {
+ /**
+ * toolContentId is not available from the toolSessions passed to the monitoring url.
+ * in this case, toolContentId must have been passed separetely
+ */
+ Long monitoredContentId=(Long)request.getSession().getAttribute(MONITORED_CONTENT_ID);
+ logger.debug(logger + " " + this.getClass().getName() + "will generateEditActivityScreen: " + monitoredContentId);
+
+ if (monitoredContentId == null)
+ {
+ throw new QaApplicationException("Exception occured: " +
+ "Tool expects a legitimate TOOL_CONTENT_ID from the container since it is also not available from the toolSession(s) passed. Can't continue!");
+ }
+ toolContentId=monitoredContentId;
+ }
+ request.getSession().setAttribute(MONITORED_CONTENT_ID, toolContentId);
+
+ logger.debug(logger + " " + this.getClass().getName() + "will use monitoredContentId: " + toolContentId);
+ QaContent qaContent=qaService.loadQa(toolContentId.longValue());
+ logger.debug(logger + " " + this.getClass().getName() + "will use qaContent: " + qaContent);
+
+ request.getSession().setAttribute(IS_MONITORING_DEFINE_LATER, new Boolean(qaContent.isDefineLater()));
+ logger.debug(logger + " " + this.getClass().getName() + "IS_MONITORING_DEFINE_LATER: " + request.getSession().getAttribute(IS_MONITORING_DEFINE_LATER));
+
+ logger.debug(logger + " " + this.getClass().getName() + "calling studentActivityOccurredGlobal with: " + qaContent);
+ boolean studentActivity=qaService.studentActivityOccurredGlobal(qaContent);
+ logger.debug(logger + " " + this.getClass().getName() + "studentActivity on content: " + studentActivity);
+
+ qaMonitoringForm.resetUserAction();
+ if (studentActivity == false)
+ {
+ /**
+ * forward to Authoring Basic tab
+ */
+ QaStarterAction qaStarterAction = new QaStarterAction();
+ QaAuthoringForm qaAuthoringForm = new QaAuthoringForm();
+ logger.debug(logger + " " + this.getClass().getName() + "forward to Authoring Basic tab ");
+ ActionForward actionForward=qaStarterAction.startMonitoringSummary(mapping, qaAuthoringForm, request, response);
+ logger.debug(logger + " " + this.getClass().getName() + "actionForward: " + actionForward);
+ return (actionForward);
+ }
+ else
+ {
+ logger.debug(logger + " " + this.getClass().getName() + "forward to warning screen as the content is not allowed to be modified.");
+ ActionMessages errors= new ActionMessages();
+ errors.add(Globals.ERROR_KEY, new ActionMessage("error.content.inUse"));
+ saveErrors(request,errors);
+ request.getSession().setAttribute(CONTENT_LOCKED, new Boolean(true));
+ request.setAttribute(START_MONITORING_SUMMARY_REQUEST, new Boolean(true));
+ logger.debug(logger + " " + this.getClass().getName() + "forward to:" + LOAD);
+ return (mapping.findForward(LOAD));
+ }
+ }
+
+
+ public ActionForward generateStatsScreen(ActionMapping mapping,
+ ActionForm form,
+ HttpServletRequest request,
+ HttpServletResponse response) throws IOException,
+ ServletException
+ {
+ QaMonitoringForm qaMonitoringForm = (QaMonitoringForm) form;
+ Boolean noToolSessionsAvailable=(Boolean)request.getSession().getAttribute(NO_TOOL_SESSIONS_AVAILABLE);
+ if ((noToolSessionsAvailable !=null) && (noToolSessionsAvailable.booleanValue()))
+ {
+ qaMonitoringForm.resetUserAction();
+ logger.debug(logger + " " + this.getClass().getName() + "detected noToolSessionsAvailable:" + noToolSessionsAvailable);
+ persistError(request,"error.content.onlyContentAndNoSessions");
+ request.setAttribute(USER_EXCEPTION_ONLYCONTENT_ANDNOSESSIONS, new Boolean(true));
+ logger.debug(logger + " " + this.getClass().getName() + "forwarding to: " + MONITORING_ERROR);
+ return (mapping.findForward(MONITORING_REPORT));
+ }
+
+ IQaService qaService=(IQaService)request.getSession().getAttribute(TOOL_SERVICE);
+ logger.debug(logger + " " + this.getClass().getName() + "retrieving qaService: " + qaService);
+
+ Map mapStats= new TreeMap(new QaStringComparator());
+ request.getSession().setAttribute(MAP_STATS,mapStats);
+
+ Map sessionList=(Map)request.getSession().getAttribute(SUMMARY_TOOL_SESSIONS);
+ for (int toolSessionIdCounter=1; toolSessionIdCounter < READABLE_TOOL_SESSION_COUNT.intValue(); toolSessionIdCounter++)
+ {
+ String strToolSessionId=(String)sessionList.get("Group" + toolSessionIdCounter);
+ logger.debug(logger + " " + this.getClass().getName() + "strToolSessionId from http session: " + strToolSessionId);
+ if ((strToolSessionId != null) && (strToolSessionId.length() > 0))
+ {
+ QaSession qaSession=qaService.retrieveQaSessionOrNullById(new Long(strToolSessionId).longValue());
+ logger.debug(logger + " " + this.getClass().getName() + "retrieving qaSession: " + qaSession);
+ if (qaSession != null)
+ {
+ logger.debug(logger + " " + this.getClass().getName() + "retrieving qaSession: " + qaSession);
+ int countSessionUser=qaService.countSessionUser(qaSession);
+ logger.debug(logger + " " + this.getClass().getName() + "countSessionUser: " + countSessionUser);
+ mapStats.put(strToolSessionId, new Integer(countSessionUser).toString());
+ request.getSession().setAttribute(MAP_STATS,mapStats);
+ }
+
+ }
+ }
+ mapStats=(Map)request.getSession().getAttribute(MAP_STATS);
+ logger.debug(logger + " " + this.getClass().getName() + "final MAP_STATS: " + mapStats);
+ qaMonitoringForm.resetUserAction();
+ return (mapping.findForward(MONITORING_REPORT));
+ }
+
+
+ /**
+ * markDataMapAsEditable(ActionMapping mapping,
+ ActionForm form,
+ HttpServletRequest request,
+ HttpServletResponse response) throws IOException,
+ ServletException
+ *
+ * @param mapping
+ * @param form
+ * @param request
+ * @param response
+ * @return
+ * @throws IOException
+ * @throws ServletException
+ *
+ *
+ * marks the dataMap so that jsp renders the summary screen as editable
+ */
+ public ActionForward markDataMapAsEditable(ActionMapping mapping,
+ ActionForm form,
+ HttpServletRequest request,
+ HttpServletResponse response) throws IOException,
+ ServletException
+ {
+ request.getSession().setAttribute(DATAMAP_EDITABLE, new Boolean(true));
+ logger.debug(logger + " " + this.getClass().getName() + "will generate editable summary screen");
+ return generateSummaryScreen(mapping, form, request, response);
+ }
+
+
+ public ActionForward handleInstructionsScreen(ActionMapping mapping,ActionForm form, HttpServletRequest request)
+ {
+ /**
+ * update online and offline instuctions content if there is a request.
+ */
+ QaMonitoringForm qaMonitoringForm = (QaMonitoringForm) form;
+ IQaService qaService =QaUtils.getToolService(request);
+ if (qaMonitoringForm.getSubmitMonitoringInstructions() != null)
+ {
+ logger.debug(logger + " " + this.getClass().getName() + "request for prosssing Monitoring instructions :");
+ qaMonitoringForm.setSubmitMonitoringInstructions(null);
+
+ logger.debug(logger + " " + this.getClass().getName() + "online instructions :" + qaMonitoringForm.getOnlineInstructions());
+ logger.debug(logger + " " + this.getClass().getName() + "offline instructions :" + qaMonitoringForm.getOfflineInstructions());
+ Long initialMonitoringContentId=(Long)request.getSession().getAttribute(INITIAL_MONITORING_TOOL_CONTENT_ID);
+ if (initialMonitoringContentId == null)
+ {
+ logger.debug(logger + " " + this.getClass().getName() + "missing content id:");
+ persistError(request,"error.tab.contentId.required");
+ request.setAttribute(USER_EXCEPTION_MONITORINGTAB_CONTENTID_REQUIRED, new Boolean(true));
+ logger.debug(logger + " " + this.getClass().getName() + "forwarding to: " + MONITORING_ERROR);
+ return (mapping.findForward(MONITORING_REPORT));
+ }
+ else
+ {
+ /**
+ * update the content
+ */
+ logger.debug(logger + " " + this.getClass().getName() + "content id: " + initialMonitoringContentId);
+ QaContent qaContent=qaService.retrieveQa(initialMonitoringContentId.longValue());
+ logger.debug(logger + " " + this.getClass().getName() + "qaContent: " + qaContent);
+ qaContent.setOnlineInstructions(qaMonitoringForm.getOnlineInstructions());
+ qaContent.setOfflineInstructions(qaMonitoringForm.getOfflineInstructions());
+ qaService.updateQa(qaContent);
+ logger.debug(logger + " " + this.getClass().getName() + "qaContent updated in the db");
+ request.getSession().setAttribute(MONITORED_OFFLINE_INSTRUCTIONS, qaContent.getOfflineInstructions());
+ request.getSession().setAttribute(MONITORED_ONLINE_INSTRUCTIONS, qaContent.getOnlineInstructions());
+ logger.debug(logger + " " + this.getClass().getName() + "session updated with on/off instructions");
+ request.setAttribute(MONITORING_INSTRUCTIONS_UPDATE_MESSAGE, new Boolean(true));
+ return (mapping.findForward(MONITORING_REPORT));
+ }
+ }
+ logger.debug(logger + " " + this.getClass().getName() + "end of online-offline instructions content handling");
+ return null;
+ }
+
+ /**
+ * persists error messages to request scope
+ * @param request
+ * @param message
+ */
+ public void persistError(HttpServletRequest request, String message)
+ {
+ ActionMessages errors= new ActionMessages();
+ errors.add(Globals.ERROR_KEY, new ActionMessage(message));
+ logger.debug(logger + " " + this.getClass().getName() + "add " + message +" to ActionMessages:");
+ saveErrors(request,errors);
+ }
+
+}
\ No newline at end of file
Index: lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/QaMonitoringForm.java
===================================================================
diff -u
--- lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/QaMonitoringForm.java (revision 0)
+++ lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/QaMonitoringForm.java (revision 16e844de3f7c34b44baee1b28e67e708f42d00bf)
@@ -0,0 +1,291 @@
+/*
+ * ozgurd
+ * Created on 26/04/2005
+ *
+ * TODO To change the template for this generated file go to
+ * Window - Preferences - Java - Code Style - Code Templates
+ */
+package org.lamsfoundation.lams.tool.qa.web;
+
+/**
+ * ActionForm for the Monitoring environment
+ */
+import org.apache.log4j.Logger;
+import org.apache.struts.action.ActionForm;
+import org.lamsfoundation.lams.tool.qa.QaAppConstants;
+
+/**
+ * @author ozgurd
+ *
+ * TODO To change the template for this generated type comment go to
+ * Window - Preferences - Java - Code Style - Code Templates
+ */
+public class QaMonitoringForm extends ActionForm implements QaAppConstants {
+ static Logger logger = Logger.getLogger(QaMonitoringForm.class.getName());
+
+ /**
+ * these buttons are not used in the deployment
+ */
+ protected String startLesson;
+ protected String deleteLesson;
+ protected String forceComplete;
+
+ /**
+ * buttons
+ */
+ protected String editReport;
+ protected String updateReport;
+ protected String hideReport;
+ protected String unhideReport;
+ protected String submitMonitoringInstructions;
+
+ protected String summary;
+ protected String instructions;
+ protected String editActivity;
+ protected String stats;
+
+ protected String responseId;
+ protected String hiddenResponseId;
+ protected String unHiddenResponseId;
+ protected String updatedResponse;
+
+ protected String offlineInstructions;
+ protected String onlineInstructions;
+
+ public void resetUserAction()
+ {
+ this.startLesson=null;
+ this.deleteLesson=null;
+ this.forceComplete=null;
+
+ this.summary=null;
+ this.instructions=null;
+ this.editActivity=null;
+ this.stats=null;
+
+ this.editReport=null;
+ this.updateReport=null;
+ this.hideReport=null;
+ this.unhideReport=null;
+
+ this.offlineInstructions=null;
+ this.onlineInstructions=null;
+ }
+ /**
+ * @return Returns the deleteLesson.
+ */
+ public String getDeleteLesson() {
+ return deleteLesson;
+ }
+ /**
+ * @param deleteLesson The deleteLesson to set.
+ */
+ public void setDeleteLesson(String deleteLesson) {
+ this.deleteLesson = deleteLesson;
+ }
+ /**
+ * @return Returns the startLesson.
+ */
+ public String getStartLesson() {
+ return startLesson;
+ }
+ /**
+ * @param startLesson The startLesson to set.
+ */
+ public void setStartLesson(String startLesson) {
+ this.startLesson = startLesson;
+ }
+ /**
+ * @return Returns the forceComplete.
+ */
+ public String getForceComplete() {
+ return forceComplete;
+ }
+ /**
+ * @param forceComplete The forceComplete to set.
+ */
+ public void setForceComplete(String forceComplete) {
+ this.forceComplete = forceComplete;
+ }
+ /**
+ * @return Returns the summary.
+ */
+ public String getSummary() {
+ return summary;
+ }
+ /**
+ * @param summary The summary to set.
+ */
+ public void setSummary(String summary) {
+ this.summary = summary;
+ }
+ /**
+ * @return Returns the instructions.
+ */
+ public String getInstructions() {
+ return instructions;
+ }
+ /**
+ * @param instructions The instructions to set.
+ */
+ public void setInstructions(String instructions) {
+ this.instructions = instructions;
+ }
+ /**
+ * @return Returns the editActivity.
+ */
+ public String getEditActivity() {
+ return editActivity;
+ }
+ /**
+ * @param editActivity The editActivity to set.
+ */
+ public void setEditActivity(String editActivity) {
+ this.editActivity = editActivity;
+ }
+ /**
+ * @return Returns the stats.
+ */
+ public String getStats() {
+ return stats;
+ }
+ /**
+ * @param stats The stats to set.
+ */
+ public void setStats(String stats) {
+ this.stats = stats;
+ }
+ /**
+ * @return Returns the editReport.
+ */
+ public String getEditReport() {
+ return editReport;
+ }
+ /**
+ * @param editReport The editReport to set.
+ */
+ public void setEditReport(String editReport) {
+ this.editReport = editReport;
+ }
+ /**
+ * @return Returns the responseId.
+ */
+ public String getResponseId() {
+ return responseId;
+ }
+ /**
+ * @param responseId The responseId to set.
+ */
+ public void setResponseId(String responseId) {
+ this.responseId = responseId;
+ }
+ /**
+ * @return Returns the updateReport.
+ */
+ public String getUpdateReport() {
+ return updateReport;
+ }
+ /**
+ * @param updateReport The updateReport to set.
+ */
+ public void setUpdateReport(String updateReport) {
+ this.updateReport = updateReport;
+ }
+ /**
+ * @return Returns the updatedResponse.
+ */
+ public String getUpdatedResponse() {
+ return updatedResponse;
+ }
+ /**
+ * @param updatedResponse The updatedResponse to set.
+ */
+ public void setUpdatedResponse(String updatedResponse) {
+ this.updatedResponse = updatedResponse;
+ }
+ /**
+ * @return Returns the hideReport.
+ */
+ public String getHideReport() {
+ return hideReport;
+ }
+ /**
+ * @param hideReport The hideReport to set.
+ */
+ public void setHideReport(String hideReport) {
+ this.hideReport = hideReport;
+ }
+ /**
+ * @return Returns the hiddenResponseId.
+ */
+ public String getHiddenResponseId() {
+ return hiddenResponseId;
+ }
+ /**
+ * @param hiddenResponseId The hiddenResponseId to set.
+ */
+ public void setHiddenResponseId(String hiddenResponseId) {
+ this.hiddenResponseId = hiddenResponseId;
+ }
+ /**
+ * @return Returns the unhideReport.
+ */
+ public String getUnhideReport() {
+ return unhideReport;
+ }
+ /**
+ * @param unhideReport The unhideReport to set.
+ */
+ public void setUnhideReport(String unhideReport) {
+ this.unhideReport = unhideReport;
+ }
+ /**
+ * @return Returns the unHiddenResponseId.
+ */
+ public String getUnHiddenResponseId() {
+ return unHiddenResponseId;
+ }
+ /**
+ * @param unHiddenResponseId The unHiddenResponseId to set.
+ */
+ public void setUnHiddenResponseId(String unHiddenResponseId) {
+ this.unHiddenResponseId = unHiddenResponseId;
+ }
+ /**
+ * @return Returns the offlineInstructions.
+ */
+ public String getOfflineInstructions() {
+ return offlineInstructions;
+ }
+ /**
+ * @param offlineInstructions The offlineInstructions to set.
+ */
+ public void setOfflineInstructions(String offlineInstructions) {
+ this.offlineInstructions = offlineInstructions;
+ }
+ /**
+ * @return Returns the onlineInstructions.
+ */
+ public String getOnlineInstructions() {
+ return onlineInstructions;
+ }
+ /**
+ * @param onlineInstructions The onlineInstructions to set.
+ */
+ public void setOnlineInstructions(String onlineInstructions) {
+ this.onlineInstructions = onlineInstructions;
+ }
+ /**
+ * @return Returns the submitMonitoringInstructions.
+ */
+ public String getSubmitMonitoringInstructions() {
+ return submitMonitoringInstructions;
+ }
+ /**
+ * @param submitMonitoringInstructions The submitMonitoringInstructions to set.
+ */
+ public void setSubmitMonitoringInstructions(
+ String submitMonitoringInstructions) {
+ this.submitMonitoringInstructions = submitMonitoringInstructions;
+ }
+}
Index: lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/QaMonitoringStarterAction.java
===================================================================
diff -u
--- lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/QaMonitoringStarterAction.java (revision 0)
+++ lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/QaMonitoringStarterAction.java (revision 16e844de3f7c34b44baee1b28e67e708f42d00bf)
@@ -0,0 +1,426 @@
+/*
+ * Created on 8/03/2005
+ *
+ * TODO To change the template for this generated file go to
+ * Window - Preferences - Java - Code Style - Code Templates
+ */
+
+/**
+ *
+ * Monitoring screen does have 4 tabs:
+ * Summary : default tab, either all sessions by default or single sessions selected, enable edit responses and hide responses
+ * Instructions: Online+offline instructions+multipe file uploads + new table
+ * Edit Activity : points to the definelater url= authoring url basic tab
+ * Stats
+ *
+ *
+ * SUMMARY_TOOL_SESSIONS keeps all the passed toolSessionIds in an arrayList.
+ */
+
+package org.lamsfoundation.lams.tool.qa.web;
+import java.io.IOException;
+
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.log4j.Logger;
+import org.apache.struts.Globals;
+import org.apache.struts.action.Action;
+import org.apache.struts.action.ActionForm;
+import org.apache.struts.action.ActionForward;
+import org.apache.struts.action.ActionMapping;
+import org.apache.struts.action.ActionMessage;
+import org.apache.struts.action.ActionMessages;
+import org.lamsfoundation.lams.tool.qa.QaAppConstants;
+import org.lamsfoundation.lams.tool.qa.QaApplicationException;
+import org.lamsfoundation.lams.tool.qa.QaContent;
+import org.lamsfoundation.lams.tool.qa.QaSession;
+import org.lamsfoundation.lams.tool.qa.QaUtils;
+import org.lamsfoundation.lams.tool.qa.service.IQaService;
+import org.lamsfoundation.lams.tool.qa.service.QaServiceProxy;
+import org.lamsfoundation.lams.usermanagement.User;
+
+public class QaMonitoringStarterAction extends Action implements QaAppConstants {
+ static Logger logger = Logger.getLogger(QaMonitoringStarterAction.class.getName());
+
+ public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response)
+ throws IOException, ServletException, QaApplicationException
+ {
+ QaMonitoringForm qaMonitoringForm = (QaMonitoringForm) form;
+ logger.debug(logger + " " + this.getClass().getName() + "started monitoring mode : " + qaMonitoringForm);
+
+ /**
+ * retrive the service
+ */
+ IQaService qaService=null;
+ qaService =(IQaService)request.getSession().getAttribute(TOOL_SERVICE);
+ if (qaService == null)
+ {
+ logger.debug(logger + " " + this.getClass().getName() + "qaService is not found yet:");
+ qaService = QaServiceProxy.getQaService(getServlet().getServletContext());
+ logger.debug(logger + " " + this.getClass().getName() + "retrieving qaService from the session: " + qaService);
+ request.getSession().setAttribute(TOOL_SERVICE, qaService);
+ }
+ logger.debug(logger + " " + this.getClass().getName() + "retrieved qaService: " + qaService);
+
+ /**
+ * mark the http session as an authoring activity
+ */
+ request.getSession().setAttribute(TARGET_MODE,TARGET_MODE_MONITORING);
+
+ /**
+ * obtain and setup the current user's data
+ */
+ String userId="";
+ User toolUser=(User)request.getSession().getAttribute(TOOL_USER);
+ if (toolUser != null)
+ userId=toolUser.getUserId().toString();
+ else
+ {
+ userId=request.getParameter(USER_ID);
+ try
+ {
+ User user=QaUtils.createAuthoringUser(new Integer(userId));
+ request.getSession().setAttribute(TOOL_USER, user);
+ }
+ catch(NumberFormatException e)
+ {
+ persistError(request,"error.userId.notNumeric");
+ request.setAttribute(USER_EXCEPTION_USERID_NOTNUMERIC, new Boolean(true));
+ logger.debug(logger + " " + this.getClass().getName() + "forwarding to: " + LOAD_QUESTIONS);
+ return (mapping.findForward(MONITORING_REPORT));
+ }
+ }
+
+ if ((userId == null) || (userId.length()==0))
+ {
+ logger.debug(logger + " " + this.getClass().getName() + "error: The tool expects userId");
+ persistError(request,"error.authoringUser.notAvailable");
+ request.setAttribute(USER_EXCEPTION_USERID_NOTAVAILABLE, new Boolean(true));
+ logger.debug(logger + " " + this.getClass().getName() + "forwarding to: " + MONITORING_ERROR);
+ return (mapping.findForward(MONITORING_REPORT));
+ }
+ logger.debug(logger + " " + this.getClass().getName() + "TOOL_USER is:" + request.getSession().getAttribute(TOOL_USER));
+
+ String toolContentId=request.getParameter(TOOL_CONTENT_ID);
+ logger.debug(logger + " " + this.getClass().getName() + "TOOL_CONTENT_ID: " + toolContentId);
+
+ Long initialMonitoringContentId=(Long) request.getSession().getAttribute(INITIAL_MONITORING_TOOL_CONTENT_ID);
+ logger.debug(logger + " " + this.getClass().getName() + "INITIAL_MONITORING_TOOL_CONTENT_ID: " + initialMonitoringContentId);
+
+ if ((toolContentId == null) || (toolContentId.length() == 0))
+ {
+ logger.debug(logger + "Warning!: passing TOOL_CONTENT_ID is optional. Since it is null, we will derive it from tool session(s).");
+ }
+ else if (initialMonitoringContentId != null)
+ {
+ logger.debug(logger + " " + this.getClass().getName() + "using INITIAL_MONITORING_TOOL_CONTENT_ID: " + initialMonitoringContentId);
+ toolContentId=initialMonitoringContentId.toString();
+ }
+
+ try
+ {
+ if ((toolContentId != null) && (toolContentId.length() > 0))
+ {
+ logger.debug(logger + "Since TOOL_CONTENT_ID has been passed explicitly we will refer to that one instead of the one derived from tool sessions");
+ if (!QaUtils.existsContent(new Long(toolContentId).longValue(), request))
+ {
+ persistError(request,"error.content.doesNotExist");
+ request.setAttribute(USER_EXCEPTION_CONTENT_DOESNOTEXIST, new Boolean(true));
+ logger.debug(logger + " " + this.getClass().getName() + "forwarding to: " + MONITORING_ERROR);
+ return (mapping.findForward(MONITORING_REPORT));
+ }
+ request.getSession().setAttribute(INITIAL_MONITORING_TOOL_CONTENT_ID, new Long(toolContentId));
+ }
+ }
+ catch(NumberFormatException e)
+ {
+ persistError(request,"error.numberFormatException");
+ request.setAttribute(USER_EXCEPTION_NUMBERFORMAT, new Boolean(true));
+ logger.debug(logger + " " + this.getClass().getName() + "forwarding to: " + MONITORING_ERROR);
+ return (mapping.findForward(MONITORING_REPORT));
+ }
+ logger.debug(logger + "final INITIAL_MONITORING_TOOL_CONTENT_ID: " + request.getSession().getAttribute(INITIAL_MONITORING_TOOL_CONTENT_ID));
+
+ /**
+ * load the values for online and offline instructions
+ */
+ initialMonitoringContentId=(Long)request.getSession().getAttribute(INITIAL_MONITORING_TOOL_CONTENT_ID);
+ if (initialMonitoringContentId != null)
+ {
+ QaContent qaContent=qaService.retrieveQa(initialMonitoringContentId.longValue());
+ logger.debug(logger + " " + this.getClass().getName() + "qaContent: " + qaContent);
+ request.getSession().setAttribute(MONITORED_OFFLINE_INSTRUCTIONS, qaContent.getOfflineInstructions());
+ request.getSession().setAttribute(MONITORED_ONLINE_INSTRUCTIONS, qaContent.getOnlineInstructions());
+ logger.debug(logger + " " + this.getClass().getName() + "session updated with on/off instructions");
+ }
+
+ /**
+ * find out if only content id but no tool sessions has been passed
+ */
+ boolean isOnlyContentIdAvailable = isOnlyContentIdAvailable(request);
+ logger.debug(logger + "final isOnlyContentIdAvailable: " + isOnlyContentIdAvailable);
+
+ request.getSession().setAttribute(NO_TOOL_SESSIONS_AVAILABLE, new Boolean(false));
+ if (isOnlyContentIdAvailable == false)
+ {
+ logger.debug(logger + "found sessions: isOnlyContentIdAvailable: " + isOnlyContentIdAvailable);
+ if ((toolContentId != null) && (toolContentId.length() > 0))
+ {
+ boolean isToolSessionCompatibleToContent=isToolSessionCompatibleToContent(new Long(toolContentId), request);
+ logger.debug(logger + "isToolSessionCompatibleToContent: " + isToolSessionCompatibleToContent);
+ if (!isToolSessionCompatibleToContent)
+ {
+ persistError(request,"error.contentAndToolSession.notCompatible");
+ request.setAttribute(USER_EXCEPTION_UNCOMPATIBLE_IDS, new Boolean(true));
+ logger.debug(logger + " " + this.getClass().getName() + "forwarding to: " + MONITORING_ERROR);
+ return (mapping.findForward(MONITORING_REPORT));
+ }
+ }
+
+ Boolean userExceptionNumberFormat=(Boolean)request.getAttribute(USER_EXCEPTION_NUMBERFORMAT);
+ logger.debug(logger + "userExceptionNumberFormat: " + userExceptionNumberFormat);
+ if ((userExceptionNumberFormat != null) && (userExceptionNumberFormat.booleanValue()))
+ {
+ persistError(request,"error.numberFormatException");
+ logger.debug(logger + " " + this.getClass().getName() + "forwarding to: " + MONITORING_ERROR);
+ return (mapping.findForward(MONITORING_REPORT));
+ }
+
+ Boolean userExceptionWrongFormat=(Boolean)request.getAttribute(USER_EXCEPTION_WRONG_FORMAT);
+ logger.debug(logger + "userExceptionWrongFormat: " + userExceptionWrongFormat);
+ if ((userExceptionWrongFormat != null) && (userExceptionWrongFormat.booleanValue()))
+ {
+ persistError(request,"error.toolSessions.wrongFormat");
+ logger.debug(logger + " " + this.getClass().getName() + "forwarding to: " + MONITORING_ERROR);
+ return (mapping.findForward(MONITORING_REPORT));
+ }
+
+ Boolean userExceptionToolSessionDoesNotExist=(Boolean)request.getAttribute(USER_EXCEPTION_TOOLSESSION_DOESNOTEXIST);
+ logger.debug(logger + "userExceptionToolSessionDoesNotExist: " + userExceptionToolSessionDoesNotExist);
+ if ((userExceptionToolSessionDoesNotExist != null) && (userExceptionToolSessionDoesNotExist.booleanValue()))
+ {
+ persistError(request,"error.toolSessions.doesNotExist");
+ logger.debug(logger + " " + this.getClass().getName() + "forwarding to: " + MONITORING_ERROR);
+ return (mapping.findForward(MONITORING_REPORT));
+ }
+ qaMonitoringForm.setSummary("summary");
+ }
+ else
+ {
+ logger.debug(logger + "found sessions: isOnlyContentIdAvailable: " + isOnlyContentIdAvailable);
+ logger.debug(logger + "no tool sessions passed");
+ qaMonitoringForm.resetUserAction();
+ logger.debug(logger + "no tool sessions passed");
+ persistError(request,"error.content.onlyContentAndNoSessions");
+ request.setAttribute(USER_EXCEPTION_ONLYCONTENT_ANDNOSESSIONS, new Boolean(true));
+ request.getSession().setAttribute(NO_TOOL_SESSIONS_AVAILABLE, new Boolean(true));
+ logger.debug(logger + " " + this.getClass().getName() + "forwarding to: " + MONITORING_REPORT);
+ request.getSession().setAttribute(INITIAL_MONITORING_TOOL_CONTENT_ID, new Long(toolContentId));
+ logger.debug(logger + "INITIAL_MONITORING_TOOL_CONTENT_ID: " + request.getSession().getAttribute(INITIAL_MONITORING_TOOL_CONTENT_ID));
+ return (mapping.findForward(MONITORING_REPORT));
+ }
+
+ String strFromToolContentId="";
+ String strToToolContentId="";
+
+ /**
+ * simulate Monitoring Service bean by calling the interface methods here
+ */
+ if (qaMonitoringForm.getStartLesson() != null)
+ {
+ qaMonitoringForm.resetUserAction();
+ /**
+ * In deployment, we won't be passing FROM_TOOL_CONTENT_ID, TO_TOOL_CONTENT_ID and TOOL_SESSION_ID from url
+ * the Monitoring Service bean calls:
+ * copyToolContent(Long fromContentId, Long toContentId)
+ */
+ strFromToolContentId=request.getParameter(FROM_TOOL_CONTENT_ID);
+ logger.debug(logger + " " + this.getClass().getName() + "FROM_TOOL_CONTENT_ID: " + strFromToolContentId);
+ if (strFromToolContentId == null)
+ {
+ throw new QaApplicationException("Exception occured: " +
+ "Tool expects a legitimate FROM_TOOL_CONTENT_ID from the container. Can't continue!");
+ }
+
+ strToToolContentId=request.getParameter(TO_TOOL_CONTENT_ID);
+ logger.debug(logger + " " + this.getClass().getName() + "TO_TOOL_CONTENT_ID: " + strToToolContentId);
+ if (strToToolContentId == null)
+ {
+ throw new QaApplicationException("Exception occured: " +
+ "Tool expects a legitimate TO_TOOL_CONTENT_ID from the container. Can't continue!");
+ }
+ qaService.copyToolContent(new Long(strFromToolContentId), new Long(strToToolContentId));
+
+ /** calls to these two methods will be made from Monitoring Service bean optionally depending on
+ * the the tool is setup for DefineLater and (or) RunOffline
+ */
+
+ /**
+ * TESTED to work
+ * qaService.setAsDefineLater(new Long(strToToolContentId));
+ qaService.setAsRunOffline(new Long(strToToolContentId));
+ *
+ */
+ }
+ else if (qaMonitoringForm.getDeleteLesson() != null)
+ {
+ qaMonitoringForm.resetUserAction();
+ /**
+ * TESTED to work
+ */
+ strToToolContentId=request.getParameter(TO_TOOL_CONTENT_ID);
+ logger.debug(logger + " " + this.getClass().getName() + "TO_TOOL_CONTENT_ID: " + strToToolContentId);
+ if (strToToolContentId == null)
+ {
+ throw new QaApplicationException("Exception occured: " +
+ "Tool expects a legitimate TO_TOOL_CONTENT_ID from the container. Can't continue!");
+ }
+ qaService.removeToolContent(new Long(strToToolContentId));
+ }
+ /**
+ *forceComplete is an API call to service bean from monitoring environment with userId as the parameter
+ */
+ else if (qaMonitoringForm.getForceComplete() != null)
+ {
+ /**
+ * Parameter: userId
+ */
+ qaMonitoringForm.resetUserAction();
+ logger.debug(logger + " " + this.getClass().getName() + "request for forceComplete");
+ userId=request.getParameter(MONITOR_USER_ID);
+ logger.debug(logger + " " + this.getClass().getName() + "MONITOR_USER_ID: " + userId);
+ qaService.setAsForceComplete(new Long(userId));
+ logger.debug(logger + " " + this.getClass().getName() + "end of setAsForceComplete with userId: " + userId);
+ }
+ /**
+ * summary tab is one of the main tabs in monitoring screen, summary is the default tab
+ */
+ else if (qaMonitoringForm.getSummary() != null)
+ {
+ qaMonitoringForm.resetUserAction();
+ logger.debug(logger + " " + this.getClass().getName() + "do generateToolSessionDataMap");
+ QaMonitoringAction qaMonitoringAction= new QaMonitoringAction();
+ return qaMonitoringAction.generateToolSessionDataMap(mapping,form,request,response);
+ }
+ else if (qaMonitoringForm.getInstructions() != null)
+ {
+ qaMonitoringForm.resetUserAction();
+ logger.debug(logger + " " + this.getClass().getName() + "request for instructions");
+ }
+ else if (qaMonitoringForm.getEditActivity() != null)
+ {
+ qaMonitoringForm.resetUserAction();
+ logger.debug(logger + " " + this.getClass().getName() + "request for editActivity");
+ }
+ else if (qaMonitoringForm.getStats() != null)
+ {
+ qaMonitoringForm.resetUserAction();
+ logger.debug(logger + " " + this.getClass().getName() + "request for stats");
+ }
+ return null;
+ }
+
+
+ public boolean isOnlyContentIdAvailable(HttpServletRequest request)
+ {
+ boolean existsContentId=false;
+ String strToolContentId=request.getParameter(TOOL_CONTENT_ID);
+ if ((strToolContentId != null) && (strToolContentId.length() > 0))
+ existsContentId=true;
+
+ boolean existsToolSession=false;
+ for (int toolSessionIdCounter=1; toolSessionIdCounter < MAX_TOOL_SESSION_COUNT.intValue(); toolSessionIdCounter++)
+ {
+ String strToolSessionId=request.getParameter(TOOL_SESSION_ID + toolSessionIdCounter);
+ if ((strToolSessionId != null) && (strToolSessionId.length() > 0))
+ {
+ existsToolSession=true;
+ }
+ }
+
+ if (existsContentId && (!existsToolSession))
+ {
+ logger.debug(logger + " " + this.getClass().getName() + "OnlyContentIdAvailable");
+ return true;
+ }
+ else
+ {
+ logger.debug(logger + " " + this.getClass().getName() + "Not OnlyContentIdAvailable");
+ return false;
+ }
+ }
+
+ /**
+ * verify that toolSession and content is compatible
+ */
+ public boolean isToolSessionCompatibleToContent(Long toolContentId, HttpServletRequest request)
+ {
+ IQaService qaService =QaUtils.getToolService(request);
+ for (int toolSessionIdCounter=1; toolSessionIdCounter < MAX_TOOL_SESSION_COUNT.intValue(); toolSessionIdCounter++)
+ {
+ String strToolSessionId=request.getParameter(TOOL_SESSION_ID + toolSessionIdCounter);
+ logger.debug(logger + " " + this.getClass().getName() + "TOOL_SESSION_ID: " + strToolSessionId);
+ if ((strToolSessionId != null) && (strToolSessionId.length() > 0))
+ {
+ QaSession qaSession=null;
+ try
+ {
+ qaSession=qaService.retrieveQaSessionOrNullById(new Long(strToolSessionId).longValue());
+ }
+ catch(NumberFormatException e)
+ {
+ request.setAttribute(USER_EXCEPTION_NUMBERFORMAT, new Boolean(true));
+ }
+
+ if (qaSession != null)
+ {
+ QaContent qaContent=qaSession.getQaContent();
+ logger.debug(logger + " " + this.getClass().getName() + "using qaContent: " + qaContent);
+ logger.debug(logger + " " + this.getClass().getName() + "qaContent id versus toolSession's content id: " + toolContentId +
+ " versus " + qaContent.getQaContentId());
+ if (!qaContent.getQaContentId().equals(toolContentId))
+ {
+ logger.debug(logger + " " + this.getClass().getName() + "qaContent and toolSesion not compatible:");
+ return false;
+ }
+ }
+ else
+ {
+ logger.debug(logger + " " + this.getClass().getName() + "error: TOOL_SESSION_ID passed does not refer to an existing tool session.");
+ request.setAttribute(USER_EXCEPTION_TOOLSESSION_DOESNOTEXIST, new Boolean(true));
+ break;
+ }
+ }
+
+ if ((strToolSessionId == null) && (toolSessionIdCounter == 1))
+ {
+ logger.debug(logger + " " + this.getClass().getName() + "error: TOOL_SESSION_IDs not passed in the right format");
+ request.setAttribute(USER_EXCEPTION_WRONG_FORMAT, new Boolean(true));
+ break;
+ }
+ if ((strToolSessionId != null) && (strToolSessionId.length() == 0) && (toolSessionIdCounter == 1))
+ {
+ logger.debug(logger + " " + this.getClass().getName() + "error: TOOL_SESSION_IDs not passed in the right format");
+ request.setAttribute(USER_EXCEPTION_WRONG_FORMAT, new Boolean(true));
+ break;
+ }
+ }
+ logger.debug(logger + " " + this.getClass().getName() + "qaContent and toolSesion compatible:");
+ return true;
+ }
+
+ /**
+ * persists error messages to request scope
+ * @param request
+ * @param message
+ */
+ public void persistError(HttpServletRequest request, String message)
+ {
+ ActionMessages errors= new ActionMessages();
+ errors.add(Globals.ERROR_KEY, new ActionMessage(message));
+ logger.debug(logger + " " + this.getClass().getName() + "add " + message +" to ActionMessages:");
+ saveErrors(request,errors);
+ }
+}
Index: lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/QaStarterAction.java
===================================================================
diff -u
--- lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/QaStarterAction.java (revision 0)
+++ lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/QaStarterAction.java (revision 16e844de3f7c34b44baee1b28e67e708f42d00bf)
@@ -0,0 +1,414 @@
+/**
+ * Created on 8/03/2005
+ * initializes the tool's authoring mode
+ */
+
+package org.lamsfoundation.lams.tool.qa.web;
+import java.io.IOException;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.TreeMap;
+
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import org.lamsfoundation.lams.usermanagement.User;
+
+import org.apache.log4j.Logger;
+import org.apache.struts.Globals;
+import org.apache.struts.action.Action;
+import org.apache.struts.action.ActionForm;
+import org.apache.struts.action.ActionForward;
+import org.apache.struts.action.ActionMapping;
+import org.apache.struts.action.ActionMessage;
+import org.apache.struts.action.ActionMessages;
+import org.lamsfoundation.lams.tool.qa.QaAppConstants;
+import org.lamsfoundation.lams.tool.qa.QaApplicationException;
+import org.lamsfoundation.lams.tool.qa.QaComparator;
+import org.lamsfoundation.lams.tool.qa.QaContent;
+import org.lamsfoundation.lams.tool.qa.QaQueContent;
+import org.lamsfoundation.lams.tool.qa.QaUtils;
+import org.lamsfoundation.lams.tool.qa.service.IQaService;
+import org.lamsfoundation.lams.tool.qa.service.QaServiceProxy;
+
+/**
+ * TODO: change DEVELOPMENT_FLAG to false once the container creates and passes users to the tool
+ * Assumption: Session attribute ATTR_USERDATA will be passed to the tool to hold User object
+ *
+ * DEFAULT_CONTENT_ID is hardcoded for the moment, it will probably go.
+ * DEFAULT_QUE_CONTENT_ID is hardcoded for the moment, it will probably go.
+ *
+ * We won't need to create a mock user once the usernames are defined properly in the container and passed to the tool
+ take off User mockUser=QaUtils.createMockUser();
+ *
+ * QaStarterAction loads the default content and initialize the presentation Map
+ *
+ * */
+
+public class QaStarterAction extends Action implements QaAppConstants {
+ static Logger logger = Logger.getLogger(QaStarterAction.class.getName());
+
+ /**
+ * A Map data structure is used to present the UI.
+ * It is fetched by subsequent Action classes to manipulate its content and gets parsed in the presentation layer for display.
+ */
+ protected Map mapQuestionContent= new TreeMap(new QaComparator());
+
+ public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response)
+ throws IOException, ServletException, QaApplicationException {
+
+ QaAuthoringForm qaAuthoringForm = (QaAuthoringForm) form;
+ qaAuthoringForm.resetRadioBoxes();
+ logger.debug(logger + " " + this.getClass().getName() + "reset radioboxes");
+
+ request.getSession().setAttribute(IS_DEFINE_LATER,"false");
+ request.getSession().setAttribute(DISABLE_TOOL,"");
+
+ /**
+ * retrive the service
+ */
+ IQaService qaService = QaUtils.getToolService(request);
+ logger.debug(logger + " " + this.getClass().getName() + "retrieving qaService from session: " + qaService);
+ if (qaService == null)
+ {
+ qaService = QaServiceProxy.getQaService(getServlet().getServletContext());
+ logger.debug(logger + " " + this.getClass().getName() + "retrieving qaService from proxy: " + qaService);
+ request.getSession().setAttribute(TOOL_SERVICE, qaService);
+ }
+
+ /**
+ * mark the http session as an authoring activity
+ */
+ request.getSession().setAttribute(TARGET_MODE,TARGET_MODE_AUTHORING);
+
+ /**
+ * define tab controllers for jsp
+ */
+ request.getSession().setAttribute(CHOICE_TYPE_BASIC,CHOICE_TYPE_BASIC);
+ request.getSession().setAttribute(CHOICE_TYPE_ADVANCED,CHOICE_TYPE_ADVANCED);
+ request.getSession().setAttribute(CHOICE_TYPE_INSTRUCTIONS,CHOICE_TYPE_INSTRUCTIONS);
+
+ request.getSession().setAttribute(EDITACTIVITY_EDITMODE, new Boolean(false));
+ request.setAttribute(FORM_INDEX, "0");
+
+ /**
+ * obtain and setup the current user's data
+ */
+ String userId="";
+ User toolUser=(User)request.getSession().getAttribute(TOOL_USER);
+ if (toolUser != null)
+ userId=toolUser.getUserId().toString();
+ else
+ {
+ userId=request.getParameter(USER_ID);
+ try
+ {
+ User user=QaUtils.createAuthoringUser(new Integer(userId));
+ request.getSession().setAttribute(TOOL_USER, user);
+ }
+ catch(NumberFormatException e)
+ {
+ persistError(request,"error.userId.notNumeric");
+ request.setAttribute(USER_EXCEPTION_USERID_NOTNUMERIC, new Boolean(true));
+ logger.debug(logger + " " + this.getClass().getName() + "forwarding to: " + LOAD_QUESTIONS);
+ return (mapping.findForward(LOAD_QUESTIONS));
+ }
+ }
+
+ if ((userId == null) || (userId.length()==0))
+ {
+ logger.debug(logger + " " + this.getClass().getName() + "error: The tool expects userId");
+ persistError(request,"error.authoringUser.notAvailable");
+ request.setAttribute(USER_EXCEPTION_USERID_NOTAVAILABLE, new Boolean(true));
+ logger.debug(logger + " " + this.getClass().getName() + "forwarding to: " + MONITORING_ERROR);
+ return (mapping.findForward(LOAD_QUESTIONS));
+ }
+
+
+ /**
+ * find out whether the request is coming from monitoring module for EditActivity tab or from authoring environment url
+ */
+ String strToolContentId="";
+ Boolean isMonitoringEditActivityVisited=(Boolean)request.getSession().getAttribute(MONITORING_EDITACTIVITY_VISITED);
+ logger.debug(logger + " " + this.getClass().getName() + "isMonitoringEditActivityVisited: " + isMonitoringEditActivityVisited);
+
+ Long monitoredContentId=(Long)request.getSession().getAttribute(MONITORED_CONTENT_ID);
+ logger.debug(logger + " " + this.getClass().getName() + "MONITORED_CONTENT_ID: " + monitoredContentId);
+
+ request.getSession().setAttribute(RENDER_MONITORING_EDITACTIVITY,new Boolean(false));
+
+ Boolean startMonitoringSummaryRequest=(Boolean)request.getAttribute(START_MONITORING_SUMMARY_REQUEST);
+ if ((startMonitoringSummaryRequest != null) && (startMonitoringSummaryRequest.booleanValue()))
+ {
+ logger.debug(logger + " " + this.getClass().getName() + "will render Monitoring summary screen");
+ if ((isMonitoringEditActivityVisited != null) && (isMonitoringEditActivityVisited.booleanValue()))
+ {
+ if (monitoredContentId != null)
+ {
+ /**
+ * request is from Edit Activity tab in monitoring
+ */
+ strToolContentId=monitoredContentId.toString();
+ logger.debug(logger + " " + this.getClass().getName() + "request is from Edit Activity tab in monitoring: " + monitoredContentId);
+ logger.debug(logger + " " + this.getClass().getName() + "using MONITORED_CONTENT_ID: " + monitoredContentId);
+ request.getSession().setAttribute(RENDER_MONITORING_EDITACTIVITY,new Boolean(true));
+ }
+ }
+ }
+ else
+ {
+ logger.debug(logger + " " + this.getClass().getName() + "will render authoring screen");
+ /**
+ * request is from authoring environment
+ */
+ request.setAttribute(START_MONITORING_SUMMARY_REQUEST, new Boolean(false));
+ logger.debug(logger + " " + this.getClass().getName() + "request is from authoring environment: ");
+ strToolContentId=request.getParameter(TOOL_CONTENT_ID);
+ }
+ logger.debug(logger + " " + this.getClass().getName() + "usable strToolContentId: " + strToolContentId);
+
+ /**
+ * Process incoming tool content id
+ * Either exists or not exists in the db yet, a toolContentId must be passed to the tool from the container
+ */
+ long toolContentId=0;
+ try
+ {
+ toolContentId=new Long(strToolContentId).longValue();
+ logger.debug(logger + " " + this.getClass().getName() + "passed TOOL_CONTENT_ID : " + toolContentId);
+ request.getSession().setAttribute(TOOL_CONTENT_ID,strToolContentId);
+ }
+ catch(NumberFormatException e)
+ {
+ persistError(request,"error.numberFormatException");
+ request.setAttribute(USER_EXCEPTION_NUMBERFORMAT, new Boolean(true));
+ logger.debug(logger + " " + this.getClass().getName() + "forwarding to: " + LOAD_QUESTIONS);
+ return (mapping.findForward(LOAD_QUESTIONS));
+ }
+
+
+ /**
+ * find out if the passed tool content id exists in the db
+ * present user either a first timer screen with default content data or fetch the existing content.
+ *
+ * if the toolcontentid does not exist in the db, create the default Map,
+ * there is no need to check if the content is locked in this case.
+ * It is always unlocked since it is the default content.
+ */
+ if (!existsContent(toolContentId, request))
+ {
+ /**
+ * get default content from db, user never created any content before
+ */
+ logger.debug(logger + " " + this.getClass().getName() + " " + "getting default content with id:" + DEFAULT_CONTENT_ID);
+ QaContent defaultQaContent = qaService.retrieveQa(DEFAULT_CONTENT_ID);
+ logger.debug(logger + " " + this.getClass().getName() + " " + defaultQaContent);
+
+ /**
+ * this is a new content creation, the content must always be unlocked
+ */
+ request.getSession().setAttribute(CONTENT_LOCKED, new Boolean(false));
+ logger.debug(logger + " " + this.getClass().getName() + "CONTENT_LOCKED: " + request.getSession().getAttribute(CONTENT_LOCKED));
+
+ if (defaultQaContent == null)
+ {
+ logger.debug(logger + " " + this.getClass().getName() + "Exception occured: " + " No DEFAULT_CONTENT_ID");
+ request.setAttribute(USER_EXCEPTION_DEFAULTCONTENT_NOT_AVAILABLE, new Boolean(true));
+ persistError(request,"error.defaultContent.notAvailable");
+ return (mapping.findForward(LOAD_QUESTIONS));
+ }
+
+ QaUtils.setDefaultSessionAttributes(request, defaultQaContent, qaAuthoringForm);
+ logger.debug(logger + " " + this.getClass().getName() + "set UsernameVisible to OFF: ");
+ qaAuthoringForm.setUsernameVisible(OFF);
+ logger.debug(logger + " " + this.getClass().getName() + "UsernameVisible: " + qaAuthoringForm.getUsernameVisible());
+ qaAuthoringForm.setQuestionsSequenced(OFF);
+ qaAuthoringForm.setSynchInMonitor(OFF);
+
+ /**
+ * get default question content
+ */
+ QaQueContent defaultQaQueContent = qaService.retrieveQaQue(DEFAULT_QUE_CONTENT_ID);
+ logger.debug(logger + " " + this.getClass().getName() + " " + defaultQaQueContent);
+
+ if (defaultQaQueContent == null)
+ {
+ logger.debug(logger + " " + this.getClass().getName() + "Exception occured: " + " No DEFAULT_CONTENT_ID");
+ request.setAttribute(USER_EXCEPTION_DEFAULTQUESTIONCONTENT_NOT_AVAILABLE, new Boolean(true));
+ persistError(request,"error.defaultQuestionContent.notAvailable");
+ return (mapping.findForward(LOAD_QUESTIONS));
+ }
+
+ /**
+ * display a single sample question
+ */
+ System.out.println(this.getClass().getName() + " set default qa que content to: " + defaultQaQueContent.getQuestion() );
+ request.getSession().setAttribute(DEFAULT_QUESTION_CONTENT, defaultQaQueContent.getQuestion());
+
+ mapQuestionContent.clear();
+ /**
+ * place the default question as the first entry in the Map
+ */
+ mapQuestionContent.put(INITIAL_QUESTION_COUNT,request.getSession().getAttribute(DEFAULT_QUESTION_CONTENT));
+ logger.debug(logger + " " + this.getClass().getName() + "Map initialized with default contentid to: " + mapQuestionContent);
+ }
+ else
+ {
+ /**
+ * fetch the existing content from db, user will be presented with her previously created content data
+ * Note that the content might have been LOCKED if one or more learner has started activuties with this content
+ */
+ logger.debug(logger + " " + this.getClass().getName() + " " + "getting existing content with id:" + toolContentId);
+ QaContent defaultQaContent = qaService.retrieveQa(toolContentId);
+ logger.debug(logger + " " + this.getClass().getName() + " " + defaultQaContent);
+
+ boolean studentActivity=qaService.studentActivityOccurredGlobal(defaultQaContent);
+ logger.debug(logger + " " + this.getClass().getName() + "studentActivity on content: " + studentActivity);
+ if (studentActivity)
+ {
+ logger.debug(logger + " " + this.getClass().getName() + "forward to warning screen as the content is not allowed to be modified.");
+ ActionMessages errors= new ActionMessages();
+ errors.add(Globals.ERROR_KEY, new ActionMessage("error.content.inUse"));
+ saveErrors(request,errors);
+ request.getSession().setAttribute(CONTENT_LOCKED, new Boolean(true));
+ logger.debug(logger + " " + this.getClass().getName() + "forward to:" + LOAD);
+ return (mapping.findForward(LOAD));
+ }
+
+ request.getSession().setAttribute(CONTENT_LOCKED, new Boolean(isContentLocked(defaultQaContent)));
+ logger.debug(logger + " " + this.getClass().getName() + "CONTENT_LOCKED: " + request.getSession().getAttribute(CONTENT_LOCKED));
+
+ QaUtils.setDefaultSessionAttributes(request, defaultQaContent, qaAuthoringForm);
+
+ /**
+ * determine the satus of radio boxes
+ */
+ logger.debug(logger + " " + this.getClass().getName() + "IS_USERNAME_VISIBLE: " + defaultQaContent.isUsernameVisible());
+ logger.debug(logger + " " + this.getClass().getName() + "set UsernameVisible to : " + defaultQaContent.isUsernameVisible());
+ if (defaultQaContent.isUsernameVisible())
+ qaAuthoringForm.setUsernameVisible(ON);
+ else
+ qaAuthoringForm.setUsernameVisible(OFF);
+ logger.debug(logger + " " + this.getClass().getName() + "UsernameVisible: " + qaAuthoringForm.getUsernameVisible());
+ if (defaultQaContent.isSynchInMonitor())
+ qaAuthoringForm.setSynchInMonitor(ON);
+ else
+ qaAuthoringForm.setSynchInMonitor(OFF);
+
+ if (defaultQaContent.isQuestionsSequenced())
+ qaAuthoringForm.setQuestionsSequenced(ON);
+ else
+ qaAuthoringForm.setQuestionsSequenced(OFF);
+
+ request.getSession().setAttribute(IS_USERNAME_VISIBLE_MONITORING, new Boolean(defaultQaContent.isUsernameVisible()));
+ request.getSession().setAttribute(IS_SYNCH_INMONITOR_MONITORING, new Boolean(defaultQaContent.isSynchInMonitor()));
+ request.getSession().setAttribute(IS_QUESTIONS_SEQUENCED_MONITORING, new Boolean(defaultQaContent.isQuestionsSequenced()));
+ request.getSession().setAttribute(IS_DEFINE_LATER, new Boolean(defaultQaContent.isDefineLater()));
+ request.getSession().setAttribute(REPORT_TITLE, defaultQaContent.getReportTitle());
+ request.getSession().setAttribute(MONITORING_REPORT_TITLE, defaultQaContent.getMonitoringReportTitle());
+ request.getSession().setAttribute(OFFLINE_INSTRUCTIONS, defaultQaContent.getOfflineInstructions());
+ request.getSession().setAttribute(ONLINE_INSTRUCTIONS, defaultQaContent.getOnlineInstructions());
+ request.getSession().setAttribute(END_LEARNING_MESSSAGE, defaultQaContent.getEndLearningMessage());
+ request.getSession().setAttribute(CREATION_DATE, defaultQaContent.getCreationDate());
+
+ logger.debug(logger + " " + this.getClass().getName() + "IS_QUESTIONS_SEQUENCED_MONITORING: " +
+ request.getSession().getAttribute(IS_QUESTIONS_SEQUENCED_MONITORING));
+
+ logger.debug(logger + " " + this.getClass().getName() + "IS_DEFINE_LATER: " +
+ request.getSession().getAttribute(IS_DEFINE_LATER));
+
+ /**
+ * get the existing question content
+ */
+ logger.debug(logger + " " + this.getClass().getName() + " " + "setting existing content data from the db");
+ mapQuestionContent.clear();
+ Iterator queIterator=defaultQaContent.getQaQueContents().iterator();
+ Long mapIndex=new Long(1);
+ logger.debug(logger + " " + this.getClass().getName() + " " + "mapQuestionContent: " + mapQuestionContent);
+ while (queIterator.hasNext())
+ {
+ QaQueContent qaQueContent=(QaQueContent) queIterator.next();
+ if (qaQueContent != null)
+ {
+ logger.debug(logger + " " + this.getClass().getName() + " " + "question: " + qaQueContent.getQuestion());
+ mapQuestionContent.put(mapIndex.toString(),qaQueContent.getQuestion());
+ /**
+ * make the first entry the default(first) one for jsp
+ */
+ if (mapIndex.longValue() == 1)
+ request.getSession().setAttribute(DEFAULT_QUESTION_CONTENT, qaQueContent.getQuestion());
+ mapIndex=new Long(mapIndex.longValue()+1);
+ }
+ }
+ logger.debug(logger + " " + this.getClass().getName() + "Map initialized with existing contentid to: " + mapQuestionContent);
+ }
+
+ request.getSession().setAttribute(MAP_QUESTION_CONTENT, mapQuestionContent);
+ logger.debug(logger + " " + this.getClass().getName() + "starter initialized the Comparable Map: " + request.getSession().getAttribute("mapQuestionContent") );
+ /**
+ * load questions page
+ */
+
+ logger.debug(logger + " " + this.getClass().getName() + "START_MONITORING_SUMMARY_REQUEST: " + request.getAttribute(START_MONITORING_SUMMARY_REQUEST));
+ logger.debug(logger + " " + this.getClass().getName() + "RENDER_MONITORING_EDITACTIVITY: " + request.getAttribute(RENDER_MONITORING_EDITACTIVITY));
+ qaAuthoringForm.resetUserAction();
+ return (mapping.findForward(LOAD_QUESTIONS));
+ }
+
+
+ /**
+ * existsContent(long toolContentId)
+ * @param long toolContentId
+ * @return boolean
+ * determine whether a specific toolContentId exists in the db
+ */
+ protected boolean existsContent(long toolContentId, HttpServletRequest request)
+ {
+ /**
+ * retrive the service
+ */
+ IQaService qaService =QaUtils.getToolService(request);
+ logger.debug(logger + " " + this.getClass().getName() + "retrieving qaService: " + qaService);
+
+ QaContent qaContent=qaService.loadQa(toolContentId);
+ logger.debug(logger + " " + this.getClass().getName() + "retrieving qaContent: " + qaContent);
+ if (qaContent == null)
+ return false;
+
+ return true;
+ }
+
+ /**
+ * find out if the content is locked or not. If it is a locked content, the author can not modify it.
+ * @param qaContent
+ * @return
+ */
+ protected boolean isContentLocked(QaContent qaContent)
+ {
+ logger.debug(logger + " " + this.getClass().getName() + "is content locked: " + qaContent.isContentLocked());
+ return qaContent.isContentLocked();
+ }
+
+
+ public ActionForward startMonitoringSummary(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response)
+ throws IOException, ServletException, QaApplicationException
+ {
+ request.setAttribute(START_MONITORING_SUMMARY_REQUEST, new Boolean(true));
+ return execute(mapping, form, request, response);
+ }
+
+
+ /**
+ * persists error messages to request scope
+ * @param request
+ * @param message
+ */
+ public void persistError(HttpServletRequest request, String message)
+ {
+ ActionMessages errors= new ActionMessages();
+ errors.add(Globals.ERROR_KEY, new ActionMessage(message));
+ logger.debug(logger + " " + this.getClass().getName() + "add " + message +" to ActionMessages:");
+ saveErrors(request,errors);
+ }
+
+}
Index: lams_tool_laqa/test/java/org/lamsfoundation/lams/tool/qa/AbstractQaTestCase.java
===================================================================
diff -u
--- lams_tool_laqa/test/java/org/lamsfoundation/lams/tool/qa/AbstractQaTestCase.java (revision 0)
+++ lams_tool_laqa/test/java/org/lamsfoundation/lams/tool/qa/AbstractQaTestCase.java (revision 16e844de3f7c34b44baee1b28e67e708f42d00bf)
@@ -0,0 +1,46 @@
+
+package org.lamsfoundation.lams.tool.qa;
+
+import org.springframework.context.ApplicationContext;
+import org.springframework.context.support.ClassPathXmlApplicationContext;
+
+import junit.framework.TestCase;
+
+
+/**
+ * @author Jacky Fang
+ *
+ */
+public abstract class AbstractQaTestCase extends TestCase
+{
+ protected ApplicationContext context;
+ protected final long TEST_LESSON_ID=1;
+ /**
+ * @param name
+ */
+ public AbstractQaTestCase(String name)
+ {
+ super(name);
+ }
+
+ /**
+ * @see TestCase#setUp()
+ */
+ protected void setUp() throws Exception
+ {
+ super.setUp();
+ System.out.println("AbstractQaTestCase: done with abstract super setup");
+ context = new ClassPathXmlApplicationContext(getContextConfigLocation());
+ System.out.println("AbstractQaTestCase: context" + context);
+ }
+
+ protected abstract String[] getContextConfigLocation();
+ /**
+ * @see TestCase#tearDown()
+ */
+ protected void tearDown() throws Exception
+ {
+ super.tearDown();
+ }
+
+}
Index: lams_tool_laqa/test/java/org/lamsfoundation/lams/tool/qa/AllTests.java
===================================================================
diff -u
--- lams_tool_laqa/test/java/org/lamsfoundation/lams/tool/qa/AllTests.java (revision 0)
+++ lams_tool_laqa/test/java/org/lamsfoundation/lams/tool/qa/AllTests.java (revision 16e844de3f7c34b44baee1b28e67e708f42d00bf)
@@ -0,0 +1,32 @@
+/*
+ * Created on 1/04/2005
+ *
+ * TODO To change the template for this generated file go to
+ * Window - Preferences - Java - Code Style - Code Templates
+ */
+package org.lamsfoundation.lams.tool.qa;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+/**
+ * @author ozgurd
+ *
+ * TODO To change the template for this generated type comment go to
+ * Window - Preferences - Java - Code Style - Code Templates
+ */
+public class AllTests {
+
+ public static void main(String[] args) {
+ junit.textui.TestRunner.run(AllTests.suite());
+ }
+
+ public static Test suite() {
+ TestSuite suite = new TestSuite("QaTestSuite");
+ //$JUnit-BEGIN$
+ suite.addTestSuite(org.lamsfoundation.lams.tool.qa.TestQaContent.class);
+
+ //$JUnit-END$
+ return suite;
+ }
+}
\ No newline at end of file
Index: lams_tool_laqa/test/java/org/lamsfoundation/lams/tool/qa/QaContent.hbm.xml
===================================================================
diff -u
--- lams_tool_laqa/test/java/org/lamsfoundation/lams/tool/qa/QaContent.hbm.xml (revision 0)
+++ lams_tool_laqa/test/java/org/lamsfoundation/lams/tool/qa/QaContent.hbm.xml (revision 16e844de3f7c34b44baee1b28e67e708f42d00bf)
@@ -0,0 +1,177 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Index: lams_tool_laqa/test/java/org/lamsfoundation/lams/tool/qa/QaDataAccessTestCase.java
===================================================================
diff -u
--- lams_tool_laqa/test/java/org/lamsfoundation/lams/tool/qa/QaDataAccessTestCase.java (revision 0)
+++ lams_tool_laqa/test/java/org/lamsfoundation/lams/tool/qa/QaDataAccessTestCase.java (revision 16e844de3f7c34b44baee1b28e67e708f42d00bf)
@@ -0,0 +1,143 @@
+package org.lamsfoundation.lams.tool.qa;
+
+import java.util.Date;
+import java.util.TreeSet;
+
+import org.lamsfoundation.lams.AbstractLamsTestCase;
+import org.lamsfoundation.lams.tool.qa.dao.hibernate.QaContentDAO;
+import org.lamsfoundation.lams.tool.qa.dao.hibernate.QaQueContentDAO;
+import org.lamsfoundation.lams.tool.qa.dao.hibernate.QaQueUsrDAO;
+import org.lamsfoundation.lams.tool.qa.dao.hibernate.QaSessionDAO;
+import org.lamsfoundation.lams.tool.qa.dao.hibernate.QaUsrRespDAO;
+
+
+
+/**
+ * @author ozgurd
+ */
+public class QaDataAccessTestCase extends AbstractLamsTestCase
+{
+ //These both refer to the same entry in the db.
+ protected final long TEST_EXISTING_CONTENT_ID = 10;
+ protected final long DEFAULT_CONTENT_ID = 10;
+
+ protected final long TEST_NEW_CONTENT_ID = 11;
+
+ protected final long TEST_EXISTING_SESSION_ID = 101;
+ protected final long TEST_NEW_SESSION_ID = 102;
+
+ protected final long TEST_NEW_USER_ID = 700;
+ protected final long TEST_EXISTING_QUE_CONTENT_ID = 20;
+ protected final long TEST_NEW_QUE_CONTENT_ID = 23;
+
+ protected final long TEST_NONEXISTING_CONTENT_ID=2475733396382404l;
+
+ protected final long ONE_DAY = 60 * 60 * 1000 * 24;
+
+ public final String NOT_ATTEMPTED = "NOT_ATTEMPTED";
+ public final String INCOMPLETE = "INCOMPLETE";
+ public static String COMPLETED = "COMPLETED";
+
+ protected QaContentDAO qaContentDAO;
+ protected QaSessionDAO qaSessionDAO;
+ protected QaQueUsrDAO qaQueUsrDAO;
+ protected QaQueContentDAO qaQueContentDAO;
+ protected QaUsrRespDAO qaUsrRespDAO;
+
+
+ protected QaSession qaSession;
+ protected QaQueContent qaQueContent;
+
+
+ public QaDataAccessTestCase(String name)
+ {
+ super(name);
+ }
+
+ protected void setUp() throws Exception
+ {
+ super.setUp();
+ qaContentDAO = (QaContentDAO) this.context.getBean("qaContentDAO");
+ qaSessionDAO = (QaSessionDAO) this.context.getBean("qaSessionDAO");
+ qaQueUsrDAO = (QaQueUsrDAO) this.context.getBean("qaQueUsrDAO");
+ qaQueContentDAO = (QaQueContentDAO) this.context.getBean("qaQueContentDAO");
+ qaUsrRespDAO = (QaUsrRespDAO) this.context.getBean("qaUsrRespDAO");
+
+ }
+
+ protected String[] getContextConfigLocation()
+ {
+ System.out.println("QaDataAccessTestCase will be configured");
+ return new String[] {"qaCompactApplicationContext.xml"};
+ }
+
+ protected String getHibernateSessionFactoryName()
+ {
+ return "qaCompactSessionFactory";
+ }
+
+ protected void tearDown() throws Exception
+ {
+ super.tearDown();
+ }
+
+
+ protected QaQueUsr getExistingUser2(String username, String fullname)
+ {
+ QaQueContent qaQueContent = qaQueContentDAO.getQaQueById(TEST_NEW_QUE_CONTENT_ID);
+ QaSession qaSession = qaSessionDAO.getQaSessionById(TEST_NEW_SESSION_ID);
+
+ QaQueUsr qaQueUsr= new QaQueUsr(new Long(TEST_NEW_USER_ID),
+ username,
+ fullname,
+ qaQueContent,
+ qaSession,
+ new TreeSet());
+ qaQueUsrDAO.createUsr(qaQueUsr);
+ return qaQueUsr;
+ }
+
+
+ protected QaQueUsr getExistingUser(String username, String fullname)
+ {
+ QaQueContent qaQueContent = qaQueContentDAO.getQaQueById(TEST_EXISTING_QUE_CONTENT_ID);
+ QaSession qaSession = qaSessionDAO.getQaSessionById(TEST_EXISTING_SESSION_ID);
+
+ QaQueUsr qaQueUsr= new QaQueUsr(new Long(TEST_NEW_USER_ID),
+ username,
+ fullname,
+ qaQueContent,
+ qaSession,
+ new TreeSet());
+ qaQueUsrDAO.createUsr(qaQueUsr);
+ return qaQueUsr;
+ }
+
+
+ protected QaUsrResp getNewResponse(String response, QaQueContent qaQueContent)
+ {
+ QaUsrResp qaUsrResp= new QaUsrResp(response, false,
+ new Date(System.currentTimeMillis()),
+ qaQueContent,
+ getExistingUser("randomstriker","Michael Random"));
+ qaUsrRespDAO.createUserResponse(qaUsrResp);
+ return qaUsrResp;
+ }
+
+ protected QaUsrResp getExistingResponse(String response)
+ {
+ QaQueContent qaQueContent = qaQueContentDAO.getQaQueById(TEST_EXISTING_QUE_CONTENT_ID);
+
+ QaUsrResp qaUsrResp= new QaUsrResp(response, false,
+ new Date(System.currentTimeMillis()),
+ qaQueContent,
+ getExistingUser("randomstriker","Michael Random"));
+ qaUsrRespDAO.createUserResponse(qaUsrResp);
+ return qaUsrResp;
+ }
+
+
+
+
+
+}
Index: lams_tool_laqa/test/java/org/lamsfoundation/lams/tool/qa/QaQueContent.hbm.xml
===================================================================
diff -u
--- lams_tool_laqa/test/java/org/lamsfoundation/lams/tool/qa/QaQueContent.hbm.xml (revision 0)
+++ lams_tool_laqa/test/java/org/lamsfoundation/lams/tool/qa/QaQueContent.hbm.xml (revision 16e844de3f7c34b44baee1b28e67e708f42d00bf)
@@ -0,0 +1,100 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Index: lams_tool_laqa/test/java/org/lamsfoundation/lams/tool/qa/QaQueUsr.hbm.xml
===================================================================
diff -u
--- lams_tool_laqa/test/java/org/lamsfoundation/lams/tool/qa/QaQueUsr.hbm.xml (revision 0)
+++ lams_tool_laqa/test/java/org/lamsfoundation/lams/tool/qa/QaQueUsr.hbm.xml (revision 16e844de3f7c34b44baee1b28e67e708f42d00bf)
@@ -0,0 +1,83 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Index: lams_tool_laqa/test/java/org/lamsfoundation/lams/tool/qa/QaSession.hbm.xml
===================================================================
diff -u
--- lams_tool_laqa/test/java/org/lamsfoundation/lams/tool/qa/QaSession.hbm.xml (revision 0)
+++ lams_tool_laqa/test/java/org/lamsfoundation/lams/tool/qa/QaSession.hbm.xml (revision 16e844de3f7c34b44baee1b28e67e708f42d00bf)
@@ -0,0 +1,85 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Index: lams_tool_laqa/test/java/org/lamsfoundation/lams/tool/qa/QaUsrResp.hbm.xml
===================================================================
diff -u
--- lams_tool_laqa/test/java/org/lamsfoundation/lams/tool/qa/QaUsrResp.hbm.xml (revision 0)
+++ lams_tool_laqa/test/java/org/lamsfoundation/lams/tool/qa/QaUsrResp.hbm.xml (revision 16e844de3f7c34b44baee1b28e67e708f42d00bf)
@@ -0,0 +1,66 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Index: lams_tool_laqa/test/java/org/lamsfoundation/lams/tool/qa/TestQaContent.java
===================================================================
diff -u
--- lams_tool_laqa/test/java/org/lamsfoundation/lams/tool/qa/TestQaContent.java (revision 0)
+++ lams_tool_laqa/test/java/org/lamsfoundation/lams/tool/qa/TestQaContent.java (revision 16e844de3f7c34b44baee1b28e67e708f42d00bf)
@@ -0,0 +1,163 @@
+/* ********************************************************************************
+ * Copyright Notice
+ * =================
+ * This file contains propriety information of LAMS Foundation.
+ * Copying or reproduction with prior written permission is prohibited.
+ * Copyright (c) 2004
+ * Created on 2004-12-23
+ ******************************************************************************** */
+
+package org.lamsfoundation.lams.tool.qa;
+
+import java.util.Iterator;
+
+
+/*
+ *
+ * @author ozgurd
+ *
+ * TODO To change the template for this generated type comment go to
+ * Window - Preferences - Java - Code Style - Code Templates
+ */
+
+/**
+ * Test case for QaContent
+ */
+
+public class TestQaContent extends QaDataAccessTestCase
+{
+ protected void setUp() throws Exception
+ {
+ super.setUp();
+ }
+
+ protected void tearDown() throws Exception
+ {
+ super.tearDown();
+ }
+
+ public TestQaContent(String name)
+ {
+ super(name);
+ }
+
+ /*
+ public void testCreateNewQaContent()
+ {
+ //create new qa content
+ QaContent qa = new QaContent();
+ qa.setQaContentId(new Long(TEST_NEW_CONTENT_ID));
+ qa.setTitle("New - Put Title Here");
+ qa.setInstructions("New - Put instructions here.");
+ qa.setCreationDate(new Date(System.currentTimeMillis()));
+ qa.setCreatedBy(0);
+ qa.setUsernameVisible(false);
+ qa.setDefineLater(false);
+ qa.setSynchInMonitor(false);
+ qa.setOnlineInstructions("New- online instructions");
+ qa.setOfflineInstructions("New- offline instructions");
+ qa.setReportTitle("New-Report title");
+ qa.setQaQueContents(new TreeSet());
+ qa.setQaSessions(new TreeSet());
+
+ //create new qa que content
+ QaQueContent qaQueContent = new QaQueContent("What planet are you from",
+ 4,
+ qa,
+ new TreeSet(),
+ new TreeSet());
+
+ qa.getQaQueContents().add(qaQueContent);
+
+ //create the new content
+ qaContentDAO.createQa(qa);
+
+
+ qaSession = new QaSession(new Long(TEST_NEW_SESSION_ID),
+ new Date(System.currentTimeMillis()),
+ new Date(System.currentTimeMillis()+ ONE_DAY),
+ this.NOT_ATTEMPTED,
+ qa,
+ new TreeSet());
+
+ qaSession.setQaContent(qa);
+
+ //create new qa que response
+ qaQueContent.getQaUsrResps().add(getNewResponse("I am from Venus", qaQueContent));
+
+ //create a new session with the new content
+ qaSessionDAO.CreateQaSession(qaSession);
+ System.out.println(this.getClass().getName() + " New session created: " + qa);
+ }
+ */
+
+
+
+
+ public void testCreateDefaultQaContent()
+ {
+ QaContent defaultQaContent = qaContentDAO.getQaById(DEFAULT_CONTENT_ID);
+ System.out.println(this.getClass().getName() + " Default qa content: " + defaultQaContent.getQaQueContents());
+ Iterator queIterator=defaultQaContent.getQaQueContents().iterator();
+ System.out.println(this.getClass().getName() + " \nqueIterator: " + queIterator);
+ while (queIterator.hasNext())
+ {
+ System.out.println(this.getClass().getName() + " \nin loop");
+ QaQueContent qaQueContent=(QaQueContent) queIterator.next();
+ System.out.println(this.getClass().getName() + " \nquestion: " + qaQueContent.getQuestion());
+ }
+ }
+
+
+
+
+ /*
+ public void testCreateExistingQaContent()
+ {
+ QaContent defaultQaContent = qaContentDAO.getQaById(242453535L);
+ if (defaultQaContent == null)
+ {
+ System.out.println(this.getClass().getName() + " Default qa content: " + defaultQaContent);
+ }
+ else
+ {
+ System.out.println(this.getClass().getName() + " other content: ");
+ }
+ }
+ */
+
+
+ /*
+ public void testIdGeneration()
+ {
+ System.out.println(this.getClass().getName() + " generated id: " + QaUtils.generateId());
+ }
+ */
+
+ /*
+ public void testRemoveNewQaContent()
+ {
+ qaContentDAO.removeQa(new Long(TEST_NEW_CONTENT_ID));
+ System.out.println("New content removed: ");
+ }
+ */
+
+ /*
+ public void testRemoveQaContent()
+ {
+ // qaQueContentDAO.removeQueContent(TEST_EXISTING_QUE_CONTENT_ID);
+ // System.out.println(this.getClass().getName() + " TEST_EXISTING_QUE_CONTENT_ID removed");
+
+ qaContentDAO.removeQa(new Long(DEFAULT_CONTENT_ID));
+ System.out.println(this.getClass().getName() + " DEFAULT_CONTENT_ID removed");
+ }
+ */
+
+ public void testRemoveQaContent()
+ {
+ QaContent qaContent = qaContentDAO.loadQaById(TEST_NONEXISTING_CONTENT_ID);
+ System.out.println(this.getClass().getName() + "qaContent loaded : " + qaContent);
+ }
+
+
+}
\ No newline at end of file
Index: lams_tool_laqa/test/java/org/lamsfoundation/lams/tool/qa/TestQaQueContent.java
===================================================================
diff -u
--- lams_tool_laqa/test/java/org/lamsfoundation/lams/tool/qa/TestQaQueContent.java (revision 0)
+++ lams_tool_laqa/test/java/org/lamsfoundation/lams/tool/qa/TestQaQueContent.java (revision 16e844de3f7c34b44baee1b28e67e708f42d00bf)
@@ -0,0 +1,100 @@
+/* ********************************************************************************
+ * Copyright Notice
+ * =================
+ * This file contains propriety information of LAMS Foundation.
+ * Copying or reproduction with prior written permission is prohibited.
+ * Copyright (c) 2004
+ * Created on 2004-12-23
+ ******************************************************************************** */
+
+package org.lamsfoundation.lams.tool.qa;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.TreeMap;
+/*
+ *
+ * @author ozgurd
+ *
+ * TODO To change the template for this generated type comment go to
+ * Window - Preferences - Java - Code Style - Code Templates
+ */
+
+/**
+ * Test case for QaQueContent
+ */
+
+public class TestQaQueContent extends QaDataAccessTestCase
+{
+ protected void setUp() throws Exception
+ {
+ super.setUp();
+ }
+
+ protected void tearDown() throws Exception
+ {
+ super.tearDown();
+ }
+
+ public TestQaQueContent(String name)
+ {
+ super(name);
+ }
+
+/*
+ public void testCreateQaQueContent()
+ {
+ QaContent qaContent = qaContentDAO.getQaById(DEFAULT_CONTENT_ID);
+ System.out.println(this.getClass().getName() + "qa content: " + qaContent);
+
+ QaQueContent qaQueContent= new QaQueContent("ozgur's new question test",
+ 1,
+ qaContent,
+ null,
+ null);
+
+ System.out.println(this.getClass().getName() + " qaQueContent: " + qaQueContent);
+ qaQueContentDAO.createQueContent(qaQueContent);
+ System.out.println(this.getClass().getName() + " qaQueContent created: ");
+ }
+ */
+
+ /*
+ public void testCreateQaQueContentMap()
+ {
+ Map mapQuestionContent= new TreeMap();
+ mapQuestionContent.put(new Long(1).toString(), "questionEntry -1");
+ mapQuestionContent.put(new Long(2).toString(), "questionEntry -2");
+
+ QaContent qaContent = qaContentDAO.getQaById(DEFAULT_CONTENT_ID);
+ System.out.println(this.getClass().getName() + "qa content: " + qaContent);
+
+
+ Iterator itMap = mapQuestionContent.entrySet().iterator();
+ while (itMap.hasNext())
+ {
+ Map.Entry pairs = (Map.Entry)itMap.next();
+
+ QaQueContent queContent= new QaQueContent(pairs.getValue().toString(),
+ new Long(pairs.getKey().toString()).intValue(),
+ qaContent,
+ null,
+ null);
+
+ queContent.setQaContent(qaContent);
+ qaContent.getQaQueContents().add(queContent);
+ qaContentDAO.createQa(qaContent);
+ System.out.println(this.getClass().getName() + " queContent: " + queContent);
+ }
+ }
+ */
+ public void testCreateDefaultQaQueContent()
+ {
+ QaQueContent defaultQaQueContent = qaQueContentDAO.getQaQueById(TEST_EXISTING_QUE_CONTENT_ID);
+ System.out.println(this.getClass().getName() + " Default qa que content: " + defaultQaQueContent);
+ }
+
+
+
+
+
+}
\ No newline at end of file
Index: lams_tool_laqa/test/java/org/lamsfoundation/lams/tool/qa/TestQaQueUsr.java
===================================================================
diff -u
--- lams_tool_laqa/test/java/org/lamsfoundation/lams/tool/qa/TestQaQueUsr.java (revision 0)
+++ lams_tool_laqa/test/java/org/lamsfoundation/lams/tool/qa/TestQaQueUsr.java (revision 16e844de3f7c34b44baee1b28e67e708f42d00bf)
@@ -0,0 +1,61 @@
+/* ********************************************************************************
+ * Copyright Notice
+ * =================
+ * This file contains propriety information of LAMS Foundation.
+ * Copying or reproduction with prior written permission is prohibited.
+ * Copyright (c) 2004
+ * Created on 2004-12-20
+ ******************************************************************************** */
+
+package org.lamsfoundation.lams.tool.qa;
+
+import java.util.TreeSet;
+
+
+/**
+ * This test is designed to test all service provided by SurveyQueUsr domain
+ * class
+ * @author ozgurd
+ *
+ */
+
+/**
+ * Test case for TestQaQueUsr
+ */
+
+public class TestQaQueUsr extends QaDataAccessTestCase
+{
+ protected void setUp() throws Exception
+ {
+ super.setUp();
+ }
+
+ protected void tearDown() throws Exception
+ {
+ super.tearDown();
+
+ }
+
+
+ public TestQaQueUsr(String name)
+ {
+ super(name);
+ }
+
+
+ public void testCreateNewUser()
+ {
+ QaQueContent qaQueContent = qaQueContentDAO.getQaQueById(TEST_EXISTING_QUE_CONTENT_ID);
+ QaSession qaSession = qaSessionDAO.getQaSessionById(TEST_EXISTING_SESSION_ID);
+
+ QaQueUsr qaQueUsr= new QaQueUsr(new Long(TEST_NEW_USER_ID),
+ "john",
+ "John Baker",
+ qaQueContent,
+ qaSession,
+ new TreeSet());
+ qaQueUsrDAO.createUsr(qaQueUsr);
+ }
+
+
+}
Index: lams_tool_laqa/test/java/org/lamsfoundation/lams/tool/qa/TestQaSession.java
===================================================================
diff -u
--- lams_tool_laqa/test/java/org/lamsfoundation/lams/tool/qa/TestQaSession.java (revision 0)
+++ lams_tool_laqa/test/java/org/lamsfoundation/lams/tool/qa/TestQaSession.java (revision 16e844de3f7c34b44baee1b28e67e708f42d00bf)
@@ -0,0 +1,122 @@
+/* ********************************************************************************
+ * Copyright Notice
+ * =================
+ * This file contains propriety information of LAMS Foundation.
+ * Copying or reproduction with prior written permission is prohibited.
+ * Copyright (c) 2004
+ * Created on 2004-12-23
+ ******************************************************************************** */
+
+package org.lamsfoundation.lams.tool.qa;
+
+import java.util.Iterator;
+import java.util.Map;
+import java.util.TreeMap;
+
+
+/*
+ *
+ * @author ozgurd
+ *
+ * TODO To change the template for this generated type comment go to
+ * Window - Preferences - Java - Code Style - Code Templates
+ */
+
+/**
+ * Test case for TestQaSession
+ */
+
+public class TestQaSession extends QaDataAccessTestCase
+{
+
+ protected final long DEVELOPMENT_TOOL_SESSION_ID= 1160776126064221551L;
+ protected void setUp() throws Exception
+ {
+ super.setUp();
+ }
+
+ protected void tearDown() throws Exception
+ {
+ super.tearDown();
+ }
+
+ public TestQaSession(String name)
+ {
+ super(name);
+ }
+
+ protected long getTestQaContentID()
+ {
+ return this.TEST_EXISTING_CONTENT_ID;
+ }
+
+ /*
+ public void testGetExistingSession()
+ {
+ QaContent qa = qaContentDAO.getQaById(getTestQaContentID());
+ System.out.println(this.getClass().getName() + " gets: " + qa);
+ }
+ */
+
+ /*
+ public void testCreateNewSession()
+ {
+ QaContent qa = qaContentDAO.getQaById(getTestQaContentID());
+
+ qaSession = new QaSession(new Long(TEST_NEW_SESSION_ID),
+ new Date(System.currentTimeMillis()),
+ new Date(System.currentTimeMillis()+ ONE_DAY),
+ this.NOT_ATTEMPTED,
+ qa,
+ new TreeSet());
+
+
+ qaSessionDAO.CreateQaSession(qaSession);
+ System.out.println(this.getClass().getName() + " New session created: " + qaSession);
+
+ qaSessionDAO.deleteQaSession(qaSession);
+ System.out.println(this.getClass().getName() + " New session deleted: ");
+ }
+ */
+
+ public void testDevToolSession()
+ {
+ QaSession qaSession=qaSessionDAO.getQaSessionById(this.DEVELOPMENT_TOOL_SESSION_ID);
+ //System.out.println(this.getClass().getName() + " Retrieved session : " + qaSession);
+
+ QaContent qaContent=qaSession.getQaContent();
+ //System.out.println(this.getClass().getName() + " \nSession has content id : " + qaContent);
+
+ Map mapQuestions= new TreeMap(new QaComparator());
+
+ //get iterator of questions collection
+ Iterator contentIterator=qaContent.getQaQueContents().iterator();
+ while (contentIterator.hasNext())
+ {
+ QaQueContent qaQueContent=(QaQueContent)contentIterator.next();
+ System.out.println(this.getClass().getName() + "\n question : " + qaQueContent.getDisplayOrder() + " " + qaQueContent.getQuestion());
+ String displayOrder= new Integer(qaQueContent.getDisplayOrder()).toString();
+ mapQuestions.put(displayOrder,qaQueContent.getQuestion());
+ }
+ System.out.println(this.getClass().getName() + "\n mapQuestions is ready" + mapQuestions);
+
+
+ Iterator itMap = mapQuestions.entrySet().iterator();
+ int diplayOrder=0;
+ while (itMap.hasNext())
+ {
+ Map.Entry pairs = (Map.Entry)itMap.next();
+ System.out.println(this.getClass().getName() + "\n pairs.key: " + pairs.getKey());
+ }
+
+
+
+
+
+
+
+
+ }
+
+
+}
\ No newline at end of file
Index: lams_tool_laqa/test/java/org/lamsfoundation/lams/tool/qa/TestQaUsrResp.java
===================================================================
diff -u
--- lams_tool_laqa/test/java/org/lamsfoundation/lams/tool/qa/TestQaUsrResp.java (revision 0)
+++ lams_tool_laqa/test/java/org/lamsfoundation/lams/tool/qa/TestQaUsrResp.java (revision 16e844de3f7c34b44baee1b28e67e708f42d00bf)
@@ -0,0 +1,57 @@
+/* ********************************************************************************
+ * Copyright Notice
+ * =================
+ * This file contains propriety information of LAMS Foundation.
+ * Copying or reproduction with prior written permission is prohibited.
+ * Copyright (c) 2004
+ * Created on 2004-12-20
+ ******************************************************************************** */
+
+package org.lamsfoundation.lams.tool.qa;
+
+import java.util.Date;
+
+
+/**
+ * This test is designed to test all service provided by SurveyQueUsr domain
+ * class
+ * @author ozgurd
+ *
+ */
+
+/**
+ * Test case for TestQaUsrResp
+ */
+
+public class TestQaUsrResp extends QaDataAccessTestCase
+{
+ protected void setUp() throws Exception
+ {
+ super.setUp();
+ }
+
+ protected void tearDown() throws Exception
+ {
+ super.tearDown();
+
+ }
+
+
+ public TestQaUsrResp(String name)
+ {
+ super(name);
+ }
+
+
+ public void testCreateNewResponse()
+ {
+ QaQueContent qaQueContent = qaQueContentDAO.getQaQueById(TEST_EXISTING_QUE_CONTENT_ID);
+
+ QaUsrResp qaUsrResp= new QaUsrResp("I am from Mars",false,
+ new Date(System.currentTimeMillis()),
+ qaQueContent,
+ getExistingUser("randomstriker","Michael Random"));
+ qaUsrRespDAO.createUserResponse(qaUsrResp);
+ }
+
+}
Index: lams_tool_laqa/test/java/org/lamsfoundation/lams/tool/qa/dbConnection.properties
===================================================================
diff -u
--- lams_tool_laqa/test/java/org/lamsfoundation/lams/tool/qa/dbConnection.properties (revision 0)
+++ lams_tool_laqa/test/java/org/lamsfoundation/lams/tool/qa/dbConnection.properties (revision 16e844de3f7c34b44baee1b28e67e708f42d00bf)
@@ -0,0 +1,19 @@
+# Properties file with Hibernate-related settings.
+# Applied by PropertyPlaceholderConfigurer from "dbConnection.xml".
+# Targetted at system administrators, to avoid touching the context XML files.
+
+#jdbc configuration
+jdbc.driverClassName=org.gjt.mm.mysql.Driver
+jdbc.url=jdbc:mysql://localhost/lams
+jdbc.username=root
+jdbc.password=root
+
+#Hibernate configuration
+hibernate.show_sql=true
+hibernate.dialect=net.sf.hibernate.dialect.MySQLDialect
+
+#Connection Pooling configuration
+hibernate.c3p0.minPoolSize=5
+hibernate.c3p0.maxPoolSize=20
+hibernate.c3p0.timeout=1800
+hibernate.c3p0.max_statement=50
\ No newline at end of file
Index: lams_tool_laqa/test/java/org/lamsfoundation/lams/tool/qa/qaCompactApplicationContext.xml
===================================================================
diff -u
--- lams_tool_laqa/test/java/org/lamsfoundation/lams/tool/qa/qaCompactApplicationContext.xml (revision 0)
+++ lams_tool_laqa/test/java/org/lamsfoundation/lams/tool/qa/qaCompactApplicationContext.xml (revision 16e844de3f7c34b44baee1b28e67e708f42d00bf)
@@ -0,0 +1,177 @@
+
+
+
+
+
+
+
+
+
+
+
+
+ dbConnection.properties
+
+
+
+
+
+
+
+ ${jdbc.driverClassName}
+ ${jdbc.url}
+ ${jdbc.username}
+ ${jdbc.password}
+
+
+
+
+
+
+
+
+ QaContent.hbm.xml
+ QaSession.hbm.xml
+ QaQueContent.hbm.xml
+ QaQueUsr.hbm.xml
+ QaUsrResp.hbm.xml
+
+
+
+
+ ${hibernate.dialect}
+ ${hibernate.show_sql}
+ ${hibernate.c3p0.minPoolSize}
+ ${hibernate.c3p0.maxPoolSize}
+ ${hibernate.c3p0.timeout}
+ ${hibernate.c3p0.max_statement}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ PROPAGATION_REQUIRED,-QaApplicationException
+ PROPAGATION_REQUIRED,-QaApplicationException
+ PROPAGATION_REQUIRED,-QaApplicationException
+ PROPAGATION_REQUIRED,readOnly,-QacpApplicationException
+ PROPAGATION_REQUIRED,-QaApplicationException
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ PROPAGATION_REQUIRED,-QaApplicationException
+
+
+
+
+
+
+
+
+
Index: lams_tool_laqa/web/AdvancedContent.jsp
===================================================================
diff -u
--- lams_tool_laqa/web/AdvancedContent.jsp (revision 0)
+++ lams_tool_laqa/web/AdvancedContent.jsp (revision 16e844de3f7c34b44baee1b28e67e708f42d00bf)
@@ -0,0 +1,94 @@
+<%@ taglib uri="/WEB-INF/struts-html-el.tld" prefix="html" %>
+<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
+<%@ taglib uri="/WEB-INF/struts-logic-el.tld" prefix="logic-el" %>
+<%@ taglib uri="/WEB-INF/c.tld" prefix="c" %>
+<%@ taglib uri="/WEB-INF/fmt.tld" prefix="fmt" %>
+
+