Index: lams_tool_laqa/build.properties =================================================================== diff -u -r036a57201d0fd2c383c67e5af4b5ac0b5c9db7c4 -r0af4ed13b963a588f3499b080801863d57f8ad95 --- lams_tool_laqa/build.properties (.../build.properties) (revision 036a57201d0fd2c383c67e5af4b5ac0b5c9db7c4) +++ lams_tool_laqa/build.properties (.../build.properties) (revision 0af4ed13b963a588f3499b080801863d57f8ad95) @@ -4,7 +4,7 @@ signature=laqa11 #version of this project -tool.version=20080108 +tool.version=20080926 # hide tool option hideTool=false Index: lams_tool_laqa/conf/hibernate/mappings/org/lamsfoundation/lams/tool/qa/QaCondition.hbm.xml =================================================================== diff -u --- lams_tool_laqa/conf/hibernate/mappings/org/lamsfoundation/lams/tool/qa/QaCondition.hbm.xml (revision 0) +++ lams_tool_laqa/conf/hibernate/mappings/org/lamsfoundation/lams/tool/qa/QaCondition.hbm.xml (revision 0af4ed13b963a588f3499b080801863d57f8ad95) @@ -0,0 +1,39 @@ + + + + + + + + + + + + + + + + + + + \ No newline at end of file Index: lams_tool_laqa/conf/hibernate/mappings/org/lamsfoundation/lams/tool/qa/QaContent.hbm.xml =================================================================== diff -u -r1046868d6997114f3b043778a68b371e03182faf -r0af4ed13b963a588f3499b080801863d57f8ad95 --- lams_tool_laqa/conf/hibernate/mappings/org/lamsfoundation/lams/tool/qa/QaContent.hbm.xml (.../QaContent.hbm.xml) (revision 1046868d6997114f3b043778a68b371e03182faf) +++ lams_tool_laqa/conf/hibernate/mappings/org/lamsfoundation/lams/tool/qa/QaContent.hbm.xml (.../QaContent.hbm.xml) (revision 0af4ed13b963a588f3499b080801863d57f8ad95) @@ -224,7 +224,24 @@ - + + + + + + + + Index: lams_tool_laqa/conf/language/lams/ApplicationResources.properties =================================================================== diff -u -raed6a7a22d1b3b1d10c2a38a687256a06a8c6eac -r0af4ed13b963a588f3499b080801863d57f8ad95 --- lams_tool_laqa/conf/language/lams/ApplicationResources.properties (.../ApplicationResources.properties) (revision aed6a7a22d1b3b1d10c2a38a687256a06a8c6eac) +++ lams_tool_laqa/conf/language/lams/ApplicationResources.properties (.../ApplicationResources.properties) (revision 0af4ed13b963a588f3499b080801863d57f8ad95) @@ -11,6 +11,7 @@ tool.description =Tool for asking one or more short answer questions and displays the results. label.basic =Basic label.advanced =Advanced +label.conditions =Conditions label.authoring.title =Title label.summary =Summary label.editActivity =Edit Activity @@ -170,5 +171,32 @@ label.other.answers =Answers from other Learners warning.empty.answers =One or more question(s) are not answered. Do you want to continue anyway? +label.authoring.heading.instructions.desc =Please enter conditions for Q&A +label.authoring.heading.conditions =Conditions +label.authoring.conditions.add.condition =Add condition +label.authoring.conditions.list.title =Conditions +label.authoring.conditions.order =Order +label.authoring.conditions.empty.condition.list =There are no conditions +label.authoring.conditions.condition.name =Name +label.authoring.edit.conditions.button =Edit conditions +label.authoring.up =Up +label.authoring.down =Down +label.authoring.edit =Edit +label.authoring.delete =Delete +error.condition.name.blank =Condition name can not be blank. +error.condition.duplicated.name =Duplicated name. Please choose unique one. +error.condition.no.questions.selected =There are no questions selected. Please select at least one. +error.condition =Error creating condition. + +output.desc.text.search.output.definition.qa =Answers contain certain words +text.search.output.definition.qa.default.condition =First answer contains word "LAMS" + +textsearch.heading =Answers that... +textsearch.all.words =have all these words: +textsearch.phrase =have this exact wording or phrase: +textsearch.any.words =have one or more of these words: +textsearch.excluded.words =have none any of these unwanted words: +textsearch.questions =Search in these questions: + #======= End labels: Exported 163 labels for en AU ===== Index: lams_tool_laqa/conf/language/lams/ApplicationResources_en_AU.properties =================================================================== diff -u -rb93c0a14919af5bff7e1a99168c91f4057799c51 -r0af4ed13b963a588f3499b080801863d57f8ad95 --- lams_tool_laqa/conf/language/lams/ApplicationResources_en_AU.properties (.../ApplicationResources_en_AU.properties) (revision b93c0a14919af5bff7e1a99168c91f4057799c51) +++ lams_tool_laqa/conf/language/lams/ApplicationResources_en_AU.properties (.../ApplicationResources_en_AU.properties) (revision 0af4ed13b963a588f3499b080801863d57f8ad95) @@ -11,6 +11,7 @@ tool.description =Tool for asking one or more short answer questions and displays the results. label.basic =Basic label.advanced =Advanced +label.conditions =Conditions label.authoring.title =Title label.summary =Summary label.editActivity =Edit Activity @@ -175,5 +176,31 @@ error.noStudentActivity =Sorry, the report can not be generated.
No student has attempted the activity yet. label.other.answers =Answers from other Learners +label.authoring.heading.instructions.desc =Please enter conditions for Q&A +label.authoring.heading.conditions =Conditions +label.authoring.conditions.add.condition =Add condition +label.authoring.conditions.list.title =Conditions +label.authoring.conditions.order =Order +label.authoring.conditions.empty.condition.list =There are no conditions +label.authoring.conditions.condition.name =Name +label.authoring.edit.conditions.button =Edit conditions +label.authoring.up =Up +label.authoring.down =Down +label.authoring.edit =Edit +label.authoring.delete =Delete +error.condition.name.blank =Condition name can not be blank. +error.condition.duplicated.name =Duplicated name. Please choose unique one. +error.condition.no.questions.selected =There are no questions selected. Please select at least one. +error.condition =Error creating condition. + +output.desc.text.search.output.definition.qa =Answers contain certain words +text.search.output.definition.qa.default.condition =First answer contains word "LAMS" + +textsearch.heading =Answers that... +textsearch.all.words =have all these words: +textsearch.phrase =have this exact wording or phrase: +textsearch.any.words =have one or more of these words: +textsearch.excluded.words =have none any of these unwanted words: +textsearch.questions =Search in these questions: #======= End labels: Exported 168 labels for en AU ===== Index: lams_tool_laqa/db/model/lams_tool_qa.clay =================================================================== diff -u -r89b6e076006b36f7edcf712cfa97b87ef9010e23 -r0af4ed13b963a588f3499b080801863d57f8ad95 --- lams_tool_laqa/db/model/lams_tool_qa.clay (.../lams_tool_qa.clay) (revision 89b6e076006b36f7edcf712cfa97b87ef9010e23) +++ lams_tool_laqa/db/model/lams_tool_qa.clay (.../lams_tool_qa.clay) (revision 0af4ed13b963a588f3499b080801863d57f8ad95) @@ -1,17 +1,17 @@ - - + + QA Tool for Lams 1.1 - + - +
- + @@ -24,7 +24,7 @@ - + @@ -37,33 +37,33 @@ - + - + - + - + - + @@ -77,13 +77,13 @@ - + - + @@ -93,11 +93,11 @@
- +
- + @@ -110,7 +110,7 @@ - + @@ -123,31 +123,31 @@ - + - + - + - + - + @@ -160,7 +160,7 @@ - + @@ -173,7 +173,7 @@ - + @@ -186,7 +186,7 @@ - + @@ -199,7 +199,7 @@ - + @@ -212,7 +212,7 @@ - + @@ -225,7 +225,7 @@ - + @@ -238,19 +238,19 @@ - + - + - + @@ -263,13 +263,13 @@ - + - + @@ -282,7 +282,7 @@ - + @@ -296,19 +296,19 @@ - +
- +
- + @@ -321,7 +321,7 @@ - + @@ -334,14 +334,14 @@ - + - + @@ -354,7 +354,7 @@ - + @@ -367,14 +367,14 @@ - + - + @@ -388,13 +388,13 @@ - + - + @@ -404,11 +404,11 @@
- +
- + - + @@ -421,19 +421,19 @@ - + - + - + @@ -446,7 +446,7 @@ - + @@ -460,13 +460,13 @@ - + - + @@ -476,11 +476,11 @@
- +
- + @@ -493,7 +493,7 @@ - + @@ -506,26 +506,26 @@ - + - + - + - + @@ -538,7 +538,7 @@ - + @@ -551,7 +551,7 @@ - + @@ -565,20 +565,20 @@ - + - + - + @@ -588,11 +588,11 @@
- +
- + @@ -605,14 +605,14 @@ - + - + @@ -625,14 +625,14 @@ - + - + @@ -646,13 +646,13 @@ - + - + @@ -662,6 +662,121 @@
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Index: lams_tool_laqa/db/sql/create_lams_tool_qa.sql =================================================================== diff -u -r28d9bd1d61f9f9177635fed69a0aff0f21230ff9 -r0af4ed13b963a588f3499b080801863d57f8ad95 --- lams_tool_laqa/db/sql/create_lams_tool_qa.sql (.../create_lams_tool_qa.sql) (revision 28d9bd1d61f9f9177635fed69a0aff0f21230ff9) +++ lams_tool_laqa/db/sql/create_lams_tool_qa.sql (.../create_lams_tool_qa.sql) (revision 0af4ed13b963a588f3499b080801863d57f8ad95) @@ -91,7 +91,26 @@ REFERENCES tl_laqa11_content (uid) )TYPE=InnoDB; +CREATE TABLE tl_laqa11_conditions ( + condition_id BIGINT(20) NOT NULL + , content_uid BIGINT(20) + , PRIMARY KEY (condition_id) + , CONSTRAINT QaConditionInheritance FOREIGN KEY (condition_id) + REFERENCES lams_branch_condition(condition_id) ON DELETE CASCADE ON UPDATE CASCADE + , CONSTRAINT QaConditionToQaContent FOREIGN KEY (content_uid) + REFERENCES tl_laqa11_content(uid) ON DELETE CASCADE ON UPDATE CASCADE +)TYPE=InnoDB; +CREATE TABLE tl_laqa11_condition_questions ( + condition_id BIGINT(20) + , question_uid BIGINT(20) + , PRIMARY KEY (condition_id,question_uid) + , CONSTRAINT QaConditionQuestionToQaCondition FOREIGN KEY (condition_id) + REFERENCES tl_laqa11_conditions(condition_id) ON DELETE CASCADE ON UPDATE CASCADE + , CONSTRAINT QaConditionQuestionToQaQuestion FOREIGN KEY (question_uid) + REFERENCES tl_laqa11_que_content(uid) ON DELETE CASCADE ON UPDATE CASCADE +)TYPE=InnoDB; + -- data for content table INSERT INTO tl_laqa11_content (qa_content_id, title, instructions, creation_date, lockWhenFinished) VALUES (${default_content_id}, 'Q&A', 'Instructions', NOW() , 0); Index: lams_tool_laqa/db/sql/drop_lams_tool_qa.sql =================================================================== diff -u -r7e9ec88b3ebb98e346843941ecfb09f57a244a10 -r0af4ed13b963a588f3499b080801863d57f8ad95 --- lams_tool_laqa/db/sql/drop_lams_tool_qa.sql (.../drop_lams_tool_qa.sql) (revision 7e9ec88b3ebb98e346843941ecfb09f57a244a10) +++ lams_tool_laqa/db/sql/drop_lams_tool_qa.sql (.../drop_lams_tool_qa.sql) (revision 0af4ed13b963a588f3499b080801863d57f8ad95) @@ -22,16 +22,12 @@ -- $Id$ SET FOREIGN_KEY_CHECKS=0; -DROP TABLE tl_laqa11_uploadedfile; -DROP TABLE tl_laqa11_usr_resp; -DROP TABLE tl_laqa11_que_content; -DROP TABLE tl_laqa11_que_usr; -DROP TABLE tl_laqa11_session; -DROP TABLE tl_laqa11_content; -SET FOREIGN_KEY_CHECKS=1; - - - - - - +DROP TABLE IF EXISTS tl_laqa11_conditions; +DROP TABLE IF EXISTS tl_laqa11_uploadedfile; +DROP TABLE IF EXISTS tl_laqa11_usr_resp; +DROP TABLE IF EXISTS tl_laqa11_que_content; +DROP TABLE IF EXISTS tl_laqa11_que_usr; +DROP TABLE IF EXISTS tl_laqa11_session; +DROP TABLE IF EXISTS tl_laqa11_content; +DROP TABLE IF EXISTS tl_laqa11_condition_questions; +SET FOREIGN_KEY_CHECKS=1; \ No newline at end of file Index: lams_tool_laqa/db/sql/tool_insert.sql =================================================================== diff -u -r691d0f5085a52d31d37cb556b134714e944d5c27 -r0af4ed13b963a588f3499b080801863d57f8ad95 --- lams_tool_laqa/db/sql/tool_insert.sql (.../tool_insert.sql) (revision 691d0f5085a52d31d37cb556b134714e944d5c27) +++ lams_tool_laqa/db/sql/tool_insert.sql (.../tool_insert.sql) (revision 0af4ed13b963a588f3499b080801863d57f8ad95) @@ -49,7 +49,8 @@ classpath_addition, context_file, create_date_time, -modified_date_time +modified_date_time, +supports_outputs ) VALUES ( @@ -79,5 +80,6 @@ 'lams-tool-laqa11.jar', '/org/lamsfoundation/lams/tool/qa/qaApplicationContext.xml', NOW(), -NOW() +NOW(), +1 ) Index: lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/QaAppConstants.java =================================================================== diff -u -reaed8e160dd64ba3f48bcdf0bb87dadf23eea2f8 -r0af4ed13b963a588f3499b080801863d57f8ad95 --- lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/QaAppConstants.java (.../QaAppConstants.java) (revision eaed8e160dd64ba3f48bcdf0bb87dadf23eea2f8) +++ lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/QaAppConstants.java (.../QaAppConstants.java) (revision 0af4ed13b963a588f3499b080801863d57f8ad95) @@ -29,247 +29,257 @@ */ public interface QaAppConstants { - public static final String MY_SIGNATURE ="laqa11"; - public static final long DEFAULT_CONTENT_ID =0; - public static final long DEFAULT_QUE_CONTENT_ID =1; - public static final String ERROR_QAAPPLICATION = "error.exception.QaApplication"; - public static final String TOOL_CONTENT_ID = "toolContentID"; - public static final String MAP_QUESTION_CONTENT_KEY = "mapQuestionContentKey"; - public static final String ATTACHMENT_LIST_KEY = "attachmentListKey"; - public static final String DELETED_ATTACHMENT_LIST_KEY = "deletedAttachmentListKey"; - public static final String ONLINE_INSTRUCTIONS_KEY = "onlineInstructionsKey"; - public static final String OFFLINE_INSTRUCTIONS_KEY = "offlineInstructionsKey"; - public static final String ACTIVITY_TITLE_KEY = "activityTitleKey"; - public static final String ACTIVITY_INSTRUCTIONS_KEY = "activityInstructionsKey"; - public static final String LIST_QUESTION_CONTENT_DTO = "listQuestionContentDTO"; - public static final String LIST_QUESTION_CONTENT_DTO_KEY = "listQuestionContentDTOKey"; + public static final String MY_SIGNATURE = "laqa11"; + public static final long DEFAULT_CONTENT_ID = 0; + public static final long DEFAULT_QUE_CONTENT_ID = 1; + public static final String ERROR_QAAPPLICATION = "error.exception.QaApplication"; + public static final String TOOL_CONTENT_ID = "toolContentID"; + public static final String MAP_QUESTION_CONTENT_KEY = "mapQuestionContentKey"; + public static final String ATTACHMENT_LIST_KEY = "attachmentListKey"; + public static final String DELETED_ATTACHMENT_LIST_KEY = "deletedAttachmentListKey"; + public static final String ONLINE_INSTRUCTIONS_KEY = "onlineInstructionsKey"; + public static final String OFFLINE_INSTRUCTIONS_KEY = "offlineInstructionsKey"; + public static final String ACTIVITY_TITLE_KEY = "activityTitleKey"; + public static final String ACTIVITY_INSTRUCTIONS_KEY = "activityInstructionsKey"; + public static final String LIST_QUESTION_CONTENT_DTO = "listQuestionContentDTO"; + public static final String LIST_QUESTION_CONTENT_DTO_KEY = "listQuestionContentDTOKey"; - 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 TARGET_MODE_EXPORT_PORTFOLIO ="ExportPortfolio"; - - public static final String TOOL_SERVICE ="toolService"; - public static final String AUTHORING_STARTER ="starter"; - public static final String TITLE ="title"; - public static final String INSTRUCTIONS ="instructions"; - public static final String LOAD_LEARNER ="loadLearner"; - public static final String LEARNING_STARTER ="learningStarter"; - public static final String MONITORING_STARTER ="monitoringStarter"; - public static final String EXPORT_PORTFOLIO ="exportPortfolio"; - public static final String VIEW_ALL_RESULTS ="viewAllResults"; - public static final String INDIVIDUAL_LEARNER_RESULTS ="individualLearnerResults"; - public static final String MAP_ALL_RESULTS_KEY ="mapAllResultsKey"; - public static final String LOAD_MONITORING ="refreshMonitoring"; - public static final String SOURCE_QA_STARTER ="sourceQaStarter"; - public static final String LOAD_VIEW_ONLY ="loadViewOnly"; - public static final String EDIT_RESPONSE ="editResponse"; - public static final String EDITABLE_RESPONSE_ID ="editableResponseId"; - public static final String COPY_TOOL_CONTENT ="copyToolContent"; - public static final String ERROR_LIST ="errorList"; - public static final String ERROR_LIST_LEARNER ="errorListLearner"; - public static final String MAP_SEQUENTIAL_ANSWERS_KEY ="mapSequentialAnswersKey"; - public static final String DEFAULT_CONTENT_ID_STR ="defaultContentIdStr"; - public static final String DEFAULT_ONLINE_INST =""; - public static final String DEFAULT_OFFLINE_INST =""; - public static final String TOOL_SESSION_ID = "toolSessionID"; - public static final String EXPORT_USER_ID ="exportUserId"; - public static final String NOTEBOOK ="notebook"; - public static final String ENTRY_TEXT ="entryText"; - public static final String REFLECTIONS_CONTAINER_DTO ="reflectionsContainerDTO"; - public static final String LEARNER_NOTEBOOK ="learnerNotebook"; - public static final String NOTEBOOK_ENTRIES_EXIST ="notebookEntriesExist"; - public static final String NO_SESSIONS_NOTEBOOK_ENTRIES_EXIST ="noSessionsNotebookEntriesExist"; - public static final String QA_STATS_DTO ="qaStatsDTO"; - public static final String LIST_ALL_GROUPS_DTO ="listAllGroupsDTO"; - public static final String CURRENT_SESSION_NAME ="currentSessionName"; - - public static final String ACTIVE_MODULE ="activeModule"; - public static final String AUTHORING ="authoring"; - public static final String MONITORING ="monitoring"; - public static final String DEFINE_LATER_IN_EDIT_MODE ="defineLaterInEditMode"; - public static final String REMOVABLE_QUESTION_INDEX ="removableQuestionIndex"; - public static final String SHOW_AUTHORING_TABS ="showAuthoringTabs"; - public static final String MONITORING_ORIGINATED_DEFINELATER ="monitoringOriginatedDefineLater"; - public static final String DEFINE_LATER ="defineLater"; - public static final String REQUESTED_MODULE ="requestedModule"; - public static final String SYNC_IN_MONITOR ="synchInMonitor"; - public static final String USERNAME_VISIBLE ="usernameVisible"; - public static final String QUESTIONS_SEQUENCED ="questionsSequenced"; - - public static final String SOURCE_MC_STARTER ="sourceMcStarter"; - public static final Integer MAX_QUESTION_COUNT =new Integer(50); + 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 TARGET_MODE_EXPORT_PORTFOLIO = "ExportPortfolio"; - public static final String RUN_OFFLINE ="runOffline"; - public static final String REFLECT ="reflect"; - public static final String REFLECTION_SUBJECT ="reflectionSubject"; - - public static final String IS_MONITORED_CONTENT_IN_USE ="isMonitoredContentInUse"; - public static final String LOAD_MONITORING_CONTENT_EDITACTIVITY ="loadMonitoringEditActivity"; - public static final String IS_PORTFOLIO_EXPORT ="isPortfolioExport"; - public static final String GENERAL_LEARNER_FLOW_DTO ="generalLearnerFlowDTO"; - - public static final Long INITIAL_QUESTION_COUNT =new Long(1); - public static final String QA_GENERAL_AUTHORING_DTO ="qaGeneralAuthoringDTO"; - public static final String QA_GENERAL_MONITORING_DTO ="qaGeneralMonitoringDTO"; - + public static final String TOOL_SERVICE = "toolService"; + public static final String AUTHORING_STARTER = "starter"; + public static final String TITLE = "title"; + public static final String INSTRUCTIONS = "instructions"; + public static final String LOAD_LEARNER = "loadLearner"; + public static final String LEARNING_STARTER = "learningStarter"; + public static final String MONITORING_STARTER = "monitoringStarter"; + public static final String EXPORT_PORTFOLIO = "exportPortfolio"; + public static final String VIEW_ALL_RESULTS = "viewAllResults"; + public static final String INDIVIDUAL_LEARNER_RESULTS = "individualLearnerResults"; + public static final String MAP_ALL_RESULTS_KEY = "mapAllResultsKey"; + public static final String LOAD_MONITORING = "refreshMonitoring"; + public static final String SOURCE_QA_STARTER = "sourceQaStarter"; + public static final String LOAD_VIEW_ONLY = "loadViewOnly"; + public static final String EDIT_RESPONSE = "editResponse"; + public static final String EDITABLE_RESPONSE_ID = "editableResponseId"; + public static final String COPY_TOOL_CONTENT = "copyToolContent"; + public static final String ERROR_LIST = "errorList"; + public static final String ERROR_LIST_LEARNER = "errorListLearner"; + public static final String MAP_SEQUENTIAL_ANSWERS_KEY = "mapSequentialAnswersKey"; + public static final String DEFAULT_CONTENT_ID_STR = "defaultContentIdStr"; + public static final String DEFAULT_ONLINE_INST = ""; + public static final String DEFAULT_OFFLINE_INST = ""; + public static final String TOOL_SESSION_ID = "toolSessionID"; + public static final String EXPORT_USER_ID = "exportUserId"; + public static final String NOTEBOOK = "notebook"; + public static final String ENTRY_TEXT = "entryText"; + public static final String REFLECTIONS_CONTAINER_DTO = "reflectionsContainerDTO"; + public static final String LEARNER_NOTEBOOK = "learnerNotebook"; + public static final String NOTEBOOK_ENTRIES_EXIST = "notebookEntriesExist"; + public static final String NO_SESSIONS_NOTEBOOK_ENTRIES_EXIST = "noSessionsNotebookEntriesExist"; + public static final String QA_STATS_DTO = "qaStatsDTO"; + public static final String LIST_ALL_GROUPS_DTO = "listAllGroupsDTO"; + public static final String CURRENT_SESSION_NAME = "currentSessionName"; + + public static final String ACTIVE_MODULE = "activeModule"; + public static final String AUTHORING = "authoring"; + public static final String MONITORING = "monitoring"; + public static final String DEFINE_LATER_IN_EDIT_MODE = "defineLaterInEditMode"; + public static final String REMOVABLE_QUESTION_INDEX = "removableQuestionIndex"; + public static final String SHOW_AUTHORING_TABS = "showAuthoringTabs"; + public static final String MONITORING_ORIGINATED_DEFINELATER = "monitoringOriginatedDefineLater"; + public static final String DEFINE_LATER = "defineLater"; + public static final String REQUESTED_MODULE = "requestedModule"; + public static final String SYNC_IN_MONITOR = "synchInMonitor"; + public static final String USERNAME_VISIBLE = "usernameVisible"; + public static final String QUESTIONS_SEQUENCED = "questionsSequenced"; + + public static final String SOURCE_MC_STARTER = "sourceMcStarter"; + public static final Integer MAX_QUESTION_COUNT = new Integer(50); + + public static final String RUN_OFFLINE = "runOffline"; + public static final String REFLECT = "reflect"; + public static final String REFLECTION_SUBJECT = "reflectionSubject"; + + public static final String IS_MONITORED_CONTENT_IN_USE = "isMonitoredContentInUse"; + public static final String LOAD_MONITORING_CONTENT_EDITACTIVITY = "loadMonitoringEditActivity"; + public static final String IS_PORTFOLIO_EXPORT = "isPortfolioExport"; + public static final String GENERAL_LEARNER_FLOW_DTO = "generalLearnerFlowDTO"; + + public static final Long INITIAL_QUESTION_COUNT = new Long(1); + public static final String QA_GENERAL_AUTHORING_DTO = "qaGeneralAuthoringDTO"; + public static final String QA_GENERAL_MONITORING_DTO = "qaGeneralMonitoringDTO"; + /* * 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 IS_DEFINE_LATER ="isDefineLater"; - public static final String LEARNING_MODE ="learningMode"; - public static final String PORTFOLIO_EXPORT_MODE ="portfolioExportMode"; - + public static final String LOAD = "load"; + public static final String LOAD_QUESTIONS = "load"; + public static final String LOAD_STARTER = "starter"; + public static final String IS_DEFINE_LATER = "isDefineLater"; + public static final String LEARNING_MODE = "learningMode"; + public static final String PORTFOLIO_EXPORT_MODE = "portfolioExportMode"; + public static final String SUCCESS = "success"; + /* * 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"; - public static final String SELECTION_CASE ="selectionCase"; - + */ + public static final String IS_ADD_QUESTION = "isAddQuestion"; + public static final String IS_REMOVE_QUESTION = "isRemoveQuestion"; + public static final String IS_REMOVE_CONTENT = "isRemoveContent"; + public static final String SELECTION_CASE = "selectionCase"; + /* * authoring mode constants */ - public static final String MAP_QUESTION_CONTENT ="mapQuestionContent"; - public static final String DEFAULT_QUESTION_CONTENT ="defaultQuestionContent"; - 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 ON ="ON"; - public static final String OFF ="OFF"; - public static final String RICHTEXT_OFFLINEINSTRUCTIONS ="richTextOfflineInstructions"; - public static final String RICHTEXT_ONLINEINSTRUCTIONS ="richTextOnlineInstructions"; - public static final String RICHTEXT_TITLE ="richTextTitle"; - public static final String RICHTEXT_INSTRUCTIONS ="richTextInstructions"; - public static final String RICHTEXT_BLANK ="

 

"; + public static final String MAP_QUESTION_CONTENT = "mapQuestionContent"; + public static final String DEFAULT_QUESTION_CONTENT = "defaultQuestionContent"; + 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 ON = "ON"; + public static final String OFF = "OFF"; + public static final String RICHTEXT_OFFLINEINSTRUCTIONS = "richTextOfflineInstructions"; + public static final String RICHTEXT_ONLINEINSTRUCTIONS = "richTextOnlineInstructions"; + public static final String RICHTEXT_TITLE = "richTextTitle"; + public static final String RICHTEXT_INSTRUCTIONS = "richTextInstructions"; + public static final String RICHTEXT_BLANK = "

 

"; - public static final String SUBMIT_OFFLINE_FILE ="submitOfflineFile"; - public static final String SUBMIT_ONLINE_FILE ="submitOnlineFile"; - public static final String POPULATED_UPLOADED_FILESDATA ="populateUploadedFilesData"; - public static final String USER_ID = "userID"; - - 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 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_USER_DOESNOTEXIST ="userExceptionUserDoesNotExist"; - public static final String USER_EXCEPTION_MONITORINGTAB_CONTENTID_REQUIRED ="userExceptionMonitoringTabContentIdRequired"; - public static final String USER_EXCEPTION_DEFAULTCONTENT_NOTSETUP ="userExceptionDefaultContentNotSetup"; - public static final String USER_EXCEPTION_NO_TOOL_SESSIONS ="userExceptionNoToolSessions"; - public static final String USER_EXCEPTION_NO_STUDENT_ACTIVITY ="userExceptionNoStudentActivity"; - public static final String USER_EXCEPTION_CONTENT_IN_USE ="userExceptionContentInUse"; - public static final String USER_EXCEPTION_RUN_OFFLINE ="userExceptionRunOffline"; - public static final String USER_EXCEPTION_MODE_REQUIRED ="userExceptionModeRequired"; - public static final String USER_EXCEPTION_MODE_INVALID ="userExceptionModeInvalid"; - public static final String USER_EXCEPTION_QUESTIONS_DUPLICATE ="userExceptionQuestionsDuplicate"; - public static final String COUNT_SESSION_COMPLETE ="countSessionComplete"; - public static final String CURRENT_MONITORED_TOOL_SESSION ="currentMonitoredToolSession"; - - - public static final String COUNT_ALL_USERS ="countAllUsers"; - public static final String LIST_MONITORED_ANSWERS_CONTAINER_DTO ="listMonitoredAnswersContainerDto"; - public static final String SUMMARY_TOOL_SESSIONS ="summaryToolSessions"; - public static final String SUMMARY_TOOL_SESSIONS_ID ="summaryToolSessionsId"; - public static final String EDIT_ACTIVITY_DTO ="editActivityDTO"; - - public static final String ACTIVITY_TITLE ="activityTitle"; - public static final String ACTIVITY_INSTRUCTIONS ="activityInstructions"; - public static final String IS_USERNAME_VISIBLE ="isUsernameVisible"; - public static final String CURRENT_ANSWER ="currentAnswer"; + public static final String SUBMIT_OFFLINE_FILE = "submitOfflineFile"; + public static final String SUBMIT_ONLINE_FILE = "submitOnlineFile"; + public static final String POPULATED_UPLOADED_FILESDATA = "populateUploadedFilesData"; + public static final String USER_ID = "userID"; - + 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 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_USER_DOESNOTEXIST = "userExceptionUserDoesNotExist"; + public static final String USER_EXCEPTION_MONITORINGTAB_CONTENTID_REQUIRED = "userExceptionMonitoringTabContentIdRequired"; + public static final String USER_EXCEPTION_DEFAULTCONTENT_NOTSETUP = "userExceptionDefaultContentNotSetup"; + public static final String USER_EXCEPTION_NO_TOOL_SESSIONS = "userExceptionNoToolSessions"; + public static final String USER_EXCEPTION_NO_STUDENT_ACTIVITY = "userExceptionNoStudentActivity"; + public static final String USER_EXCEPTION_CONTENT_IN_USE = "userExceptionContentInUse"; + public static final String USER_EXCEPTION_RUN_OFFLINE = "userExceptionRunOffline"; + public static final String USER_EXCEPTION_MODE_REQUIRED = "userExceptionModeRequired"; + public static final String USER_EXCEPTION_MODE_INVALID = "userExceptionModeInvalid"; + public static final String USER_EXCEPTION_QUESTIONS_DUPLICATE = "userExceptionQuestionsDuplicate"; + public static final String COUNT_SESSION_COMPLETE = "countSessionComplete"; + public static final String CURRENT_MONITORED_TOOL_SESSION = "currentMonitoredToolSession"; + + public static final String COUNT_ALL_USERS = "countAllUsers"; + public static final String LIST_MONITORED_ANSWERS_CONTAINER_DTO = "listMonitoredAnswersContainerDto"; + public static final String SUMMARY_TOOL_SESSIONS = "summaryToolSessions"; + public static final String SUMMARY_TOOL_SESSIONS_ID = "summaryToolSessionsId"; + public static final String EDIT_ACTIVITY_DTO = "editActivityDTO"; + + public static final String ACTIVITY_TITLE = "activityTitle"; + public static final String ACTIVITY_INSTRUCTIONS = "activityInstructions"; + public static final String IS_USERNAME_VISIBLE = "isUsernameVisible"; + public static final String CURRENT_ANSWER = "currentAnswer"; + /* * export portfolio constants */ - public static final String MODE ="mode"; - public static final String LEARNER ="learner"; - public static final String TEACHER ="teacher"; - - public static final String PORTFOLIO_REPORT ="portfolioReport"; - public static final String PORTFOLIO_REQUEST ="portfolioRequest"; - public static final int MAX_GROUPS_COUNT =250; - + public static final String MODE = "mode"; + public static final String LEARNER = "learner"; + public static final String TEACHER = "teacher"; + + public static final String PORTFOLIO_REPORT = "portfolioReport"; + public static final String PORTFOLIO_REQUEST = "portfolioRequest"; + public static final int MAX_GROUPS_COUNT = 250; + /* * 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 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 ="isToolActivityOffline"; - 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 ="learnerRep"; - public static final String INDIVIDUAL_LEARNER_REPORT ="individualLearnerRep"; - public static final String REQUEST_LEARNING_REPORT ="requestLearningReport"; - public static final String REQUEST_LEARNING_REPORT_PROGRESS ="requestLearningReportProgress"; - public static final String REQUEST_PREVIEW ="requestPreview"; - public static final String REQUEST_LEARNING_REPORT_VIEWONLY ="requestLearningReportViewOnly"; - public static final String REVISITED_LEARNER_REP ="revisitedLearnerRep"; - - + 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 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 = "isToolActivityOffline"; + 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 = "learnerRep"; + public static final String INDIVIDUAL_LEARNER_REPORT = "individualLearnerRep"; + public static final String REQUEST_LEARNING_REPORT = "requestLearningReport"; + public static final String REQUEST_LEARNING_REPORT_PROGRESS = "requestLearningReportProgress"; + public static final String REQUEST_PREVIEW = "requestPreview"; + public static final String REQUEST_LEARNING_REPORT_VIEWONLY = "requestLearningReportViewOnly"; + public static final String REVISITED_LEARNER_REP = "revisitedLearnerRep"; + /* * Monitoring Mode constants */ - public static final String EDITACTIVITY_EDITMODE ="editActivityEditMode"; - public static final String RENDER_MONITORING_EDITACTIVITY ="renderMonitoringEditActivity"; - public static final String NO_AVAILABLE_SESSIONS ="noAvailableSessions"; - public static final String NO_TOOL_SESSIONS_AVAILABLE ="noToolSessionAvailable"; - - public static final String TIMEZONE ="timeZone"; - public static final String TIMEZONE_ID ="timeZoneId"; + public static final String EDITACTIVITY_EDITMODE = "editActivityEditMode"; + public static final String RENDER_MONITORING_EDITACTIVITY = "renderMonitoringEditActivity"; + public static final String NO_AVAILABLE_SESSIONS = "noAvailableSessions"; + public static final String NO_TOOL_SESSIONS_AVAILABLE = "noToolSessionAvailable"; + + public static final String TIMEZONE = "timeZone"; + public static final String TIMEZONE_ID = "timeZoneId"; /* * Monitor and Learning common constants - used in jsp reporting */ - - public static final String QUESTION_LISTING_MODE ="questionListingMode"; - public static final String QUESTION_LISTING_MODE_SEQUENTIAL ="questionListingModeSequential"; - public static final String QUESTION_LISTING_MODE_PREVIEW ="questionListingModePreview"; - 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 total of: "; - public static final String QUESTIONS =" questions."; - public static final String ATTACHMENT_LIST ="attachmentList"; - public static final String SUBMIT_SUCCESS ="sbmtSuccess"; - public static final String DELETED_ATTACHMENT_LIST ="deletedAttachmentList"; - public static final String UUID ="uuid"; + public static final String QUESTION_LISTING_MODE = "questionListingMode"; + public static final String QUESTION_LISTING_MODE_SEQUENTIAL = "questionListingModeSequential"; + public static final String QUESTION_LISTING_MODE_PREVIEW = "questionListingModePreview"; + 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 total of: "; + public static final String QUESTIONS = " questions."; + + public static final String ATTACHMENT_LIST = "attachmentList"; + public static final String SUBMIT_SUCCESS = "sbmtSuccess"; + public static final String DELETED_ATTACHMENT_LIST = "deletedAttachmentList"; + public static final String UUID = "uuid"; + // for condition management use + public static final String ATTR_SESSION_MAP_ID = "sessionMapID"; + public static final Object ATTR_CONDITION_SET = "conditionList"; + public static final Object ATTR_QA_AUTHORING_FORM = "QaAuthoringForm"; + public static final String PARAM_ORDER_ID = "orderId"; + public static final String ATTR_DELETED_CONDITION_LIST = "deletedConditionList"; + public static final int QUESTION_CUTOFF_INDEX = 40; + public static final String HTML_TAG_REGEX = "\\<.*?>"; + public static final String TEXT_SEARCH_DEFINITION_NAME = "text.search.output.definition"; + public static final String TEXT_SEARCH_DEFAULT_CONDITION_DISPLAY_NAME_KEY = "text.search.output.definition.default.condition"; } Index: lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/QaCondition.java =================================================================== diff -u --- lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/QaCondition.java (revision 0) +++ lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/QaCondition.java (revision 0af4ed13b963a588f3499b080801863d57f8ad95) @@ -0,0 +1,104 @@ +/**************************************************************** + * Copyright (C) 2005 LAMS Foundation (http://lamsfoundation.org) + * ============================================================= + * License Information: http://lamsfoundation.org/licensing/lams/2.0/ + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2.0 + * as published by the Free Software Foundation. + * + * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 * USA + * + * http://www.gnu.org/licenses/gpl.txt + * **************************************************************** + */ + +/* $$Id$$ */ +package org.lamsfoundation.lams.tool.qa; + +import java.util.Set; +import java.util.SortedSet; +import java.util.TreeSet; + +import org.lamsfoundation.lams.learningdesign.TextSearchCondition; +import org.lamsfoundation.lams.learningdesign.dto.BranchConditionDTO; +import org.lamsfoundation.lams.tool.OutputType; +import org.lamsfoundation.lams.tool.ToolOutput; +import org.lamsfoundation.lams.tool.ToolOutputFormatException; +import org.lamsfoundation.lams.tool.ToolOutputValue; +import org.lamsfoundation.lams.tool.qa.util.QaQueContentComparator; +import org.lamsfoundation.lams.tool.qa.util.QaQuestionContentDTOComparator; + +/** + * A text search condition with a set of questions on answers to which the search should be performed. + * + * @author Marcin Cieslak + * + */ +public class QaCondition extends TextSearchCondition { + /** + * Questions linked to this condition. Answers to them will be scanned for the words that make the condition's + * parameters. + */ + private Set questions = new TreeSet(new QaQueContentComparator()); + + public SortedSet temporaryQuestionDTOSet = new TreeSet( + new QaQuestionContentDTOComparator()); + + public QaCondition() { + + } + + public QaCondition(BranchConditionDTO conditionDTO) { + super(conditionDTO); + } + + public QaCondition(Long conditionId, Integer conditionUIID, Integer orderId, String name, String displayName, + String type, String startValue, String endValue, String exactMatchValue, String allWords, String phrase, + String anyWords, String excludedWords, Set questions) { + super(conditionId, conditionUIID, orderId, name, displayName, type, startValue, endValue, exactMatchValue, + allWords, phrase, anyWords, excludedWords); + setQuestions(questions); + } + + @Override + public boolean isMet(ToolOutput output) throws ToolOutputFormatException { + boolean result = false; + if (output != null) { + ToolOutputValue value = output.getValue(); + if (value != null) { + if (OutputType.OUTPUT_COMPLEX.equals(value.getType())) { + // the condition "knows" it's an array of strings, i.e. user's answers + String[] answers = (String[]) value.getValue(); + result = true; + for (QaQueContent question : questions) { + String textToMatch = answers[question.getDisplayOrder() - 1]; + result &= matches(textToMatch); + // if at least one answer does not satisfy the condition, there is no need to look further + if (!result) { + break; + } + } + } else { + throw new ToolOutputFormatException("Q&A produced a non-complex tool output."); + } + } + } + return result; + } + + public Set getQuestions() { + return questions; + } + + public void setQuestions(Set questions) { + this.questions = questions; + } +} \ No newline at end of file Index: lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/QaContent.java =================================================================== diff -u -r1046868d6997114f3b043778a68b371e03182faf -r0af4ed13b963a588f3499b080801863d57f8ad95 --- lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/QaContent.java (.../QaContent.java) (revision 1046868d6997114f3b043778a68b371e03182faf) +++ lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/QaContent.java (.../QaContent.java) (revision 0af4ed13b963a588f3499b080801863d57f8ad95) @@ -23,6 +23,7 @@ /* $$Id$$ */ package org.lamsfoundation.lams.tool.qa; + import java.io.Serializable; import java.util.Date; import java.util.Iterator; @@ -36,594 +37,639 @@ import org.lamsfoundation.lams.contentrepository.ItemNotFoundException; import org.lamsfoundation.lams.contentrepository.RepositoryCheckedException; import org.lamsfoundation.lams.contentrepository.client.IToolContentHandler; -import org.lamsfoundation.lams.tool.qa.QaQueContent; +import org.lamsfoundation.lams.tool.qa.util.QaConditionComparator; - /** * @author Ozgur Demirtas - * - * TODO To change the template for this generated type comment go to - * Window - Preferences - Java - Code Style - Code Templates + * + * 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 + * 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. + * 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 */ + static Logger logger = Logger.getLogger(QaContent.class.getName()); + + /** identifier field */ private Long uid; - - /** identifier field */ + + /** identifier field */ private Long qaContentId; - + /** nullable persistent field */ private String title; - + /** nullable persistent field */ private String instructions; - + /** persistent field, used for export portfolio */ private String content; - + /** 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; - + private boolean reflect; - - private String reflectionSubject; - + + private String reflectionSubject; + /** nullable persistent field */ private boolean runOffline; - + private boolean questionsSequenced; - + private boolean lockWhenFinished; - + private boolean showOtherAnswers; - + /** nullable persistent field */ private boolean usernameVisible; - + /** nullable persistent field */ private boolean synchInMonitor; - + /** nullable persistent field */ private boolean contentLocked; - + /** nullable persistent field */ private Date creationDate; - + /** nullable persistent field */ private Date updateDate; - - - /** persistent field */ + + /** persistent field */ private Set qaQueContents; - + /** persistent field */ private Set qaSessions; - + /** persistent field */ private Set qaUploadedFiles; + /** persistent field */ + private Set conditions = new TreeSet( + new QaConditionComparator()); - public QaContent(){}; - + private String nonHTMLtitle; + + public QaContent() { + }; + /** full constructor */ - public QaContent(Long qaContentId, - String content, - String title, - String instructions, - String reportTitle, - String monitoringReportTitle, - String offlineInstructions, - String onlineInstructions, - long createdBy, - boolean defineLater, - boolean runOffline, - boolean questionsSequenced, - boolean usernameVisible, - boolean synchInMonitor, - boolean lockWhenFinished, - boolean contentLocked, - boolean showOtherAnswers, - boolean reflect, - String reflectionSubject, - Date creationDate, - Date updateDate, - Set qaQueContents, - Set qaSessions, - Set qaUploadedFiles) - { - this.qaContentId = qaContentId; - this.content = content; - this.title = title; - this.instructions = instructions; - this.reportTitle = reportTitle; - this.monitoringReportTitle=monitoringReportTitle; - this.offlineInstructions = offlineInstructions; - this.onlineInstructions = onlineInstructions; - this.createdBy = createdBy; - this.defineLater = defineLater; - this.runOffline = runOffline; - this.questionsSequenced = questionsSequenced; - this.usernameVisible = usernameVisible; - this.synchInMonitor = synchInMonitor; - this.lockWhenFinished = lockWhenFinished; - this.contentLocked = contentLocked; - this.showOtherAnswers = showOtherAnswers; - this.reflect = reflect; - this.reflectionSubject =reflectionSubject; - this.creationDate = creationDate; - this.updateDate = updateDate; - this.qaQueContents = qaQueContents; - this.qaSessions = qaSessions; - this.qaUploadedFiles = qaUploadedFiles; - logger.debug(logger + " " + this.getClass().getName() + "in full constructor: QaContent()"); + public QaContent(Long qaContentId, String content, String title, + String instructions, String reportTitle, + String monitoringReportTitle, String offlineInstructions, + String onlineInstructions, long createdBy, boolean defineLater, + boolean runOffline, boolean questionsSequenced, + boolean usernameVisible, boolean synchInMonitor, + boolean lockWhenFinished, boolean contentLocked, + boolean showOtherAnswers, boolean reflect, + String reflectionSubject, Date creationDate, Date updateDate, + Set qaQueContents, Set qaSessions, Set qaUploadedFiles) { + this.qaContentId = qaContentId; + this.content = content; + this.title = title; + this.instructions = instructions; + this.reportTitle = reportTitle; + this.monitoringReportTitle = monitoringReportTitle; + this.offlineInstructions = offlineInstructions; + this.onlineInstructions = onlineInstructions; + this.createdBy = createdBy; + this.defineLater = defineLater; + this.runOffline = runOffline; + this.questionsSequenced = questionsSequenced; + this.usernameVisible = usernameVisible; + this.synchInMonitor = synchInMonitor; + this.lockWhenFinished = lockWhenFinished; + this.contentLocked = contentLocked; + this.showOtherAnswers = showOtherAnswers; + this.reflect = reflect; + this.reflectionSubject = reflectionSubject; + this.creationDate = creationDate; + this.updateDate = updateDate; + this.qaQueContents = qaQueContents; + this.qaSessions = qaSessions; + this.qaUploadedFiles = qaUploadedFiles; + QaContent.logger.debug(QaContent.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. + * 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(IToolContentHandler toolContentHandler, QaContent qa, - Long newContentId) - throws ItemNotFoundException, RepositoryCheckedException - { - QaContent newContent = new QaContent(newContentId, - qa.getContent(), - qa.getTitle(), - qa.getInstructions(), - qa.getReportTitle(), - qa.getMonitoringReportTitle(), - qa.getOfflineInstructions(), - qa.getOnlineInstructions(), - qa.getCreatedBy(), - qa.isDefineLater(), - qa.isRunOffline(), - qa.isQuestionsSequenced(), - qa.isUsernameVisible(), - qa.isSynchInMonitor(), - qa.isLockWhenFinished(), - qa.isContentLocked(), - qa.isShowOtherAnswers(), - qa.isReflect(), - qa.getReflectionSubject(), - qa.getCreationDate(), - qa.getUpdateDate(), - new TreeSet(), - new TreeSet(), - new TreeSet()); + public static QaContent newInstance(IToolContentHandler toolContentHandler, + QaContent qa, Long newContentId) throws ItemNotFoundException, + RepositoryCheckedException { + QaContent newContent = new QaContent(newContentId, qa.getContent(), qa + .getTitle(), qa.getInstructions(), qa.getReportTitle(), qa + .getMonitoringReportTitle(), qa.getOfflineInstructions(), qa + .getOnlineInstructions(), qa.getCreatedBy(), + qa.isDefineLater(), qa.isRunOffline(), qa + .isQuestionsSequenced(), qa.isUsernameVisible(), qa + .isSynchInMonitor(), qa.isLockWhenFinished(), qa + .isContentLocked(), qa.isShowOtherAnswers(), qa + .isReflect(), qa.getReflectionSubject(), qa + .getCreationDate(), qa.getUpdateDate(), new TreeSet(), + new TreeSet(), new TreeSet()); - newContent.setQaQueContents(qa.deepCopyQaQueContent(newContent)); - logger.debug(logger + " " + "QaContent" + " " + "after doing deepCopyQaQueContent"); + newContent.setQaQueContents(qa.deepCopyQaQueContent(newContent)); + QaContent.logger.debug(QaContent.logger + " " + "QaContent" + " " + + "after doing deepCopyQaQueContent"); - newContent.setQaUploadedFiles(qa.deepCopyQaAttachments(toolContentHandler, newContent)); - - return newContent; + newContent.setQaUploadedFiles(qa.deepCopyQaAttachments( + toolContentHandler, newContent)); + + return newContent; + } + + public Set deepCopyQaQueContent(QaContent newQaContent) { + QaContent.logger.debug(QaContent.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)); } + QaContent.logger.debug(QaContent.logger + " " + "QaContent" + " " + + "returning newQaQueContent: " + newQaQueContent); + return newQaQueContent; + } - 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 deepCopyQaAttachments(IToolContentHandler toolContentHandler, + QaContent newQaContent) throws ItemNotFoundException, + RepositoryCheckedException { + Set attachments = new TreeSet(); + for (Iterator i = this.getQaUploadedFiles().iterator(); i.hasNext();) { + QaUploadedFile qaUploadedFile = (QaUploadedFile) i.next(); + if (qaUploadedFile.getQaContent() != null) { + QaUploadedFile newQaUploadedFile = QaUploadedFile.newInstance( + toolContentHandler, qaUploadedFile, newQaContent); + attachments.add(newQaUploadedFile); + } + } + return attachments; } - - - public Set deepCopyQaAttachments(IToolContentHandler toolContentHandler,QaContent newQaContent) - throws ItemNotFoundException, RepositoryCheckedException - { - Set attachments = new TreeSet(); - for (Iterator i = this.getQaUploadedFiles().iterator(); i.hasNext();) - { - QaUploadedFile qaUploadedFile = (QaUploadedFile) i.next(); - if (qaUploadedFile.getQaContent() != null) - { - QaUploadedFile newQaUploadedFile=QaUploadedFile.newInstance(toolContentHandler, qaUploadedFile, - newQaContent); - attachments.add(newQaUploadedFile); - } - } - return attachments; + + public Set deepCopyQaSession(QaContent newQaSession) { + return new TreeSet(); } - - - - public Set deepCopyQaSession(QaContent newQaSession) - { - return new TreeSet(); + + public Set getQaQueContents() { + if (qaQueContents == null) { + setQaQueContents(new TreeSet()); + } + return qaQueContents; } - - - public Set getQaQueContents() - { - if (this.qaQueContents == null) - setQaQueContents(new TreeSet()); - return this.qaQueContents; + + public void setQaQueContents(Set qaQueContents) { + this.qaQueContents = qaQueContents; } - public void setQaQueContents(Set qaQueContents) - { - this.qaQueContents = qaQueContents; + public Set getQaSessions() { + if (qaSessions == null) { + setQaSessions(new TreeSet()); + } + return qaSessions; } - public Set getQaSessions() - { - if (this.qaSessions == null) - setQaSessions(new TreeSet()); - return this.qaSessions; + public void setQaSessions(Set qaSessions) { + this.qaSessions = qaSessions; } - public void setQaSessions(Set qaSessions) - { - this.qaSessions = qaSessions; + /** + * @return Returns the qaContentId. + */ + public Long getQaContentId() { + return qaContentId; } - - /** - * @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; + } + + @Override + public String toString() { + return new ToStringBuilder(this).append("qaContentId:", + getQaContentId()).append("qa title:", getTitle()).append( + "qa instructions:", getInstructions()).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( + "reflection subject: ", getReflectionSubject()).append( + "synch_in_monitor: ", isSynchInMonitor()).toString(); + } + + @Override + public boolean equals(Object other) { + if (!(other instanceof QaContent)) { + return false; } - /** - * @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("creator user id", - getCreatedBy()) - .append("username_visible:", isUsernameVisible()) - .append("defineLater", isDefineLater()) - .append("offline_instructions:", getOfflineInstructions()) - .append("online_instructions:", getOnlineInstructions()) - .append("report_title: ", getReportTitle()) - .append("reflection subject: ", getReflectionSubject()) - .append("synch_in_monitor: ", isSynchInMonitor()) - .toString(); + QaContent castOther = (QaContent) other; + return new EqualsBuilder().append(this.getQaContentId(), + castOther.getQaContentId()).isEquals(); } + @Override + public int hashCode() { + return new HashCodeBuilder().append(getQaContentId()).toHashCode(); + } - public boolean equals(Object other) - { - if (!(other instanceof QaContent)) - return false; - QaContent castOther = (QaContent) other; - return new EqualsBuilder().append(this.getQaContentId(), - castOther.getQaContentId()) - .isEquals(); + /** + * @return Returns the createdBy. + */ + public long getCreatedBy() { + return createdBy; } + /** + * @param createdBy + * The createdBy to set. + */ + public void setCreatedBy(long createdBy) { + this.createdBy = createdBy; + } - public int hashCode() - { - return new HashCodeBuilder().append(getQaContentId()).toHashCode(); + /** + * @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 createdBy. - */ - public long getCreatedBy() { - return createdBy; + /** + * @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 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; + } + + /** + * @return Returns the qaUploadedFiles. + */ + public Set getQaUploadedFiles() { + if (qaUploadedFiles == null) { + qaUploadedFiles = new TreeSet(); } - /** - * @param createdBy The createdBy to set. - */ - public void setCreatedBy(long createdBy) { - this.createdBy = createdBy; - } - /** - * @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 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; - } - /** - * @return Returns the qaUploadedFiles. - */ - public Set getQaUploadedFiles() { - if(qaUploadedFiles == null) - qaUploadedFiles = new TreeSet(); - return qaUploadedFiles; - } - /** - * @param qaUploadedFiles The qaUploadedFiles to set. - */ - public void setQaUploadedFiles(Set qaUploadedFiles) { - this.qaUploadedFiles = qaUploadedFiles; - } - /** - * @return Returns the uid. - */ - public Long getUid() { - return uid; - } - /** - * @param uid The uid to set. - */ - public void setUid(Long uid) { - this.uid = uid; - } - /** - * @return Returns the content. - */ - public String getContent() { - return content; - } - /** - * @param content The content to set. - */ - public void setContent(String content) { - this.content = content; - } + return qaUploadedFiles; + } + /** + * @param qaUploadedFiles + * The qaUploadedFiles to set. + */ + public void setQaUploadedFiles(Set qaUploadedFiles) { + this.qaUploadedFiles = qaUploadedFiles; + } + + /** + * @return Returns the uid. + */ + public Long getUid() { + return uid; + } + + /** + * @param uid + * The uid to set. + */ + public void setUid(Long uid) { + this.uid = uid; + } + + /** + * @return Returns the content. + */ + public String getContent() { + return content; + } + + /** + * @param content + * The content to set. + */ + public void setContent(String content) { + this.content = content; + } + + /** * @return Returns the logger. */ public static Logger getLogger() { - return logger; + return QaContent.logger; } + /** - * @param logger The logger to set. + * @param logger + * The logger to set. */ public static void setLogger(Logger logger) { - QaContent.logger = logger; + QaContent.logger = logger; } + /** * @return Returns the creationDate. */ public Date getCreationDate() { - return creationDate; + return creationDate; } + /** - * @param creationDate The creationDate to set. + * @param creationDate + * The creationDate to set. */ public void setCreationDate(Date creationDate) { - this.creationDate = creationDate; + this.creationDate = creationDate; } + /** * @return Returns the reflect. */ public boolean isReflect() { - return reflect; + return reflect; } + /** - * @param reflect The reflect to set. + * @param reflect + * The reflect to set. */ public void setReflect(boolean reflect) { - this.reflect = reflect; + this.reflect = reflect; } + /** * @return Returns the reflectionSubject. */ public String getReflectionSubject() { - return reflectionSubject; + return reflectionSubject; } + /** - * @param reflectionSubject The reflectionSubject to set. + * @param reflectionSubject + * The reflectionSubject to set. */ public void setReflectionSubject(String reflectionSubject) { - this.reflectionSubject = reflectionSubject; + this.reflectionSubject = reflectionSubject; } + /** * @return Returns the lockWhenFinished. */ public boolean isLockWhenFinished() { - return lockWhenFinished; + return lockWhenFinished; } + /** - * @param lockWhenFinished The lockWhenFinished to set. + * @param lockWhenFinished + * The lockWhenFinished to set. */ public void setLockWhenFinished(boolean lockWhenFinished) { - this.lockWhenFinished = lockWhenFinished; + this.lockWhenFinished = lockWhenFinished; } - + /** * @return Returns the showOtherAnswers. */ public boolean isShowOtherAnswers() { - return showOtherAnswers; + return showOtherAnswers; } + /** - * @param showOtherAnswers The showOtherAnswers to set. + * @param showOtherAnswers + * The showOtherAnswers to set. */ public void setShowOtherAnswers(boolean showOtherAnswers) { - this.showOtherAnswers = showOtherAnswers; + this.showOtherAnswers = showOtherAnswers; } - -} + + public Set getConditions() { + return conditions; + } + + public void setConditions(Set conditions) { + this.conditions = conditions; + } + + public String getNonHTMLtitle() { + if (title == null) { + return null; + } + return title.replaceAll("\\<.*?>", ""); + } +} \ No newline at end of file Index: lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/QaQuestionContentDTO.java =================================================================== diff -u -r987a74c62956d533b5e9dc73443257d7931fe40a -r0af4ed13b963a588f3499b080801863d57f8ad95 --- lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/QaQuestionContentDTO.java (.../QaQuestionContentDTO.java) (revision 987a74c62956d533b5e9dc73443257d7931fe40a) +++ lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/QaQuestionContentDTO.java (.../QaQuestionContentDTO.java) (revision 0af4ed13b963a588f3499b080801863d57f8ad95) @@ -25,70 +25,90 @@ import org.apache.commons.lang.builder.ToStringBuilder; - /** - *

DTO that holds users attempt history data for jsp purposes + *

+ * DTO that holds users attempt history data for jsp purposes *

* * @author Ozgur Demirtas */ -public class QaQuestionContentDTO implements Comparable -{ +public class QaQuestionContentDTO implements Comparable { private String question; private String displayOrder; private String feedback; - - public String toString() { - return new ToStringBuilder(this) - .append("question:", question) - .append("feedback:", feedback) - .append("displayOrder:", displayOrder) - .toString(); + + @Override + public String toString() { + return new ToStringBuilder(this).append("question:", question).append("feedback:", feedback).append( + "displayOrder:", displayOrder).toString(); } - - public int compareTo(Object o) - { - QaMonitoredUserDTO qaMonitoredUserDTO = (QaMonitoredUserDTO) o; - - if (qaMonitoredUserDTO == null) - return 1; - else - return 0; + + public int compareTo(Object o) { + QaMonitoredUserDTO qaMonitoredUserDTO = (QaMonitoredUserDTO) o; + + if (qaMonitoredUserDTO == null) { + return 1; + } else { + return 0; + } } + /** * @return Returns the displayOrder. */ public String getDisplayOrder() { - return displayOrder; + return displayOrder; } + /** - * @param displayOrder The displayOrder to set. + * @param displayOrder + * The displayOrder to set. */ public void setDisplayOrder(String displayOrder) { - this.displayOrder = displayOrder; + this.displayOrder = displayOrder; } + /** * @return Returns the feedback. */ public String getFeedback() { - return feedback; + return feedback; } + /** - * @param feedback The feedback to set. + * @param feedback + * The feedback to set. */ public void setFeedback(String feedback) { - this.feedback = feedback; + this.feedback = feedback; } + /** * @return Returns the question. */ public String getQuestion() { - return question; + return question; } + /** - * @param question The question to set. + * @param question + * The question to set. */ public void setQuestion(String question) { - this.question = question; + this.question = question; } + + @Override + public boolean equals(Object o) { + if (o instanceof QaQuestionContentDTO) { + QaQuestionContentDTO compare = (QaQuestionContentDTO) o; + return compare.getDisplayOrder().equals(getDisplayOrder()); + } + return false; + } + + @Override + public int hashCode() { + return new Integer(getDisplayOrder()); + } } Index: lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/dbupdates/patch20080926_updateFrom21.sql =================================================================== diff -u --- lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/dbupdates/patch20080926_updateFrom21.sql (revision 0) +++ lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/dbupdates/patch20080926_updateFrom21.sql (revision 0af4ed13b963a588f3499b080801863d57f8ad95) @@ -0,0 +1,20 @@ +-- SQL statements to update from LAMS 2.1/2.1.1 +CREATE TABLE tl_laqa11_conditions ( + condition_id BIGINT(20) NOT NULL + , content_uid BIGINT(20) + , PRIMARY KEY (condition_id) + , CONSTRAINT QaConditionInheritance FOREIGN KEY (condition_id) + REFERENCES lams_branch_condition(condition_id) ON DELETE CASCADE ON UPDATE CASCADE + , CONSTRAINT QaConditionToQaContent FOREIGN KEY (content_uid) + REFERENCES tl_laqa11_content(uid) ON DELETE CASCADE ON UPDATE CASCADE +)TYPE=InnoDB; + +CREATE TABLE tl_laqa11_condition_questions ( + condition_id BIGINT(20) + , question_uid BIGINT(20) + , PRIMARY KEY (condition_id,question_uid) + , CONSTRAINT QaConditionQuestionToQaCondition FOREIGN KEY (condition_id) + REFERENCES tl_laqa11_conditions(condition_id) ON DELETE CASCADE ON UPDATE CASCADE + , CONSTRAINT QaConditionQuestionToQaQuestion FOREIGN KEY (question_uid) + REFERENCES tl_laqa11_que_content(uid) ON DELETE CASCADE ON UPDATE CASCADE +)TYPE=InnoDB; \ No newline at end of file Index: lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/qaApplicationContext.xml =================================================================== diff -u -r407ec95b4825be357d61eefa7799b8fbd6a3c1bd -r0af4ed13b963a588f3499b080801863d57f8ad95 --- lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/qaApplicationContext.xml (.../qaApplicationContext.xml) (revision 407ec95b4825be357d61eefa7799b8fbd6a3c1bd) +++ lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/qaApplicationContext.xml (.../qaApplicationContext.xml) (revision 0af4ed13b963a588f3499b080801863d57f8ad95) @@ -11,25 +11,38 @@ + + + + org.lamsfoundation.lams.tool.qa.ApplicationResources + + + - + + org/lamsfoundation/lams/learningdesign/BranchCondition.hbm.xml /org/lamsfoundation/lams/tool/qa/QaContent.hbm.xml /org/lamsfoundation/lams/tool/qa/QaSession.hbm.xml /org/lamsfoundation/lams/tool/qa/QaQueContent.hbm.xml /org/lamsfoundation/lams/tool/qa/QaQueUsr.hbm.xml /org/lamsfoundation/lams/tool/qa/QaUsrResp.hbm.xml /org/lamsfoundation/lams/tool/qa/QaUploadedFile.hbm.xml + /org/lamsfoundation/lams/tool/qa/QaCondition.hbm.xml - + + + + + @@ -80,9 +93,10 @@ + - + Index: lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/service/IQaService.java =================================================================== diff -u -r9481bb9c6f8c0e4d6fbed6b230a41c77feda64c6 -r0af4ed13b963a588f3499b080801863d57f8ad95 --- lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/service/IQaService.java (.../IQaService.java) (revision 9481bb9c6f8c0e4d6fbed6b230a41c77feda64c6) +++ lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/service/IQaService.java (.../IQaService.java) (revision 0af4ed13b963a588f3499b080801863d57f8ad95) @@ -24,6 +24,7 @@ package org.lamsfoundation.lams.tool.qa.service; import java.io.InputStream; +import java.util.Collection; import java.util.List; import org.lamsfoundation.lams.contentrepository.ITicket; @@ -32,6 +33,7 @@ import org.lamsfoundation.lams.tool.exception.DataMissingException; import org.lamsfoundation.lams.tool.exception.ToolException; import org.lamsfoundation.lams.tool.qa.QaApplicationException; +import org.lamsfoundation.lams.tool.qa.QaCondition; import org.lamsfoundation.lams.tool.qa.QaContent; import org.lamsfoundation.lams.tool.qa.QaQueContent; import org.lamsfoundation.lams.tool.qa.QaQueUsr; @@ -41,239 +43,253 @@ import org.lamsfoundation.lams.usermanagement.User; import org.lamsfoundation.lams.util.audit.IAuditService; - - /** - * This interface define the contract that all Q/A service provider must - * follow. + * This interface define the contract that all Q/A service provider must follow. * * @author Ozgur Demirtas */ -public interface IQaService -{ - /** +public interface IQaService { + /** * Return the qa object according to the requested content id. - * @param toolContentId the tool content id + * + * @param toolContentId + * the tool content id * @return the qa object */ - - public QaContent retrieveQa(long toolContentId) throws QaApplicationException; - - - /** + + public QaContent retrieveQa(long toolContentId) throws QaApplicationException; + + /** * Return the qa object according to the requested content id. - * @param toolContentId the tool content id + * + * @param toolContentId + * the tool content id * @return the qa object or null */ - - public QaContent loadQa(long toolContentId) throws QaApplicationException; - - public void saveOrUpdateQa(QaContent qa) throws QaApplicationException; - public QaContent getQaContentByUID(Long uid) throws QaApplicationException; - - public int getTotalNumberOfUsers() throws QaApplicationException; - - public int getTotalNumberOfUsers(QaContent qa) throws QaApplicationException; - - public int countSessionComplete(QaContent qa) throws QaApplicationException; - - public int countSessionComplete() throws QaApplicationException; - + public QaContent loadQa(long toolContentId) throws QaApplicationException; + + public void saveOrUpdateQa(QaContent qa) throws QaApplicationException; + + public QaContent getQaContentByUID(Long uid) throws QaApplicationException; + + public int getTotalNumberOfUsers() throws QaApplicationException; + + public int getTotalNumberOfUsers(QaContent qa) throws QaApplicationException; + + public int countSessionComplete(QaContent qa) throws QaApplicationException; + + public int countSessionComplete() throws QaApplicationException; + public void updateQaQueUsr(QaQueUsr qaQueUsr) throws QaApplicationException; - - - /** + + /** * Return the question content object according to the requested question content id. - * @param qaQueContentId qa question content id + * + * @param qaQueContentId + * qa question content id * @return the qa question object */ - public QaQueContent retrieveQaQue(long qaQueContentId) throws QaApplicationException; - - public QaQueUsr loadQaQueUsr(Long userId) throws QaApplicationException; - - public List getAttemptsForUserAndQuestionContent(final Long queUsrId, final Long qaQueContentId) throws QaApplicationException; - - public void createQaQue(QaQueContent qaQueContent) throws QaApplicationException; - - public void removeQaQueContent(QaQueContent qaQueContent) throws QaApplicationException; - - public void createQaUsrResp(QaUsrResp qaUsrResp) throws QaApplicationException; - - public void updateUserResponse(QaUsrResp resp) throws QaApplicationException; - - public QaUsrResp retrieveQaUsrResp(long responseId) throws QaApplicationException; - - public void updateQaUsrResp(QaUsrResp qaUsrResp) throws QaApplicationException; - - public QaQueContent getQuestionContentByQuestionText(final String question, Long contentUid) throws QaApplicationException; - - public QaQueContent getQuestionContentByDisplayOrder(Long displayOrder, Long contentUid) throws QaApplicationException; - - public List getAllQuestionEntriesSorted(final long qaContentId) throws QaApplicationException; - - public void updateQaQueContent(QaQueContent qaQueContent) throws QaApplicationException; - - /** + public QaQueContent retrieveQaQue(long qaQueContentId) throws QaApplicationException; + + public QaQueUsr loadQaQueUsr(Long userId) throws QaApplicationException; + + public List getAttemptsForUserAndQuestionContent(final Long queUsrId, final Long qaQueContentId) + throws QaApplicationException; + + public void createQaQue(QaQueContent qaQueContent) throws QaApplicationException; + + public void removeQaQueContent(QaQueContent qaQueContent) throws QaApplicationException; + + public void createQaUsrResp(QaUsrResp qaUsrResp) throws QaApplicationException; + + public void updateUserResponse(QaUsrResp resp) throws QaApplicationException; + + public QaUsrResp retrieveQaUsrResp(long responseId) throws QaApplicationException; + + public void updateQaUsrResp(QaUsrResp qaUsrResp) throws QaApplicationException; + + public QaQueContent getQuestionContentByQuestionText(final String question, Long contentUid) + throws QaApplicationException; + + public QaQueContent getQuestionContentByDisplayOrder(Long displayOrder, Long contentUid) + throws QaApplicationException; + + public List getAllQuestionEntriesSorted(final long qaContentId) throws QaApplicationException; + + public void updateQaQueContent(QaQueContent qaQueContent) throws QaApplicationException; + + /** * Return the qa session object according to the requested session id. - * @param qaSessionId qa session id + * + * @param qaSessionId + * qa session id * @return the qa session object */ - public QaSession retrieveQaSession(long qaSessionId) throws QaApplicationException; - - public QaSession retrieveQaSessionOrNullById(long qaSessionId) throws QaApplicationException; - - public void createQaSession(QaSession qaSession) throws QaApplicationException; - - public List getSessionNamesFromContent(QaContent qaContent) throws QaApplicationException; - - public String getSessionNameById(long qaSessionId) throws QaApplicationException; - - public void removeToolSession(Long toolSessionId) throws DataMissingException, ToolException; - - public List getSessionsFromContent(QaContent qaContent) throws QaApplicationException; - - public void createQaQueUsr(QaQueUsr qaQueUsr) throws QaApplicationException; - - public void updateQaSession(QaSession qaSession) throws QaApplicationException; - - - /** + public QaSession retrieveQaSession(long qaSessionId) throws QaApplicationException; + + public QaSession retrieveQaSessionOrNullById(long qaSessionId) throws QaApplicationException; + + public void createQaSession(QaSession qaSession) throws QaApplicationException; + + public List getSessionNamesFromContent(QaContent qaContent) throws QaApplicationException; + + public String getSessionNameById(long qaSessionId) throws QaApplicationException; + + public void removeToolSession(Long toolSessionId) throws DataMissingException, ToolException; + + public List getSessionsFromContent(QaContent qaContent) throws QaApplicationException; + + public void createQaQueUsr(QaQueUsr qaQueUsr) throws QaApplicationException; + + public void updateQaSession(QaSession qaSession) throws QaApplicationException; + + /** * Return the qa que user object according to the requested usr id. - * @param qaQaUsrId qa usr id + * + * @param qaQaUsrId + * qa usr id * @return the qa que usr object */ - public QaQueUsr retrieveQaQueUsr(long qaQaUsrId) throws QaApplicationException; - - public QaQueUsr getQaQueUsrById(long qaQueUsrId) throws QaApplicationException; - - public void updateQa(QaContent qa) throws QaApplicationException; - - public void createQa(QaContent qa) throws QaApplicationException; - - public QaUsrResp getAttemptByUID(Long uid) throws QaApplicationException; - - public void removeAttemptsForUserAndQuestionContent(final Long queUsrId, final Long qaQueContentId); - + public QaQueUsr retrieveQaQueUsr(long qaQaUsrId) throws QaApplicationException; + + public QaQueUsr getQaQueUsrById(long qaQueUsrId) throws QaApplicationException; + + public void updateQa(QaContent qa) throws QaApplicationException; + + public void createQa(QaContent qa) throws QaApplicationException; + + public QaUsrResp getAttemptByUID(Long uid) throws QaApplicationException; + + public void removeAttemptsForUserAndQuestionContent(final Long queUsrId, final Long qaQueContentId); + public void hideResponse(QaUsrResp qaUsrResp) throws QaApplicationException; public void showResponse(QaUsrResp qaUsrResp) throws QaApplicationException; - - public void deleteQa(QaContent qa) throws QaApplicationException; - - public void deleteQaSession(QaSession QaSession) throws QaApplicationException; - - public QaContent retrieveQaBySession(long qaSessionId) throws QaApplicationException; - - public void deleteUsrRespByQueId(Long qaQueId) throws QaApplicationException; - - public void deleteQaById(Long qaId) throws QaApplicationException; - - public QaQueUsr getQaUserBySession(final Long queUsrId, final Long qaSessionId) throws QaApplicationException; - - public void deleteQaQueUsr(QaQueUsr qaQueUsr) throws QaApplicationException; - - public void removeUserResponse(QaUsrResp resp) throws QaApplicationException; - - public List getAllQuestionEntries(final Long uid) throws QaApplicationException; - + + public void deleteQa(QaContent qa) throws QaApplicationException; + + public void deleteQaSession(QaSession QaSession) throws QaApplicationException; + + public QaContent retrieveQaBySession(long qaSessionId) throws QaApplicationException; + + public void deleteUsrRespByQueId(Long qaQueId) throws QaApplicationException; + + public void deleteQaById(Long qaId) throws QaApplicationException; + + public QaQueUsr getQaUserBySession(final Long queUsrId, final Long qaSessionId) throws QaApplicationException; + + public void deleteQaQueUsr(QaQueUsr qaQueUsr) throws QaApplicationException; + + public void removeUserResponse(QaUsrResp resp) throws QaApplicationException; + + public List getAllQuestionEntries(final Long uid) throws QaApplicationException; + public User getCurrentUserData(String username) throws QaApplicationException; - + public List getUserBySessionOnly(final QaSession qaSession) throws QaApplicationException; - + /** - * copyToolContent(Long fromContentId, Long toContentId) - * return void + * copyToolContent(Long fromContentId, Long toContentId) return void + * * @param fromContentId * @param toContentId */ public void copyToolContent(Long fromContentId, Long toContentId) throws ToolException; - + public void setAsDefineLater(Long toolContentId, boolean value) throws DataMissingException, ToolException; - + public void setAsRunOffline(Long toolContentId, boolean value) throws DataMissingException, ToolException; - + public void setAsForceComplete(Long userId) throws QaApplicationException; - + public void setAsForceCompleteSession(Long toolSessionId) throws QaApplicationException; - + public boolean studentActivityOccurred(QaContent qa) throws QaApplicationException; - + public boolean studentActivityOccurredGlobal(QaContent qaContent) throws QaApplicationException; - - + /** - * removeToolContent(Long toolContentId) - * return void + * removeToolContent(Long toolContentId) return void + * * @param toolContentId */ public void removeToolContent(Long toolContentId) throws QaApplicationException; - - + /** - * createToolSession(Long toolSessionId,String toolSessionName, Long toolContentId) + * createToolSession(Long toolSessionId,String toolSessionName, Long toolContentId) * - * It is also defined here since in development we want to be able call it directly from the web-layer - * instead of it being called by the container. + * It is also defined here since in development we want to be able call it directly from the web-layer instead of it + * being called by the container. + * * @param toolSessionId * @param toolContentId */ public void createToolSession(Long toolSessionId, String toolSessionName, Long toolContentId) throws ToolException; - + /** - * leaveToolSession(Long toolSessionId, Long learnerId) + * leaveToolSession(Long toolSessionId, Long learnerId) * - * 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. + * 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,Long learnerId) throws DataMissingException, ToolException; - + public String leaveToolSession(Long toolSessionId, Long learnerId) throws DataMissingException, ToolException; + public IToolVO getToolBySignature(String toolSignature) throws QaApplicationException; - + public long getToolDefaultContentIdBySignature(String toolSignature) throws QaApplicationException; - + public int countSessionUser(QaSession qaSession) throws QaApplicationException; - + public List getToolSessionsForContent(QaContent qa) throws QaApplicationException; - + public QaQueContent getToolDefaultQuestionContent(long contentId) throws QaApplicationException; - + public void configureContentRepository() throws QaApplicationException; - + public ITicket getRepositoryLoginTicket() throws QaApplicationException; - + public void deleteFromRepository(Long uuid, Long versionID) throws QaApplicationException; - public InputStream downloadFile(Long uuid, Long versionID)throws QaApplicationException; - - public void persistFile(String uuid, boolean isOnlineFile, String fileName, QaContent qaContent) throws QaApplicationException; - + public InputStream downloadFile(Long uuid, Long versionID) throws QaApplicationException; + + public void persistFile(String uuid, boolean isOnlineFile, String fileName, QaContent qaContent) + throws QaApplicationException; + public void persistFile(QaContent content, QaUploadedFile file) throws QaApplicationException; - + public void removeFile(Long submissionId) throws QaApplicationException; - + public List retrieveQaUploadedFiles(QaContent qa) throws QaApplicationException; - + public void cleanUploadedFilesMetaData() throws QaApplicationException; - + public List retrieveQaQueContentsByToolContentId(long toolContentId); - - public Long createNotebookEntry(Long id, Integer idType, String signature, - Integer userID, String entry); - - public NotebookEntry getEntry(Long id, Integer idType, String signature, - Integer userID); + public Long createNotebookEntry(Long id, Integer idType, String signature, Integer userID, String entry); + public NotebookEntry getEntry(Long id, Integer idType, String signature, Integer userID); - - /** Get the LAMS audit service. Needed as the web layer controls the staff updating of an answer, - * so the log entry must be made by the web layer. */ + /** + * Get the LAMS audit service. Needed as the web layer controls the staff updating of an answer, so the log entry + * must be made by the web layer. + */ public IAuditService getAuditService(); - - public void updateEntry(NotebookEntry notebookEntry); -} + public void updateEntry(NotebookEntry notebookEntry); + public QaContent getQaContentBySessionId(Long sessionId); + + /** + * Creates an unique name for a QaCondition. It consists of the tool output definition name and a unique positive + * integer number. + * + * @param existingConditions + * existing conditions; required to check if a condition with the same name does not exist. + * @return unique QaCondition name + */ + public String createConditionName(Collection existingConditions); +} Index: lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/service/QaOutputFactory.java =================================================================== diff -u --- lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/service/QaOutputFactory.java (revision 0) +++ lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/service/QaOutputFactory.java (revision 0af4ed13b963a588f3499b080801863d57f8ad95) @@ -0,0 +1,164 @@ +/**************************************************************** + * Copyright (C) 2005 LAMS Foundation (http://lamsfoundation.org) + * ============================================================= + * License Information: http://lamsfoundation.org/licensing/lams/2.0/ + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2.0 + * as published by the Free Software Foundation. + * + * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 * USA + * + * http://www.gnu.org/licenses/gpl.txt + * **************************************************************** + */ + +/* $Id$ */ +package org.lamsfoundation.lams.tool.qa.service; + +import java.util.ArrayList; +import java.util.HashSet; +import java.util.List; +import java.util.Set; +import java.util.SortedMap; +import java.util.TreeMap; + +import org.lamsfoundation.lams.learningdesign.BranchCondition; +import org.lamsfoundation.lams.tool.OutputFactory; +import org.lamsfoundation.lams.tool.ToolOutput; +import org.lamsfoundation.lams.tool.ToolOutputDefinition; +import org.lamsfoundation.lams.tool.exception.ToolException; +import org.lamsfoundation.lams.tool.qa.QaAppConstants; +import org.lamsfoundation.lams.tool.qa.QaCondition; +import org.lamsfoundation.lams.tool.qa.QaContent; +import org.lamsfoundation.lams.tool.qa.QaQueContent; +import org.lamsfoundation.lams.tool.qa.QaUsrResp; + +/** + * Output factory for Q&A tool. Currently it provides only one type of output - a user answers represented by an array + * of strings (output type "OUTPUT_COMPLEX"). + * + * @author Marcin Cieslak + */ +public class QaOutputFactory extends OutputFactory { + + /** + * {@inheritDoc} + */ + @Override + public SortedMap getToolOutputDefinitions(Object toolContentObject) + throws ToolException { + SortedMap definitionMap = new TreeMap(); + if (toolContentObject != null) { + ToolOutputDefinition allAnswersDefinition = buildComplexOutputDefinition(QaAppConstants.TEXT_SEARCH_DEFINITION_NAME); + QaContent qaContent = (QaContent) toolContentObject; + // adding all existing conditions + allAnswersDefinition.setDefaultConditions(new ArrayList(qaContent.getConditions())); + // if no conditions were created in the tool instance, a default condition is added; the condition is + // persisted in QaService. + if (allAnswersDefinition.getDefaultConditions().isEmpty() && !qaContent.getQaQueContents().isEmpty()) { + Set questions = new HashSet(); + questions.add((QaQueContent) qaContent.getQaQueContents().iterator().next()); + String name = buildConditionName(QaAppConstants.TEXT_SEARCH_DEFINITION_NAME, qaContent.getQaContentId() + .toString()); + // Default condition checks if the first answer contains word "LAMS" + QaCondition defaultCondition = new QaCondition(null, null, 1, name, getI18NText( + QaAppConstants.TEXT_SEARCH_DEFAULT_CONDITION_DISPLAY_NAME_KEY, false), "OUTPUT_COMPLEX", null, + null, null, "LAMS", null, null, null, questions); + qaContent.getConditions().add(defaultCondition); + + allAnswersDefinition.getDefaultConditions().add(defaultCondition); + } + definitionMap.put(QaAppConstants.TEXT_SEARCH_DEFINITION_NAME, allAnswersDefinition); + } + + return definitionMap; + } + + /** + * Follows {@link QaServicePOJO#getToolOutput(List, Long, Long)}. + * + */ + public SortedMap getToolOutput(List names, IQaService qaService, Long toolSessionId, + Long learnerId) { + + TreeMap outputs = new TreeMap(); + // cached tool output for all text search conditions + ToolOutput allAnswersOutput = null; + if (names == null) { + // output will be set for all the existing conditions + QaContent qaContent = qaService.getQaContentBySessionId(toolSessionId); + Set conditions = qaContent.getConditions(); + for (QaCondition condition : conditions) { + String name = condition.getName(); + if (isTextSearchConditionName(name) && allAnswersOutput != null) { + outputs.put(name, allAnswersOutput); + } else { + ToolOutput output = getToolOutput(name, qaService, toolSessionId, learnerId); + if (output != null) { + outputs.put(name, output); + if (isTextSearchConditionName(QaAppConstants.TEXT_SEARCH_DEFINITION_NAME)) { + allAnswersOutput = output; + } + } + } + } + } else { + for (String name : names) { + if (isTextSearchConditionName(name) && allAnswersOutput != null) { + outputs.put(name, allAnswersOutput); + } else { + ToolOutput output = getToolOutput(name, qaService, toolSessionId, learnerId); + if (output != null) { + outputs.put(name, output); + if (isTextSearchConditionName(QaAppConstants.TEXT_SEARCH_DEFINITION_NAME)) { + allAnswersOutput = output; + } + } + } + } + } + return outputs; + + } + + public ToolOutput getToolOutput(String name, IQaService qaService, Long toolSessionId, Long learnerId) { + if (isTextSearchConditionName(QaAppConstants.TEXT_SEARCH_DEFINITION_NAME)) { + // user answers are loaded from the DB and array of strings is created + QaContent taskList = qaService.getQaContentBySessionId(toolSessionId); + Set questions = taskList.getQaQueContents(); + String[] answers = new String[questions.size()]; + for (QaQueContent question : questions) { + List attempts = qaService.getAttemptsForUserAndQuestionContent(learnerId, question + .getQaContentId()); + if (attempts != null && !attempts.isEmpty()) { + // only the last attempt is taken into consideration + String answer = attempts.get(attempts.size() - 1).getAnswer(); + answers[question.getDisplayOrder()] = answer; + } + } + return new ToolOutput(name, getI18NText(QaAppConstants.TEXT_SEARCH_DEFINITION_NAME, true), answers, false); + } + return null; + } + + @Override + protected String[] splitConditionName(String conditionName) { + return super.splitConditionName(conditionName); + } + + protected String buildConditionName(String uniquePart) { + return super.buildConditionName(QaAppConstants.TEXT_SEARCH_DEFINITION_NAME, uniquePart); + } + + private boolean isTextSearchConditionName(String name) { + return name != null && name.startsWith(QaAppConstants.TEXT_SEARCH_DEFINITION_NAME); + } +} \ No newline at end of file Index: lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/service/QaServicePOJO.java =================================================================== diff -u -r97612142f4697066beb66064e83ff31fef1712b9 -r0af4ed13b963a588f3499b080801863d57f8ad95 --- lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/service/QaServicePOJO.java (.../QaServicePOJO.java) (revision 97612142f4697066beb66064e83ff31fef1712b9) +++ lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/service/QaServicePOJO.java (.../QaServicePOJO.java) (revision 0af4ed13b963a588f3499b080801863d57f8ad95) @@ -23,14 +23,16 @@ /* $$Id$$ */ package org.lamsfoundation.lams.tool.qa.service; + import java.io.InputStream; +import java.util.Collection; import java.util.Date; import java.util.Hashtable; import java.util.Iterator; import java.util.List; +import java.util.Random; import java.util.Set; import java.util.SortedMap; -import java.util.TreeMap; import java.util.TreeSet; import org.apache.log4j.Logger; @@ -66,6 +68,7 @@ import org.lamsfoundation.lams.tool.exception.ToolException; import org.lamsfoundation.lams.tool.qa.QaAppConstants; import org.lamsfoundation.lams.tool.qa.QaApplicationException; +import org.lamsfoundation.lams.tool.qa.QaCondition; import org.lamsfoundation.lams.tool.qa.QaContent; import org.lamsfoundation.lams.tool.qa.QaQueContent; import org.lamsfoundation.lams.tool.qa.QaQueUsr; @@ -88,2114 +91,1758 @@ import org.lamsfoundation.lams.util.wddx.WDDXProcessorConversionException; 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. + * 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. + * 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. + * 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 Ozgur Demirtas - * + * */ -public class QaServicePOJO - implements IQaService, ToolContentManager, ToolSessionManager, - ToolContentImport102Manager, QaAppConstants - +public class QaServicePOJO implements IQaService, ToolContentManager, ToolSessionManager, ToolContentImport102Manager, + QaAppConstants + { - static Logger logger = Logger.getLogger(QaServicePOJO.class.getName()); - - private final String repositoryUser = "laqa11"; - private final char[] repositoryId = {'l','a','q','a','_','1', '1'}; - private final String repositoryWorkspace = "laqa11"; - private IRepositoryService repositoryService; - private ICredentials cred; - - private IQaContentDAO qaDAO; - private IQaQueContentDAO qaQueContentDAO; - private IQaSessionDAO qaSessionDAO; - private IQaQueUsrDAO qaQueUsrDAO; - private IQaUsrRespDAO qaUsrRespDAO; - private IQaUploadedFileDAO qaUploadedFileDAO; - + static Logger logger = Logger.getLogger(QaServicePOJO.class.getName()); + + private final String repositoryUser = "laqa11"; + private final char[] repositoryId = { 'l', 'a', 'q', 'a', '_', '1', '1' }; + private final String repositoryWorkspace = "laqa11"; + private IRepositoryService repositoryService; + private ICredentials cred; + + private IQaContentDAO qaDAO; + private IQaQueContentDAO qaQueContentDAO; + + private IQaSessionDAO qaSessionDAO; + private IQaQueUsrDAO qaQueUsrDAO; + private IQaUsrRespDAO qaUsrRespDAO; + private IQaUploadedFileDAO qaUploadedFileDAO; + private IToolContentHandler qaToolContentHandler = null; private IUserManagementService userManagementService; private ILamsToolService toolService; private ILearnerService learnerService; - private IAuditService auditService; - private IExportToolContentService exportContentService; - - private ICoreNotebookService coreNotebookService; - + private IAuditService auditService; + private IExportToolContentService exportContentService; + private QaOutputFactory qaOutputFactory; + + private ICoreNotebookService coreNotebookService; + + private Random generator = new Random(); + public void configureContentRepository() throws QaApplicationException { - logger.debug("retrieved repService: " + repositoryService); - cred = new SimpleCredentials(repositoryUser, repositoryId); - logger.debug("retrieved cred: "+ cred); - try - { - repositoryService.createCredentials(cred); - logger.debug("created credentails."); - repositoryService.addWorkspace(cred,repositoryWorkspace); - logger.debug("created workspace."); - } catch (ItemExistsException ie) { - logger.warn("Tried to configure repository but it " - +" appears to be already configured. Exception thrown by repository being ignored. ", ie); - } catch (RepositoryCheckedException e) { - String error = "Error occured while trying to configure repository." - +" Unable to recover from error: "+e.getMessage(); - logger.error(error, e); - throw new QaApplicationException(error,e); - } - } - - - public QaServicePOJO(){} - - - public void createQa(QaContent qaContent) throws QaApplicationException - { - try - { - qaDAO.saveQa(qaContent); - } - catch (DataAccessException e) - { - throw new QaApplicationException("Exception occured when lams is creating qa content: " - + e.getMessage(), - e); - } + QaServicePOJO.logger.debug("retrieved repService: " + repositoryService); + cred = new SimpleCredentials(repositoryUser, repositoryId); + QaServicePOJO.logger.debug("retrieved cred: " + cred); + try { + repositoryService.createCredentials(cred); + QaServicePOJO.logger.debug("created credentails."); + repositoryService.addWorkspace(cred, repositoryWorkspace); + QaServicePOJO.logger.debug("created workspace."); + } catch (ItemExistsException ie) { + QaServicePOJO.logger.warn("Tried to configure repository but it " + + " appears to be already configured. Exception thrown by repository being ignored. ", ie); + } catch (RepositoryCheckedException e) { + String error = "Error occured while trying to configure repository." + " Unable to recover from error: " + + e.getMessage(); + QaServicePOJO.logger.error(error, e); + throw new QaApplicationException(error, e); + } } - public QaContent getQaContentByUID(Long uid) throws QaApplicationException - { - try - { - return qaDAO.getQaContentByUID(uid); - } - catch (DataAccessException e) - { - throw new QaApplicationException("Exception occured when lams is getting qa content by uid: " - + e.getMessage(), - e); - } - + public QaServicePOJO() { } - - - public QaContent retrieveQa(long toolContentID) throws QaApplicationException - { - try - { - return qaDAO.getQaById(toolContentID); - } - catch (DataAccessException e) - { - throw new QaApplicationException("Exception occured when lams is loading qa content: " - + e.getMessage(), - e); - } + + public void createQa(QaContent qaContent) throws QaApplicationException { + try { + qaDAO.saveQa(qaContent); + } catch (DataAccessException e) { + throw new QaApplicationException("Exception occured when lams is creating qa content: " + e.getMessage(), e); + } } - - public void saveOrUpdateQa(QaContent qa) throws QaApplicationException - { - try - { - qaDAO.saveOrUpdateQa(qa); - } - catch (DataAccessException e) - { - throw new QaApplicationException("Exception occured when lams is saveOrUpdating qa content: " - + e.getMessage(), - e); - } - + + public QaContent getQaContentByUID(Long uid) throws QaApplicationException { + try { + return qaDAO.getQaContentByUID(uid); + } catch (DataAccessException e) { + throw new QaApplicationException("Exception occured when lams is getting qa content by uid: " + + e.getMessage(), e); } + } + + public QaContent retrieveQa(long toolContentID) throws QaApplicationException { + try { + return qaDAO.getQaById(toolContentID); + } catch (DataAccessException e) { + throw new QaApplicationException("Exception occured when lams is loading qa content: " + e.getMessage(), e); + } + } + + public void saveOrUpdateQa(QaContent qa) throws QaApplicationException { + try { + qaDAO.saveOrUpdateQa(qa); + } catch (DataAccessException e) { + throw new QaApplicationException("Exception occured when lams is saveOrUpdating qa content: " + + e.getMessage(), e); + } + + } + /** * returns null if not found */ - public QaContent loadQa(long toolContentID) throws QaApplicationException - { - try - { - return qaDAO.loadQaById(toolContentID); - } - catch (DataAccessException e) - { - throw new QaApplicationException("Exception occured when lams is loading qa content: " - + e.getMessage(), - e); - } + public QaContent loadQa(long toolContentID) throws QaApplicationException { + try { + return qaDAO.loadQaById(toolContentID); + } catch (DataAccessException e) { + throw new QaApplicationException("Exception occured when lams is loading qa content: " + e.getMessage(), e); + } } - - public QaQueContent getQuestionContentByQuestionText(final String question, Long contentUid) throws QaApplicationException - { - try - { - return qaQueContentDAO.getQuestionContentByQuestionText(question, contentUid); + public QaQueContent getQuestionContentByQuestionText(final String question, Long contentUid) + throws QaApplicationException { + try { + return qaQueContentDAO.getQuestionContentByQuestionText(question, contentUid); - } - catch (DataAccessException e) - { - throw new QaApplicationException("Exception occured when lams is getting qa content by question text: " - + e.getMessage(), - e); - } + } catch (DataAccessException e) { + throw new QaApplicationException("Exception occured when lams is getting qa content by question text: " + + e.getMessage(), e); } - + } - public QaQueContent getQuestionContentByDisplayOrder(Long displayOrder, Long contentUid) throws QaApplicationException - { - try - { - return qaQueContentDAO.getQuestionContentByDisplayOrder(displayOrder, contentUid); + public QaQueContent getQuestionContentByDisplayOrder(Long displayOrder, Long contentUid) + throws QaApplicationException { + try { + return qaQueContentDAO.getQuestionContentByDisplayOrder(displayOrder, contentUid); - } - catch (DataAccessException e) - { - throw new QaApplicationException("Exception occured when lams is getting qa content by question text: " - + e.getMessage(), - e); - } + } catch (DataAccessException e) { + throw new QaApplicationException("Exception occured when lams is getting qa content by question text: " + + e.getMessage(), e); } + } - - public void updateQaQueContent(QaQueContent qaQueContent) throws QaApplicationException - { - try - { - qaQueContentDAO.updateQaQueContent(qaQueContent); + public void updateQaQueContent(QaQueContent qaQueContent) throws QaApplicationException { + try { + qaQueContentDAO.updateQaQueContent(qaQueContent); - } - catch (DataAccessException e) - { - throw new QaApplicationException("Exception occured when lams is updating qa content by question: " - + e.getMessage(), - e); - } - + } catch (DataAccessException e) { + throw new QaApplicationException("Exception occured when lams is updating qa content by question: " + + e.getMessage(), e); } - - public void createQaQue(QaQueContent qaQueContent) throws QaApplicationException - { - try - { - logger.debug("attempt service createQaQue: " + qaQueContent); - qaQueContentDAO.createQueContent(qaQueContent); - logger.debug("after servicecreateQaQue: " + qaQueContent); - } - catch (DataAccessException e) - { - throw new QaApplicationException("Exception occured when lams is creating qa content: " - + e.getMessage(), - e); - } } - - public void createQaSession(QaSession qaSession) throws QaApplicationException - { - try - { - qaSessionDAO.CreateQaSession(qaSession); - } - catch (DataAccessException e) - { - throw new QaApplicationException("Exception occured when lams is creating qa session: " - + e.getMessage(), - e); - } + + public void createQaQue(QaQueContent qaQueContent) throws QaApplicationException { + try { + QaServicePOJO.logger.debug("attempt service createQaQue: " + qaQueContent); + qaQueContentDAO.createQueContent(qaQueContent); + QaServicePOJO.logger.debug("after servicecreateQaQue: " + qaQueContent); + } catch (DataAccessException e) { + throw new QaApplicationException("Exception occured when lams is creating qa content: " + e.getMessage(), e); + } } - - - public List getSessionNamesFromContent(QaContent qaContent) throws QaApplicationException - { - try - { - return qaSessionDAO.getSessionNamesFromContent(qaContent); - } - catch (DataAccessException e) - { - throw new QaApplicationException("Exception occured when lams is getting session names from content: " - + e.getMessage(), - e); - } + + public void createQaSession(QaSession qaSession) throws QaApplicationException { + try { + qaSessionDAO.CreateQaSession(qaSession); + } catch (DataAccessException e) { + throw new QaApplicationException("Exception occured when lams is creating qa session: " + e.getMessage(), e); + } } - - public String getSessionNameById(long qaSessionId) throws QaApplicationException - { - try - { - return qaSessionDAO.getSessionNameById(qaSessionId); - } - catch (DataAccessException e) - { - throw new QaApplicationException("Exception occured when lams is getting session name: " - + e.getMessage(), - e); - } + public List getSessionNamesFromContent(QaContent qaContent) throws QaApplicationException { + try { + return qaSessionDAO.getSessionNamesFromContent(qaContent); + } catch (DataAccessException e) { + throw new QaApplicationException("Exception occured when lams is getting session names from content: " + + e.getMessage(), e); + } } - - public List getSessionsFromContent(QaContent qaContent) throws QaApplicationException - { - try - { - return qaSessionDAO.getSessionsFromContent(qaContent); - } - catch (DataAccessException e) - { - throw new QaApplicationException("Exception occured when lams is getting" - + " the qa sessions list: " - + e.getMessage(),e); - } + + public String getSessionNameById(long qaSessionId) throws QaApplicationException { + try { + return qaSessionDAO.getSessionNameById(qaSessionId); + } catch (DataAccessException e) { + throw new QaApplicationException("Exception occured when lams is getting session name: " + e.getMessage(), + e); } + } - public void createQaQueUsr(QaQueUsr qaQueUsr) throws QaApplicationException - { - try - { - qaQueUsrDAO.createUsr(qaQueUsr); - } - catch (DataAccessException e) - { - throw new QaApplicationException("Exception occured when lams is creating qa QueUsr: " - + e.getMessage(), - e); - } + public List getSessionsFromContent(QaContent qaContent) throws QaApplicationException { + try { + return qaSessionDAO.getSessionsFromContent(qaContent); + } catch (DataAccessException e) { + throw new QaApplicationException("Exception occured when lams is getting" + " the qa sessions list: " + + e.getMessage(), e); + } } - - - public QaQueUsr getQaUserBySession(final Long queUsrId, final Long qaSessionId) throws QaApplicationException - { - try - { - return qaQueUsrDAO.getQaUserBySession(queUsrId, qaSessionId); - } - catch (DataAccessException e) - { - throw new QaApplicationException("Exception occured when lams is getting qa QueUsr: " - + e.getMessage(), - e); - } + + public void createQaQueUsr(QaQueUsr qaQueUsr) throws QaApplicationException { + 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) throws QaApplicationException - { - 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 QaQueUsr getQaQueUsrById(long qaQueUsrId) throws QaApplicationException - { - try - { - QaQueUsr qaQueUsr=qaQueUsrDAO.getQaQueUsrById(qaQueUsrId); - return qaQueUsr; - } - catch (DataAccessException e) - { - throw new QaApplicationException("Exception occured when lams is getting qa QueUsr: " - + e.getMessage(), - e); - } + public QaQueUsr getQaUserBySession(final Long queUsrId, final Long qaSessionId) throws QaApplicationException { + try { + return qaQueUsrDAO.getQaUserBySession(queUsrId, qaSessionId); + } catch (DataAccessException e) { + throw new QaApplicationException("Exception occured when lams is getting qa QueUsr: " + e.getMessage(), e); } - - public List getAttemptsForUserAndQuestionContent(final Long queUsrId, final Long qaQueContentId) throws QaApplicationException - { - try - { - return qaUsrRespDAO.getAttemptsForUserAndQuestionContent(queUsrId, qaQueContentId); - } - catch (DataAccessException e) - { - throw new QaApplicationException("Exception occured when lams is getting qa qaUsrRespDAO by user id and que content id: " - + e.getMessage(), - e); - } + } + + public QaQueUsr loadQaQueUsr(Long userId) throws QaApplicationException { + 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 QaUsrResp getAttemptByUID(Long uid) throws QaApplicationException - { - try - { - return qaUsrRespDAO.getAttemptByUID(uid); - } - catch (DataAccessException e) - { - throw new QaApplicationException("Exception occured when lams is getting response by uid: " - + e.getMessage(), - e); - } } - - - public void removeAttemptsForUserAndQuestionContent(final Long queUsrId, final Long qaQueContentId) throws QaApplicationException - { - try - { - qaUsrRespDAO.removeAttemptsForUserAndQuestionContent(queUsrId, qaQueContentId); - } - catch (DataAccessException e) - { - throw new QaApplicationException("Exception occured when lams is removing attempts by queUsrId and qaQueContentId: " - + e.getMessage(), - e); - } + + public QaQueUsr getQaQueUsrById(long qaQueUsrId) throws QaApplicationException { + try { + QaQueUsr qaQueUsr = qaQueUsrDAO.getQaQueUsrById(qaQueUsrId); + return qaQueUsr; + } catch (DataAccessException e) { + throw new QaApplicationException("Exception occured when lams is getting qa QueUsr: " + e.getMessage(), e); + } } - - - public void updateUserResponse(QaUsrResp resp) throws QaApplicationException - { - try - { - qaUsrRespDAO.updateUserResponse(resp); - } - catch (DataAccessException e) - { - throw new QaApplicationException("Exception occured when lams is updating response" - + e.getMessage(), - e); - } + + public List getAttemptsForUserAndQuestionContent(final Long queUsrId, final Long qaQueContentId) + throws QaApplicationException { + try { + return qaUsrRespDAO.getAttemptsForUserAndQuestionContent(queUsrId, qaQueContentId); + } catch (DataAccessException e) { + throw new QaApplicationException( + "Exception occured when lams is getting qa qaUsrRespDAO by user id and que content id: " + + e.getMessage(), e); + } } - - public List getUserBySessionOnly(final QaSession qaSession) throws QaApplicationException - { - try - { - return qaQueUsrDAO.getUserBySessionOnly(qaSession); - } - catch (DataAccessException e) - { - throw new QaApplicationException("Exception occured when lams is getting qa QueUsr by qa session " - + e.getMessage(), - e); - } + public QaUsrResp getAttemptByUID(Long uid) throws QaApplicationException { + try { + return qaUsrRespDAO.getAttemptByUID(uid); + } catch (DataAccessException e) { + throw new QaApplicationException("Exception occured when lams is getting response by uid: " + + e.getMessage(), e); + } } - - public void createQaUsrResp(QaUsrResp qaUsrResp) throws QaApplicationException - { - try - { - qaUsrRespDAO.createUserResponse(qaUsrResp); - } - catch (DataAccessException e) - { - throw new QaApplicationException("Exception occured when lams is creating qa UsrResp: " - + e.getMessage(), - e); - } + public void removeAttemptsForUserAndQuestionContent(final Long queUsrId, final Long qaQueContentId) + throws QaApplicationException { + try { + qaUsrRespDAO.removeAttemptsForUserAndQuestionContent(queUsrId, qaQueContentId); + } catch (DataAccessException e) { + throw new QaApplicationException( + "Exception occured when lams is removing attempts by queUsrId and qaQueContentId: " + + e.getMessage(), e); + } } - - public void updateQaQueUsr(QaQueUsr qaQueUsr) throws QaApplicationException - { - try - { - qaQueUsrDAO.updateUsr(qaQueUsr); - } - catch (DataAccessException e) - { - throw new QaApplicationException("Exception occured when lams is updating qa QueUsr: " - + e.getMessage(), - e); - } + + public void updateUserResponse(QaUsrResp resp) throws QaApplicationException { + try { + qaUsrRespDAO.updateUserResponse(resp); + } catch (DataAccessException e) { + throw new QaApplicationException("Exception occured when lams is updating response" + e.getMessage(), e); + } } - - - public QaUsrResp retrieveQaUsrResp(long responseId) throws QaApplicationException - { - 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 List getUserBySessionOnly(final QaSession qaSession) throws QaApplicationException { + try { + return qaQueUsrDAO.getUserBySessionOnly(qaSession); + } catch (DataAccessException e) { + throw new QaApplicationException("Exception occured when lams is getting qa QueUsr by qa session " + + e.getMessage(), e); + } } - - public void updateQaUsrResp(QaUsrResp qaUsrResp) throws QaApplicationException - { - try - { - qaUsrRespDAO.updateUserResponse(qaUsrResp); - } - catch (DataAccessException e) - { - throw new QaApplicationException("Exception occured when lams is updating qa UsrResp: " - + e.getMessage(), - e); - } + + public void createQaUsrResp(QaUsrResp qaUsrResp) throws QaApplicationException { + try { + qaUsrRespDAO.createUserResponse(qaUsrResp); + } catch (DataAccessException e) { + throw new QaApplicationException("Exception occured when lams is creating qa UsrResp: " + e.getMessage(), e); + } } - - - public int countSessionComplete(QaContent qa) throws QaApplicationException - { - try - { - return qaSessionDAO.countSessionComplete(qa); - } - catch(DataAccessException e) - { - throw new QaApplicationException("Exception occured when lams is counting complete sessions" - + e.getMessage(),e); - } + + public void updateQaQueUsr(QaQueUsr qaQueUsr) throws QaApplicationException { + try { + qaQueUsrDAO.updateUsr(qaQueUsr); + } catch (DataAccessException e) { + throw new QaApplicationException("Exception occured when lams is updating qa QueUsr: " + e.getMessage(), e); + } } - - public int countSessionComplete() throws QaApplicationException - { - try - { - return qaSessionDAO.countSessionComplete(); - } - catch(DataAccessException e) - { - throw new QaApplicationException("Exception occured when lams is counting complete sessions" - + e.getMessage(),e); - } + + public QaUsrResp retrieveQaUsrResp(long responseId) throws QaApplicationException { + 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 QaQueContent retrieveQaQue(long qaQueContentId) throws QaApplicationException - { - 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) throws QaApplicationException - { - try - { - return qaSessionDAO.getQaSessionById(qaSessionId); - } - catch (DataAccessException e) - { - throw new QaApplicationException("Exception occured when lams is loading qa session : " - + e.getMessage(), - e); - } + + public void updateQaUsrResp(QaUsrResp qaUsrResp) throws QaApplicationException { + try { + qaUsrRespDAO.updateUserResponse(qaUsrResp); + } catch (DataAccessException e) { + throw new QaApplicationException("Exception occured when lams is updating qa UsrResp: " + e.getMessage(), e); + } } - - public QaSession retrieveQaSessionOrNullById(long qaSessionId) throws QaApplicationException - { - try - { - return qaSessionDAO.getQaSessionOrNullById(qaSessionId); - } - catch (DataAccessException e) - { - throw new QaApplicationException("Exception occured when lams is loading qa session : " - + e.getMessage(), - e); - } + + public int countSessionComplete(QaContent qa) throws QaApplicationException { + try { + return qaSessionDAO.countSessionComplete(qa); + } catch (DataAccessException e) { + throw new QaApplicationException("Exception occured when lams is counting complete sessions" + + e.getMessage(), e); + } } - - - public QaContent retrieveQaBySession(long qaSessionId) throws QaApplicationException - { - try - { - return qaDAO.getQaBySession(new Long(qaSessionId)); - } - catch (DataAccessException e) - { - throw new QaApplicationException("Exception occured when lams is loading qa: " - + e.getMessage(), - e); - } + + public int countSessionComplete() throws QaApplicationException { + try { + return qaSessionDAO.countSessionComplete(); + } catch (DataAccessException e) { + throw new QaApplicationException("Exception occured when lams is counting complete sessions" + + e.getMessage(), e); + } } - - public List retrieveQaQueContentsByToolContentId(long qaContentId) throws QaApplicationException - { - try - { - return qaQueContentDAO.getQaQueContentsByContentId(qaContentId); - } - catch (DataAccessException e) - { - throw new QaApplicationException("Exception occured when lams is loading qa que usr: " - + e.getMessage(), - e); - } + public QaQueContent retrieveQaQue(long qaQueContentId) throws QaApplicationException { + try { + return qaQueContentDAO.getQaQueById(qaQueContentId); + } catch (DataAccessException e) { + throw new QaApplicationException("Exception occured when lams is loading qa question content: " + + e.getMessage(), e); + } } - - public void updateQa(QaContent qa) throws QaApplicationException - { - try - { - qaDAO.updateQa(qa); - } - catch(DataAccessException e) - { - throw new QaApplicationException("Exception occured when lams is updating" - + " the qa content: " - + e.getMessage(),e); - } + public QaSession retrieveQaSession(long qaSessionId) throws QaApplicationException { + try { + return qaSessionDAO.getQaSessionById(qaSessionId); + } catch (DataAccessException e) { + throw new QaApplicationException("Exception occured when lams is loading qa session : " + e.getMessage(), e); + } } - - public void updateQaSession(QaSession qaSession) throws QaApplicationException - { - try - { - logger.debug("before updateQaSession: " + qaSession); - qaSessionDAO.UpdateQaSession(qaSession); - } - catch (DataAccessException e) - { - throw new QaApplicationException("Exception occured when lams is updating qa session : " - + e.getMessage(), - e); - } + public QaSession retrieveQaSessionOrNullById(long qaSessionId) throws QaApplicationException { + try { + return qaSessionDAO.getQaSessionOrNullById(qaSessionId); + } catch (DataAccessException e) { + throw new QaApplicationException("Exception occured when lams is loading qa session : " + e.getMessage(), e); + } } - - public void deleteQa(QaContent qa) throws QaApplicationException - { - try - { - qaDAO.deleteQa(qa); - } - catch(DataAccessException e) - { - throw new QaApplicationException("Exception occured when lams is deleting" - + " the qa content: " - + e.getMessage(),e); - } + + public QaContent retrieveQaBySession(long qaSessionId) throws QaApplicationException { + 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 deleteQaById(Long qaId) throws QaApplicationException - { - try - { - qaDAO.removeQaById(qaId); - } - catch(DataAccessException e) - { - throw new QaApplicationException("Exception occured when lams is deleting" - + " the qa content: " - + e.getMessage(),e); - } + + public List retrieveQaQueContentsByToolContentId(long qaContentId) throws QaApplicationException { + try { + return qaQueContentDAO.getQaQueContentsByContentId(qaContentId); + } catch (DataAccessException e) { + throw new QaApplicationException("Exception occured when lams is loading qa que usr: " + e.getMessage(), e); + } } - public void deleteQaSession(QaSession QaSession) throws QaApplicationException - { - try - { - qaSessionDAO.deleteQaSession(QaSession); - } - catch(DataAccessException e) - { - throw new QaApplicationException("Exception occured when lams is deleting" - + " the qa session: " - + e.getMessage(),e); - } + public void updateQa(QaContent qa) throws QaApplicationException { + try { + qaDAO.updateQa(qa); + } catch (DataAccessException e) { + throw new QaApplicationException("Exception occured when lams is updating" + " the qa content: " + + e.getMessage(), e); } - - - public void removeUserResponse(QaUsrResp resp) throws QaApplicationException - { - try - { - auditService.logChange(MY_SIGNATURE, - resp.getQaQueUser().getQueUsrId(),resp.getQaQueUser().getUsername(), - resp.getAnswer(), null); - qaUsrRespDAO.removeUserResponse(resp); - } - catch(DataAccessException e) - { - throw new QaApplicationException("Exception occured when lams is deleting" - + " the resp: " - + e.getMessage(),e); - } + } + + public void updateQaSession(QaSession qaSession) throws QaApplicationException { + try { + QaServicePOJO.logger.debug("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) throws QaApplicationException { + 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) throws QaApplicationException { + try { + qaDAO.removeQaById(qaId); + } catch (DataAccessException e) { + throw new QaApplicationException("Exception occured when lams is deleting" + " the qa content: " + + e.getMessage(), e); + } + } + + public void deleteQaSession(QaSession QaSession) throws QaApplicationException { + try { + qaSessionDAO.deleteQaSession(QaSession); + } catch (DataAccessException e) { + throw new QaApplicationException("Exception occured when lams is deleting" + " the qa session: " + + e.getMessage(), e); + } + } + + public void removeUserResponse(QaUsrResp resp) throws QaApplicationException { + try { + auditService.logChange(QaAppConstants.MY_SIGNATURE, resp.getQaQueUser().getQueUsrId(), resp.getQaQueUser() + .getUsername(), resp.getAnswer(), null); + qaUsrRespDAO.removeUserResponse(resp); + } catch (DataAccessException e) { + throw new QaApplicationException( + "Exception occured when lams is deleting" + " the resp: " + e.getMessage(), e); + } + } + /** - * logs hiding of a user entered vote + * logs hiding of a user entered vote */ - public void hideResponse(QaUsrResp qaUsrResp) throws QaApplicationException - { - logger.debug("hiding user entry: " + qaUsrResp.getAnswer()); - auditService.logHideEntry(MY_SIGNATURE, qaUsrResp.getQueUsrId(), - qaUsrResp.getQaQueUser().getUsername(), qaUsrResp.getAnswer()); + public void hideResponse(QaUsrResp qaUsrResp) throws QaApplicationException { + QaServicePOJO.logger.debug("hiding user entry: " + qaUsrResp.getAnswer()); + auditService.logHideEntry(QaAppConstants.MY_SIGNATURE, qaUsrResp.getQueUsrId(), qaUsrResp.getQaQueUser() + .getUsername(), qaUsrResp.getAnswer()); } /** - * logs showing of a user entered vote + * logs showing of a user entered vote */ - public void showResponse(QaUsrResp qaUsrResp) throws QaApplicationException - { - logger.debug("showing user entry: " + qaUsrResp.getAnswer()); - auditService.logShowEntry(MY_SIGNATURE, qaUsrResp.getQueUsrId(), - qaUsrResp.getQaQueUser().getUsername(), qaUsrResp.getAnswer()); + public void showResponse(QaUsrResp qaUsrResp) throws QaApplicationException { + QaServicePOJO.logger.debug("showing user entry: " + qaUsrResp.getAnswer()); + auditService.logShowEntry(QaAppConstants.MY_SIGNATURE, qaUsrResp.getQueUsrId(), qaUsrResp.getQaQueUser() + .getUsername(), qaUsrResp.getAnswer()); } - - - public void deleteUsrRespByQueId(Long qaQueId) throws QaApplicationException - { - try - { - qaUsrRespDAO.removeUserResponseByQaQueId(qaQueId); - } - catch(DataAccessException e) - { - throw new QaApplicationException("Exception occured when lams is deleting" - + " the resp: " - + e.getMessage(),e); - } + public void deleteUsrRespByQueId(Long qaQueId) throws QaApplicationException { + 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) throws QaApplicationException - { - try - { - qaQueUsrDAO.deleteQaQueUsr(qaQueUsr); - } - catch(DataAccessException e) - { - throw new QaApplicationException("Exception occured when lams is deleting" - + " the user: " - + e.getMessage(),e); - } + + public void deleteQaQueUsr(QaQueUsr qaQueUsr) throws QaApplicationException { + try { + qaQueUsrDAO.deleteQaQueUsr(qaQueUsr); + } catch (DataAccessException e) { + throw new QaApplicationException( + "Exception occured when lams is deleting" + " the user: " + e.getMessage(), e); + } } - + public List retrieveQaUploadedFiles(QaContent qa) throws QaApplicationException { - try { - return qaUploadedFileDAO.retrieveQaUploadedFiles(qa); - } - catch (DataAccessException e) { - throw new QaApplicationException("Exception occured when lams is loading qa uploaded files: " - + e.getMessage(), - e); - } + try { + return qaUploadedFileDAO.retrieveQaUploadedFiles(qa); + } catch (DataAccessException e) { + throw new QaApplicationException("Exception occured when lams is loading qa uploaded files: " + + e.getMessage(), e); + } } - - public int getTotalNumberOfUsers(QaContent qa) - { - try - { - return qaQueUsrDAO.getTotalNumberOfUsers(qa); - } - catch (DataAccessException e) - { - throw new QaApplicationException("Exception occured when lams is retrieving total number of QaQueUsr: " - + e.getMessage(), - e); - } + public int getTotalNumberOfUsers(QaContent qa) { + try { + return qaQueUsrDAO.getTotalNumberOfUsers(qa); + } catch (DataAccessException e) { + throw new QaApplicationException("Exception occured when lams is retrieving total number of QaQueUsr: " + + e.getMessage(), e); + } } - - public int getTotalNumberOfUsers() throws QaApplicationException - { - try - { - return qaQueUsrDAO.getTotalNumberOfUsers(); - } - catch (DataAccessException e) - { - throw new QaApplicationException("Exception occured when lams is retrieving total number of QaQueUsr: " - + e.getMessage(), - e); - } + + public int getTotalNumberOfUsers() throws QaApplicationException { + try { + return qaQueUsrDAO.getTotalNumberOfUsers(); + } catch (DataAccessException e) { + throw new QaApplicationException("Exception occured when lams is retrieving total number of QaQueUsr: " + + e.getMessage(), e); } + } - public int countTotalNumberOfUserResponsed(QaContent qa) throws QaApplicationException - { - try - { - return qaDAO.countUserResponsed(qa); - } - catch (DataAccessException e) - { - throw new QaApplicationException("Exception occured in [countTotalNumberOfUserResponsed]: " - + e.getMessage(), - e); - } + public int countTotalNumberOfUserResponsed(QaContent qa) throws QaApplicationException { + try { + return qaDAO.countUserResponsed(qa); + } catch (DataAccessException e) { + throw new QaApplicationException("Exception occured in [countTotalNumberOfUserResponsed]: " + + e.getMessage(), e); + } } - - public List getAllQuestionEntries(final Long uid) throws QaApplicationException - { - try - { - return qaQueContentDAO.getAllQuestionEntries(uid.longValue()); - } - catch (DataAccessException e) - { - throw new QaApplicationException("Exception occured when lams is getting by uid qa question content: " - + e.getMessage(), - e); - } + public List getAllQuestionEntries(final Long uid) throws QaApplicationException { + try { + return qaQueContentDAO.getAllQuestionEntries(uid.longValue()); + } catch (DataAccessException e) { + throw new QaApplicationException("Exception occured when lams is getting by uid qa question content: " + + e.getMessage(), e); } - - - public List getAllQuestionEntriesSorted(final long qaContentId) throws QaApplicationException - { - try - { - return qaQueContentDAO.getAllQuestionEntriesSorted(qaContentId); - } - catch (DataAccessException e) - { - throw new QaApplicationException("Exception occured when lams is getting all question entries: " - + e.getMessage(), - e); - } + } + + public List getAllQuestionEntriesSorted(final long qaContentId) throws QaApplicationException { + try { + return qaQueContentDAO.getAllQuestionEntriesSorted(qaContentId); + } catch (DataAccessException e) { + throw new QaApplicationException("Exception occured when lams is getting all question entries: " + + e.getMessage(), e); } - - - public void removeQaQueContent(QaQueContent qaQueContent) throws QaApplicationException - { - try - { - qaQueContentDAO.removeQaQueContent(qaQueContent); - } - catch (DataAccessException e) - { - throw new QaApplicationException("Exception occured when lams is removing question content: " - + e.getMessage(), - e); - } + } + + public void removeQaQueContent(QaQueContent qaQueContent) throws QaApplicationException { + try { + qaQueContentDAO.removeQaQueContent(qaQueContent); + } catch (DataAccessException e) { + throw new QaApplicationException("Exception occured when lams is removing question content: " + + e.getMessage(), e); } + } - - public User getCurrentUserData(String username) throws QaApplicationException - { - try - { - logger.debug("getCurrentUserData: " + username); - /* - * this will return null if the username not found - */ - User user=userManagementService.getUserByLogin(username); - if (user == null) - { - logger.debug("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 User getCurrentUserData(String username) throws QaApplicationException { + try { + QaServicePOJO.logger.debug("getCurrentUserData: " + username); + /* + * this will return null if the username not found + */ + User user = userManagementService.getUserByLogin(username); + if (user == null) { + QaServicePOJO.logger.debug("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 void saveQaContent(QaContent qa) throws QaApplicationException - { - try - { - qaDAO.saveQa(qa); - } - catch (DataAccessException e) - { - throw new QaApplicationException("Exception occured when lams is saving" - + " the qa content: " - + e.getMessage(),e); - } + public void saveQaContent(QaContent qa) throws QaApplicationException { + 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) throws QaApplicationException - { - try - { - return qaQueUsrDAO.getQaQueUsrById(qaQaQueUsrId); - } - catch (DataAccessException e) - { - throw new QaApplicationException("Exception occured when lams is loading qa que usr: " - + e.getMessage(), - e); - } + + public QaQueUsr retrieveQaQueUsr(long qaQaQueUsrId) throws QaApplicationException { + 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) throws QaApplicationException - { - try - { - return qaQueUsrDAO.countSessionUser(qaSession); - } - catch (DataAccessException e) - { - throw new QaApplicationException("Exception occured when lams is counting users in the session " - + e.getMessage(), - e); - } + + public int countSessionUser(QaSession qaSession) throws QaApplicationException { + 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 - * boolean studentActivityOccurredGlobal(QaContent qaContent) throws QaApplicationException - * - * @param qa - * @return boolean - * @throws QaApplicationException - */ - public boolean studentActivityOccurredGlobal(QaContent qaContent) throws QaApplicationException - { - logger.debug("doing studentActivityOccurredGlobal : " + qaContent); - - if (qaContent != null) - { - Iterator questionIterator=qaContent.getQaQueContents().iterator(); - while (questionIterator.hasNext()) - { - QaQueContent qaQueContent=(QaQueContent)questionIterator.next(); - logger.debug("iterated question : " + qaQueContent); - Iterator responsesIterator=qaQueContent.getQaUsrResps().iterator(); - while (responsesIterator.hasNext()) - { - logger.debug("there is at least one response"); - return true; - } - } - logger.debug("there is no response for this content"); + } + + /** + * checks the paramter content in the user responses table boolean studentActivityOccurredGlobal(QaContent + * qaContent) throws QaApplicationException + * + * @param qa + * @return boolean + * @throws QaApplicationException + */ + public boolean studentActivityOccurredGlobal(QaContent qaContent) throws QaApplicationException { + QaServicePOJO.logger.debug("doing studentActivityOccurredGlobal : " + qaContent); + + if (qaContent != null) { + Iterator questionIterator = qaContent.getQaQueContents().iterator(); + while (questionIterator.hasNext()) { + QaQueContent qaQueContent = (QaQueContent) questionIterator.next(); + QaServicePOJO.logger.debug("iterated question : " + qaQueContent); + Iterator responsesIterator = qaQueContent.getQaUsrResps().iterator(); + while (responsesIterator.hasNext()) { + QaServicePOJO.logger.debug("there is at least one response"); + return true; + } } - return false; + QaServicePOJO.logger.debug("there is no response for this content"); } - + return false; + } - /** - * counts the number of sessions marked INCOMPLETE for a content - * int countIncompleteSession(QaContent qa) throws QaApplicationException - * - * @param qa - * @return int - * @throws QaApplicationException - */ - public int countIncompleteSession(QaContent qa) throws QaApplicationException - { - logger.debug("start of countIncompleteSession: " + qa); - logger.debug("qaContentId: " + qa.getQaContentId()); - int countIncompleteSession=qaSessionDAO.countSessionIncomplete(); - logger.debug("countIncompleteSession: " + countIncompleteSession); - return countIncompleteSession; + /** + * counts the number of sessions marked INCOMPLETE for a content int countIncompleteSession(QaContent qa) throws + * QaApplicationException + * + * @param qa + * @return int + * @throws QaApplicationException + */ + public int countIncompleteSession(QaContent qa) throws QaApplicationException { + QaServicePOJO.logger.debug("start of countIncompleteSession: " + qa); + QaServicePOJO.logger.debug("qaContentId: " + qa.getQaContentId()); + int countIncompleteSession = qaSessionDAO.countSessionIncomplete(); + QaServicePOJO.logger.debug("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 + * + * boolean studentActivityOccurred(QaContent qa) throws QaApplicationException + * + * @param qa + * @return boolean + * @throws QaApplicationException + */ + public boolean studentActivityOccurred(QaContent qa) throws QaApplicationException { + QaServicePOJO.logger.debug("start of studentActivityOccurred: " + qa); + QaServicePOJO.logger.debug("qaContentId: " + qa.getQaContentId()); + int countStudentActivity = qaSessionDAO.studentActivityOccurred(qa); + QaServicePOJO.logger.debug("countIncompleteSession: " + countStudentActivity); + if (countStudentActivity > 0) { + return true; } - - /** - * 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 - * - * boolean studentActivityOccurred(QaContent qa) throws QaApplicationException - * @param qa - * @return boolean - * @throws QaApplicationException - */ - public boolean studentActivityOccurred(QaContent qa) throws QaApplicationException - { - logger.debug("start of studentActivityOccurred: " + qa); - logger.debug("qaContentId: " + qa.getQaContentId()); - int countStudentActivity=qaSessionDAO.studentActivityOccurred(qa); - logger.debug("countIncompleteSession: " + countStudentActivity); - if (countStudentActivity > 0) - return true; - return false; - } - - - /** - * 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 - * - */ + return false; + } + + /** + * 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 ToolException - + { - logger.debug("start of copyToolContent with ids: " + fromContentId + " and " + toContentId); + QaServicePOJO.logger.debug("start of copyToolContent with ids: " + fromContentId + " and " + toContentId); - if (fromContentId == null) - { - logger.debug("fromContentId is null."); - logger.debug("attempt retrieving tool's default content id with signatute : " + MY_SIGNATURE); - long defaultContentId=0; - try - { - defaultContentId=getToolDefaultContentIdBySignature(MY_SIGNATURE); - fromContentId= new Long(defaultContentId); - } - catch(Exception e) - { - logger.debug("default content id has not been setup for signature: " + MY_SIGNATURE); - throw new ToolException("WARNING! default content has not been setup for signature" + MY_SIGNATURE + " Can't continue!"); - } - } - - if (toContentId == null) - { - logger.debug("throwing ToolException: toContentId is null"); - throw new ToolException("toContentId is missing"); - } - logger.debug("final - copyToolContent using ids: " + fromContentId + " and " + toContentId); - - try - { - QaContent fromContent = qaDAO.loadQaById(fromContentId.longValue()); - - if (fromContent == null) - { - logger.debug("fromContent is null."); - logger.debug("attempt retrieving tool's default content id with signatute : " + MY_SIGNATURE); - long defaultContentId=0; - try - { - defaultContentId=getToolDefaultContentIdBySignature(MY_SIGNATURE); - fromContentId= new Long(defaultContentId); - } - catch(Exception e) - { - logger.debug("default content id has not been setup for signature: " + MY_SIGNATURE); - throw new ToolException("WARNING! default content has not been setup for signature" + MY_SIGNATURE + " Can't continue!"); - } - - fromContent = qaDAO.loadQaById(fromContentId.longValue()); - logger.debug("using fromContent: " + fromContent); - } - - logger.debug("final - retrieved fromContent: " + fromContent); - logger.debug("final - before new instance using " + fromContent + " and " + toContentId); - - - QaContent toContent = QaContent.newInstance(qaToolContentHandler, fromContent,toContentId); - if (toContent == null) - { - logger.debug("throwing ToolException: WARNING!, retrieved toContent is null."); - throw new ToolException("WARNING! Fail to create toContent. Can't continue!"); - } - else - { - logger.debug("retrieved toContent: " + toContent); - qaDAO.saveQa(toContent); - logger.debug("toContent has been saved successfully: " + toContent); - } - logger.debug("end of copyToolContent with ids: " + fromContentId + " and " + toContentId); - } - catch (DataAccessException e) - { - logger.debug("throwing ToolException: Exception occured when lams is copying content between content ids."); - throw new ToolException("Exception occured when lams is copying content between content ids."); - } - catch (ItemNotFoundException e) - { - throw new ToolException("Exception occured when lams is copying content between content ids."); - } - catch (RepositoryCheckedException e) - { - throw new ToolException("Exception occured when lams is copying content between content ids."); - } - - } + if (fromContentId == null) { + QaServicePOJO.logger.debug("fromContentId is null."); + QaServicePOJO.logger.debug("attempt retrieving tool's default content id with signatute : " + + QaAppConstants.MY_SIGNATURE); + long defaultContentId = 0; + try { + defaultContentId = getToolDefaultContentIdBySignature(QaAppConstants.MY_SIGNATURE); + fromContentId = new Long(defaultContentId); + } catch (Exception e) { + QaServicePOJO.logger.debug("default content id has not been setup for signature: " + + QaAppConstants.MY_SIGNATURE); + throw new ToolException("WARNING! default content has not been setup for signature" + + QaAppConstants.MY_SIGNATURE + " Can't continue!"); + } + } + if (toContentId == null) { + QaServicePOJO.logger.debug("throwing ToolException: toContentId is null"); + throw new ToolException("toContentId is missing"); + } + QaServicePOJO.logger.debug("final - copyToolContent using ids: " + fromContentId + " and " + toContentId); - + try { + QaContent fromContent = qaDAO.loadQaById(fromContentId.longValue()); + + if (fromContent == null) { + QaServicePOJO.logger.debug("fromContent is null."); + QaServicePOJO.logger.debug("attempt retrieving tool's default content id with signatute : " + + QaAppConstants.MY_SIGNATURE); + long defaultContentId = 0; + try { + defaultContentId = getToolDefaultContentIdBySignature(QaAppConstants.MY_SIGNATURE); + fromContentId = new Long(defaultContentId); + } catch (Exception e) { + QaServicePOJO.logger.debug("default content id has not been setup for signature: " + + QaAppConstants.MY_SIGNATURE); + throw new ToolException("WARNING! default content has not been setup for signature" + + QaAppConstants.MY_SIGNATURE + " Can't continue!"); + } + + fromContent = qaDAO.loadQaById(fromContentId.longValue()); + QaServicePOJO.logger.debug("using fromContent: " + fromContent); + } + + QaServicePOJO.logger.debug("final - retrieved fromContent: " + fromContent); + QaServicePOJO.logger.debug("final - before new instance using " + fromContent + " and " + toContentId); + + QaContent toContent = QaContent.newInstance(qaToolContentHandler, fromContent, toContentId); + if (toContent == null) { + QaServicePOJO.logger.debug("throwing ToolException: WARNING!, retrieved toContent is null."); + throw new ToolException("WARNING! Fail to create toContent. Can't continue!"); + } else { + QaServicePOJO.logger.debug("retrieved toContent: " + toContent); + qaDAO.saveQa(toContent); + QaServicePOJO.logger.debug("toContent has been saved successfully: " + toContent); + } + QaServicePOJO.logger.debug("end of copyToolContent with ids: " + fromContentId + " and " + toContentId); + } catch (DataAccessException e) { + QaServicePOJO.logger + .debug("throwing ToolException: Exception occured when lams is copying content between content ids."); + throw new ToolException("Exception occured when lams is copying content between content ids."); + } catch (ItemNotFoundException e) { + throw new ToolException("Exception occured when lams is copying content between content ids."); + } catch (RepositoryCheckedException e) { + throw new ToolException("Exception occured when lams is copying content between content ids."); + } + + } + /** - * setAsForceCompleteSession(Long toolSessionId) throws QaApplicationException - * update the tool session status to COMPLETE for this tool session + * setAsForceCompleteSession(Long toolSessionId) throws QaApplicationException update the tool session status to + * COMPLETE for this tool session * - * @param Long toolSessionId + * @param Long + * toolSessionId */ - public void setAsForceCompleteSession(Long toolSessionId) throws QaApplicationException - { - logger.debug("rrequest for setAsForceCompleteSession has come for toolSessionId: " + toolSessionId); - - QaSession qaSession=retrieveQaSessionOrNullById(toolSessionId.longValue()); - logger.debug("retrieved qaSession is : " + qaSession); - qaSession.setSession_status(QaSession.COMPLETED); - logger.debug("updated qaSession to COMPLETED : "); - updateQaSession(qaSession); - logger.debug("updated qaSession to COMPLETED in the db : "); - } + public void setAsForceCompleteSession(Long toolSessionId) throws QaApplicationException { + QaServicePOJO.logger.debug("rrequest for setAsForceCompleteSession has come for toolSessionId: " + + toolSessionId); - + QaSession qaSession = retrieveQaSessionOrNullById(toolSessionId.longValue()); + QaServicePOJO.logger.debug("retrieved qaSession is : " + qaSession); + qaSession.setSession_status(QaSession.COMPLETED); + QaServicePOJO.logger.debug("updated qaSession to COMPLETED : "); + updateQaSession(qaSession); + QaServicePOJO.logger.debug("updated qaSession to COMPLETED in the db : "); + } + /** - * setAsForceComplete(Long userId) throws QaApplicationException - * update the tool session status to COMPLETE for this user + * setAsForceComplete(Long userId) throws QaApplicationException update the tool session status to COMPLETE for this + * user + * * @param userId */ - public void setAsForceComplete(Long userId) throws QaApplicationException - { - logger.debug("request for setAsForceComplete has come for userId: " + userId); - QaQueUsr qaQueUsr=loadQaQueUsr(userId); - - if (qaQueUsr != null) - { - logger.debug("retrieved qaQueUsr : " + qaQueUsr); - logger.debug("retrieved qaQueUsr has the tool session : " + qaQueUsr.getQaSession()); - QaSession qaSession=qaQueUsr.getQaSession(); - if (qaSession != null) - { - Long usersToolSessionId=qaSession.getQaSessionId(); - logger.debug("retrieved tool session has tool session id : " + usersToolSessionId); - - qaSession=retrieveQaSessionOrNullById(usersToolSessionId.longValue()); - logger.debug("retrieved qaSession is : " + qaSession); - qaSession.setSession_status(QaSession.COMPLETED); - logger.debug("updated qaSession to COMPLETED : "); - updateQaSession(qaSession); - logger.debug("updated qaSession to COMPLETED in the db : "); - QaContent qaContent=qaSession.getQaContent(); - logger.debug("qaSession uses qaContent : " + qaContent); - logger.debug("qaSession uses qaContentId : " + qaContent.getQaContentId()); - - int countIncompleteSession=countIncompleteSession(qaContent); - logger.debug("qaSession countIncompleteSession : " + countIncompleteSession); - - if (countIncompleteSession == 0) - { - qaContent.setContentLocked(false); - updateQa(qaContent); - logger.debug("qaContent has been updated for contentLocked" + qaContent); - } - } - else - { - logger.debug("WARNING!: retrieved qaSession is null."); - throw new QaApplicationException("Fail to setAsForceComplete" - + " based on null qaSession."); - } - } - else - { - logger.debug("WARNING!: retrieved qaQueUsr is null."); - throw new QaApplicationException("Fail to setAsForceComplete" - + " based on null qaQueUsr."); - } + public void setAsForceComplete(Long userId) throws QaApplicationException { + QaServicePOJO.logger.debug("request for setAsForceComplete has come for userId: " + userId); + QaQueUsr qaQueUsr = loadQaQueUsr(userId); + + if (qaQueUsr != null) { + QaServicePOJO.logger.debug("retrieved qaQueUsr : " + qaQueUsr); + QaServicePOJO.logger.debug("retrieved qaQueUsr has the tool session : " + qaQueUsr.getQaSession()); + QaSession qaSession = qaQueUsr.getQaSession(); + if (qaSession != null) { + Long usersToolSessionId = qaSession.getQaSessionId(); + QaServicePOJO.logger.debug("retrieved tool session has tool session id : " + usersToolSessionId); + + qaSession = retrieveQaSessionOrNullById(usersToolSessionId.longValue()); + QaServicePOJO.logger.debug("retrieved qaSession is : " + qaSession); + qaSession.setSession_status(QaSession.COMPLETED); + QaServicePOJO.logger.debug("updated qaSession to COMPLETED : "); + updateQaSession(qaSession); + QaServicePOJO.logger.debug("updated qaSession to COMPLETED in the db : "); + QaContent qaContent = qaSession.getQaContent(); + QaServicePOJO.logger.debug("qaSession uses qaContent : " + qaContent); + QaServicePOJO.logger.debug("qaSession uses qaContentId : " + qaContent.getQaContentId()); + + int countIncompleteSession = countIncompleteSession(qaContent); + QaServicePOJO.logger.debug("qaSession countIncompleteSession : " + countIncompleteSession); + + if (countIncompleteSession == 0) { + qaContent.setContentLocked(false); + updateQa(qaContent); + QaServicePOJO.logger.debug("qaContent has been updated for contentLocked" + qaContent); + } + } else { + QaServicePOJO.logger.debug("WARNING!: retrieved qaSession is null."); + throw new QaApplicationException("Fail to setAsForceComplete" + " based on null qaSession."); + } + } else { + QaServicePOJO.logger.debug("WARNING!: retrieved qaQueUsr is null."); + throw new QaApplicationException("Fail to setAsForceComplete" + " based on null qaQueUsr."); + } } - - + /** * setAsDefineLater(Long toolContentID) throws DataMissingException, ToolException * * @param toolContentID - * return void + * return void */ - public void setAsDefineLater(Long toolContentID, boolean value) throws DataMissingException, ToolException - { - logger.debug("request for setAsDefineLater with toolContentID: " + toolContentID); - if (toolContentID == null) - { - logger.debug("throwing DataMissingException: WARNING!: retrieved toolContentID is null."); - throw new DataMissingException("toolContentID is missing"); - } - QaContent qaContent = qaDAO.loadQaById(toolContentID.longValue()); - if (qaContent == null) - { - logger.debug("throwing DataMissingException: WARNING!: retrieved qaContent is null."); - throw new DataMissingException("qaContent is missing"); - } - qaContent.setDefineLater(value); - updateQa(qaContent); - logger.debug("qaContent has been updated for defineLater: " + qaContent); + public void setAsDefineLater(Long toolContentID, boolean value) throws DataMissingException, ToolException { + QaServicePOJO.logger.debug("request for setAsDefineLater with toolContentID: " + toolContentID); + if (toolContentID == null) { + QaServicePOJO.logger.debug("throwing DataMissingException: WARNING!: retrieved toolContentID is null."); + throw new DataMissingException("toolContentID is missing"); + } + QaContent qaContent = qaDAO.loadQaById(toolContentID.longValue()); + if (qaContent == null) { + QaServicePOJO.logger.debug("throwing DataMissingException: WARNING!: retrieved qaContent is null."); + throw new DataMissingException("qaContent is missing"); + } + qaContent.setDefineLater(value); + updateQa(qaContent); + QaServicePOJO.logger.debug("qaContent has been updated for defineLater: " + qaContent); } /** - * setAsRunOffline(Long toolContentID) throws DataMissingException, ToolException - * set the runOffline to true on this content + * setAsRunOffline(Long toolContentID) throws DataMissingException, ToolException set the runOffline to true on this + * content * * @param toolContentID - * return void + * return void */ - public void setAsRunOffline(Long toolContentID, boolean value) throws DataMissingException, ToolException - { - logger.debug("request for setAsRunOffline with toolContentID:" + toolContentID); - if (toolContentID == null) - { - logger.debug("throwing DataMissingException: WARNING!: retrieved toolContentID is null."); - throw new DataMissingException("toolContentID is missing"); - } - QaContent qaContent = qaDAO.loadQaById(toolContentID.longValue()); - if (qaContent == null) - { - logger.debug("throwing DataMissingException: WARNING!: retrieved qaContent is null."); - throw new DataMissingException("qaContent is missing"); - } - qaContent.setRunOffline(value); - updateQa(qaContent); - logger.debug("qaContent has been updated for runOffline: " + qaContent); + public void setAsRunOffline(Long toolContentID, boolean value) throws DataMissingException, ToolException { + QaServicePOJO.logger.debug("request for setAsRunOffline with toolContentID:" + toolContentID); + if (toolContentID == null) { + QaServicePOJO.logger.debug("throwing DataMissingException: WARNING!: retrieved toolContentID is null."); + throw new DataMissingException("toolContentID is missing"); + } + QaContent qaContent = qaDAO.loadQaById(toolContentID.longValue()); + if (qaContent == null) { + QaServicePOJO.logger.debug("throwing DataMissingException: WARNING!: retrieved qaContent is null."); + throw new DataMissingException("qaContent is missing"); + } + qaContent.setRunOffline(value); + updateQa(qaContent); + QaServicePOJO.logger.debug("qaContent has been updated for runOffline: " + qaContent); } - - /** + /** * - * removeToolContent(Long toolContentID) - * gets automatically called only in monitoring mode when the author chooses to delete a lesson. + * removeToolContent(Long toolContentID) 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. + * 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("start of removeToolContent with toolContentID: " + toolContentID); - - QaContent qaContent = qaDAO.loadQaById(toolContentID.longValue()); - logger.debug("retrieving qaContent: " + qaContent); - - if (qaContent != null) - { - Iterator sessionIterator=qaContent.getQaSessions().iterator(); - while (sessionIterator.hasNext()) - { - QaSession qaSession=(QaSession)sessionIterator.next(); - logger.debug("iterated qaSession : " + qaSession); - - Iterator sessionUsersIterator=qaSession.getQaQueUsers().iterator(); - while (sessionUsersIterator.hasNext()) - { - QaQueUsr qaQueUsr=(QaQueUsr) sessionUsersIterator.next(); - logger.debug("iterated qaQueUsr : " + qaQueUsr); - - Iterator sessionUsersResponsesIterator=qaQueUsr.getQaUsrResps().iterator(); - while (sessionUsersResponsesIterator.hasNext()) - { - QaUsrResp qaUsrResp=(QaUsrResp)sessionUsersResponsesIterator.next(); - logger.debug("iterated qaUsrResp : " + qaUsrResp); - removeUserResponse(qaUsrResp); - logger.debug("removed qaUsrResp : " + qaUsrResp); - } - } - } - - logger.debug("removed all existing responses of toolContent with toolContentID:" + - toolContentID); - qaDAO.removeQa(toolContentID); - logger.debug("removed qaContent:" + qaContent); - } + public void removeToolContent(Long toolContentID) { + QaServicePOJO.logger.debug("start of removeToolContent with toolContentID: " + toolContentID); + + QaContent qaContent = qaDAO.loadQaById(toolContentID.longValue()); + QaServicePOJO.logger.debug("retrieving qaContent: " + qaContent); + + if (qaContent != null) { + Iterator sessionIterator = qaContent.getQaSessions().iterator(); + while (sessionIterator.hasNext()) { + QaSession qaSession = (QaSession) sessionIterator.next(); + QaServicePOJO.logger.debug("iterated qaSession : " + qaSession); + + Iterator sessionUsersIterator = qaSession.getQaQueUsers().iterator(); + while (sessionUsersIterator.hasNext()) { + QaQueUsr qaQueUsr = (QaQueUsr) sessionUsersIterator.next(); + QaServicePOJO.logger.debug("iterated qaQueUsr : " + qaQueUsr); + + Iterator sessionUsersResponsesIterator = qaQueUsr.getQaUsrResps().iterator(); + while (sessionUsersResponsesIterator.hasNext()) { + QaUsrResp qaUsrResp = (QaUsrResp) sessionUsersResponsesIterator.next(); + QaServicePOJO.logger.debug("iterated qaUsrResp : " + qaUsrResp); + removeUserResponse(qaUsrResp); + QaServicePOJO.logger.debug("removed qaUsrResp : " + qaUsrResp); + } + } + } + + QaServicePOJO.logger.debug("removed all existing responses of toolContent with toolContentID:" + + toolContentID); + qaDAO.removeQa(toolContentID); + QaServicePOJO.logger.debug("removed qaContent:" + qaContent); + } } - - public void removeQuestions(Long toolContentID) throws QaApplicationException - { - QaContent qaContent = qaDAO.loadQaById(toolContentID.longValue()); - qaContent.setQaQueContents(new TreeSet()); - - if (qaContent != null) - { - Iterator sessionIterator=qaContent.getQaSessions().iterator(); - while (sessionIterator.hasNext()) - { - QaSession qaSession=(QaSession)sessionIterator.next(); - logger.debug("iterated qaSession : " + qaSession); - - Iterator sessionUsersIterator=qaSession.getQaQueUsers().iterator(); - while (sessionUsersIterator.hasNext()) - { - QaQueUsr qaQueUsr=(QaQueUsr) sessionUsersIterator.next(); - logger.debug("iterated qaQueUsr : " + qaQueUsr); - - Iterator sessionUsersResponsesIterator=qaQueUsr.getQaUsrResps().iterator(); - while (sessionUsersResponsesIterator.hasNext()) - { - QaUsrResp qaUsrResp=(QaUsrResp)sessionUsersResponsesIterator.next(); - logger.debug("iterated qaUsrResp : " + qaUsrResp); - removeUserResponse(qaUsrResp); - logger.debug("removed qaUsrResp : " + qaUsrResp); - } - } - } - } + + public void removeQuestions(Long toolContentID) throws QaApplicationException { + QaContent qaContent = qaDAO.loadQaById(toolContentID.longValue()); + qaContent.setQaQueContents(new TreeSet()); + + if (qaContent != null) { + Iterator sessionIterator = qaContent.getQaSessions().iterator(); + while (sessionIterator.hasNext()) { + QaSession qaSession = (QaSession) sessionIterator.next(); + QaServicePOJO.logger.debug("iterated qaSession : " + qaSession); + + Iterator sessionUsersIterator = qaSession.getQaQueUsers().iterator(); + while (sessionUsersIterator.hasNext()) { + QaQueUsr qaQueUsr = (QaQueUsr) sessionUsersIterator.next(); + QaServicePOJO.logger.debug("iterated qaQueUsr : " + qaQueUsr); + + Iterator sessionUsersResponsesIterator = qaQueUsr.getQaUsrResps().iterator(); + while (sessionUsersResponsesIterator.hasNext()) { + QaUsrResp qaUsrResp = (QaUsrResp) sessionUsersResponsesIterator.next(); + QaServicePOJO.logger.debug("iterated qaUsrResp : " + qaUsrResp); + removeUserResponse(qaUsrResp); + QaServicePOJO.logger.debug("removed qaUsrResp : " + qaUsrResp); + } + } + } + } } - - + /** * removeToolContent(Long toolContentID, boolean removeSessionData) throws SessionDataExistsException, ToolException - * Will need an update on the core tool signature: reason : when qaContent is null throw an exception + * Will need an update on the core tool signature: reason : when qaContent is null throw an exception * */ - public void removeToolContent(Long toolContentID, boolean removeSessionData) throws SessionDataExistsException, ToolException - { - logger.debug("start of: removeToolContent(Long toolContentID, boolean removeSessionData"); - logger.debug("start of removeToolContent with toolContentID: " + toolContentID + "removeSessionData: " + removeSessionData); - - if (toolContentID == null) - { - logger.debug("toolContentID is null"); - throw new ToolException("toolContentID is missing"); - } - - QaContent qaContent = qaDAO.loadQaById(toolContentID.longValue()); - logger.debug("retrieving qaContent: " + qaContent); - - if (qaContent != null) - { - Iterator sessionIterator=qaContent.getQaSessions().iterator(); - while (sessionIterator.hasNext()) - { - if (removeSessionData == false) - { - logger.debug("removeSessionData is false, throwing SessionDataExistsException."); - throw new SessionDataExistsException(); - } - - QaSession qaSession=(QaSession)sessionIterator.next(); - logger.debug("iterated qaSession : " + qaSession); - - Iterator sessionUsersIterator=qaSession.getQaQueUsers().iterator(); - while (sessionUsersIterator.hasNext()) - { - QaQueUsr qaQueUsr=(QaQueUsr) sessionUsersIterator.next(); - logger.debug("iterated qaQueUsr : " + qaQueUsr); - - Iterator sessionUsersResponsesIterator=qaQueUsr.getQaUsrResps().iterator(); - while (sessionUsersResponsesIterator.hasNext()) - { - QaUsrResp qaUsrResp=(QaUsrResp)sessionUsersResponsesIterator.next(); - logger.debug("iterated qaUsrResp : " + qaUsrResp); - removeUserResponse(qaUsrResp); - logger.debug("removed qaUsrResp : " + qaUsrResp); - } - } - } - - logger.debug("removed all existing responses of toolContent with toolContentID:" + - toolContentID); - qaDAO.removeQa(toolContentID); - logger.debug("removed qaContent:" + qaContent); - } - else - { - logger.debug("Warning!!!, We should have not come here. qaContent is null."); - throw new ToolException("toolContentID is missing"); - } + public void removeToolContent(Long toolContentID, boolean removeSessionData) throws SessionDataExistsException, + ToolException { + QaServicePOJO.logger.debug("start of: removeToolContent(Long toolContentID, boolean removeSessionData"); + QaServicePOJO.logger.debug("start of removeToolContent with toolContentID: " + toolContentID + + "removeSessionData: " + removeSessionData); + + if (toolContentID == null) { + QaServicePOJO.logger.debug("toolContentID is null"); + throw new ToolException("toolContentID is missing"); } - - /** - * Export the XML fragment for the tool's content, along with any files needed - * for the content. - * @throws DataMissingException if no tool content matches the toolSessionId - * @throws ToolException if any other error occurs - */ - public void exportToolContent(Long toolContentID, String rootPath) throws DataMissingException, ToolException { - QaContent toolContentObj = qaDAO.getQaById(toolContentID); - if(toolContentObj == null) { - long defaultToolContentId = toolService.getToolDefaultContentIdBySignature(MY_SIGNATURE); - toolContentObj = retrieveQa(defaultToolContentId); - } - if(toolContentObj == null) - throw new DataMissingException("Unable to find default content for the question and answer tool"); - - try { - //set ToolContentHandler as null to avoid copy file node in repository again. - toolContentObj = QaContent.newInstance(null,toolContentObj,toolContentID); - - //don't export following fields value - toolContentObj.setQaSessions(null); - Set questions = toolContentObj.getQaQueContents(); - for(QaQueContent question : questions){ - question.setQaQueUsers(null); - question.setQaContent(null); - question.setQaUsrResps(null); - question.setUserResponses(null); - } - Set files = toolContentObj.getQaUploadedFiles(); - for(QaUploadedFile file : files){ - file.setQaContent(null); - } - - exportContentService.registerFileClassForExport(QaUploadedFile.class.getName(),"uuid",null); - exportContentService.exportToolContent( toolContentID, toolContentObj,qaToolContentHandler, rootPath); - } catch (ExportToolContentException e) { - throw new ToolException(e); - } catch (ItemNotFoundException e) { - throw new ToolException(e); - } catch (RepositoryCheckedException e) { - throw new ToolException(e); + QaContent qaContent = qaDAO.loadQaById(toolContentID.longValue()); + QaServicePOJO.logger.debug("retrieving qaContent: " + qaContent); + + if (qaContent != null) { + Iterator sessionIterator = qaContent.getQaSessions().iterator(); + while (sessionIterator.hasNext()) { + if (removeSessionData == false) { + QaServicePOJO.logger.debug("removeSessionData is false, throwing SessionDataExistsException."); + throw new SessionDataExistsException(); } + + QaSession qaSession = (QaSession) sessionIterator.next(); + QaServicePOJO.logger.debug("iterated qaSession : " + qaSession); + + Iterator sessionUsersIterator = qaSession.getQaQueUsers().iterator(); + while (sessionUsersIterator.hasNext()) { + QaQueUsr qaQueUsr = (QaQueUsr) sessionUsersIterator.next(); + QaServicePOJO.logger.debug("iterated qaQueUsr : " + qaQueUsr); + + Iterator sessionUsersResponsesIterator = qaQueUsr.getQaUsrResps().iterator(); + while (sessionUsersResponsesIterator.hasNext()) { + QaUsrResp qaUsrResp = (QaUsrResp) sessionUsersResponsesIterator.next(); + QaServicePOJO.logger.debug("iterated qaUsrResp : " + qaUsrResp); + removeUserResponse(qaUsrResp); + QaServicePOJO.logger.debug("removed qaUsrResp : " + qaUsrResp); + } + } + } + + QaServicePOJO.logger.debug("removed all existing responses of toolContent with toolContentID:" + + toolContentID); + qaDAO.removeQa(toolContentID); + QaServicePOJO.logger.debug("removed qaContent:" + qaContent); + } else { + QaServicePOJO.logger.debug("Warning!!!, We should have not come here. qaContent is null."); + throw new ToolException("toolContentID is missing"); } + } /** - * Import the XML fragment for the tool's content, along with any files needed - * for the content. - * @throws ToolException if any other error occurs + * Export the XML fragment for the tool's content, along with any files needed for the content. + * + * @throws DataMissingException + * if no tool content matches the toolSessionId + * @throws ToolException + * if any other error occurs */ - public void importToolContent(Long toolContentID, Integer newUserUid, String toolContentPath ,String fromVersion,String toVersion) throws ToolException { - try { - exportContentService.registerFileClassForImport(QaUploadedFile.class.getName(),"uuid",null,"fileName","fileProperty",null,null); - - //register version filter class - exportContentService.registerImportVersionFilterClass(QaImportContentVersionFilter.class); - Object toolPOJO = exportContentService.importToolContent(toolContentPath,qaToolContentHandler,fromVersion,toVersion); - if(!(toolPOJO instanceof QaContent)) - throw new ImportToolContentException("Import QA tool content failed. Deserialized object is " + toolPOJO); - QaContent toolContentObj = (QaContent) toolPOJO; - -// reset it to new toolContentID - toolContentObj.setQaContentId(toolContentID); - toolContentObj.setCreatedBy(newUserUid); - - //set back the tool content - Set questions = toolContentObj.getQaQueContents(); - for(QaQueContent question : questions){ - question.setQaContent(toolContentObj); - } - Set files = toolContentObj.getQaUploadedFiles(); - for(QaUploadedFile file : files){ - file.setQaContent(toolContentObj); - } - qaDAO.saveOrUpdateQa(toolContentObj); - } catch (ImportToolContentException e) { - throw new ToolException(e); - } + public void exportToolContent(Long toolContentID, String rootPath) throws DataMissingException, ToolException { + QaContent toolContentObj = qaDAO.getQaById(toolContentID); + if (toolContentObj == null) { + long defaultToolContentId = toolService.getToolDefaultContentIdBySignature(QaAppConstants.MY_SIGNATURE); + toolContentObj = retrieveQa(defaultToolContentId); } + if (toolContentObj == null) { + throw new DataMissingException("Unable to find default content for the question and answer tool"); + } - /** Get the definitions for possible output for an activity, based on the toolContentId. These may be definitions that are always - * available for the tool (e.g. number of marks for Multiple Choice) or a custom definition created for a particular activity - * such as the answer to the third question contains the word Koala and hence the need for the toolContentId - * @return SortedMap of ToolOutputDefinitions with the key being the name of each definition - */ - public SortedMap getToolOutputDefinitions(Long toolContentId) throws ToolException { - return new TreeMap(); - } - + try { + // set ToolContentHandler as null to avoid copy file node in + // repository again. + toolContentObj = QaContent.newInstance(null, toolContentObj, toolContentID); + + // don't export following fields value + toolContentObj.setQaSessions(null); + Set questions = toolContentObj.getQaQueContents(); + for (QaQueContent question : questions) { + question.setQaQueUsers(null); + question.setQaContent(null); + question.setQaUsrResps(null); + question.setUserResponses(null); + } + Set files = toolContentObj.getQaUploadedFiles(); + for (QaUploadedFile file : files) { + file.setQaContent(null); + } + + exportContentService.registerFileClassForExport(QaUploadedFile.class.getName(), "uuid", null); + exportContentService.exportToolContent(toolContentID, toolContentObj, qaToolContentHandler, rootPath); + } catch (ExportToolContentException e) { + throw new ToolException(e); + } catch (ItemNotFoundException e) { + throw new ToolException(e); + } catch (RepositoryCheckedException e) { + throw new ToolException(e); + } + } + /** - * 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) - { - logger.debug("toolSessionId: " + toolSessionId); - QaSession qaSession=retrieveQaSessionOrNullById(toolSessionId); - logger.debug("qaSession: " + qaSession); - - if (qaSession == null) - { - logger.debug("qaSession does not exist yet: " + toolSessionId); - return false; + * Import the XML fragment for the tool's content, along with any files needed for the content. + * + * @throws ToolException + * if any other error occurs + */ + public void importToolContent(Long toolContentID, Integer newUserUid, String toolContentPath, String fromVersion, + String toVersion) throws ToolException { + try { + exportContentService.registerFileClassForImport(QaUploadedFile.class.getName(), "uuid", null, "fileName", + "fileProperty", null, null); + + // register version filter class + exportContentService.registerImportVersionFilterClass(QaImportContentVersionFilter.class); + + Object toolPOJO = exportContentService.importToolContent(toolContentPath, qaToolContentHandler, + fromVersion, toVersion); + if (!(toolPOJO instanceof QaContent)) { + throw new ImportToolContentException("Import QA tool content failed. Deserialized object is " + + toolPOJO); } - else - { - logger.debug("retrieving an existing qaSession: " + qaSession + " " + toolSessionId); + QaContent toolContentObj = (QaContent) toolPOJO; + + // reset it to new toolContentID + toolContentObj.setQaContentId(toolContentID); + toolContentObj.setCreatedBy(newUserUid); + + // set back the tool content + Set questions = toolContentObj.getQaQueContents(); + for (QaQueContent question : questions) { + question.setQaContent(toolContentObj); } - return true; + Set files = toolContentObj.getQaUploadedFiles(); + for (QaUploadedFile file : files) { + file.setQaContent(toolContentObj); + } + qaDAO.saveOrUpdateQa(toolContentObj); + } catch (ImportToolContentException e) { + throw new ToolException(e); } - + } + /** + * Get the definitions for possible output for an activity, based on the toolContentId. These may be definitions + * that are always available for the tool (e.g. number of marks for Multiple Choice) or a custom definition created + * for a particular activity such as the answer to the third question contains the word Koala and hence the need for + * the toolContentId + * + * @return SortedMap of ToolOutputDefinitions with the key being the name of each definition + */ + public SortedMap getToolOutputDefinitions(Long toolContentId) throws ToolException { + QaContent qaContent = qaDAO.getQaById(toolContentId); + if (qaContent == null) { + long defaultToolContentId = toolService.getToolDefaultContentIdBySignature(QaAppConstants.MY_SIGNATURE); + qaContent = retrieveQa(defaultToolContentId); + } + // If there are no user added conditions, the default condition will be added in the output factory. It also + // needs to be persisted. + boolean defaultConditionToBeAdded = qaContent.getConditions().isEmpty(); + SortedMap map = getQaOutputFactory().getToolOutputDefinitions(qaContent); + if (defaultConditionToBeAdded && !qaContent.getConditions().isEmpty()) { + updateQa(qaContent); + } + return map; + } + + /** + * 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) { + QaServicePOJO.logger.debug("toolSessionId: " + toolSessionId); + QaSession qaSession = retrieveQaSessionOrNullById(toolSessionId); + QaServicePOJO.logger.debug("qaSession: " + qaSession); + + if (qaSession == null) { + QaServicePOJO.logger.debug("qaSession does not exist yet: " + toolSessionId); + return false; + } else { + QaServicePOJO.logger.debug("retrieving an existing qaSession: " + qaSession + " " + toolSessionId); + } + return true; + } + + /** * createToolSession(Long toolSessionId,String toolSessionName, Long toolContentID) throws ToolException * 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. + * gets called only in the Learner mode. All the learners in the same group have the same toolSessionId. * */ - public void createToolSession(Long toolSessionId, String toolSessionName, Long toolContentID) throws ToolException - { - logger.debug("start of createToolSession with ids: " + toolSessionId + " and " + toolContentID); - logger.debug("toolSessionName: " + toolSessionName); - - if (toolSessionId == null) - { - logger.debug("toolSessionId is null"); - throw new ToolException("toolSessionId is missing"); - } - - long defaultContentId=0; - if (toolContentID == null) - { - logger.debug("toolContentID is null."); - logger.debug("attempt retrieving tool's default content id with signatute : " + MY_SIGNATURE); - - try - { - defaultContentId=getToolDefaultContentIdBySignature(MY_SIGNATURE); - toolContentID=new Long(defaultContentId); - logger.debug("updated toolContentID to: " + toolContentID); - } - catch(Exception e) - { - logger.debug("default content id has not been setup for signature: " + MY_SIGNATURE); - throw new ToolException("WARNING! default content has not been setup for signature" + MY_SIGNATURE + " Can't continue!"); - } - } - logger.debug("final toolSessionId and toolContentID: " + toolSessionId + " " + toolContentID); - - QaContent qaContent = qaDAO.loadQaById(toolContentID.longValue()); - logger.debug("retrieved qaContent: " + qaContent); - - if (qaContent == null) - { - logger.debug("qaContent is null."); - logger.debug("attempt retrieving tool's default content id with signatute : " + MY_SIGNATURE); - - try - { - defaultContentId=getToolDefaultContentIdBySignature(MY_SIGNATURE); - toolContentID=new Long(defaultContentId); - logger.debug("updated toolContentID to: " + toolContentID); - } - catch(Exception e) - { - logger.debug("default content id has not been setup for signature: " + MY_SIGNATURE); - throw new ToolException("WARNING! default content has not been setup for signature" + MY_SIGNATURE + " Can't continue!"); - } + public void createToolSession(Long toolSessionId, String toolSessionName, Long toolContentID) throws ToolException { + QaServicePOJO.logger.debug("start of createToolSession with ids: " + toolSessionId + " and " + toolContentID); + QaServicePOJO.logger.debug("toolSessionName: " + toolSessionName); - qaContent = qaDAO.loadQaById(toolContentID.longValue()); - } - logger.debug("final - retrieved qaContent: " + qaContent); + if (toolSessionId == null) { + QaServicePOJO.logger.debug("toolSessionId is null"); + throw new ToolException("toolSessionId is missing"); + } - /* - * create a new a new tool session if it does not already exist in the tool session table - */ - if (!existsSession(toolSessionId.longValue())) - { - try - { - QaSession qaSession = new QaSession(toolSessionId, - new Date(System.currentTimeMillis()), - QaSession.INCOMPLETE, - toolSessionName, - qaContent, - new TreeSet()); + long defaultContentId = 0; + if (toolContentID == null) { + QaServicePOJO.logger.debug("toolContentID is null."); + QaServicePOJO.logger.debug("attempt retrieving tool's default content id with signatute : " + + QaAppConstants.MY_SIGNATURE); - logger.debug("created qaSession: " + qaSession); - qaSessionDAO.CreateQaSession(qaSession); - logger.debug("created qaSession in the db: " + qaSession); - - } - catch(Exception e) - { - logger.debug("Error creating new toolsession in the db"); - throw new ToolException("Error creating new toolsession in the db: " + e); - } - } + try { + defaultContentId = getToolDefaultContentIdBySignature(QaAppConstants.MY_SIGNATURE); + toolContentID = new Long(defaultContentId); + QaServicePOJO.logger.debug("updated toolContentID to: " + toolContentID); + } catch (Exception e) { + QaServicePOJO.logger.debug("default content id has not been setup for signature: " + + QaAppConstants.MY_SIGNATURE); + throw new ToolException("WARNING! default content has not been setup for signature" + + QaAppConstants.MY_SIGNATURE + " Can't continue!"); + } + } + QaServicePOJO.logger.debug("final toolSessionId and toolContentID: " + toolSessionId + " " + toolContentID); + + QaContent qaContent = qaDAO.loadQaById(toolContentID.longValue()); + QaServicePOJO.logger.debug("retrieved qaContent: " + qaContent); + + if (qaContent == null) { + QaServicePOJO.logger.debug("qaContent is null."); + QaServicePOJO.logger.debug("attempt retrieving tool's default content id with signatute : " + + QaAppConstants.MY_SIGNATURE); + + try { + defaultContentId = getToolDefaultContentIdBySignature(QaAppConstants.MY_SIGNATURE); + toolContentID = new Long(defaultContentId); + QaServicePOJO.logger.debug("updated toolContentID to: " + toolContentID); + } catch (Exception e) { + QaServicePOJO.logger.debug("default content id has not been setup for signature: " + + QaAppConstants.MY_SIGNATURE); + throw new ToolException("WARNING! default content has not been setup for signature" + + QaAppConstants.MY_SIGNATURE + " Can't continue!"); + } + + qaContent = qaDAO.loadQaById(toolContentID.longValue()); + } + QaServicePOJO.logger.debug("final - retrieved qaContent: " + qaContent); + + /* + * create a new a new tool session if it does not already exist in the tool session table + */ + if (!existsSession(toolSessionId.longValue())) { + try { + QaSession qaSession = new QaSession(toolSessionId, new Date(System.currentTimeMillis()), + QaSession.INCOMPLETE, toolSessionName, qaContent, new TreeSet()); + + QaServicePOJO.logger.debug("created qaSession: " + qaSession); + qaSessionDAO.CreateQaSession(qaSession); + QaServicePOJO.logger.debug("created qaSession in the db: " + qaSession); + + } catch (Exception e) { + QaServicePOJO.logger.debug("Error creating new toolsession in the db"); + throw new ToolException("Error creating new toolsession in the db: " + e); + } + } } - - public void removeToolSession(Long toolSessionId) throws DataMissingException, ToolException - { - logger.debug("start of removeToolSession with id: " + toolSessionId); - if (toolSessionId == null) - { - logger.debug("toolSessionId is null"); - throw new DataMissingException("toolSessionId is missing"); - } - - QaSession qaSession=null; - try - { - qaSession=retrieveQaSessionOrNullById(toolSessionId.longValue()); - logger.debug("retrieved qaSession: " + qaSession); - } - catch(QaApplicationException e) - { - throw new DataMissingException("error retrieving qaSession: " + e); - } - catch(Exception e) - { - throw new ToolException("error retrieving qaSession: " + e); - } - - if (qaSession == null) - { - logger.debug("qaSession is null"); - throw new DataMissingException("qaSession is missing"); - } - - try - { - qaSessionDAO.deleteQaSession(qaSession); - logger.debug("qaSession " + qaSession + " has been deleted successfully."); - } - catch(QaApplicationException e) - { - throw new ToolException("error deleting qaSession:" + e); - } + public void removeToolSession(Long toolSessionId) throws DataMissingException, ToolException { + QaServicePOJO.logger.debug("start of removeToolSession with id: " + toolSessionId); + if (toolSessionId == null) { + QaServicePOJO.logger.debug("toolSessionId is null"); + throw new DataMissingException("toolSessionId is missing"); } - - + + QaSession qaSession = null; + try { + qaSession = retrieveQaSessionOrNullById(toolSessionId.longValue()); + QaServicePOJO.logger.debug("retrieved qaSession: " + qaSession); + } catch (QaApplicationException e) { + throw new DataMissingException("error retrieving qaSession: " + e); + } catch (Exception e) { + throw new ToolException("error retrieving qaSession: " + e); + } + + if (qaSession == null) { + QaServicePOJO.logger.debug("qaSession is null"); + throw new DataMissingException("qaSession is missing"); + } + + try { + qaSessionDAO.deleteQaSession(qaSession); + QaServicePOJO.logger.debug("qaSession " + qaSession + " has been deleted successfully."); + } catch (QaApplicationException e) { + throw new ToolException("error deleting qaSession:" + e); + } + } + /** * Complete the tool session. * - * Part of the ToolSessionManager contract. Called by controller service to force complete the qa session, or - * by the web front end to complete the qa session + * Part of the ToolSessionManager contract. Called by controller service to force complete the qa session, or by the + * web front end to complete the qa session * */ - public String leaveToolSession(Long toolSessionId,Long learnerId) throws DataMissingException, ToolException - { - logger.debug("start of leaveToolSession with toolSessionId:" + toolSessionId); - logger.debug("start of leaveToolSession with learnerId:" + learnerId); - - if (toolSessionId == null) - { - logger.debug("toolSessionId is null"); - throw new DataMissingException("toolSessionId is missing"); - } - - if (learnerId == null) - { - logger.debug("learnerId is null"); - throw new DataMissingException("learnerId is missing"); - } - - QaSession qaSession = retrieveQaSessionOrNullById(toolSessionId.longValue()); - qaSession.setSession_end_date(new Date(System.currentTimeMillis())); - qaSession.setSession_status(COMPLETED); - updateQaSession(qaSession); - logger.debug("tool session has been marked COMPLETE: " + qaSession); - - try - { - String nextUrl = learnerService.completeToolSession(toolSessionId,learnerId); - logger.debug(logger + " " + this.getClass().getName() + " " + "nextUrl: " + nextUrl); - return nextUrl; - } - catch(DataAccessException e) - { - throw new ToolException("Exception occured when user is leaving tool session: " + e); - } - + public String leaveToolSession(Long toolSessionId, Long learnerId) throws DataMissingException, ToolException { + QaServicePOJO.logger.debug("start of leaveToolSession with toolSessionId:" + toolSessionId); + QaServicePOJO.logger.debug("start of leaveToolSession with learnerId:" + learnerId); + + if (toolSessionId == null) { + QaServicePOJO.logger.debug("toolSessionId is null"); + throw new DataMissingException("toolSessionId is missing"); + } + + if (learnerId == null) { + QaServicePOJO.logger.debug("learnerId is null"); + throw new DataMissingException("learnerId is missing"); + } + + QaSession qaSession = retrieveQaSessionOrNullById(toolSessionId.longValue()); + qaSession.setSession_end_date(new Date(System.currentTimeMillis())); + qaSession.setSession_status(QaAppConstants.COMPLETED); + updateQaSession(qaSession); + QaServicePOJO.logger.debug("tool session has been marked COMPLETE: " + qaSession); + + try { + String nextUrl = learnerService.completeToolSession(toolSessionId, learnerId); + QaServicePOJO.logger.debug(QaServicePOJO.logger + " " + this.getClass().getName() + " " + "nextUrl: " + + nextUrl); + return nextUrl; + } catch (DataAccessException e) { + throw new ToolException("Exception occured when user is leaving tool session: " + e); + } + } /** * ToolSessionManager CONTRACT * */ - public ToolSessionExportOutputData exportToolSession(Long toolSessionId) throws DataMissingException, ToolException - { - throw new ToolException("not yet implemented"); + public ToolSessionExportOutputData exportToolSession(Long toolSessionId) throws DataMissingException, ToolException { + throw new ToolException("not yet implemented"); } /** * ToolSessionManager CONTRACT * */ - public ToolSessionExportOutputData exportToolSession(List toolSessionIds) throws DataMissingException, ToolException - { + public ToolSessionExportOutputData exportToolSession(List toolSessionIds) throws DataMissingException, + ToolException { - throw new ToolException("not yet implemented"); + throw new ToolException("not yet implemented"); } - - /** - * Get the tool output for the given tool output names. - * @see org.lamsfoundation.lams.tool.ToolSessionManager#getToolOutput(java.util.List, java.lang.Long, java.lang.Long) - */ - public SortedMap getToolOutput(List names, - Long toolSessionId, Long learnerId) { - return new TreeMap(); - } - /** - * Get the tool output for the given tool output name. - * @see org.lamsfoundation.lams.tool.ToolSessionManager#getToolOutput(java.lang.String, java.lang.Long, java.lang.Long) - */ - public ToolOutput getToolOutput(String name, Long toolSessionId, - Long learnerId) { - return null; - } + /** + * Get the tool output for the given tool output names. + * + * @see org.lamsfoundation.lams.tool.ToolSessionManager#getToolOutput(java.util.List, java.lang.Long, + * java.lang.Long) + */ + public SortedMap getToolOutput(List names, Long toolSessionId, Long learnerId) { + return getQaOutputFactory().getToolOutput(names, this, toolSessionId, learnerId); + } - public IToolVO getToolBySignature(String toolSignature) throws QaApplicationException - { - logger.debug("attempt retrieving tool with signature : " + toolSignature); - IToolVO tool=toolService.getToolBySignature(toolSignature); - logger.debug("retrieved tool: " + tool); - return tool; + /** + * Get the tool output for the given tool output name. + * + * @see org.lamsfoundation.lams.tool.ToolSessionManager#getToolOutput(java.lang.String, java.lang.Long, + * java.lang.Long) + */ + public ToolOutput getToolOutput(String name, Long toolSessionId, Long learnerId) { + return getQaOutputFactory().getToolOutput(name, this, toolSessionId, learnerId); } - - public long getToolDefaultContentIdBySignature(String toolSignature) throws QaApplicationException - { - long contentId=0; - logger.debug("before attempting retrieving tool with signature : " + toolSignature); - contentId=toolService.getToolDefaultContentIdBySignature(toolSignature); - logger.debug("tool default contentId : " + contentId); - return contentId; + + public IToolVO getToolBySignature(String toolSignature) throws QaApplicationException { + QaServicePOJO.logger.debug("attempt retrieving tool with signature : " + toolSignature); + IToolVO tool = toolService.getToolBySignature(toolSignature); + QaServicePOJO.logger.debug("retrieved tool: " + tool); + return tool; } - public QaQueContent getToolDefaultQuestionContent(long contentId) throws QaApplicationException - { - logger.debug("before attempting retrieving QaQueContent with contentId : " + contentId); - QaQueContent qaQueContent=qaQueContentDAO.getToolDefaultQuestionContent(contentId); - logger.debug("retrieved QaQueContent : " + qaQueContent); - return qaQueContent; + public long getToolDefaultContentIdBySignature(String toolSignature) throws QaApplicationException { + long contentId = 0; + QaServicePOJO.logger.debug("before attempting retrieving tool with signature : " + toolSignature); + contentId = toolService.getToolDefaultContentIdBySignature(toolSignature); + QaServicePOJO.logger.debug("tool default contentId : " + contentId); + return contentId; } - - public List getToolSessionsForContent(QaContent qa) - { - logger.debug("attempt retrieving listToolSessionIds for : " + qa); - List listToolSessionIds=qaSessionDAO.getToolSessionsForContent(qa); - return listToolSessionIds; + public QaQueContent getToolDefaultQuestionContent(long contentId) throws QaApplicationException { + QaServicePOJO.logger.debug("before attempting retrieving QaQueContent with contentId : " + contentId); + QaQueContent qaQueContent = qaQueContentDAO.getToolDefaultQuestionContent(contentId); + QaServicePOJO.logger.debug("retrieved QaQueContent : " + qaQueContent); + return qaQueContent; } - - - - /** - * This method verifies the credentials of the SubmitFiles Tool and gives it - * the Ticket to login and access the Content Repository. - * - * A valid ticket is needed in order to access the content from the - * repository. This method would be called evertime the tool needs to - * upload/download files from the content repository. - * - * @return ITicket The ticket for repostory access - * @throws SubmitFilesException - */ - public ITicket getRepositoryLoginTicket() throws QaApplicationException { - repositoryService = RepositoryProxy.getRepositoryService(); - logger.debug("retrieved repositoryService : " + repositoryService); - - ICredentials credentials = new SimpleCredentials( - repositoryUser, - repositoryId); - try { - ITicket ticket = repositoryService.login(credentials, - repositoryWorkspace); - logger.debug("retrieved ticket: " + ticket); - return ticket; - } catch (AccessDeniedException e) { - throw new QaApplicationException("Access Denied to repository." - + e.getMessage()); - } catch (WorkspaceNotFoundException e) { - throw new QaApplicationException("Workspace not found." - + e.getMessage()); - } catch (LoginException e) { - throw new QaApplicationException("Login failed." + e.getMessage()); - } + + public List getToolSessionsForContent(QaContent qa) { + QaServicePOJO.logger.debug("attempt retrieving listToolSessionIds for : " + qa); + List listToolSessionIds = qaSessionDAO.getToolSessionsForContent(qa); + return listToolSessionIds; + } + + /** + * This method verifies the credentials of the SubmitFiles Tool and gives it the Ticket to login and + * access the Content Repository. + * + * A valid ticket is needed in order to access the content from the repository. This method would be called evertime + * the tool needs to upload/download files from the content repository. + * + * @return ITicket The ticket for repostory access + * @throws SubmitFilesException + */ + public ITicket getRepositoryLoginTicket() throws QaApplicationException { + repositoryService = RepositoryProxy.getRepositoryService(); + QaServicePOJO.logger.debug("retrieved repositoryService : " + repositoryService); + + ICredentials credentials = new SimpleCredentials(repositoryUser, repositoryId); + try { + ITicket ticket = repositoryService.login(credentials, repositoryWorkspace); + QaServicePOJO.logger.debug("retrieved ticket: " + ticket); + return ticket; + } catch (AccessDeniedException e) { + throw new QaApplicationException("Access Denied to repository." + e.getMessage()); + } catch (WorkspaceNotFoundException e) { + throw new QaApplicationException("Workspace not found." + e.getMessage()); + } catch (LoginException e) { + throw new QaApplicationException("Login failed." + e.getMessage()); } - - - /** - * This method deletes the content with the given uuid and - * versionID from the content repository - * - * @param uuid - * The uuid of the node to be deleted - * @param versionID - * The version_id of the node to be deleted. - * @throws SubmitFilesException - */ - public void deleteFromRepository(Long uuid, Long versionID) - throws QaApplicationException { - ITicket ticket = getRepositoryLoginTicket(); - logger.debug("retrieved ticket: " + ticket); - try { - String files[] = repositoryService.deleteVersion(ticket, uuid,versionID); - logger.debug("retrieved files: " + files); - } catch (Exception e) { - throw new QaApplicationException( - "Exception occured while deleting files from" - + " the repository " + e.getMessage()); - } + } + + /** + * This method deletes the content with the given uuid and versionID from the content + * repository + * + * @param uuid + * The uuid of the node to be deleted + * @param versionID + * The version_id of the node to be deleted. + * @throws SubmitFilesException + */ + public void deleteFromRepository(Long uuid, Long versionID) throws QaApplicationException { + ITicket ticket = getRepositoryLoginTicket(); + QaServicePOJO.logger.debug("retrieved ticket: " + ticket); + try { + String files[] = repositoryService.deleteVersion(ticket, uuid, versionID); + QaServicePOJO.logger.debug("retrieved files: " + files); + } catch (Exception e) { + throw new QaApplicationException("Exception occured while deleting files from" + " the repository " + + e.getMessage()); } - - - public InputStream downloadFile(Long uuid, Long versionID)throws QaApplicationException{ - ITicket ticket = getRepositoryLoginTicket(); - try{ - IVersionedNode node = repositoryService.getFileItem(ticket,uuid,null); - logger.debug("retrieved node: " + node); - return node.getFile(); - }catch(AccessDeniedException e){ - throw new QaApplicationException("AccessDeniedException occured while trying to download file " + e.getMessage()); - }catch(FileException e){ - throw new QaApplicationException("FileException occured while trying to download file " + e.getMessage()); - }catch(ItemNotFoundException e){ - throw new QaApplicationException("ItemNotFoundException occured while trying to download file " + e.getMessage()); - } + } + + public InputStream downloadFile(Long uuid, Long versionID) throws QaApplicationException { + ITicket ticket = getRepositoryLoginTicket(); + try { + IVersionedNode node = repositoryService.getFileItem(ticket, uuid, null); + QaServicePOJO.logger.debug("retrieved node: " + node); + return node.getFile(); + } catch (AccessDeniedException e) { + throw new QaApplicationException("AccessDeniedException occured while trying to download file " + + e.getMessage()); + } catch (FileException e) { + throw new QaApplicationException("FileException occured while trying to download file " + e.getMessage()); + } catch (ItemNotFoundException e) { + throw new QaApplicationException("ItemNotFoundException occured while trying to download file " + + e.getMessage()); } - - /** - * adds a new entry to the uploaded files table - */ - public void persistFile(String uuid, boolean isOnlineFile, String fileName, QaContent qaContent) throws QaApplicationException { - logger.debug("attempt persisting file to the db: " + uuid + " " + isOnlineFile + " " + fileName + " " + qaContent); - QaUploadedFile qaUploadedFile= new QaUploadedFile(uuid, isOnlineFile, fileName, qaContent); - logger.debug("created qaUploadedFile: " + qaUploadedFile); - qaUploadedFileDAO.saveUploadFile(qaUploadedFile); - logger.debug("persisted qaUploadedFile: " + qaUploadedFile); - } - - + } + /** * adds a new entry to the uploaded files table */ + public void persistFile(String uuid, boolean isOnlineFile, String fileName, QaContent qaContent) + throws QaApplicationException { + QaServicePOJO.logger.debug("attempt persisting file to the db: " + uuid + " " + isOnlineFile + " " + fileName + + " " + qaContent); + QaUploadedFile qaUploadedFile = new QaUploadedFile(uuid, isOnlineFile, fileName, qaContent); + QaServicePOJO.logger.debug("created qaUploadedFile: " + qaUploadedFile); + qaUploadedFileDAO.saveUploadFile(qaUploadedFile); + QaServicePOJO.logger.debug("persisted qaUploadedFile: " + qaUploadedFile); + } + + /** + * adds a new entry to the uploaded files table + */ public void persistFile(QaContent content, QaUploadedFile file) throws QaApplicationException { - logger.debug("in persistFile: " + file); - content.getQaUploadedFiles().add(file); - file.setQaContent(content); - qaDAO.saveOrUpdateQa(content); - logger.debug("persisted qaUploadedFile: " + file); + QaServicePOJO.logger.debug("in persistFile: " + file); + content.getQaUploadedFiles().add(file); + file.setQaContent(content); + qaDAO.saveOrUpdateQa(content); + QaServicePOJO.logger.debug("persisted qaUploadedFile: " + file); } - - + /** * removes an entry from the uploaded files table */ public void removeFile(Long submissionId) throws QaApplicationException { - qaUploadedFileDAO.removeUploadFile(submissionId); - logger.debug("removed qaUploadedFile: " + submissionId); + qaUploadedFileDAO.removeUploadFile(submissionId); + QaServicePOJO.logger.debug("removed qaUploadedFile: " + submissionId); } - - /** - * removes all the entries in the uploaded files table - */ - public void cleanUploadedFilesMetaData() throws QaApplicationException { - logger.debug("attempt cleaning up uploaded file meta data table from the db"); - qaUploadedFileDAO.cleanUploadedFilesMetaData(); - logger.debug("files meta data has been cleaned up"); - } - - - public Long createNotebookEntry(Long id, Integer idType, String signature, - Integer userID, String entry) { - logger.debug("coreNotebookService: " + coreNotebookService); - return coreNotebookService.createNotebookEntry(id, idType, signature, userID, "", entry); - } - - - + /** + * removes all the entries in the uploaded files table + */ + public void cleanUploadedFilesMetaData() throws QaApplicationException { + QaServicePOJO.logger.debug("attempt cleaning up uploaded file meta data table from the db"); + qaUploadedFileDAO.cleanUploadedFilesMetaData(); + QaServicePOJO.logger.debug("files meta data has been cleaned up"); + } - public NotebookEntry getEntry(Long id, Integer idType, String signature, - Integer userID) { - - List list = coreNotebookService.getEntry(id, idType, signature, userID); - if (list == null || list.isEmpty()) { - return null; - } else { - return list.get(0); - } - } - - - - /** - * @return Returns the logger. - */ - public static Logger getLogger() { - return logger; - } - /** - * @param logger The logger to set. - */ - public static void setLogger(Logger logger) { - QaServicePOJO.logger = logger; - } - /** - * @return Returns the cred. - */ - public ICredentials getCred() { - return cred; - } - /** - * @param cred The cred to set. - */ - public void setCred(ICredentials cred) { - this.cred = cred; - } - /** - * @return Returns the qaUploadedFileDAO. - */ - public IQaUploadedFileDAO getQaUploadedFileDAO() { - return qaUploadedFileDAO; - } - /** - * @param qaUploadedFileDAO The qaUploadedFileDAO to set. - */ - public void setQaUploadedFileDAO(IQaUploadedFileDAO qaUploadedFileDAO) { - this.qaUploadedFileDAO = qaUploadedFileDAO; - } - /** - * @return Returns the repositoryId. - */ - public char[] getRepositoryId() { - return repositoryId; - } - /** - * @return Returns the repositoryUser. - */ - public String getRepositoryUser() { - return repositoryUser; - } - /** - * @return Returns the repositoryWorkspace. - */ - public String getRepositoryWorkspace() { - return repositoryWorkspace; - } - /** - * @return Returns the qaQueContentDAO. - */ - public IQaQueContentDAO getQaQueContentDAO() { - return qaQueContentDAO; - } - /** - * @return Returns the qaQueUsrDAO. - */ - public IQaQueUsrDAO getQaQueUsrDAO() { - return qaQueUsrDAO; - } - /** - * @return Returns the toolService. - */ - public ILamsToolService getToolService() { - return toolService; - } - /** - * @return Returns the userManagementService. - */ - public IUserManagementService getUserManagementService() { - return userManagementService; - } + public Long createNotebookEntry(Long id, Integer idType, String signature, Integer userID, String entry) { + QaServicePOJO.logger.debug("coreNotebookService: " + coreNotebookService); + return coreNotebookService.createNotebookEntry(id, idType, signature, userID, "", entry); + } + public NotebookEntry getEntry(Long id, Integer idType, String signature, Integer userID) { - public ILearnerService getLearnerService() { - return learnerService; + List list = coreNotebookService.getEntry(id, idType, signature, userID); + if (list == null || list.isEmpty()) { + return null; + } else { + return list.get(0); } + } + /** + * @return Returns the logger. + */ + public static Logger getLogger() { + return QaServicePOJO.logger; + } - public void setLearnerService(ILearnerService learnerService) { - this.learnerService = learnerService; - } - - public void setQaDAO(IQaContentDAO qaDAO) - { - this.qaDAO = qaDAO; + /** + * @param logger + * The logger to set. + */ + public static void setLogger(Logger logger) { + QaServicePOJO.logger = logger; } - - public void setQaQueContentDAO(IQaQueContentDAO qaQueContentDAO) - { - this.qaQueContentDAO = qaQueContentDAO; + + /** + * @return Returns the cred. + */ + public ICredentials getCred() { + return cred; } - public void setQaSessionDAO(IQaSessionDAO qaSessionDAO) - { - this.qaSessionDAO = qaSessionDAO; + /** + * @param cred + * The cred to set. + */ + public void setCred(ICredentials cred) { + this.cred = cred; } - - public void setQaQueUsrDAO(IQaQueUsrDAO qaQueUsrDAO) - { - this.qaQueUsrDAO = qaQueUsrDAO; + + /** + * @return Returns the qaUploadedFileDAO. + */ + public IQaUploadedFileDAO getQaUploadedFileDAO() { + return qaUploadedFileDAO; } - - public void setQaUsrRespDAO(IQaUsrRespDAO qaUsrRespDAO) - { - this.qaUsrRespDAO = qaUsrRespDAO; + + /** + * @param qaUploadedFileDAO + * The qaUploadedFileDAO to set. + */ + public void setQaUploadedFileDAO(IQaUploadedFileDAO qaUploadedFileDAO) { + this.qaUploadedFileDAO = qaUploadedFileDAO; } /** - * @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; - } + * @return Returns the repositoryId. + */ + public char[] getRepositoryId() { + return repositoryId; + } - /** - * @return Returns the repositoryService. - */ - public IRepositoryService getRepositoryService() { - return repositoryService; - } - /** - * @param repositoryService The repositoryService to set. - */ - public void setRepositoryService(IRepositoryService repositoryService) { - this.repositoryService = repositoryService; - } + /** + * @return Returns the repositoryUser. + */ + public String getRepositoryUser() { + return repositoryUser; + } - - - public void setUserManagementService(IUserManagementService userManagementService) - { - this.userManagementService = userManagementService; + /** + * @return Returns the repositoryWorkspace. + */ + public String getRepositoryWorkspace() { + return repositoryWorkspace; } - - public void setToolService(ILamsToolService toolService) - { - this.toolService = toolService; + + /** + * @return Returns the qaQueContentDAO. + */ + public IQaQueContentDAO getQaQueContentDAO() { + return qaQueContentDAO; } - /** - * @return Returns the qaToolContentHandler. - */ - public IToolContentHandler getQaToolContentHandler() { - return qaToolContentHandler; - } - /** - * @param qaToolContentHandler The qaToolContentHandler to set. - */ - public void setQaToolContentHandler(IToolContentHandler qaToolContentHandler) { - this.qaToolContentHandler = qaToolContentHandler; - } + /** + * @return Returns the qaQueUsrDAO. + */ + public IQaQueUsrDAO getQaQueUsrDAO() { + return qaQueUsrDAO; + } - public IAuditService getAuditService() { - return auditService; - } + /** + * @return Returns the toolService. + */ + public ILamsToolService getToolService() { + return toolService; + } + /** + * @return Returns the userManagementService. + */ + public IUserManagementService getUserManagementService() { + return userManagementService; + } - public void setAuditService(IAuditService auditService) { - this.auditService = auditService; - } + public ILearnerService getLearnerService() { + return learnerService; + } + public void setLearnerService(ILearnerService learnerService) { + this.learnerService = learnerService; + } - public IExportToolContentService getExportContentService() { - return exportContentService; - } + public void setQaDAO(IQaContentDAO qaDAO) { + this.qaDAO = qaDAO; + } + public void setQaQueContentDAO(IQaQueContentDAO qaQueContentDAO) { + this.qaQueContentDAO = qaQueContentDAO; + } - public void setExportContentService(IExportToolContentService exportContentService) { - this.exportContentService = exportContentService; - } - - /* ===============Methods implemented from ToolContentImport102Manager =============== */ - + public void setQaSessionDAO(IQaSessionDAO qaSessionDAO) { + this.qaSessionDAO = qaSessionDAO; + } + public void setQaQueUsrDAO(IQaQueUsrDAO qaQueUsrDAO) { + this.qaQueUsrDAO = qaQueUsrDAO; + } + + public void setQaUsrRespDAO(IQaUsrRespDAO qaUsrRespDAO) { + this.qaUsrRespDAO = qaUsrRespDAO; + } + /** + * @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; + } + + /** + * @return Returns the repositoryService. + */ + public IRepositoryService getRepositoryService() { + return repositoryService; + } + + /** + * @param repositoryService + * The repositoryService to set. + */ + public void setRepositoryService(IRepositoryService repositoryService) { + this.repositoryService = repositoryService; + } + + public void setUserManagementService(IUserManagementService userManagementService) { + this.userManagementService = userManagementService; + } + + public void setToolService(ILamsToolService toolService) { + this.toolService = toolService; + } + + /** + * @return Returns the qaToolContentHandler. + */ + public IToolContentHandler getQaToolContentHandler() { + return qaToolContentHandler; + } + + /** + * @param qaToolContentHandler + * The qaToolContentHandler to set. + */ + public void setQaToolContentHandler(IToolContentHandler qaToolContentHandler) { + this.qaToolContentHandler = qaToolContentHandler; + } + + public IAuditService getAuditService() { + return auditService; + } + + public void setAuditService(IAuditService auditService) { + this.auditService = auditService; + } + + public IExportToolContentService getExportContentService() { + return exportContentService; + } + + public void setExportContentService(IExportToolContentService exportContentService) { + this.exportContentService = exportContentService; + } + + /* + * ===============Methods implemented from ToolContentImport102Manager =============== + */ + + /** * Import the data for a 1.0.2 Chat */ - public void import102ToolContent(Long toolContentId, UserDTO user, Hashtable importValues) - { - Date now = new Date(); - QaContent toolContentObj = new QaContent(); - toolContentObj.setContentLocked(false); - toolContentObj.setCreatedBy(user.getUserID().longValue()); - toolContentObj.setCreationDate(now); - toolContentObj.setDefineLater(false); - toolContentObj.setInstructions(null); - toolContentObj.setOfflineInstructions(null); - toolContentObj.setOnlineInstructions(null); - toolContentObj.setReflect(false); - toolContentObj.setReflectionSubject(null); - toolContentObj.setRunOffline(false); - toolContentObj.setTitle((String)importValues.get(ToolContentImport102Manager.CONTENT_TITLE)); - toolContentObj.setQaContentId(toolContentId); - toolContentObj.setUpdateDate(now); - toolContentObj.setQuestionsSequenced(false); // there is only 1 question - toolContentObj.setContent(null); - toolContentObj.setReportTitle(null); - toolContentObj.setMonitoringReportTitle(null); - toolContentObj.setSynchInMonitor(false); // doesn't appear to be used in LAMS 2.0 - toolContentObj.setLockWhenFinished(true); - toolContentObj.setShowOtherAnswers(true); - - Boolean bool; - try { - bool = WDDXProcessor.convertToBoolean(importValues, ToolContentImport102Manager.CONTENT_SHOW_USER); - toolContentObj.setUsernameVisible(bool!=null?bool:false); - } catch (WDDXProcessorConversionException e) { - logger.error("Unable to content for activity "+toolContentObj.getTitle()+"properly due to a WDDXProcessorConversionException.",e); - throw new ToolException("Invalid import data format for activity "+toolContentObj.getTitle()+"- WDDX caused an exception. Some data from the design will have been lost. See log for more details."); - } - - // leave as empty, no need to set them to anything. - //setQaUploadedFiles(Set qaUploadedFiles); - //setQaSessions(Set qaSessions); - - // set up question from body - QaQueContent question = new QaQueContent(); - String content = WebUtil.convertNewlines((String)importValues.get(ToolContentImport102Manager.CONTENT_BODY)); - question.setQuestion(content); - question.setDisplayOrder(1); - question.setQaContent(toolContentObj); - toolContentObj.getQaQueContents().add(question); + public void import102ToolContent(Long toolContentId, UserDTO user, Hashtable importValues) { + Date now = new Date(); + QaContent toolContentObj = new QaContent(); + toolContentObj.setContentLocked(false); + toolContentObj.setCreatedBy(user.getUserID().longValue()); + toolContentObj.setCreationDate(now); + toolContentObj.setDefineLater(false); + toolContentObj.setInstructions(null); + toolContentObj.setOfflineInstructions(null); + toolContentObj.setOnlineInstructions(null); + toolContentObj.setReflect(false); + toolContentObj.setReflectionSubject(null); + toolContentObj.setRunOffline(false); + toolContentObj.setTitle((String) importValues.get(ToolContentImport102Manager.CONTENT_TITLE)); + toolContentObj.setQaContentId(toolContentId); + toolContentObj.setUpdateDate(now); + toolContentObj.setQuestionsSequenced(false); // there is only 1 + // question + toolContentObj.setContent(null); + toolContentObj.setReportTitle(null); + toolContentObj.setMonitoringReportTitle(null); + toolContentObj.setSynchInMonitor(false); // doesn't appear to be used + // in LAMS 2.0 + toolContentObj.setLockWhenFinished(true); + toolContentObj.setShowOtherAnswers(true); - qaDAO.saveOrUpdateQa(toolContentObj); + Boolean bool; + try { + bool = WDDXProcessor.convertToBoolean(importValues, ToolContentImport102Manager.CONTENT_SHOW_USER); + toolContentObj.setUsernameVisible(bool != null ? bool : false); + } catch (WDDXProcessorConversionException e) { + QaServicePOJO.logger.error("Unable to content for activity " + toolContentObj.getTitle() + + "properly due to a WDDXProcessorConversionException.", e); + throw new ToolException( + "Invalid import data format for activity " + + toolContentObj.getTitle() + + "- WDDX caused an exception. Some data from the design will have been lost. See log for more details."); + } + // leave as empty, no need to set them to anything. + // setQaUploadedFiles(Set qaUploadedFiles); + // setQaSessions(Set qaSessions); + + // set up question from body + QaQueContent question = new QaQueContent(); + String content = WebUtil.convertNewlines((String) importValues.get(ToolContentImport102Manager.CONTENT_BODY)); + question.setQuestion(content); + question.setDisplayOrder(1); + question.setQaContent(toolContentObj); + toolContentObj.getQaQueContents().add(question); + + qaDAO.saveOrUpdateQa(toolContentObj); + } - /** Set the description, throws away the title value as this is not supported in 2.0 */ - public void setReflectiveData(Long toolContentId, String title, String description) - throws ToolException, DataMissingException { - - QaContent qaContent = null; - if ( toolContentId != null ) { - qaContent=loadQa(toolContentId.longValue()); - } - if ( qaContent == null ) { - throw new DataMissingException("Unable to set reflective data titled "+title - +" on activity toolContentId "+toolContentId - +" as the tool content does not exist."); - } - - qaContent.setReflect(true); - qaContent.setReflectionSubject(description); + /** + * Set the description, throws away the title value as this is not supported in 2.0 + */ + public void setReflectiveData(Long toolContentId, String title, String description) throws ToolException, + DataMissingException { + + QaContent qaContent = null; + if (toolContentId != null) { + qaContent = loadQa(toolContentId.longValue()); + } + if (qaContent == null) { + throw new DataMissingException("Unable to set reflective data titled " + title + + " on activity toolContentId " + toolContentId + " as the tool content does not exist."); + } + + qaContent.setReflect(true); + qaContent.setReflectionSubject(description); } - - //========================================================================================= + + // ========================================================================================= /** * @return Returns the coreNotebookService. */ public ICoreNotebookService getCoreNotebookService() { - return coreNotebookService; + return coreNotebookService; } + /** - * @param coreNotebookService The coreNotebookService to set. + * @param coreNotebookService + * The coreNotebookService to set. */ public void setCoreNotebookService(ICoreNotebookService coreNotebookService) { - this.coreNotebookService = coreNotebookService; + this.coreNotebookService = coreNotebookService; } - - public void updateEntry(NotebookEntry notebookEntry) { - coreNotebookService.updateEntry(notebookEntry); - } -} + public void updateEntry(NotebookEntry notebookEntry) { + coreNotebookService.updateEntry(notebookEntry); + } + + public QaOutputFactory getQaOutputFactory() { + return qaOutputFactory; + } + + public void setQaOutputFactory(QaOutputFactory qaOutputFactory) { + this.qaOutputFactory = qaOutputFactory; + } + + public QaContent getQaContentBySessionId(Long sessionId) { + QaSession session = qaSessionDAO.getQaSessionOrNullById(sessionId); + // to skip CGLib problem + Long contentId = session.getQaContent().getQaContentId(); + QaContent qaContent = qaDAO.getQaById(contentId); + return qaContent; + } + + /** + * {@inheritDoc} + */ + public String createConditionName(Collection existingConditions) { + String uniqueNumber = null; + do { + uniqueNumber = String.valueOf(Math.abs(generator.nextInt())); + for (QaCondition condition : existingConditions) { + String[] splitedName = getQaOutputFactory().splitConditionName(condition.getName()); + if (uniqueNumber.equals(splitedName[1])) { + uniqueNumber = null; + } + } + } while (uniqueNumber == null); + return getQaOutputFactory().buildConditionName(uniqueNumber); + } +} \ No newline at end of file Index: lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/util/QaConditionComparator.java =================================================================== diff -u --- lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/util/QaConditionComparator.java (revision 0) +++ lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/util/QaConditionComparator.java (revision 0af4ed13b963a588f3499b080801863d57f8ad95) @@ -0,0 +1,50 @@ +/**************************************************************** + * Copyright (C) 2005 LAMS Foundation (http://lamsfoundation.org) + * ============================================================= + * License Information: http://lamsfoundation.org/licensing/lams/2.0/ + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2.0 + * as published by the Free Software Foundation. + * + * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 * USA + * + * http://www.gnu.org/licenses/gpl.txt + * **************************************************************** + */ + +/* $Id$ */ +package org.lamsfoundation.lams.tool.qa.util; + +import java.util.Comparator; + +import org.lamsfoundation.lams.tool.qa.QaCondition; + +/** + * Comparator for QaCondition. Only the order ID is compared. + * + * @author Marcin Cieslak + * @see org.lamsfoundation.lams.tool.qa.QaCondition + */ +public class QaConditionComparator implements Comparator { + + /** + * {@inheritDoc} + */ + public int compare(QaCondition o1, QaCondition o2) { + if (o1 != null && o2 != null) { + return o1.getOrderId() - o2.getOrderId(); + } else if (o1 != null) { + return 1; + } else { + return -1; + } + } +} \ No newline at end of file Index: lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/util/QaQueContentComparator.java =================================================================== diff -u --- lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/util/QaQueContentComparator.java (revision 0) +++ lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/util/QaQueContentComparator.java (revision 0af4ed13b963a588f3499b080801863d57f8ad95) @@ -0,0 +1,27 @@ +package org.lamsfoundation.lams.tool.qa.util; + +import java.util.Comparator; + +import org.lamsfoundation.lams.tool.qa.QaQueContent; + +/** + * Comparator for QaQueContent. Only the display order is compared. + * + * @author Marcin Cieslak + */ +public class QaQueContentComparator implements Comparator { + + /** + * {@inheritDoc} + */ + public int compare(QaQueContent o1, QaQueContent o2) { + if (o1 != null && o2 != null) { + return o1.getDisplayOrder() - o2.getDisplayOrder(); + } else if (o1 != null) { + return 1; + } else { + return -1; + } + } + +} Index: lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/util/QaQuestionContentDTOComparator.java =================================================================== diff -u --- lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/util/QaQuestionContentDTOComparator.java (revision 0) +++ lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/util/QaQuestionContentDTOComparator.java (revision 0af4ed13b963a588f3499b080801863d57f8ad95) @@ -0,0 +1,26 @@ +package org.lamsfoundation.lams.tool.qa.util; + +import java.util.Comparator; + +import org.lamsfoundation.lams.tool.qa.QaQuestionContentDTO; + +/** + * Comparator for QaQuestionContentDTO. Only the display order is compared. + * + * @author Marcin Cieslak + */ +public class QaQuestionContentDTOComparator implements Comparator { + + /** + * {@inheritDoc} + */ + public int compare(QaQuestionContentDTO o1, QaQuestionContentDTO o2) { + if (o1 != null && o2 != null) { + return Integer.parseInt(o1.getDisplayOrder()) - Integer.parseInt(o2.getDisplayOrder()); + } else if (o1 != null) { + return 1; + } else { + return -1; + } + } +} \ No newline at end of file Index: lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/AuthoringUtil.java =================================================================== diff -u -r1046868d6997114f3b043778a68b371e03182faf -r0af4ed13b963a588f3499b080801863d57f8ad95 --- lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/AuthoringUtil.java (.../AuthoringUtil.java) (revision 1046868d6997114f3b043778a68b371e03182faf) +++ lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/AuthoringUtil.java (.../AuthoringUtil.java) (revision 0af4ed13b963a588f3499b080801863d57f8ad95) @@ -29,840 +29,787 @@ import java.util.LinkedList; import java.util.List; import java.util.Map; +import java.util.Set; +import java.util.SortedSet; import java.util.TreeMap; +import java.util.TreeSet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpSession; 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.QaCondition; import org.lamsfoundation.lams.tool.qa.QaContent; import org.lamsfoundation.lams.tool.qa.QaQueContent; import org.lamsfoundation.lams.tool.qa.QaQuestionContentDTO; import org.lamsfoundation.lams.tool.qa.service.IQaService; +import org.lamsfoundation.lams.tool.qa.util.QaConditionComparator; +import org.lamsfoundation.lams.tool.qa.util.QaQueContentComparator; +import org.lamsfoundation.lams.tool.qa.util.QaQuestionContentDTOComparator; import org.lamsfoundation.lams.usermanagement.dto.UserDTO; import org.lamsfoundation.lams.web.session.SessionManager; import org.lamsfoundation.lams.web.util.AttributeNames; /** * - * Keeps all operations needed for Authoring mode. + * Keeps all operations needed for Authoring mode. + * * @author Ozgur Demirtas - * + * */ public class AuthoringUtil implements QaAppConstants { - static Logger logger = Logger.getLogger(AuthoringUtil.class.getName()); - - - protected static List swapNodes(List listQuestionContentDTO, String questionIndex, String direction) - { - logger.debug("swapNodes:"); - logger.debug("listQuestionContentDTO:" + listQuestionContentDTO); - logger.debug("questionIndex:" + questionIndex); - logger.debug("direction:" + direction); + static Logger logger = Logger.getLogger(AuthoringUtil.class.getName()); - int intQuestionIndex=new Integer(questionIndex).intValue(); - int intOriginalQuestionIndex=intQuestionIndex; - logger.debug("intQuestionIndex:" + intQuestionIndex); - - int replacedNodeIndex=0; - if (direction.equals("down")) - { - logger.debug("direction down:"); - replacedNodeIndex=++intQuestionIndex; - } - else - { - logger.debug("direction up:"); - replacedNodeIndex=--intQuestionIndex; - - } - logger.debug("replacedNodeIndex:" + replacedNodeIndex); - logger.debug("replacing nodes:" + intOriginalQuestionIndex + " and " + replacedNodeIndex); - - QaQuestionContentDTO mainNode=extractNodeAtDisplayOrder(listQuestionContentDTO, intOriginalQuestionIndex); - logger.debug("mainNode:" + mainNode); - + protected static List swapNodes(List listQuestionContentDTO, String questionIndex, String direction, + Set conditions) { + AuthoringUtil.logger.debug("swapNodes:"); + AuthoringUtil.logger.debug("listQuestionContentDTO:" + listQuestionContentDTO); + AuthoringUtil.logger.debug("questionIndex:" + questionIndex); + AuthoringUtil.logger.debug("direction:" + direction); - QaQuestionContentDTO replacedNode=extractNodeAtDisplayOrder(listQuestionContentDTO, replacedNodeIndex); - logger.debug("replacedNode:" + replacedNode); + int intQuestionIndex = new Integer(questionIndex).intValue(); + int intOriginalQuestionIndex = intQuestionIndex; + AuthoringUtil.logger.debug("intQuestionIndex:" + intQuestionIndex); - List listFinalQuestionContentDTO=new LinkedList(); - - listFinalQuestionContentDTO=reorderSwappedListQuestionContentDTO(listQuestionContentDTO, intOriginalQuestionIndex, - replacedNodeIndex, mainNode, replacedNode); - - - logger.debug("listFinalQuestionContentDTO:" + listFinalQuestionContentDTO); - return listFinalQuestionContentDTO; + int replacedNodeIndex = 0; + if (direction.equals("down")) { + AuthoringUtil.logger.debug("direction down:"); + replacedNodeIndex = ++intQuestionIndex; + } else { + AuthoringUtil.logger.debug("direction up:"); + replacedNodeIndex = --intQuestionIndex; + + } + AuthoringUtil.logger.debug("replacedNodeIndex:" + replacedNodeIndex); + AuthoringUtil.logger.debug("replacing nodes:" + intOriginalQuestionIndex + " and " + replacedNodeIndex); + + QaQuestionContentDTO mainNode = extractNodeAtDisplayOrder(listQuestionContentDTO, intOriginalQuestionIndex); + AuthoringUtil.logger.debug("mainNode:" + mainNode); + + QaQuestionContentDTO replacedNode = extractNodeAtDisplayOrder(listQuestionContentDTO, replacedNodeIndex); + AuthoringUtil.logger.debug("replacedNode:" + replacedNode); + + List listFinalQuestionContentDTO = new LinkedList(); + + listFinalQuestionContentDTO = reorderSwappedListQuestionContentDTO(listQuestionContentDTO, + intOriginalQuestionIndex, replacedNodeIndex, mainNode, replacedNode, conditions); + + AuthoringUtil.logger.debug("listFinalQuestionContentDTO:" + listFinalQuestionContentDTO); + return listFinalQuestionContentDTO; } - - - - protected static List reorderSwappedListQuestionContentDTO(List listQuestionContentDTO, int intOriginalQuestionIndex, - int replacedNodeIndex, QaQuestionContentDTO mainNode, QaQuestionContentDTO replacedNode) - { - logger.debug("reorderSwappedListQuestionContentDTO: intOriginalQuestionIndex:" + intOriginalQuestionIndex); - logger.debug("reorderSwappedListQuestionContentDTO: replacedNodeIndex:" + replacedNodeIndex); - logger.debug("mainNode: " + mainNode); - logger.debug("replacedNode: " + replacedNode); - - - List listFinalQuestionContentDTO=new LinkedList(); - - int queIndex=0; - Iterator listIterator=listQuestionContentDTO.iterator(); - while (listIterator.hasNext()) - { - QaQuestionContentDTO qaQuestionContentDTO= (QaQuestionContentDTO)listIterator.next(); - logger.debug("qaQuestionContentDTO:" + qaQuestionContentDTO); - logger.debug("qaQuestionContentDTO question:" + qaQuestionContentDTO.getQuestion()); - queIndex++; - QaQuestionContentDTO tempNode=new QaQuestionContentDTO(); - - if ((!qaQuestionContentDTO.getDisplayOrder().equals(new Integer(intOriginalQuestionIndex).toString())) && - !qaQuestionContentDTO.getDisplayOrder().equals(new Integer(replacedNodeIndex).toString())) - { - logger.debug("normal copy "); - tempNode.setQuestion(qaQuestionContentDTO.getQuestion()); - tempNode.setDisplayOrder(qaQuestionContentDTO.getDisplayOrder()); - tempNode.setFeedback(qaQuestionContentDTO.getFeedback()); - } - else if (qaQuestionContentDTO.getDisplayOrder().equals(new Integer(intOriginalQuestionIndex).toString())) - { - logger.debug("move type 1 "); - tempNode.setQuestion(replacedNode.getQuestion()); - tempNode.setDisplayOrder(replacedNode.getDisplayOrder()); - tempNode.setFeedback(replacedNode.getFeedback()); - } - else if (qaQuestionContentDTO.getDisplayOrder().equals(new Integer(replacedNodeIndex).toString())) - { - logger.debug("move type 1 "); - tempNode.setQuestion(mainNode.getQuestion()); - tempNode.setDisplayOrder(mainNode.getDisplayOrder()); - tempNode.setFeedback(mainNode.getFeedback()); - } - - listFinalQuestionContentDTO.add(tempNode); + + protected static List reorderSwappedListQuestionContentDTO(List listQuestionContentDTO, + int intOriginalQuestionIndex, int replacedNodeIndex, QaQuestionContentDTO mainNode, + QaQuestionContentDTO replacedNode, Set conditions) { + AuthoringUtil.logger.debug("reorderSwappedListQuestionContentDTO: intOriginalQuestionIndex:" + + intOriginalQuestionIndex); + AuthoringUtil.logger.debug("reorderSwappedListQuestionContentDTO: replacedNodeIndex:" + replacedNodeIndex); + AuthoringUtil.logger.debug("mainNode: " + mainNode); + AuthoringUtil.logger.debug("replacedNode: " + replacedNode); + + List listFinalQuestionContentDTO = new LinkedList(); + + int queIndex = 0; + Iterator listIterator = listQuestionContentDTO.iterator(); + while (listIterator.hasNext()) { + QaQuestionContentDTO qaQuestionContentDTO = (QaQuestionContentDTO) listIterator.next(); + AuthoringUtil.logger.debug("qaQuestionContentDTO:" + qaQuestionContentDTO); + AuthoringUtil.logger.debug("qaQuestionContentDTO question:" + qaQuestionContentDTO.getQuestion()); + queIndex++; + QaQuestionContentDTO tempNode = new QaQuestionContentDTO(); + + if (!qaQuestionContentDTO.getDisplayOrder().equals(new Integer(intOriginalQuestionIndex).toString()) + && !qaQuestionContentDTO.getDisplayOrder().equals(new Integer(replacedNodeIndex).toString())) { + AuthoringUtil.logger.debug("normal copy "); + tempNode.setQuestion(qaQuestionContentDTO.getQuestion()); + tempNode.setDisplayOrder(qaQuestionContentDTO.getDisplayOrder()); + tempNode.setFeedback(qaQuestionContentDTO.getFeedback()); + } else if (qaQuestionContentDTO.getDisplayOrder().equals(new Integer(intOriginalQuestionIndex).toString())) { + AuthoringUtil.logger.debug("move type 1 "); + tempNode.setQuestion(replacedNode.getQuestion()); + tempNode.setDisplayOrder(replacedNode.getDisplayOrder()); + tempNode.setFeedback(replacedNode.getFeedback()); + } else if (qaQuestionContentDTO.getDisplayOrder().equals(new Integer(replacedNodeIndex).toString())) { + AuthoringUtil.logger.debug("move type 1 "); + tempNode.setQuestion(mainNode.getQuestion()); + tempNode.setDisplayOrder(mainNode.getDisplayOrder()); + tempNode.setFeedback(mainNode.getFeedback()); } - - - logger.debug("final listFinalQuestionContentDTO:" + listFinalQuestionContentDTO); - return listFinalQuestionContentDTO; + listFinalQuestionContentDTO.add(tempNode); + } + // references in conditions also need to be changed + if (conditions != null) { + for (QaCondition condition : conditions) { + SortedSet newQuestionDTOSet = new TreeSet( + new QaQuestionContentDTOComparator()); + for (QaQuestionContentDTO dto : (List) listFinalQuestionContentDTO) { + if (condition.temporaryQuestionDTOSet.contains(dto)) { + newQuestionDTOSet.add(dto); + } + } + condition.temporaryQuestionDTOSet = newQuestionDTOSet; + } + } + AuthoringUtil.logger.debug("final listFinalQuestionContentDTO:" + listFinalQuestionContentDTO); + return listFinalQuestionContentDTO; } + protected static QaQuestionContentDTO extractNodeAtDisplayOrder(List listQuestionContentDTO, + int intOriginalQuestionIndex) { + AuthoringUtil.logger.debug("listQuestionContentDTO:" + listQuestionContentDTO); + AuthoringUtil.logger.debug("intOriginalQuestionIndex:" + intOriginalQuestionIndex); - + Iterator listIterator = listQuestionContentDTO.iterator(); + while (listIterator.hasNext()) { + QaQuestionContentDTO qaQuestionContentDTO = (QaQuestionContentDTO) listIterator.next(); + AuthoringUtil.logger.debug("qaQuestionContentDTO:" + qaQuestionContentDTO); + AuthoringUtil.logger.debug("qaQuestionContentDTO question:" + qaQuestionContentDTO.getQuestion()); - - protected static QaQuestionContentDTO extractNodeAtDisplayOrder(List listQuestionContentDTO, int intOriginalQuestionIndex) - { - logger.debug("listQuestionContentDTO:" + listQuestionContentDTO); - logger.debug("intOriginalQuestionIndex:" + intOriginalQuestionIndex); - - Iterator listIterator=listQuestionContentDTO.iterator(); - while (listIterator.hasNext()) - { - QaQuestionContentDTO qaQuestionContentDTO=(QaQuestionContentDTO)listIterator.next(); - logger.debug("qaQuestionContentDTO:" + qaQuestionContentDTO); - logger.debug("qaQuestionContentDTO question:" + qaQuestionContentDTO.getQuestion()); - - logger.debug("intOriginalQuestionIndex versus displayOrder:" + new Integer(intOriginalQuestionIndex).toString() + " versus " + - qaQuestionContentDTO.getDisplayOrder()); - if (new Integer(intOriginalQuestionIndex).toString().equals(qaQuestionContentDTO.getDisplayOrder())) - { - logger.debug("node found:" + qaQuestionContentDTO); - return qaQuestionContentDTO; - } - } - return null; + AuthoringUtil.logger.debug("intOriginalQuestionIndex versus displayOrder:" + + new Integer(intOriginalQuestionIndex).toString() + " versus " + + qaQuestionContentDTO.getDisplayOrder()); + if (new Integer(intOriginalQuestionIndex).toString().equals(qaQuestionContentDTO.getDisplayOrder())) { + AuthoringUtil.logger.debug("node found:" + qaQuestionContentDTO); + return qaQuestionContentDTO; + } + } + return null; } + protected static Map extractMapQuestionContent(List listQuestionContentDTO) { + AuthoringUtil.logger.debug("listQuestionContentDTO:" + listQuestionContentDTO); + Map mapQuestionContent = new TreeMap(new QaComparator()); - - protected static Map extractMapQuestionContent(List listQuestionContentDTO) - { - logger.debug("listQuestionContentDTO:" + listQuestionContentDTO); - Map mapQuestionContent= new TreeMap(new QaComparator()); - - Iterator listIterator=listQuestionContentDTO.iterator(); - int queIndex=0; - while (listIterator.hasNext()) - { - QaQuestionContentDTO qaQuestionContentDTO=(QaQuestionContentDTO)listIterator.next(); - logger.debug("qaQuestionContentDTO:" + qaQuestionContentDTO); - logger.debug("qaQuestionContentDTO question:" + qaQuestionContentDTO.getQuestion()); - - queIndex++; - logger.debug("queIndex:" + queIndex); - mapQuestionContent.put(new Integer(queIndex).toString(), qaQuestionContentDTO.getQuestion()); - } - logger.debug("mapQuestionContent:" + mapQuestionContent); - return mapQuestionContent; + Iterator listIterator = listQuestionContentDTO.iterator(); + int queIndex = 0; + while (listIterator.hasNext()) { + QaQuestionContentDTO qaQuestionContentDTO = (QaQuestionContentDTO) listIterator.next(); + AuthoringUtil.logger.debug("qaQuestionContentDTO:" + qaQuestionContentDTO); + AuthoringUtil.logger.debug("qaQuestionContentDTO question:" + qaQuestionContentDTO.getQuestion()); + + queIndex++; + AuthoringUtil.logger.debug("queIndex:" + queIndex); + mapQuestionContent.put(new Integer(queIndex).toString(), qaQuestionContentDTO.getQuestion()); + } + AuthoringUtil.logger.debug("mapQuestionContent:" + mapQuestionContent); + return mapQuestionContent; } - protected static Map extractMapFeedback(List listQuestionContentDTO) - { - logger.debug("listQuestionContentDTO:" + listQuestionContentDTO); - Map mapFeedbackContent= new TreeMap(new QaComparator()); - - Iterator listIterator=listQuestionContentDTO.iterator(); - int queIndex=0; - while (listIterator.hasNext()) - { - QaQuestionContentDTO qaQuestionContentDTO=(QaQuestionContentDTO)listIterator.next(); - logger.debug("qaQuestionContentDTO:" + qaQuestionContentDTO); - logger.debug("qaQuestionContentDTO feedback:" + qaQuestionContentDTO.getFeedback()); - - queIndex++; - logger.debug("queIndex:" + queIndex); - mapFeedbackContent.put(new Integer(queIndex).toString(), qaQuestionContentDTO.getFeedback()); - } - logger.debug("mapFeedbackContent:" + mapFeedbackContent); - return mapFeedbackContent; + protected static Map extractMapFeedback(List listQuestionContentDTO) { + AuthoringUtil.logger.debug("listQuestionContentDTO:" + listQuestionContentDTO); + Map mapFeedbackContent = new TreeMap(new QaComparator()); + + Iterator listIterator = listQuestionContentDTO.iterator(); + int queIndex = 0; + while (listIterator.hasNext()) { + QaQuestionContentDTO qaQuestionContentDTO = (QaQuestionContentDTO) listIterator.next(); + AuthoringUtil.logger.debug("qaQuestionContentDTO:" + qaQuestionContentDTO); + AuthoringUtil.logger.debug("qaQuestionContentDTO feedback:" + qaQuestionContentDTO.getFeedback()); + + queIndex++; + AuthoringUtil.logger.debug("queIndex:" + queIndex); + mapFeedbackContent.put(new Integer(queIndex).toString(), qaQuestionContentDTO.getFeedback()); + } + AuthoringUtil.logger.debug("mapFeedbackContent:" + mapFeedbackContent); + return mapFeedbackContent; } - - protected static Map reorderQuestionContentMap(Map mapQuestionContent) - { - logger.debug("reorderQuestionContentMap:" + mapQuestionContent); - - Map mapFinalQuestionContent = new TreeMap(new QaComparator()); - - int queIndex=0; - Iterator itMap = mapQuestionContent.entrySet().iterator(); - while (itMap.hasNext()) { - Map.Entry pairs = (Map.Entry)itMap.next(); - if ((pairs.getValue() != null) && (!pairs.getValue().equals(""))) - { - ++queIndex; - logger.debug("using queIndex:" + queIndex); - mapFinalQuestionContent.put(new Integer(queIndex).toString(), pairs.getValue()); + protected static Map reorderQuestionContentMap(Map mapQuestionContent) { + AuthoringUtil.logger.debug("reorderQuestionContentMap:" + mapQuestionContent); - } + Map mapFinalQuestionContent = new TreeMap(new QaComparator()); + + int queIndex = 0; + Iterator itMap = mapQuestionContent.entrySet().iterator(); + while (itMap.hasNext()) { + Map.Entry pairs = (Map.Entry) itMap.next(); + if (pairs.getValue() != null && !pairs.getValue().equals("")) { + ++queIndex; + AuthoringUtil.logger.debug("using queIndex:" + queIndex); + mapFinalQuestionContent.put(new Integer(queIndex).toString(), pairs.getValue()); + } - - logger.debug("final mapFinalQuestionContent:" + mapFinalQuestionContent); - return mapFinalQuestionContent; + } + + AuthoringUtil.logger.debug("final mapFinalQuestionContent:" + mapFinalQuestionContent); + return mapFinalQuestionContent; } + protected static List reorderListQuestionContentDTO(List listQuestionContentDTO, String excludeQuestionIndex) { + AuthoringUtil.logger.debug("reorderListQuestionContentDTO"); + AuthoringUtil.logger.debug("listQuestionContentDTO:" + listQuestionContentDTO); + AuthoringUtil.logger.debug("excludeQuestionIndex:" + excludeQuestionIndex); - protected static List reorderListQuestionContentDTO(List listQuestionContentDTO, String excludeQuestionIndex) - { - logger.debug("reorderListQuestionContentDTO"); - logger.debug("listQuestionContentDTO:" + listQuestionContentDTO); - logger.debug("excludeQuestionIndex:" + excludeQuestionIndex); - - List listFinalQuestionContentDTO=new LinkedList(); - - int queIndex=0; - Iterator listIterator=listQuestionContentDTO.iterator(); - while (listIterator.hasNext()) - { - QaQuestionContentDTO qaQuestionContentDTO= (QaQuestionContentDTO)listIterator.next(); - logger.debug("qaQuestionContentDTO:" + qaQuestionContentDTO); - logger.debug("qaQuestionContentDTO question:" + qaQuestionContentDTO.getQuestion()); - - String question=qaQuestionContentDTO.getQuestion(); - logger.debug("question:" + question); - - String displayOrder=qaQuestionContentDTO.getDisplayOrder(); - logger.debug("displayOrder:" + displayOrder); - - String feedback=qaQuestionContentDTO.getFeedback(); - logger.debug("feedback:" + feedback); - - logger.debug("displayOrder versus excludeQuestionIndex :" + displayOrder + " versus " + excludeQuestionIndex); - - if ((question != null) && (!question.equals(""))) - { - if (!displayOrder.equals(excludeQuestionIndex)) - { - ++queIndex; - logger.debug("using queIndex:" + queIndex); - - qaQuestionContentDTO.setQuestion(question); - qaQuestionContentDTO.setDisplayOrder(new Integer(queIndex).toString()); - qaQuestionContentDTO.setFeedback(feedback); - - listFinalQuestionContentDTO.add(qaQuestionContentDTO); - } - } + List listFinalQuestionContentDTO = new LinkedList(); + + int queIndex = 0; + Iterator listIterator = listQuestionContentDTO.iterator(); + while (listIterator.hasNext()) { + QaQuestionContentDTO qaQuestionContentDTO = (QaQuestionContentDTO) listIterator.next(); + AuthoringUtil.logger.debug("qaQuestionContentDTO:" + qaQuestionContentDTO); + AuthoringUtil.logger.debug("qaQuestionContentDTO question:" + qaQuestionContentDTO.getQuestion()); + + String question = qaQuestionContentDTO.getQuestion(); + AuthoringUtil.logger.debug("question:" + question); + + String displayOrder = qaQuestionContentDTO.getDisplayOrder(); + AuthoringUtil.logger.debug("displayOrder:" + displayOrder); + + String feedback = qaQuestionContentDTO.getFeedback(); + AuthoringUtil.logger.debug("feedback:" + feedback); + + AuthoringUtil.logger.debug("displayOrder versus excludeQuestionIndex :" + displayOrder + " versus " + + excludeQuestionIndex); + + if (question != null && !question.equals("")) { + if (!displayOrder.equals(excludeQuestionIndex)) { + ++queIndex; + AuthoringUtil.logger.debug("using queIndex:" + queIndex); + + qaQuestionContentDTO.setQuestion(question); + qaQuestionContentDTO.setDisplayOrder(new Integer(queIndex).toString()); + qaQuestionContentDTO.setFeedback(feedback); + + listFinalQuestionContentDTO.add(qaQuestionContentDTO); + } } - - - logger.debug("final listFinalQuestionContentDTO:" + listFinalQuestionContentDTO); - return listFinalQuestionContentDTO; + } + + AuthoringUtil.logger.debug("final listFinalQuestionContentDTO:" + listFinalQuestionContentDTO); + return listFinalQuestionContentDTO; } - - protected static List reorderSimpleListQuestionContentDTO(List listQuestionContentDTO) - { - logger.debug("reorderListQuestionContentDTO"); - logger.debug("listQuestionContentDTO:" + listQuestionContentDTO); - List listFinalQuestionContentDTO=new LinkedList(); - - int queIndex=0; - Iterator listIterator=listQuestionContentDTO.iterator(); - while (listIterator.hasNext()) - { - QaQuestionContentDTO qaQuestionContentDTO= (QaQuestionContentDTO)listIterator.next(); - logger.debug("qaQuestionContentDTO:" + qaQuestionContentDTO); - logger.debug("qaQuestionContentDTO question:" + qaQuestionContentDTO.getQuestion()); - - String question=qaQuestionContentDTO.getQuestion(); - logger.debug("question:" + question); - - String displayOrder=qaQuestionContentDTO.getDisplayOrder(); - logger.debug("displayOrder:" + displayOrder); - - String feedback=qaQuestionContentDTO.getFeedback(); - logger.debug("feedback:" + feedback); - - if ((question != null) && (!question.equals(""))) - { - ++queIndex; - logger.debug("using queIndex:" + queIndex); - - qaQuestionContentDTO.setQuestion(question); - qaQuestionContentDTO.setDisplayOrder(new Integer(queIndex).toString()); - qaQuestionContentDTO.setFeedback(feedback); - - listFinalQuestionContentDTO.add(qaQuestionContentDTO); - } + protected static List reorderSimpleListQuestionContentDTO(List listQuestionContentDTO) { + AuthoringUtil.logger.debug("reorderListQuestionContentDTO"); + AuthoringUtil.logger.debug("listQuestionContentDTO:" + listQuestionContentDTO); + List listFinalQuestionContentDTO = new LinkedList(); + + int queIndex = 0; + Iterator listIterator = listQuestionContentDTO.iterator(); + while (listIterator.hasNext()) { + QaQuestionContentDTO qaQuestionContentDTO = (QaQuestionContentDTO) listIterator.next(); + AuthoringUtil.logger.debug("qaQuestionContentDTO:" + qaQuestionContentDTO); + AuthoringUtil.logger.debug("qaQuestionContentDTO question:" + qaQuestionContentDTO.getQuestion()); + + String question = qaQuestionContentDTO.getQuestion(); + AuthoringUtil.logger.debug("question:" + question); + + String displayOrder = qaQuestionContentDTO.getDisplayOrder(); + AuthoringUtil.logger.debug("displayOrder:" + displayOrder); + + String feedback = qaQuestionContentDTO.getFeedback(); + AuthoringUtil.logger.debug("feedback:" + feedback); + + if (question != null && !question.equals("")) { + ++queIndex; + AuthoringUtil.logger.debug("using queIndex:" + queIndex); + + qaQuestionContentDTO.setQuestion(question); + qaQuestionContentDTO.setDisplayOrder(new Integer(queIndex).toString()); + qaQuestionContentDTO.setFeedback(feedback); + + listFinalQuestionContentDTO.add(qaQuestionContentDTO); } - - - logger.debug("final listFinalQuestionContentDTO:" + listFinalQuestionContentDTO); - return listFinalQuestionContentDTO; + } + + AuthoringUtil.logger.debug("final listFinalQuestionContentDTO:" + listFinalQuestionContentDTO); + return listFinalQuestionContentDTO; } - - - protected static List reorderUpdateListQuestionContentDTO(List listQuestionContentDTO, - QaQuestionContentDTO qaQuestionContentDTONew, - String editableQuestionIndex) - { - logger.debug("reorderUpdateListQuestionContentDTO"); - logger.debug("listQuestionContentDTO:" + listQuestionContentDTO); - logger.debug("qaQuestionContentDTONew:" + qaQuestionContentDTONew); - logger.debug("editableQuestionIndex:" + editableQuestionIndex); - - - List listFinalQuestionContentDTO=new LinkedList(); - - int queIndex=0; - Iterator listIterator=listQuestionContentDTO.iterator(); - while (listIterator.hasNext()) - { - QaQuestionContentDTO qaQuestionContentDTO= (QaQuestionContentDTO)listIterator.next(); - logger.debug("qaQuestionContentDTO:" + qaQuestionContentDTO); - logger.debug("qaQuestionContentDTO question:" + qaQuestionContentDTO.getQuestion()); - - ++queIndex; - logger.debug("using queIndex:" + queIndex); - String question=qaQuestionContentDTO.getQuestion(); - logger.debug("question:" + question); - - String displayOrder=qaQuestionContentDTO.getDisplayOrder(); - logger.debug("displayOrder:" + displayOrder); - - String feedback=qaQuestionContentDTO.getFeedback(); - logger.debug("feedback:" + feedback); - - if (displayOrder.equals(editableQuestionIndex)) - { - logger.debug("displayOrder equals editableQuestionIndex:" + editableQuestionIndex); - qaQuestionContentDTO.setQuestion(qaQuestionContentDTONew.getQuestion()); - qaQuestionContentDTO.setDisplayOrder(qaQuestionContentDTONew.getDisplayOrder()); - qaQuestionContentDTO.setFeedback(qaQuestionContentDTONew.getFeedback()); - - listFinalQuestionContentDTO.add(qaQuestionContentDTO); - } - else - { - logger.debug("displayOrder does not equal editableQuestionIndex:" + editableQuestionIndex); - qaQuestionContentDTO.setQuestion(question); - qaQuestionContentDTO.setDisplayOrder(displayOrder); - qaQuestionContentDTO.setFeedback(feedback); + protected static List reorderUpdateListQuestionContentDTO(List listQuestionContentDTO, + QaQuestionContentDTO qaQuestionContentDTONew, String editableQuestionIndex) { + AuthoringUtil.logger.debug("reorderUpdateListQuestionContentDTO"); + AuthoringUtil.logger.debug("listQuestionContentDTO:" + listQuestionContentDTO); + AuthoringUtil.logger.debug("qaQuestionContentDTONew:" + qaQuestionContentDTONew); + AuthoringUtil.logger.debug("editableQuestionIndex:" + editableQuestionIndex); - listFinalQuestionContentDTO.add(qaQuestionContentDTO); - - } - - } - - logger.debug("listFinalQuestionContentDTO:" + listFinalQuestionContentDTO); - return listFinalQuestionContentDTO; + List listFinalQuestionContentDTO = new LinkedList(); + + int queIndex = 0; + Iterator listIterator = listQuestionContentDTO.iterator(); + while (listIterator.hasNext()) { + QaQuestionContentDTO qaQuestionContentDTO = (QaQuestionContentDTO) listIterator.next(); + AuthoringUtil.logger.debug("qaQuestionContentDTO:" + qaQuestionContentDTO); + AuthoringUtil.logger.debug("qaQuestionContentDTO question:" + qaQuestionContentDTO.getQuestion()); + + ++queIndex; + AuthoringUtil.logger.debug("using queIndex:" + queIndex); + String question = qaQuestionContentDTO.getQuestion(); + AuthoringUtil.logger.debug("question:" + question); + + String displayOrder = qaQuestionContentDTO.getDisplayOrder(); + AuthoringUtil.logger.debug("displayOrder:" + displayOrder); + + String feedback = qaQuestionContentDTO.getFeedback(); + AuthoringUtil.logger.debug("feedback:" + feedback); + + if (displayOrder.equals(editableQuestionIndex)) { + AuthoringUtil.logger.debug("displayOrder equals editableQuestionIndex:" + editableQuestionIndex); + qaQuestionContentDTO.setQuestion(qaQuestionContentDTONew.getQuestion()); + qaQuestionContentDTO.setDisplayOrder(qaQuestionContentDTONew.getDisplayOrder()); + qaQuestionContentDTO.setFeedback(qaQuestionContentDTONew.getFeedback()); + + listFinalQuestionContentDTO.add(qaQuestionContentDTO); + } else { + AuthoringUtil.logger + .debug("displayOrder does not equal editableQuestionIndex:" + editableQuestionIndex); + qaQuestionContentDTO.setQuestion(question); + qaQuestionContentDTO.setDisplayOrder(displayOrder); + qaQuestionContentDTO.setFeedback(feedback); + + listFinalQuestionContentDTO.add(qaQuestionContentDTO); + + } + + } + + AuthoringUtil.logger.debug("listFinalQuestionContentDTO:" + listFinalQuestionContentDTO); + return listFinalQuestionContentDTO; } - - - - + /** - * repopulateMap(TreeMap mapQuestionContent, HttpServletRequest request) - * return void - * repopulates the user entries into the Map + * repopulateMap(TreeMap mapQuestionContent, HttpServletRequest request) return void repopulates the user entries + * into the Map */ - protected void repopulateMap(Map mapQuestionContent, HttpServletRequest request) - { - logger.debug("starting repopulateMap"); - int intQuestionIndex= mapQuestionContent.size(); - logger.debug("intQuestionIndex: " + intQuestionIndex); + protected void repopulateMap(Map mapQuestionContent, HttpServletRequest request) { + AuthoringUtil.logger.debug("starting repopulateMap"); + int intQuestionIndex = mapQuestionContent.size(); + AuthoringUtil.logger.debug("intQuestionIndex: " + intQuestionIndex); - /* if there is data in the Map remaining from previous session remove those */ - mapQuestionContent.clear(); - logger.debug("Map got initialized: " + mapQuestionContent); - - for (long i=0; i < intQuestionIndex ; i++) - { - String candidateQuestionEntry =request.getParameter("questionContent" + i); - if (i==0) - { - logger.debug("defaultQuestionContent set to: " + candidateQuestionEntry); - } - if ((candidateQuestionEntry != null) && (candidateQuestionEntry.length() > 0)) - { - logger.debug("using key: " + i); - mapQuestionContent.put(new Long(i+1).toString(), candidateQuestionEntry); - logger.debug("added new entry."); - } - } + /* + * if there is data in the Map remaining from previous session remove those + */ + mapQuestionContent.clear(); + AuthoringUtil.logger.debug("Map got initialized: " + mapQuestionContent); + + for (long i = 0; i < intQuestionIndex; i++) { + String candidateQuestionEntry = request.getParameter("questionContent" + i); + if (i == 0) { + AuthoringUtil.logger.debug("defaultQuestionContent set to: " + candidateQuestionEntry); + } + if (candidateQuestionEntry != null && candidateQuestionEntry.length() > 0) { + AuthoringUtil.logger.debug("using key: " + i); + mapQuestionContent.put(new Long(i + 1).toString(), candidateQuestionEntry); + AuthoringUtil.logger.debug("added new entry."); + } + } } + public QaContent saveOrUpdateQaContent(Map mapQuestionContent, Map mapFeedback, IQaService qaService, + QaAuthoringForm qaAuthoringForm, HttpServletRequest request, QaContent qaContent, String strToolContentID, + Set conditions) { + UserDTO toolUser = (UserDTO) SessionManager.getSession().getAttribute(AttributeNames.USER); - public QaContent saveOrUpdateQaContent(Map mapQuestionContent, Map mapFeedback, IQaService qaService, QaAuthoringForm qaAuthoringForm, - HttpServletRequest request, QaContent qaContent, String strToolContentID) - { - UserDTO toolUser = (UserDTO) SessionManager.getSession().getAttribute(AttributeNames.USER); - - String richTextTitle = request.getParameter(TITLE); - String richTextInstructions = request.getParameter(INSTRUCTIONS); + String richTextTitle = request.getParameter(QaAppConstants.TITLE); + String richTextInstructions = request.getParameter(QaAppConstants.INSTRUCTIONS); - logger.debug("richTextTitle: " + richTextTitle); - logger.debug("richTextInstructions: " + richTextInstructions); + AuthoringUtil.logger.debug("richTextTitle: " + richTextTitle); + AuthoringUtil.logger.debug("richTextInstructions: " + richTextInstructions); - String synchInMonitor=request.getParameter(SYNC_IN_MONITOR); - logger.debug("synchInMonitor: " + synchInMonitor); - - String usernameVisible=request.getParameter(USERNAME_VISIBLE); - logger.debug("usernameVisible: " + usernameVisible); - - String showOtherAnswers=request.getParameter("showOtherAnswers"); - logger.debug("showOtherAnswers: " + showOtherAnswers); - - String questionsSequenced=request.getParameter(QUESTIONS_SEQUENCED); - logger.debug("questionsSequenced: " + questionsSequenced); - - String lockWhenFinished=request.getParameter("lockWhenFinished"); - logger.debug("lockWhenFinished: " + lockWhenFinished); - - - String richTextOfflineInstructions=request.getParameter(OFFLINE_INSTRUCTIONS); - String richTextOnlineInstructions=request.getParameter(ONLINE_INSTRUCTIONS); - String reflect=request.getParameter(REFLECT); - logger.debug("reflect: " + reflect); - - String reflectionSubject=request.getParameter(REFLECTION_SUBJECT); - logger.debug("reflectionSubject: " + reflectionSubject); - - String activeModule=request.getParameter(ACTIVE_MODULE); - logger.debug("activeModule: " + activeModule); - - - boolean setCommonContent=true; - if ((questionsSequenced == null) || (synchInMonitor == null) || (lockWhenFinished == null) || - (usernameVisible == null) || (reflect == null) || (showOtherAnswers == null)) - { - setCommonContent=false; - } - logger.debug("setCommonContent: " + setCommonContent); - - boolean questionsSequencedBoolean=false; - boolean synchInMonitorBoolean=false; - boolean lockWhenFinishedBoolean=false; - boolean usernameVisibleBoolean=false; - boolean showOtherAnswersBoolean=false; - boolean reflectBoolean=false; + String synchInMonitor = request.getParameter(QaAppConstants.SYNC_IN_MONITOR); + AuthoringUtil.logger.debug("synchInMonitor: " + synchInMonitor); - if ((questionsSequenced != null) && (questionsSequenced.equalsIgnoreCase("1"))) - questionsSequencedBoolean=true; - - if ((synchInMonitor != null) && (synchInMonitor.equalsIgnoreCase("1"))) - synchInMonitorBoolean=true; - - if ((lockWhenFinished != null) && (lockWhenFinished.equalsIgnoreCase("1"))) - lockWhenFinishedBoolean=true; - - if ((usernameVisible != null) && (usernameVisible.equalsIgnoreCase("1"))) - usernameVisibleBoolean=true; + String usernameVisible = request.getParameter(QaAppConstants.USERNAME_VISIBLE); + AuthoringUtil.logger.debug("usernameVisible: " + usernameVisible); - if ((showOtherAnswers != null) && (showOtherAnswers.equalsIgnoreCase("1"))) - showOtherAnswersBoolean=true; + String showOtherAnswers = request.getParameter("showOtherAnswers"); + AuthoringUtil.logger.debug("showOtherAnswers: " + showOtherAnswers); - - if ((reflect != null) && (reflect.equalsIgnoreCase("1"))) - reflectBoolean=true; - - - logger.debug("questionsSequencedBoolean: " + questionsSequencedBoolean); - logger.debug("synchInMonitorBoolean: " + synchInMonitorBoolean); - logger.debug("lockWhenFinishedBoolean: " + lockWhenFinishedBoolean); - logger.debug("usernameVisibleBoolean: " + usernameVisibleBoolean); - logger.debug("showOtherAnswersBoolean: " + showOtherAnswersBoolean); - logger.debug("reflectBoolean: " + reflectBoolean); - - long userId=0; - if (toolUser != null) - { - userId = toolUser.getUserID().longValue(); - } - else - { - HttpSession ss = SessionManager.getSession(); - logger.debug("ss: " + ss); - UserDTO user = (UserDTO) ss.getAttribute(AttributeNames.USER); - logger.debug("user" + user); - if (user != null) - { - userId = user.getUserID().longValue(); - } - else - { - logger.debug("should not reach here"); - userId=0; - } - } - logger.debug("userId: " + userId); - logger.debug("qaContent: " + qaContent); - - boolean newContent=false; - if(qaContent == null) - { - qaContent = new QaContent(); - newContent=true; - } + String questionsSequenced = request.getParameter(QaAppConstants.QUESTIONS_SEQUENCED); + AuthoringUtil.logger.debug("questionsSequenced: " + questionsSequenced); + String lockWhenFinished = request.getParameter("lockWhenFinished"); + AuthoringUtil.logger.debug("lockWhenFinished: " + lockWhenFinished); - logger.debug("setting common content values..." + richTextTitle + " " + richTextInstructions); - qaContent.setQaContentId(new Long(strToolContentID)); - qaContent.setTitle(richTextTitle); - qaContent.setInstructions(richTextInstructions); - qaContent.setUpdateDate(new Date(System.currentTimeMillis())); /**keep updating this one*/ - logger.debug("userId: " + userId); - qaContent.setCreatedBy(userId); /**make sure we are setting the userId from the User object above*/ - logger.debug("end of setting common content values..."); + String richTextOfflineInstructions = request.getParameter(QaAppConstants.OFFLINE_INSTRUCTIONS); + String richTextOnlineInstructions = request.getParameter(QaAppConstants.ONLINE_INSTRUCTIONS); + String reflect = request.getParameter(QaAppConstants.REFLECT); + AuthoringUtil.logger.debug("reflect: " + reflect); - + String reflectionSubject = request.getParameter(QaAppConstants.REFLECTION_SUBJECT); + AuthoringUtil.logger.debug("reflectionSubject: " + reflectionSubject); - logger.debug("activeModule:" + activeModule); - if (activeModule.equals(AUTHORING)) - { - logger.debug("setting other content values..."); - qaContent.setOnlineInstructions(richTextOnlineInstructions); - qaContent.setOfflineInstructions(richTextOfflineInstructions); - qaContent.setUsernameVisible(usernameVisibleBoolean); - qaContent.setShowOtherAnswers(showOtherAnswersBoolean); - qaContent.setQuestionsSequenced(questionsSequencedBoolean); - qaContent.setLockWhenFinished(lockWhenFinishedBoolean); - qaContent.setSynchInMonitor(synchInMonitorBoolean); - qaContent.setReflect(reflectBoolean); - qaContent.setReflectionSubject(reflectionSubject); + String activeModule = request.getParameter(QaAppConstants.ACTIVE_MODULE); + AuthoringUtil.logger.debug("activeModule: " + activeModule); + + boolean setCommonContent = true; + if (questionsSequenced == null || synchInMonitor == null || lockWhenFinished == null || usernameVisible == null + || reflect == null || showOtherAnswers == null) { + setCommonContent = false; + } + AuthoringUtil.logger.debug("setCommonContent: " + setCommonContent); + + boolean questionsSequencedBoolean = false; + boolean synchInMonitorBoolean = false; + boolean lockWhenFinishedBoolean = false; + boolean usernameVisibleBoolean = false; + boolean showOtherAnswersBoolean = false; + boolean reflectBoolean = false; + + if (questionsSequenced != null && questionsSequenced.equalsIgnoreCase("1")) { + questionsSequencedBoolean = true; + } + + if (synchInMonitor != null && synchInMonitor.equalsIgnoreCase("1")) { + synchInMonitorBoolean = true; + } + + if (lockWhenFinished != null && lockWhenFinished.equalsIgnoreCase("1")) { + lockWhenFinishedBoolean = true; + } + + if (usernameVisible != null && usernameVisible.equalsIgnoreCase("1")) { + usernameVisibleBoolean = true; + } + + if (showOtherAnswers != null && showOtherAnswers.equalsIgnoreCase("1")) { + showOtherAnswersBoolean = true; + } + + if (reflect != null && reflect.equalsIgnoreCase("1")) { + reflectBoolean = true; + } + + AuthoringUtil.logger.debug("questionsSequencedBoolean: " + questionsSequencedBoolean); + AuthoringUtil.logger.debug("synchInMonitorBoolean: " + synchInMonitorBoolean); + AuthoringUtil.logger.debug("lockWhenFinishedBoolean: " + lockWhenFinishedBoolean); + AuthoringUtil.logger.debug("usernameVisibleBoolean: " + usernameVisibleBoolean); + AuthoringUtil.logger.debug("showOtherAnswersBoolean: " + showOtherAnswersBoolean); + AuthoringUtil.logger.debug("reflectBoolean: " + reflectBoolean); + + long userId = 0; + if (toolUser != null) { + userId = toolUser.getUserID().longValue(); + } else { + HttpSession ss = SessionManager.getSession(); + AuthoringUtil.logger.debug("ss: " + ss); + UserDTO user = (UserDTO) ss.getAttribute(AttributeNames.USER); + AuthoringUtil.logger.debug("user" + user); + if (user != null) { + userId = user.getUserID().longValue(); + } else { + AuthoringUtil.logger.debug("should not reach here"); + userId = 0; + } + } + AuthoringUtil.logger.debug("userId: " + userId); + AuthoringUtil.logger.debug("qaContent: " + qaContent); + + boolean newContent = false; + if (qaContent == null) { + qaContent = new QaContent(); + newContent = true; + } + + AuthoringUtil.logger.debug("setting common content values..." + richTextTitle + " " + richTextInstructions); + qaContent.setQaContentId(new Long(strToolContentID)); + qaContent.setTitle(richTextTitle); + qaContent.setInstructions(richTextInstructions); + qaContent.setUpdateDate(new Date(System.currentTimeMillis())); + /** keep updating this one */ + AuthoringUtil.logger.debug("userId: " + userId); + qaContent.setCreatedBy(userId); + /** make sure we are setting the userId from the User object above */ + AuthoringUtil.logger.debug("end of setting common content values..."); + + AuthoringUtil.logger.debug("activeModule:" + activeModule); + if (activeModule.equals(QaAppConstants.AUTHORING)) { + AuthoringUtil.logger.debug("setting other content values..."); + qaContent.setOnlineInstructions(richTextOnlineInstructions); + qaContent.setOfflineInstructions(richTextOfflineInstructions); + qaContent.setUsernameVisible(usernameVisibleBoolean); + qaContent.setShowOtherAnswers(showOtherAnswersBoolean); + qaContent.setQuestionsSequenced(questionsSequencedBoolean); + qaContent.setLockWhenFinished(lockWhenFinishedBoolean); + qaContent.setSynchInMonitor(synchInMonitorBoolean); + qaContent.setReflect(reflectBoolean); + qaContent.setReflectionSubject(reflectionSubject); + + } + + qaContent.setConditions(new TreeSet(new QaConditionComparator())); + if (newContent) { + AuthoringUtil.logger.debug("will create: " + qaContent); + qaService.createQa(qaContent); + } else { + AuthoringUtil.logger.debug("will update: " + qaContent); + qaService.updateQa(qaContent); + } + + qaContent = qaService.loadQa(new Long(strToolContentID).longValue()); + AuthoringUtil.logger.debug("qaContent: " + qaContent); + qaContent = createQuestionContent(mapQuestionContent, mapFeedback, qaService, qaContent, conditions); + + qaContent = qaService.loadQa(new Long(strToolContentID).longValue()); + + for (QaCondition condition : conditions) { + condition.setQuestions(new TreeSet(new QaQueContentComparator())); + for (QaQuestionContentDTO dto : condition.temporaryQuestionDTOSet) { + for (QaQueContent queContent : (Set) qaContent.getQaQueContents()) { + if (dto.getDisplayOrder().equals(String.valueOf(queContent.getDisplayOrder()))) { + condition.getQuestions().add(queContent); + } } - - - if (newContent) - { - logger.debug("will create: " + qaContent); - qaService.createQa(qaContent); - } - else - { - logger.debug("will update: " + qaContent); - qaService.updateQa(qaContent); - } - - qaContent=qaService.loadQa(new Long(strToolContentID).longValue()); - logger.debug("qaContent: " + qaContent); - - qaContent=createQuestionContent(mapQuestionContent, mapFeedback, qaService, qaContent); - - return qaContent; + } + } + qaContent.setConditions(conditions); + qaService.updateQa(qaContent); + return qaContent; } - - + /** - * removes unused question entries from db - * removeRedundantQuestions (Map mapQuestionContent, IQaService qaService, QaAuthoringForm qaAuthoringForm) + * removes unused question entries from db removeRedundantQuestions (Map mapQuestionContent, IQaService qaService, + * QaAuthoringForm qaAuthoringForm) * * @param mapQuestionContent * @param qaService * @param qaAuthoringForm */ - public void removeRedundantQuestions (Map mapQuestionContent, IQaService qaService, QaAuthoringForm qaAuthoringForm, - HttpServletRequest request, String toolContentID) - { - logger.debug("removing unused entries... "); - logger.debug("mapQuestionContent: " + mapQuestionContent); - logger.debug("toolContentID: " + toolContentID); - - QaContent qaContent=qaService.loadQa( new Long(toolContentID).longValue()); - logger.debug("qaContent: " + qaContent); - - if (qaContent != null) - { - logger.debug("qaContent uid: " + qaContent.getUid()); - List allQuestions=qaService.getAllQuestionEntries(qaContent.getUid()); - logger.debug("allQuestions: " + allQuestions); - - Iterator listIterator=allQuestions.iterator(); - int mapIndex=0; - boolean entryUsed=false; - while (listIterator.hasNext()) - { - ++mapIndex; - logger.debug("current mapIndex: " + mapIndex); + public void removeRedundantQuestions(Map mapQuestionContent, IQaService qaService, QaAuthoringForm qaAuthoringForm, + HttpServletRequest request, String toolContentID) { + AuthoringUtil.logger.debug("removing unused entries... "); + AuthoringUtil.logger.debug("mapQuestionContent: " + mapQuestionContent); + AuthoringUtil.logger.debug("toolContentID: " + toolContentID); - QaQueContent queContent=(QaQueContent)listIterator.next(); - logger.debug("queContent data: " + queContent); - logger.debug("queContent: " + queContent.getQuestion() + " " + queContent.getDisplayOrder()); - - entryUsed=false; - Iterator itMap = mapQuestionContent.entrySet().iterator(); - int displayOrder=0; - while (itMap.hasNext()) - { - ++displayOrder; - logger.debug("current displayOrder: " + displayOrder); - entryUsed=false; - Map.Entry pairs = (Map.Entry)itMap.next(); - logger.debug("using the pair: " + pairs.getKey() + " = " + pairs.getValue()); - - if (pairs.getValue().toString().length() != 0) - { - logger.debug("text from map:" + pairs.getValue().toString()); - logger.debug("text from db:" + queContent.getQuestion()); + QaContent qaContent = qaService.loadQa(new Long(toolContentID).longValue()); + AuthoringUtil.logger.debug("qaContent: " + qaContent); - logger.debug("mapIndex versus displayOrder:" + mapIndex + " versus " + displayOrder); - if (mapIndex == displayOrder) - { - //logger.debug("used entry in db:" + queContent.getQuestion()); - logger.debug("used displayOrder position:" + displayOrder); - entryUsed=true; - break; - } - - } - } - - if (entryUsed == false) - { - logger.debug("removing unused entry in db:" + queContent.getQuestion()); - - QaQueContent removeableQaQueContent=qaService.getQuestionContentByQuestionText(queContent.getQuestion(), qaContent.getUid()); - logger.debug("removeableQaQueContent" + removeableQaQueContent); - if (removeableQaQueContent != null) - { - //qaContent.getQaQueContents().remove(removeableQaQueContent); - qaService.removeQaQueContent(removeableQaQueContent); - logger.debug("removed removeableQaQueContent from the db: " + removeableQaQueContent); - } - - } - } - } - + if (qaContent != null) { + AuthoringUtil.logger.debug("qaContent uid: " + qaContent.getUid()); + List allQuestions = qaService.getAllQuestionEntries(qaContent.getUid()); + AuthoringUtil.logger.debug("allQuestions: " + allQuestions); + + Iterator listIterator = allQuestions.iterator(); + int mapIndex = 0; + boolean entryUsed = false; + while (listIterator.hasNext()) { + ++mapIndex; + AuthoringUtil.logger.debug("current mapIndex: " + mapIndex); + + QaQueContent queContent = (QaQueContent) listIterator.next(); + AuthoringUtil.logger.debug("queContent data: " + queContent); + AuthoringUtil.logger.debug("queContent: " + queContent.getQuestion() + " " + + queContent.getDisplayOrder()); + + entryUsed = false; + Iterator itMap = mapQuestionContent.entrySet().iterator(); + int displayOrder = 0; + while (itMap.hasNext()) { + ++displayOrder; + AuthoringUtil.logger.debug("current displayOrder: " + displayOrder); + entryUsed = false; + Map.Entry pairs = (Map.Entry) itMap.next(); + AuthoringUtil.logger.debug("using the pair: " + pairs.getKey() + " = " + pairs.getValue()); + + if (pairs.getValue().toString().length() != 0) { + AuthoringUtil.logger.debug("text from map:" + pairs.getValue().toString()); + AuthoringUtil.logger.debug("text from db:" + queContent.getQuestion()); + + AuthoringUtil.logger.debug("mapIndex versus displayOrder:" + mapIndex + " versus " + + displayOrder); + if (mapIndex == displayOrder) { + // logger.debug("used entry in db:" + + // queContent.getQuestion()); + AuthoringUtil.logger.debug("used displayOrder position:" + displayOrder); + entryUsed = true; + break; + } + + } + } + + if (entryUsed == false) { + AuthoringUtil.logger.debug("removing unused entry in db:" + queContent.getQuestion()); + + QaQueContent removeableQaQueContent = qaService.getQuestionContentByQuestionText(queContent + .getQuestion(), qaContent.getUid()); + AuthoringUtil.logger.debug("removeableQaQueContent" + removeableQaQueContent); + if (removeableQaQueContent != null) { + // qaContent.getQaQueContents().remove(removeableQaQueContent); + qaService.removeQaQueContent(removeableQaQueContent); + AuthoringUtil.logger.debug("removed removeableQaQueContent from the db: " + + removeableQaQueContent); + } + + } + } } - + + } + /** - * createQuestionContent(TreeMap mapQuestionContent, HttpServletRequest request) - * return void + * createQuestionContent(TreeMap mapQuestionContent, HttpServletRequest request) return void * - * persist the questions in the Map the user has submitted + * persist the questions in the Map the user has submitted */ - protected QaContent createQuestionContent(Map mapQuestionContent, Map mapFeedback, IQaService qaService, QaContent qaContent) - { - logger.debug("createQuestionContent: "); - logger.debug("content uid is: " + qaContent.getUid()); - List questions=qaService.retrieveQaQueContentsByToolContentId(qaContent.getUid().longValue()); - logger.debug("questions: " + questions); - - logger.debug("mapQuestionContent: " + mapQuestionContent); - logger.debug("mapFeedback: " + mapFeedback); + protected QaContent createQuestionContent(Map mapQuestionContent, Map mapFeedback, IQaService qaService, + QaContent qaContent, Set conditions) { + AuthoringUtil.logger.debug("createQuestionContent: "); + AuthoringUtil.logger.debug("content uid is: " + qaContent.getUid()); + List questions = qaService.retrieveQaQueContentsByToolContentId(qaContent.getUid().longValue()); + AuthoringUtil.logger.debug("questions: " + questions); - - Iterator itMap = mapQuestionContent.entrySet().iterator(); - int displayOrder=0; - while (itMap.hasNext()) - { - Map.Entry pairs = (Map.Entry)itMap.next(); - logger.debug("using the pair: " + pairs.getKey() + " = " + pairs.getValue()); - - if (pairs.getValue().toString().length() != 0) - { - logger.debug("starting createQuestionContent: pairs.getValue().toString():" + pairs.getValue().toString()); - logger.debug("starting createQuestionContent: qaContent: " + qaContent); - - ++displayOrder; - logger.debug("starting createQuestionContent: displayOrder: " + displayOrder); - String currentFeedback=(String)mapFeedback.get(new Integer(displayOrder).toString()); - logger.debug("currentFeedback: " + currentFeedback); - - QaQueContent queContent= new QaQueContent(pairs.getValue().toString(), - displayOrder, - currentFeedback, - qaContent, - null, - null); - - - logger.debug("queContent: " + queContent); - - /* checks if the question is already recorded*/ - logger.debug("question text is: " + pairs.getValue().toString()); - logger.debug("content uid is: " + qaContent.getUid()); - logger.debug("question display order is: " + displayOrder); - QaQueContent existingQaQueContent=qaService.getQuestionContentByDisplayOrder(new Long(displayOrder), qaContent.getUid()); - logger.debug("existingQaQueContent: " + existingQaQueContent); - - if (existingQaQueContent == null) - { - /*make sure a question with the same question text is not already saved*/ - QaQueContent duplicateQaQueContent=qaService.getQuestionContentByQuestionText(pairs.getValue().toString(), qaContent.getUid()); - logger.debug("duplicateQaQueContent: " + duplicateQaQueContent); - //if (duplicateQaQueContent == null) - //{ - logger.debug("adding a new question to content: " + queContent); - qaContent.getQaQueContents().add(queContent); - queContent.setQaContent(qaContent); - - qaService.createQaQue(queContent); - //} - } - else - { + AuthoringUtil.logger.debug("mapQuestionContent: " + mapQuestionContent); + AuthoringUtil.logger.debug("mapFeedback: " + mapFeedback); - String existingQuestion=existingQaQueContent.getQuestion(); - logger.debug("existingQuestion: " + existingQuestion); - - logger.debug("map question versus existingQuestion: " + pairs.getValue().toString() + - " versus db question value: " + existingQuestion); + Iterator itMap = mapQuestionContent.entrySet().iterator(); + int displayOrder = 0; + while (itMap.hasNext()) { + Map.Entry pairs = (Map.Entry) itMap.next(); + AuthoringUtil.logger.debug("using the pair: " + pairs.getKey() + " = " + pairs.getValue()); - existingQaQueContent.setQuestion(pairs.getValue().toString()); - existingQaQueContent.setFeedback(currentFeedback); - existingQaQueContent.setDisplayOrder(displayOrder); - - logger.debug("updating the existing question content: " + existingQaQueContent); - qaService.updateQaQueContent(existingQaQueContent); - } - } + if (pairs.getValue().toString().length() != 0) { + AuthoringUtil.logger.debug("starting createQuestionContent: pairs.getValue().toString():" + + pairs.getValue().toString()); + AuthoringUtil.logger.debug("starting createQuestionContent: qaContent: " + qaContent); + + ++displayOrder; + AuthoringUtil.logger.debug("starting createQuestionContent: displayOrder: " + displayOrder); + String currentFeedback = (String) mapFeedback.get(new Integer(displayOrder).toString()); + AuthoringUtil.logger.debug("currentFeedback: " + currentFeedback); + + QaQueContent queContent = new QaQueContent(pairs.getValue().toString(), displayOrder, currentFeedback, + qaContent, null, null); + + AuthoringUtil.logger.debug("queContent: " + queContent); + + /* checks if the question is already recorded */ + AuthoringUtil.logger.debug("question text is: " + pairs.getValue().toString()); + AuthoringUtil.logger.debug("content uid is: " + qaContent.getUid()); + AuthoringUtil.logger.debug("question display order is: " + displayOrder); + QaQueContent existingQaQueContent = qaService.getQuestionContentByDisplayOrder(new Long(displayOrder), + qaContent.getUid()); + AuthoringUtil.logger.debug("existingQaQueContent: " + existingQaQueContent); + + if (existingQaQueContent == null) { + /* + * make sure a question with the same question text is not already saved + */ + QaQueContent duplicateQaQueContent = qaService.getQuestionContentByQuestionText(pairs.getValue() + .toString(), qaContent.getUid()); + AuthoringUtil.logger.debug("duplicateQaQueContent: " + duplicateQaQueContent); + // if (duplicateQaQueContent == null) + // { + AuthoringUtil.logger.debug("adding a new question to content: " + queContent); + qaContent.getQaQueContents().add(queContent); + queContent.setQaContent(qaContent); + + qaService.createQaQue(queContent); + + // } + } else { + + String existingQuestion = existingQaQueContent.getQuestion(); + AuthoringUtil.logger.debug("existingQuestion: " + existingQuestion); + + AuthoringUtil.logger.debug("map question versus existingQuestion: " + pairs.getValue().toString() + + " versus db question value: " + existingQuestion); + + existingQaQueContent.setQuestion(pairs.getValue().toString()); + existingQaQueContent.setFeedback(currentFeedback); + existingQaQueContent.setDisplayOrder(displayOrder); + + AuthoringUtil.logger.debug("updating the existing question content: " + existingQaQueContent); + qaService.updateQaQueContent(existingQaQueContent); + } } - return qaContent; + } + + return qaContent; } - - - public static boolean checkDuplicateQuestions(List listQuestionContentDTO, String newQuestion) - { - logger.debug("checkDuplicateQuestions: " + listQuestionContentDTO); - logger.debug("newQuestion: " + newQuestion); - - Map mapQuestionContent=extractMapQuestionContent(listQuestionContentDTO); - logger.debug("mapQuestionContent: " + mapQuestionContent); - - Iterator itMap = mapQuestionContent.entrySet().iterator(); - while (itMap.hasNext()) { - Map.Entry pairs = (Map.Entry)itMap.next(); - if ((pairs.getValue() != null) && (!pairs.getValue().equals(""))) - { - logger.debug("checking the pair: " + pairs.getKey() + " = " + pairs.getValue()); - - if (pairs.getValue().equals(newQuestion)) - { - logger.debug("entry found: " + newQuestion); - return true; - } - } + + public static boolean checkDuplicateQuestions(List listQuestionContentDTO, String newQuestion) { + AuthoringUtil.logger.debug("checkDuplicateQuestions: " + listQuestionContentDTO); + AuthoringUtil.logger.debug("newQuestion: " + newQuestion); + + Map mapQuestionContent = extractMapQuestionContent(listQuestionContentDTO); + AuthoringUtil.logger.debug("mapQuestionContent: " + mapQuestionContent); + + Iterator itMap = mapQuestionContent.entrySet().iterator(); + while (itMap.hasNext()) { + Map.Entry pairs = (Map.Entry) itMap.next(); + if (pairs.getValue() != null && !pairs.getValue().equals("")) { + AuthoringUtil.logger.debug("checking the pair: " + pairs.getKey() + " = " + pairs.getValue()); + + if (pairs.getValue().equals(newQuestion)) { + AuthoringUtil.logger.debug("entry found: " + newQuestion); + return true; + } } - return false; + } + return false; } - - - /** - * sorts the questions by the display order - * reOrganizeDisplayOrder(Map mapQuestionContent, IQaService qaService, QaAuthoringForm qaAuthoringForm, QaContent qaContent) + * sorts the questions by the display order reOrganizeDisplayOrder(Map mapQuestionContent, IQaService qaService, + * QaAuthoringForm qaAuthoringForm, QaContent qaContent) * * @param mapQuestionContent * @param qaService * @param qaAuthoringForm * @param qaContent */ - public void reOrganizeDisplayOrder(Map mapQuestionContent, IQaService qaService, QaAuthoringForm qaAuthoringForm, QaContent qaContent) - { - logger.debug("qaContent: " + qaContent); - if (qaContent != null) - { - logger.debug("content uid: " + qaContent.getUid()); - List sortedQuestions=qaService.getAllQuestionEntriesSorted(qaContent.getUid().longValue()); - logger.debug("sortedQuestions: " + sortedQuestions); - - Iterator listIterator=sortedQuestions.iterator(); - int displayOrder=1; - while (listIterator.hasNext()) - { - QaQueContent queContent=(QaQueContent)listIterator.next(); - logger.debug("queContent data: " + queContent); - logger.debug("queContent: " + queContent.getQuestion() + " " + queContent.getDisplayOrder()); - - QaQueContent existingQaQueContent=qaService.getQuestionContentByQuestionText(queContent.getQuestion(), qaContent.getUid()); - logger.debug("existingQaQueContent: " + existingQaQueContent); - existingQaQueContent.setDisplayOrder(displayOrder); - logger.debug("updating the existing question content for displayOrder: " + existingQaQueContent); - qaService.updateQaQueContent(existingQaQueContent); - displayOrder++; - } - } - logger.debug("done with reOrganizeDisplayOrder..."); + public void reOrganizeDisplayOrder(Map mapQuestionContent, IQaService qaService, QaAuthoringForm qaAuthoringForm, + QaContent qaContent) { + AuthoringUtil.logger.debug("qaContent: " + qaContent); + if (qaContent != null) { + AuthoringUtil.logger.debug("content uid: " + qaContent.getUid()); + List sortedQuestions = qaService.getAllQuestionEntriesSorted(qaContent.getUid().longValue()); + AuthoringUtil.logger.debug("sortedQuestions: " + sortedQuestions); + + Iterator listIterator = sortedQuestions.iterator(); + int displayOrder = 1; + while (listIterator.hasNext()) { + QaQueContent queContent = (QaQueContent) listIterator.next(); + AuthoringUtil.logger.debug("queContent data: " + queContent); + AuthoringUtil.logger.debug("queContent: " + queContent.getQuestion() + " " + + queContent.getDisplayOrder()); + + QaQueContent existingQaQueContent = qaService.getQuestionContentByQuestionText( + queContent.getQuestion(), qaContent.getUid()); + AuthoringUtil.logger.debug("existingQaQueContent: " + existingQaQueContent); + existingQaQueContent.setDisplayOrder(displayOrder); + AuthoringUtil.logger.debug("updating the existing question content for displayOrder: " + + existingQaQueContent); + qaService.updateQaQueContent(existingQaQueContent); + displayOrder++; + } + } + AuthoringUtil.logger.debug("done with reOrganizeDisplayOrder..."); } - - + /** - * checks if any entry is duplicate - * verifyDuplicatesOptionsMap(Map mapQuestions) + * checks if any entry is duplicate verifyDuplicatesOptionsMap(Map mapQuestions) * * @param mapQuestions * @return */ - public static boolean verifyDuplicatesOptionsMap(Map mapQuestions) - { - Map originalMap=mapQuestions; - Map backupMap=mapQuestions; - - int optionCount=0; - for (long i=1; i <= MAX_QUESTION_COUNT.longValue() ; i++) - { - String currentOption=(String)originalMap.get(new Long(i).toString()); - - optionCount=0; - for (long j=1; j <= MAX_QUESTION_COUNT.longValue() ; j++) - { - String backedOption=(String)backupMap.get(new Long(j).toString()); - - if ((currentOption != null) && (backedOption !=null)) - { - if (currentOption.equals(backedOption)) - { - optionCount++; - } - - if (optionCount > 1) - return false; - } - } + public static boolean verifyDuplicatesOptionsMap(Map mapQuestions) { + Map originalMap = mapQuestions; + Map backupMap = mapQuestions; + + int optionCount = 0; + for (long i = 1; i <= QaAppConstants.MAX_QUESTION_COUNT.longValue(); i++) { + String currentOption = (String) originalMap.get(new Long(i).toString()); + + optionCount = 0; + for (long j = 1; j <= QaAppConstants.MAX_QUESTION_COUNT.longValue(); j++) { + String backedOption = (String) backupMap.get(new Long(j).toString()); + + if (currentOption != null && backedOption != null) { + if (currentOption.equals(backedOption)) { + optionCount++; + } + + if (optionCount > 1) { + return false; + } } - return true; + } } + return true; + } } \ No newline at end of file Index: lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/QaAction.java =================================================================== diff -u -rcd71920aa725c01e396c4ad9b7bd7ef7bd236da2 -r0af4ed13b963a588f3499b080801863d57f8ad95 --- lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/QaAction.java (.../QaAction.java) (revision cd71920aa725c01e396c4ad9b7bd7ef7bd236da2) +++ lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/QaAction.java (.../QaAction.java) (revision 0af4ed13b963a588f3499b080801863d57f8ad95) @@ -31,6 +31,7 @@ import java.util.LinkedList; import java.util.List; import java.util.Map; +import java.util.SortedSet; import javax.servlet.ServletException; import javax.servlet.http.HttpServletRequest; @@ -52,6 +53,7 @@ import org.lamsfoundation.lams.tool.qa.EditActivityDTO; import org.lamsfoundation.lams.tool.qa.QaAppConstants; import org.lamsfoundation.lams.tool.qa.QaApplicationException; +import org.lamsfoundation.lams.tool.qa.QaCondition; import org.lamsfoundation.lams.tool.qa.QaContent; import org.lamsfoundation.lams.tool.qa.QaGeneralAuthoringDTO; import org.lamsfoundation.lams.tool.qa.QaQueContent; @@ -69,118 +71,126 @@ import org.springframework.web.context.WebApplicationContext; import org.springframework.web.context.support.WebApplicationContextUtils; -/** - * setAsForceComplete(Long userId) throws QaApplicationException ? +/** + * setAsForceComplete(Long userId) throws QaApplicationException ? */ - /** - *

Action class that controls the logic of tool behavior.

+ *

+ * 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. + *

+ * 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 + * 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 Ozgur Demirtas * - - - - - - - - - - - + - + + - - + - * + + + + + + + + + + + * */ -public class QaAction extends LamsDispatchAction implements QaAppConstants -{ +public class QaAction extends LamsDispatchAction implements QaAppConstants { static Logger logger = Logger.getLogger(QaAction.class.getName()); - + private QaToolContentHandler toolContentHandler; - - /** - *

Struts dispatch method.

+ + /** + *

+ * Struts dispatch method. + *

* - *

It is assuming that progress engine should pass in the tool access - * mode and the tool session id as http parameters.

+ *

+ * 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. + * @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 + * @throws QaApplicationException + * the known runtime exception * */ - public ActionForward unspecified(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) { - return (mapping.findForward(LOAD_QUESTIONS)); + @Override + public ActionForward unspecified(ActionMapping mapping, ActionForm form, HttpServletRequest request, + HttpServletResponse response) { + return mapping.findForward(QaAppConstants.LOAD_QUESTIONS); } - + /** - * submits content into the tool database - * ActionForward submitAllContent(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) - throws IOException, ServletException + * submits content into the tool database ActionForward submitAllContent(ActionMapping mapping, ActionForm form, + * HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException * * @param mapping * @param form @@ -190,239 +200,230 @@ * @throws IOException * @throws ServletException */ - public ActionForward submitAllContent(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) - throws IOException, ServletException { - - logger.debug("dispathcing submitAllContent :" +form); - - QaAuthoringForm qaAuthoringForm = (QaAuthoringForm) form; + public ActionForward submitAllContent(ActionMapping mapping, ActionForm form, HttpServletRequest request, + HttpServletResponse response) throws IOException, ServletException { - IQaService qaService =QaServiceProxy.getQaService(getServlet().getServletContext()); - logger.debug("qaService: " + qaService); - - String httpSessionID=qaAuthoringForm.getHttpSessionID(); - logger.debug("httpSessionID: " + httpSessionID); - - SessionMap sessionMap=(SessionMap)request.getSession().getAttribute(httpSessionID); - logger.debug("sessionMap: " + sessionMap); + QaAction.logger.debug("dispathcing submitAllContent :" + form); - String contentFolderID = WebUtil.readStrParam(request, AttributeNames.PARAM_CONTENT_FOLDER_ID); - logger.debug("contentFolderID: " + contentFolderID); - qaAuthoringForm.setContentFolderID(contentFolderID); + QaAuthoringForm qaAuthoringForm = (QaAuthoringForm) form; - String activeModule=request.getParameter(ACTIVE_MODULE); - logger.debug("activeModule: " + activeModule); + IQaService qaService = QaServiceProxy.getQaService(getServlet().getServletContext()); + QaAction.logger.debug("qaService: " + qaService); - String strToolContentID=request.getParameter(AttributeNames.PARAM_TOOL_CONTENT_ID); - logger.debug("strToolContentID: " + strToolContentID); + String httpSessionID = qaAuthoringForm.getHttpSessionID(); + QaAction.logger.debug("httpSessionID: " + httpSessionID); - String defaultContentIdStr=request.getParameter(DEFAULT_CONTENT_ID_STR); - logger.debug("defaultContentIdStr: " + defaultContentIdStr); - - List listQuestionContentDTO=(List)sessionMap.get(LIST_QUESTION_CONTENT_DTO_KEY); - logger.debug("listQuestionContentDTO: " + listQuestionContentDTO); - - Map mapQuestionContent=AuthoringUtil.extractMapQuestionContent(listQuestionContentDTO); - logger.debug("extracted mapQuestionContent: " + mapQuestionContent); - + SessionMap sessionMap = (SessionMap) request.getSession().getAttribute(httpSessionID); + QaAction.logger.debug("sessionMap: " + sessionMap); - Map mapFeedback=AuthoringUtil.extractMapFeedback(listQuestionContentDTO); - logger.debug("extracted mapFeedback: " + mapFeedback); + SortedSet conditionSet = (SortedSet) sessionMap + .get(QaAppConstants.ATTR_CONDITION_SET); - ActionMessages errors = new ActionMessages(); - logger.debug("mapQuestionContent size: " + mapQuestionContent.size()); - - if (mapQuestionContent.size() == 0) - { - ActionMessage error = new ActionMessage("questions.none.submitted"); - errors.add(ActionMessages.GLOBAL_MESSAGE, error); - } - logger.debug("errors: " + errors); - - AuthoringUtil authoringUtil= new AuthoringUtil(); - - QaGeneralAuthoringDTO qaGeneralAuthoringDTO= new QaGeneralAuthoringDTO(); - - logger.debug("activeModule: " + activeModule); - if (activeModule.equals(AUTHORING)) - { - List attachmentListBackup= new ArrayList(); - List attachmentList=(List)sessionMap.get(ATTACHMENT_LIST_KEY); - logger.debug("attachmentList: " + attachmentList); - attachmentListBackup=attachmentList; - - List deletedAttachmentListBackup= new ArrayList(); - List deletedAttachmentList=(List)sessionMap.get(DELETED_ATTACHMENT_LIST_KEY); - logger.debug("deletedAttachmentList: " + deletedAttachmentList); - deletedAttachmentListBackup=deletedAttachmentList; - - String onlineInstructions=(String)sessionMap.get(ONLINE_INSTRUCTIONS_KEY); - logger.debug("onlineInstructions: " + onlineInstructions); - qaGeneralAuthoringDTO.setOnlineInstructions(onlineInstructions); + String contentFolderID = WebUtil.readStrParam(request, AttributeNames.PARAM_CONTENT_FOLDER_ID); + QaAction.logger.debug("contentFolderID: " + contentFolderID); + qaAuthoringForm.setContentFolderID(contentFolderID); - String offlineInstructions=(String)sessionMap.get(OFFLINE_INSTRUCTIONS_KEY); - logger.debug("offlineInstructions: " + offlineInstructions); - qaGeneralAuthoringDTO.setOfflineInstructions(offlineInstructions); + String activeModule = request.getParameter(QaAppConstants.ACTIVE_MODULE); + QaAction.logger.debug("activeModule: " + activeModule); - qaGeneralAuthoringDTO.setAttachmentList(attachmentList); - qaGeneralAuthoringDTO.setDeletedAttachmentList(deletedAttachmentList); - - String strOnlineInstructions= request.getParameter("onlineInstructions"); - String strOfflineInstructions= request.getParameter("offlineInstructions"); - logger.debug("onlineInstructions: " + strOnlineInstructions); - logger.debug("offlineInstructions: " + strOfflineInstructions); - qaAuthoringForm.setOfflineInstructions(strOfflineInstructions); - qaAuthoringForm.setOnlineInstructions(strOnlineInstructions); + String strToolContentID = request.getParameter(AttributeNames.PARAM_TOOL_CONTENT_ID); + QaAction.logger.debug("strToolContentID: " + strToolContentID); - } - - - qaGeneralAuthoringDTO.setContentFolderID(contentFolderID); - - String richTextTitle = request.getParameter(TITLE); - String richTextInstructions = request.getParameter(INSTRUCTIONS); - - logger.debug("richTextTitle: " + richTextTitle); - logger.debug("richTextInstructions: " + richTextInstructions); - - qaGeneralAuthoringDTO.setActivityTitle(richTextTitle); - qaAuthoringForm.setTitle(richTextTitle); - - qaGeneralAuthoringDTO.setActivityInstructions(richTextInstructions); - - sessionMap.put(ACTIVITY_TITLE_KEY, richTextTitle); - sessionMap.put(ACTIVITY_INSTRUCTIONS_KEY, richTextInstructions); - - qaGeneralAuthoringDTO.setMapQuestionContent(mapQuestionContent); - logger.debug("qaGeneralAuthoringDTO: " + qaGeneralAuthoringDTO); - - logger.debug("qaGeneralAuthoringDTO now: " + qaGeneralAuthoringDTO); - request.setAttribute(QA_GENERAL_AUTHORING_DTO, qaGeneralAuthoringDTO); - - logger.debug("there are no issues with input, continue and submit data"); + String defaultContentIdStr = request.getParameter(QaAppConstants.DEFAULT_CONTENT_ID_STR); + QaAction.logger.debug("defaultContentIdStr: " + defaultContentIdStr); - QaContent qaContentTest=qaService.loadQa(new Long(strToolContentID).longValue()); - logger.debug("qaContentTest: " + qaContentTest); + List listQuestionContentDTO = (List) sessionMap.get(QaAppConstants.LIST_QUESTION_CONTENT_DTO_KEY); + QaAction.logger.debug("listQuestionContentDTO: " + listQuestionContentDTO); - logger.debug("errors: " + errors); - if(!errors.isEmpty()){ - saveErrors(request, errors); - logger.debug("errors saved: " + errors); + Map mapQuestionContent = AuthoringUtil.extractMapQuestionContent(listQuestionContentDTO); + QaAction.logger.debug("extracted mapQuestionContent: " + mapQuestionContent); + + Map mapFeedback = AuthoringUtil.extractMapFeedback(listQuestionContentDTO); + QaAction.logger.debug("extracted mapFeedback: " + mapFeedback); + + ActionMessages errors = new ActionMessages(); + QaAction.logger.debug("mapQuestionContent size: " + mapQuestionContent.size()); + + if (mapQuestionContent.size() == 0) { + ActionMessage error = new ActionMessage("questions.none.submitted"); + errors.add(ActionMessages.GLOBAL_MESSAGE, error); + } + QaAction.logger.debug("errors: " + errors); + + AuthoringUtil authoringUtil = new AuthoringUtil(); + + QaGeneralAuthoringDTO qaGeneralAuthoringDTO = new QaGeneralAuthoringDTO(); + + QaAction.logger.debug("activeModule: " + activeModule); + if (activeModule.equals(QaAppConstants.AUTHORING)) { + List attachmentListBackup = new ArrayList(); + List attachmentList = (List) sessionMap.get(QaAppConstants.ATTACHMENT_LIST_KEY); + QaAction.logger.debug("attachmentList: " + attachmentList); + attachmentListBackup = attachmentList; + + List deletedAttachmentListBackup = new ArrayList(); + List deletedAttachmentList = (List) sessionMap.get(QaAppConstants.DELETED_ATTACHMENT_LIST_KEY); + QaAction.logger.debug("deletedAttachmentList: " + deletedAttachmentList); + deletedAttachmentListBackup = deletedAttachmentList; + + String onlineInstructions = (String) sessionMap.get(QaAppConstants.ONLINE_INSTRUCTIONS_KEY); + QaAction.logger.debug("onlineInstructions: " + onlineInstructions); + qaGeneralAuthoringDTO.setOnlineInstructions(onlineInstructions); + + String offlineInstructions = (String) sessionMap.get(QaAppConstants.OFFLINE_INSTRUCTIONS_KEY); + QaAction.logger.debug("offlineInstructions: " + offlineInstructions); + qaGeneralAuthoringDTO.setOfflineInstructions(offlineInstructions); + + qaGeneralAuthoringDTO.setAttachmentList(attachmentList); + qaGeneralAuthoringDTO.setDeletedAttachmentList(deletedAttachmentList); + + String strOnlineInstructions = request.getParameter("onlineInstructions"); + String strOfflineInstructions = request.getParameter("offlineInstructions"); + QaAction.logger.debug("onlineInstructions: " + strOnlineInstructions); + QaAction.logger.debug("offlineInstructions: " + strOfflineInstructions); + qaAuthoringForm.setOfflineInstructions(strOfflineInstructions); + qaAuthoringForm.setOnlineInstructions(strOnlineInstructions); + + } + + qaGeneralAuthoringDTO.setContentFolderID(contentFolderID); + + String richTextTitle = request.getParameter(QaAppConstants.TITLE); + String richTextInstructions = request.getParameter(QaAppConstants.INSTRUCTIONS); + + QaAction.logger.debug("richTextTitle: " + richTextTitle); + QaAction.logger.debug("richTextInstructions: " + richTextInstructions); + + qaGeneralAuthoringDTO.setActivityTitle(richTextTitle); + qaAuthoringForm.setTitle(richTextTitle); + + qaGeneralAuthoringDTO.setActivityInstructions(richTextInstructions); + + sessionMap.put(QaAppConstants.ACTIVITY_TITLE_KEY, richTextTitle); + sessionMap.put(QaAppConstants.ACTIVITY_INSTRUCTIONS_KEY, richTextInstructions); + + qaGeneralAuthoringDTO.setMapQuestionContent(mapQuestionContent); + QaAction.logger.debug("qaGeneralAuthoringDTO: " + qaGeneralAuthoringDTO); + + QaAction.logger.debug("qaGeneralAuthoringDTO now: " + qaGeneralAuthoringDTO); + request.setAttribute(QaAppConstants.QA_GENERAL_AUTHORING_DTO, qaGeneralAuthoringDTO); + + QaAction.logger.debug("there are no issues with input, continue and submit data"); + + QaContent qaContentTest = qaService.loadQa(new Long(strToolContentID).longValue()); + QaAction.logger.debug("qaContentTest: " + qaContentTest); + + QaAction.logger.debug("errors: " + errors); + if (!errors.isEmpty()) { + saveErrors(request, errors); + QaAction.logger.debug("errors saved: " + errors); + } + + QaContent qaContent = qaContentTest; + if (errors.isEmpty()) { + QaAction.logger.debug("errors is empty: " + errors); + /* + * to remove deleted entries in the questions table based on mapQuestionContent + */ + authoringUtil.removeRedundantQuestions(mapQuestionContent, qaService, qaAuthoringForm, request, + strToolContentID); + QaAction.logger.debug("end of removing unused entries... "); + + qaContent = authoringUtil.saveOrUpdateQaContent(mapQuestionContent, mapFeedback, qaService, + qaAuthoringForm, request, qaContentTest, strToolContentID, conditionSet); + QaAction.logger.debug("qaContent: " + qaContent); + + long defaultContentID = 0; + QaAction.logger.debug("attempt retrieving tool with signatute : " + QaAppConstants.MY_SIGNATURE); + defaultContentID = qaService.getToolDefaultContentIdBySignature(QaAppConstants.MY_SIGNATURE); + QaAction.logger.debug("retrieved tool default contentId: " + defaultContentID); + + if (qaContent != null) { + qaGeneralAuthoringDTO.setDefaultContentIdStr(new Long(defaultContentID).toString()); + } + QaAction.logger.debug("updated qaGeneralAuthoringDTO to: " + qaGeneralAuthoringDTO); + + authoringUtil.reOrganizeDisplayOrder(mapQuestionContent, qaService, qaAuthoringForm, qaContent); + + QaAction.logger.debug("activeModule: " + activeModule); + if (activeModule.equals(QaAppConstants.AUTHORING)) { + + List attachmentList = (List) sessionMap.get(QaAppConstants.ATTACHMENT_LIST_KEY); + QaAction.logger.debug("attachmentList: " + attachmentList); + + List deletedAttachmentList = (List) sessionMap.get(QaAppConstants.DELETED_ATTACHMENT_LIST_KEY); + + List attachments = saveAttachments(qaContent, attachmentList, deletedAttachmentList, mapping, request); + QaAction.logger.debug("attachments: " + attachments); + } + + QaAction.logger.debug("strToolContentID: " + strToolContentID); + QaUtils.setDefineLater(request, false, strToolContentID, qaService); + QaAction.logger.debug("define later set to false"); + + QaUtils.setFormProperties(request, qaService, qaAuthoringForm, qaGeneralAuthoringDTO, strToolContentID, + defaultContentIdStr, activeModule, sessionMap, httpSessionID); + + if (activeModule.equals(QaAppConstants.AUTHORING)) { + QaAction.logger.debug("standard authoring close"); + request.setAttribute(AuthoringConstants.LAMS_AUTHORING_SUCCESS_FLAG, Boolean.TRUE); + qaGeneralAuthoringDTO.setDefineLaterInEditMode(new Boolean(true).toString()); + } else { + QaAction.logger.debug("go back to view only screen"); + qaGeneralAuthoringDTO.setDefineLaterInEditMode(new Boolean(false).toString()); + } + + } else { + QaAction.logger.debug("errors is not empty: " + errors); + + if (qaContent != null) { + long defaultContentID = 0; + QaAction.logger.debug("attempt retrieving tool with signatute : " + QaAppConstants.MY_SIGNATURE); + defaultContentID = qaService.getToolDefaultContentIdBySignature(QaAppConstants.MY_SIGNATURE); + QaAction.logger.debug("retrieved tool default contentId: " + defaultContentID); + + if (qaContent != null) { + qaGeneralAuthoringDTO.setDefaultContentIdStr(new Long(defaultContentID).toString()); } - - QaContent qaContent=qaContentTest; - if(errors.isEmpty()){ - logger.debug("errors is empty: " + errors); - /*to remove deleted entries in the questions table based on mapQuestionContent */ - authoringUtil.removeRedundantQuestions(mapQuestionContent, qaService, qaAuthoringForm, request, strToolContentID); - logger.debug("end of removing unused entries... "); + QaUtils.setFormProperties(request, qaService, qaAuthoringForm, qaGeneralAuthoringDTO, strToolContentID, + defaultContentIdStr, activeModule, sessionMap, httpSessionID); - qaContent=authoringUtil.saveOrUpdateQaContent(mapQuestionContent, mapFeedback, qaService, qaAuthoringForm, request, qaContentTest, strToolContentID); - logger.debug("qaContent: " + qaContent); - - - long defaultContentID=0; - logger.debug("attempt retrieving tool with signatute : " + MY_SIGNATURE); - defaultContentID=qaService.getToolDefaultContentIdBySignature(MY_SIGNATURE); - logger.debug("retrieved tool default contentId: " + defaultContentID); - - if (qaContent != null) - { - qaGeneralAuthoringDTO.setDefaultContentIdStr(new Long(defaultContentID).toString()); - } - logger.debug("updated qaGeneralAuthoringDTO to: " + qaGeneralAuthoringDTO); - - authoringUtil.reOrganizeDisplayOrder(mapQuestionContent, qaService, qaAuthoringForm, qaContent); + } + } - logger.debug("activeModule: " + activeModule); - if (activeModule.equals(AUTHORING)) - { + qaGeneralAuthoringDTO.setSbmtSuccess(new Integer(1).toString()); - List attachmentList=(List)sessionMap.get(ATTACHMENT_LIST_KEY); - logger.debug("attachmentList: " + attachmentList); + qaAuthoringForm.resetUserAction(); + qaGeneralAuthoringDTO.setMapQuestionContent(mapQuestionContent); - List deletedAttachmentList=(List)sessionMap.get(DELETED_ATTACHMENT_LIST_KEY); + QaAction.logger.debug("before saving final qaGeneralAuthoringDTO: " + qaGeneralAuthoringDTO); + request.setAttribute(QaAppConstants.QA_GENERAL_AUTHORING_DTO, qaGeneralAuthoringDTO); - List attachments=saveAttachments(qaContent, attachmentList, deletedAttachmentList, mapping, request); - logger.debug("attachments: " + attachments); - } - - logger.debug("strToolContentID: " + strToolContentID); - QaUtils.setDefineLater(request, false, strToolContentID, qaService); - logger.debug("define later set to false"); - - QaUtils.setFormProperties(request, qaService, - qaAuthoringForm, qaGeneralAuthoringDTO, strToolContentID, defaultContentIdStr, activeModule, sessionMap, httpSessionID); + request.setAttribute(QaAppConstants.LIST_QUESTION_CONTENT_DTO, listQuestionContentDTO); + sessionMap.put(QaAppConstants.LIST_QUESTION_CONTENT_DTO_KEY, listQuestionContentDTO); + request.getSession().setAttribute(httpSessionID, sessionMap); - if (activeModule.equals(AUTHORING)) - { - logger.debug("standard authoring close"); - request.setAttribute(AuthoringConstants.LAMS_AUTHORING_SUCCESS_FLAG,Boolean.TRUE); - qaGeneralAuthoringDTO.setDefineLaterInEditMode(new Boolean(true).toString()); - } - else - { - logger.debug("go back to view only screen"); - qaGeneralAuthoringDTO.setDefineLaterInEditMode(new Boolean(false).toString()); - } - - } - else - { - logger.debug("errors is not empty: " + errors); - - if (qaContent != null) - { - long defaultContentID=0; - logger.debug("attempt retrieving tool with signatute : " + MY_SIGNATURE); - defaultContentID=qaService.getToolDefaultContentIdBySignature(MY_SIGNATURE); - logger.debug("retrieved tool default contentId: " + defaultContentID); - - if (qaContent != null) - { - qaGeneralAuthoringDTO.setDefaultContentIdStr(new Long(defaultContentID).toString()); - } + request.setAttribute(QaAppConstants.TOTAL_QUESTION_COUNT, new Integer(listQuestionContentDTO.size())); - QaUtils.setFormProperties(request, qaService, - qaAuthoringForm, qaGeneralAuthoringDTO, strToolContentID, defaultContentIdStr, activeModule, sessionMap, httpSessionID); - - } - } - + qaGeneralAuthoringDTO.setToolContentID(strToolContentID); + qaGeneralAuthoringDTO.setHttpSessionID(httpSessionID); + qaGeneralAuthoringDTO.setActiveModule(activeModule); + qaGeneralAuthoringDTO.setDefaultContentIdStr(defaultContentIdStr); - qaGeneralAuthoringDTO.setSbmtSuccess(new Integer(1).toString()); - - qaAuthoringForm.resetUserAction(); - qaGeneralAuthoringDTO.setMapQuestionContent(mapQuestionContent); - - logger.debug("before saving final qaGeneralAuthoringDTO: " + qaGeneralAuthoringDTO); - request.setAttribute(QA_GENERAL_AUTHORING_DTO, qaGeneralAuthoringDTO); + qaAuthoringForm.setToolContentID(strToolContentID); + qaAuthoringForm.setHttpSessionID(httpSessionID); + qaAuthoringForm.setActiveModule(activeModule); + qaAuthoringForm.setDefaultContentIdStr(defaultContentIdStr); + qaAuthoringForm.setCurrentTab("1"); - request.setAttribute(LIST_QUESTION_CONTENT_DTO,listQuestionContentDTO); - sessionMap.put(LIST_QUESTION_CONTENT_DTO_KEY, listQuestionContentDTO); - request.getSession().setAttribute(httpSessionID, sessionMap); - - request.setAttribute(TOTAL_QUESTION_COUNT, new Integer(listQuestionContentDTO.size())); - - qaGeneralAuthoringDTO.setToolContentID(strToolContentID); - qaGeneralAuthoringDTO.setHttpSessionID(httpSessionID); - qaGeneralAuthoringDTO.setActiveModule(activeModule); - qaGeneralAuthoringDTO.setDefaultContentIdStr(defaultContentIdStr); - - qaAuthoringForm.setToolContentID(strToolContentID); - qaAuthoringForm.setHttpSessionID(httpSessionID); - qaAuthoringForm.setActiveModule(activeModule); - qaAuthoringForm.setDefaultContentIdStr(defaultContentIdStr); - qaAuthoringForm.setCurrentTab("1"); - - logger.debug("forwarding to :" + LOAD_QUESTIONS); - return mapping.findForward(LOAD_QUESTIONS); + QaAction.logger.debug("forwarding to :" + QaAppConstants.LOAD_QUESTIONS); + return mapping.findForward(QaAppConstants.LOAD_QUESTIONS); } - /** * saveSingleQuestion + * * @param mapping * @param form * @param request @@ -431,251 +432,224 @@ * @throws IOException * @throws ServletException */ - public ActionForward saveSingleQuestion(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) - throws IOException, ServletException { - - logger.debug("dispathcing saveSingleQuestion"); - QaAuthoringForm qaAuthoringForm = (QaAuthoringForm) form; - - IQaService qaService =QaServiceProxy.getQaService(getServlet().getServletContext()); - logger.debug("qaService: " + qaService); - - String httpSessionID=qaAuthoringForm.getHttpSessionID(); - logger.debug("httpSessionID: " + httpSessionID); - - SessionMap sessionMap=(SessionMap)request.getSession().getAttribute(httpSessionID); - logger.debug("sessionMap: " + sessionMap); - - String contentFolderID = WebUtil.readStrParam(request, AttributeNames.PARAM_CONTENT_FOLDER_ID); - logger.debug("contentFolderID: " + contentFolderID); - qaAuthoringForm.setContentFolderID(contentFolderID); - - - String activeModule=request.getParameter(ACTIVE_MODULE); - logger.debug("activeModule: " + activeModule); - - String strToolContentID=request.getParameter(AttributeNames.PARAM_TOOL_CONTENT_ID); - logger.debug("strToolContentID: " + strToolContentID); - - String defaultContentIdStr=request.getParameter(DEFAULT_CONTENT_ID_STR); - logger.debug("defaultContentIdStr: " + defaultContentIdStr); - - String editQuestionBoxRequest=request.getParameter("editQuestionBoxRequest"); - logger.debug("editQuestionBoxRequest: " + editQuestionBoxRequest); - - QaContent qaContent=qaService.loadQa(new Long(strToolContentID).longValue()); - logger.debug("qaContent: " + qaContent); - - /* - if (qaContent == null) - { - logger.debug("using defaultContentIdStr: " + defaultContentIdStr); - qaContent=qaService.loadQa(new Long(defaultContentIdStr).longValue()); + public ActionForward saveSingleQuestion(ActionMapping mapping, ActionForm form, HttpServletRequest request, + HttpServletResponse response) throws IOException, ServletException { + + QaAction.logger.debug("dispathcing saveSingleQuestion"); + QaAuthoringForm qaAuthoringForm = (QaAuthoringForm) form; + + IQaService qaService = QaServiceProxy.getQaService(getServlet().getServletContext()); + QaAction.logger.debug("qaService: " + qaService); + + String httpSessionID = qaAuthoringForm.getHttpSessionID(); + QaAction.logger.debug("httpSessionID: " + httpSessionID); + + SessionMap sessionMap = (SessionMap) request.getSession().getAttribute(httpSessionID); + QaAction.logger.debug("sessionMap: " + sessionMap); + + String contentFolderID = WebUtil.readStrParam(request, AttributeNames.PARAM_CONTENT_FOLDER_ID); + QaAction.logger.debug("contentFolderID: " + contentFolderID); + qaAuthoringForm.setContentFolderID(contentFolderID); + + String activeModule = request.getParameter(QaAppConstants.ACTIVE_MODULE); + QaAction.logger.debug("activeModule: " + activeModule); + + String strToolContentID = request.getParameter(AttributeNames.PARAM_TOOL_CONTENT_ID); + QaAction.logger.debug("strToolContentID: " + strToolContentID); + + String defaultContentIdStr = request.getParameter(QaAppConstants.DEFAULT_CONTENT_ID_STR); + QaAction.logger.debug("defaultContentIdStr: " + defaultContentIdStr); + + String editQuestionBoxRequest = request.getParameter("editQuestionBoxRequest"); + QaAction.logger.debug("editQuestionBoxRequest: " + editQuestionBoxRequest); + + QaContent qaContent = qaService.loadQa(new Long(strToolContentID).longValue()); + QaAction.logger.debug("qaContent: " + qaContent); + + /* + * if (qaContent == null) { logger.debug("using defaultContentIdStr: " + defaultContentIdStr); + * qaContent=qaService.loadQa(new Long(defaultContentIdStr).longValue()); } + */ + + QaGeneralAuthoringDTO qaGeneralAuthoringDTO = new QaGeneralAuthoringDTO(); + + QaAction.logger.debug("qaGeneralAuthoringDTO: " + qaGeneralAuthoringDTO); + qaGeneralAuthoringDTO.setContentFolderID(contentFolderID); + + qaGeneralAuthoringDTO.setSbmtSuccess(new Integer(0).toString()); + + AuthoringUtil authoringUtil = new AuthoringUtil(); + + List listQuestionContentDTO = (List) sessionMap.get(QaAppConstants.LIST_QUESTION_CONTENT_DTO_KEY); + QaAction.logger.debug("listQuestionContentDTO: " + listQuestionContentDTO); + + String newQuestion = request.getParameter("newQuestion"); + QaAction.logger.debug("newQuestion: " + newQuestion); + + String feedback = request.getParameter("feedback"); + QaAction.logger.debug("feedback: " + feedback); + + String editableQuestionIndex = request.getParameter("editableQuestionIndex"); + QaAction.logger.debug("editableQuestionIndex: " + editableQuestionIndex); + + if (newQuestion != null && newQuestion.length() > 0) { + if (editQuestionBoxRequest != null && editQuestionBoxRequest.equals("false")) { + QaAction.logger.debug("request for add and save"); + boolean duplicates = AuthoringUtil.checkDuplicateQuestions(listQuestionContentDTO, newQuestion); + QaAction.logger.debug("duplicates: " + duplicates); + + if (!duplicates) { + QaQuestionContentDTO qaQuestionContentDTO = null; + Iterator listIterator = listQuestionContentDTO.iterator(); + while (listIterator.hasNext()) { + qaQuestionContentDTO = (QaQuestionContentDTO) listIterator.next(); + QaAction.logger.debug("qaQuestionContentDTO:" + qaQuestionContentDTO); + QaAction.logger.debug("qaQuestionContentDTO question:" + qaQuestionContentDTO.getQuestion()); + + String question = qaQuestionContentDTO.getQuestion(); + String displayOrder = qaQuestionContentDTO.getDisplayOrder(); + QaAction.logger.debug("displayOrder:" + displayOrder); + + if (displayOrder != null && !displayOrder.equals("")) { + if (displayOrder.equals(editableQuestionIndex)) { + break; + } + + } + } + QaAction.logger.debug("qaQuestionContentDTO found:" + qaQuestionContentDTO); + + qaQuestionContentDTO.setQuestion(newQuestion); + qaQuestionContentDTO.setFeedback(feedback); + qaQuestionContentDTO.setDisplayOrder(editableQuestionIndex); + + listQuestionContentDTO = AuthoringUtil.reorderUpdateListQuestionContentDTO(listQuestionContentDTO, + qaQuestionContentDTO, editableQuestionIndex); + QaAction.logger.debug("post reorderUpdateListQuestionContentDTO listQuestionContentDTO: " + + listQuestionContentDTO); + } else { + QaAction.logger.debug("duplicate question entry, not adding"); } - */ - - QaGeneralAuthoringDTO qaGeneralAuthoringDTO= new QaGeneralAuthoringDTO(); - - logger.debug("qaGeneralAuthoringDTO: " + qaGeneralAuthoringDTO); - qaGeneralAuthoringDTO.setContentFolderID(contentFolderID); - - qaGeneralAuthoringDTO.setSbmtSuccess(new Integer(0).toString()); - - AuthoringUtil authoringUtil= new AuthoringUtil(); - - List listQuestionContentDTO=(List)sessionMap.get(LIST_QUESTION_CONTENT_DTO_KEY); - logger.debug("listQuestionContentDTO: " + listQuestionContentDTO); - - - String newQuestion=request.getParameter("newQuestion"); - logger.debug("newQuestion: " + newQuestion); - - String feedback=request.getParameter("feedback"); - logger.debug("feedback: " + feedback); + } else { + QaAction.logger.debug("request for edit and save."); + QaQuestionContentDTO qaQuestionContentDTO = null; + Iterator listIterator = listQuestionContentDTO.iterator(); + while (listIterator.hasNext()) { + qaQuestionContentDTO = (QaQuestionContentDTO) listIterator.next(); + QaAction.logger.debug("qaQuestionContentDTO:" + qaQuestionContentDTO); + QaAction.logger.debug("qaQuestionContentDTO question:" + qaQuestionContentDTO.getQuestion()); - - String editableQuestionIndex=request.getParameter("editableQuestionIndex"); - logger.debug("editableQuestionIndex: " + editableQuestionIndex); - + String question = qaQuestionContentDTO.getQuestion(); + String displayOrder = qaQuestionContentDTO.getDisplayOrder(); + QaAction.logger.debug("displayOrder:" + displayOrder); - if ((newQuestion != null) && (newQuestion.length() > 0)) - { - if ((editQuestionBoxRequest != null) && (editQuestionBoxRequest.equals("false"))) - { - logger.debug("request for add and save"); - boolean duplicates=AuthoringUtil.checkDuplicateQuestions(listQuestionContentDTO, newQuestion); - logger.debug("duplicates: " + duplicates); - - if (!duplicates) - { - QaQuestionContentDTO qaQuestionContentDTO= null; - Iterator listIterator=listQuestionContentDTO.iterator(); - while (listIterator.hasNext()) - { - qaQuestionContentDTO= (QaQuestionContentDTO)listIterator.next(); - logger.debug("qaQuestionContentDTO:" + qaQuestionContentDTO); - logger.debug("qaQuestionContentDTO question:" + qaQuestionContentDTO.getQuestion()); - - String question=qaQuestionContentDTO.getQuestion(); - String displayOrder=qaQuestionContentDTO.getDisplayOrder(); - logger.debug("displayOrder:" + displayOrder); - - if ((displayOrder != null) && (!displayOrder.equals(""))) - { - if (displayOrder.equals(editableQuestionIndex)) - { - break; - } - - } - } - logger.debug("qaQuestionContentDTO found:" + qaQuestionContentDTO); - - qaQuestionContentDTO.setQuestion(newQuestion); - qaQuestionContentDTO.setFeedback(feedback); - qaQuestionContentDTO.setDisplayOrder(editableQuestionIndex); - - listQuestionContentDTO=AuthoringUtil.reorderUpdateListQuestionContentDTO(listQuestionContentDTO, qaQuestionContentDTO, editableQuestionIndex); - logger.debug("post reorderUpdateListQuestionContentDTO listQuestionContentDTO: " + listQuestionContentDTO); - } - else - { - logger.debug("duplicate question entry, not adding"); - } - } - else - { - logger.debug("request for edit and save."); - QaQuestionContentDTO qaQuestionContentDTO= null; - Iterator listIterator=listQuestionContentDTO.iterator(); - while (listIterator.hasNext()) - { - qaQuestionContentDTO= (QaQuestionContentDTO)listIterator.next(); - logger.debug("qaQuestionContentDTO:" + qaQuestionContentDTO); - logger.debug("qaQuestionContentDTO question:" + qaQuestionContentDTO.getQuestion()); - - String question=qaQuestionContentDTO.getQuestion(); - String displayOrder=qaQuestionContentDTO.getDisplayOrder(); - logger.debug("displayOrder:" + displayOrder); - - if ((displayOrder != null) && (!displayOrder.equals(""))) - { - if (displayOrder.equals(editableQuestionIndex)) - { - break; - } - - } - } - logger.debug("qaQuestionContentDTO found:" + qaQuestionContentDTO); - - qaQuestionContentDTO.setQuestion(newQuestion); - qaQuestionContentDTO.setFeedback(feedback); - qaQuestionContentDTO.setDisplayOrder(editableQuestionIndex); - - listQuestionContentDTO=AuthoringUtil.reorderUpdateListQuestionContentDTO(listQuestionContentDTO, qaQuestionContentDTO, editableQuestionIndex); - logger.debug("post reorderUpdateListQuestionContentDTO listQuestionContentDTO: " + listQuestionContentDTO); - } - } - else - { - logger.debug("entry blank, not adding"); - } - - - + if (displayOrder != null && !displayOrder.equals("")) { + if (displayOrder.equals(editableQuestionIndex)) { + break; + } - request.setAttribute(LIST_QUESTION_CONTENT_DTO,listQuestionContentDTO); - sessionMap.put(LIST_QUESTION_CONTENT_DTO_KEY, listQuestionContentDTO); - logger.debug("listQuestionContentDTO now: " + listQuestionContentDTO); - - - String richTextTitle = request.getParameter(TITLE); - String richTextInstructions = request.getParameter(INSTRUCTIONS); - - logger.debug("richTextTitle: " + richTextTitle); - logger.debug("richTextInstructions: " + richTextInstructions); - qaGeneralAuthoringDTO.setActivityTitle(richTextTitle); - qaAuthoringForm.setTitle(richTextTitle); - - qaGeneralAuthoringDTO.setActivityInstructions(richTextInstructions); - - sessionMap.put(ACTIVITY_TITLE_KEY, richTextTitle); - sessionMap.put(ACTIVITY_INSTRUCTIONS_KEY, richTextInstructions); - - - logger.debug("activeModule: " + activeModule); - if (activeModule.equals(AUTHORING)) - { - String onlineInstructions=(String)sessionMap.get(ONLINE_INSTRUCTIONS_KEY); - logger.debug("onlineInstructions: " + onlineInstructions); - qaGeneralAuthoringDTO.setOnlineInstructions(onlineInstructions); - - String offlineInstructions=(String)sessionMap.get(OFFLINE_INSTRUCTIONS_KEY); - logger.debug("offlineInstructions: " + offlineInstructions); - qaGeneralAuthoringDTO.setOfflineInstructions(offlineInstructions); - - List attachmentList=(List)sessionMap.get(ATTACHMENT_LIST_KEY); - logger.debug("attachmentList: " + attachmentList); - - List deletedAttachmentList=(List)sessionMap.get(DELETED_ATTACHMENT_LIST_KEY); - logger.debug("deletedAttachmentList: " + deletedAttachmentList); - - qaGeneralAuthoringDTO.setAttachmentList(attachmentList); - qaGeneralAuthoringDTO.setDeletedAttachmentList(deletedAttachmentList); - - String strOnlineInstructions= request.getParameter("onlineInstructions"); - String strOfflineInstructions= request.getParameter("offlineInstructions"); - logger.debug("onlineInstructions: " + strOnlineInstructions); - logger.debug("offlineInstructions: " + strOfflineInstructions); - qaAuthoringForm.setOnlineInstructions(strOnlineInstructions); - qaAuthoringForm.setOfflineInstructions(strOfflineInstructions); + } + } + QaAction.logger.debug("qaQuestionContentDTO found:" + qaQuestionContentDTO); + qaQuestionContentDTO.setQuestion(newQuestion); + qaQuestionContentDTO.setFeedback(feedback); + qaQuestionContentDTO.setDisplayOrder(editableQuestionIndex); + + listQuestionContentDTO = AuthoringUtil.reorderUpdateListQuestionContentDTO(listQuestionContentDTO, + qaQuestionContentDTO, editableQuestionIndex); + QaAction.logger.debug("post reorderUpdateListQuestionContentDTO listQuestionContentDTO: " + + listQuestionContentDTO); } - - - qaGeneralAuthoringDTO.setEditActivityEditMode(new Boolean(true).toString()); - - request.getSession().setAttribute(httpSessionID, sessionMap); - sessionMap.put(LIST_QUESTION_CONTENT_DTO_KEY, listQuestionContentDTO); - - QaUtils.setFormProperties(request, qaService, - qaAuthoringForm, qaGeneralAuthoringDTO, strToolContentID, defaultContentIdStr, activeModule, sessionMap, httpSessionID); - - - qaGeneralAuthoringDTO.setToolContentID(strToolContentID); - qaGeneralAuthoringDTO.setHttpSessionID(httpSessionID); - qaGeneralAuthoringDTO.setActiveModule(activeModule); - qaGeneralAuthoringDTO.setDefaultContentIdStr(defaultContentIdStr); - - qaAuthoringForm.setToolContentID(strToolContentID); - qaAuthoringForm.setHttpSessionID(httpSessionID); - qaAuthoringForm.setActiveModule(activeModule); - qaAuthoringForm.setDefaultContentIdStr(defaultContentIdStr); - qaAuthoringForm.setCurrentTab("1"); - - qaGeneralAuthoringDTO.setDefineLaterInEditMode(new Boolean(true).toString()); - - logger.debug("qaGeneralAuthoringDTO now: " + qaGeneralAuthoringDTO); - request.setAttribute(QA_GENERAL_AUTHORING_DTO, qaGeneralAuthoringDTO); - - logger.debug("httpSessionID: " + httpSessionID); - logger.debug("sessionMap: " + sessionMap); - - request.getSession().setAttribute(httpSessionID, sessionMap); - logger.debug("qaGeneralAuthoringDTO.getMapQuestionContent(); " + qaGeneralAuthoringDTO.getMapQuestionContent()); - - request.setAttribute(TOTAL_QUESTION_COUNT, new Integer(listQuestionContentDTO.size())); - - - logger.debug("fwd ing to LOAD_QUESTIONS: " + LOAD_QUESTIONS); - return (mapping.findForward(LOAD_QUESTIONS)); + } else { + QaAction.logger.debug("entry blank, not adding"); } - - + request.setAttribute(QaAppConstants.LIST_QUESTION_CONTENT_DTO, listQuestionContentDTO); + sessionMap.put(QaAppConstants.LIST_QUESTION_CONTENT_DTO_KEY, listQuestionContentDTO); + QaAction.logger.debug("listQuestionContentDTO now: " + listQuestionContentDTO); + + String richTextTitle = request.getParameter(QaAppConstants.TITLE); + String richTextInstructions = request.getParameter(QaAppConstants.INSTRUCTIONS); + + QaAction.logger.debug("richTextTitle: " + richTextTitle); + QaAction.logger.debug("richTextInstructions: " + richTextInstructions); + qaGeneralAuthoringDTO.setActivityTitle(richTextTitle); + qaAuthoringForm.setTitle(richTextTitle); + + qaGeneralAuthoringDTO.setActivityInstructions(richTextInstructions); + + sessionMap.put(QaAppConstants.ACTIVITY_TITLE_KEY, richTextTitle); + sessionMap.put(QaAppConstants.ACTIVITY_INSTRUCTIONS_KEY, richTextInstructions); + + QaAction.logger.debug("activeModule: " + activeModule); + if (activeModule.equals(QaAppConstants.AUTHORING)) { + String onlineInstructions = (String) sessionMap.get(QaAppConstants.ONLINE_INSTRUCTIONS_KEY); + QaAction.logger.debug("onlineInstructions: " + onlineInstructions); + qaGeneralAuthoringDTO.setOnlineInstructions(onlineInstructions); + + String offlineInstructions = (String) sessionMap.get(QaAppConstants.OFFLINE_INSTRUCTIONS_KEY); + QaAction.logger.debug("offlineInstructions: " + offlineInstructions); + qaGeneralAuthoringDTO.setOfflineInstructions(offlineInstructions); + + List attachmentList = (List) sessionMap.get(QaAppConstants.ATTACHMENT_LIST_KEY); + QaAction.logger.debug("attachmentList: " + attachmentList); + + List deletedAttachmentList = (List) sessionMap.get(QaAppConstants.DELETED_ATTACHMENT_LIST_KEY); + QaAction.logger.debug("deletedAttachmentList: " + deletedAttachmentList); + + qaGeneralAuthoringDTO.setAttachmentList(attachmentList); + qaGeneralAuthoringDTO.setDeletedAttachmentList(deletedAttachmentList); + + String strOnlineInstructions = request.getParameter("onlineInstructions"); + String strOfflineInstructions = request.getParameter("offlineInstructions"); + QaAction.logger.debug("onlineInstructions: " + strOnlineInstructions); + QaAction.logger.debug("offlineInstructions: " + strOfflineInstructions); + qaAuthoringForm.setOnlineInstructions(strOnlineInstructions); + qaAuthoringForm.setOfflineInstructions(strOfflineInstructions); + + } + + qaGeneralAuthoringDTO.setEditActivityEditMode(new Boolean(true).toString()); + + request.getSession().setAttribute(httpSessionID, sessionMap); + sessionMap.put(QaAppConstants.LIST_QUESTION_CONTENT_DTO_KEY, listQuestionContentDTO); + + QaUtils.setFormProperties(request, qaService, qaAuthoringForm, qaGeneralAuthoringDTO, strToolContentID, + defaultContentIdStr, activeModule, sessionMap, httpSessionID); + + qaGeneralAuthoringDTO.setToolContentID(strToolContentID); + qaGeneralAuthoringDTO.setHttpSessionID(httpSessionID); + qaGeneralAuthoringDTO.setActiveModule(activeModule); + qaGeneralAuthoringDTO.setDefaultContentIdStr(defaultContentIdStr); + + qaAuthoringForm.setToolContentID(strToolContentID); + qaAuthoringForm.setHttpSessionID(httpSessionID); + qaAuthoringForm.setActiveModule(activeModule); + qaAuthoringForm.setDefaultContentIdStr(defaultContentIdStr); + qaAuthoringForm.setCurrentTab("1"); + + qaGeneralAuthoringDTO.setDefineLaterInEditMode(new Boolean(true).toString()); + + QaAction.logger.debug("qaGeneralAuthoringDTO now: " + qaGeneralAuthoringDTO); + request.setAttribute(QaAppConstants.QA_GENERAL_AUTHORING_DTO, qaGeneralAuthoringDTO); + + QaAction.logger.debug("httpSessionID: " + httpSessionID); + QaAction.logger.debug("sessionMap: " + sessionMap); + + request.getSession().setAttribute(httpSessionID, sessionMap); + QaAction.logger.debug("qaGeneralAuthoringDTO.getMapQuestionContent(); " + + qaGeneralAuthoringDTO.getMapQuestionContent()); + + request.setAttribute(QaAppConstants.TOTAL_QUESTION_COUNT, new Integer(listQuestionContentDTO.size())); + + QaAction.logger.debug("fwd ing to LOAD_QUESTIONS: " + QaAppConstants.LOAD_QUESTIONS); + return mapping.findForward(QaAppConstants.LOAD_QUESTIONS); + } + /** * addSingleQuestion + * * @param mapping * @param form * @param request @@ -684,193 +658,173 @@ * @throws IOException * @throws ServletException */ - public ActionForward addSingleQuestion(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) - throws IOException, ServletException { - - logger.debug("dispathcing addSingleQuestion"); - QaAuthoringForm qaAuthoringForm = (QaAuthoringForm) form; - - IQaService qaService =QaServiceProxy.getQaService(getServlet().getServletContext()); - logger.debug("qaService: " + qaService); - - String httpSessionID=qaAuthoringForm.getHttpSessionID(); - logger.debug("httpSessionID: " + httpSessionID); - - SessionMap sessionMap=(SessionMap)request.getSession().getAttribute(httpSessionID); - logger.debug("sessionMap: " + sessionMap); - - String contentFolderID = WebUtil.readStrParam(request, AttributeNames.PARAM_CONTENT_FOLDER_ID); - logger.debug("contentFolderID: " + contentFolderID); - qaAuthoringForm.setContentFolderID(contentFolderID); - - - String activeModule=request.getParameter(ACTIVE_MODULE); - logger.debug("activeModule: " + activeModule); - - String strToolContentID=request.getParameter(AttributeNames.PARAM_TOOL_CONTENT_ID); - logger.debug("strToolContentID: " + strToolContentID); - - String defaultContentIdStr=request.getParameter(DEFAULT_CONTENT_ID_STR); - logger.debug("defaultContentIdStr: " + defaultContentIdStr); - - QaContent qaContent=qaService.loadQa(new Long(strToolContentID).longValue()); - logger.debug("qaContent: " + qaContent); + public ActionForward addSingleQuestion(ActionMapping mapping, ActionForm form, HttpServletRequest request, + HttpServletResponse response) throws IOException, ServletException { + + QaAction.logger.debug("dispathcing addSingleQuestion"); + QaAuthoringForm qaAuthoringForm = (QaAuthoringForm) form; + + IQaService qaService = QaServiceProxy.getQaService(getServlet().getServletContext()); + QaAction.logger.debug("qaService: " + qaService); + + String httpSessionID = qaAuthoringForm.getHttpSessionID(); + QaAction.logger.debug("httpSessionID: " + httpSessionID); + + SessionMap sessionMap = (SessionMap) request.getSession().getAttribute(httpSessionID); + QaAction.logger.debug("sessionMap: " + sessionMap); + + String contentFolderID = WebUtil.readStrParam(request, AttributeNames.PARAM_CONTENT_FOLDER_ID); + QaAction.logger.debug("contentFolderID: " + contentFolderID); + qaAuthoringForm.setContentFolderID(contentFolderID); + + String activeModule = request.getParameter(QaAppConstants.ACTIVE_MODULE); + QaAction.logger.debug("activeModule: " + activeModule); + + String strToolContentID = request.getParameter(AttributeNames.PARAM_TOOL_CONTENT_ID); + QaAction.logger.debug("strToolContentID: " + strToolContentID); + + String defaultContentIdStr = request.getParameter(QaAppConstants.DEFAULT_CONTENT_ID_STR); + QaAction.logger.debug("defaultContentIdStr: " + defaultContentIdStr); + + QaContent qaContent = qaService.loadQa(new Long(strToolContentID).longValue()); + QaAction.logger.debug("qaContent: " + qaContent); + /* + * if (qaContent == null) { logger.debug("using defaultContentIdStr: " + defaultContentIdStr); + * qaContent=qaService.loadQa(new Long(defaultContentIdStr).longValue()); } logger.debug("final qaContent: " + + * qaContent); + */ + + QaGeneralAuthoringDTO qaGeneralAuthoringDTO = new QaGeneralAuthoringDTO(); + QaAction.logger.debug("qaGeneralAuthoringDTO: " + qaGeneralAuthoringDTO); + qaGeneralAuthoringDTO.setContentFolderID(contentFolderID); + + qaGeneralAuthoringDTO.setSbmtSuccess(new Integer(0).toString()); + + AuthoringUtil authoringUtil = new AuthoringUtil(); + + List listQuestionContentDTO = (List) sessionMap.get(QaAppConstants.LIST_QUESTION_CONTENT_DTO_KEY); + QaAction.logger.debug("listQuestionContentDTO: " + listQuestionContentDTO); + + String newQuestion = request.getParameter("newQuestion"); + QaAction.logger.debug("newQuestion: " + newQuestion); + + String feedback = request.getParameter("feedback"); + QaAction.logger.debug("feedback: " + feedback); + + int listSize = listQuestionContentDTO.size(); + QaAction.logger.debug("listSize: " + listSize); + + if (newQuestion != null && newQuestion.length() > 0) { + boolean duplicates = AuthoringUtil.checkDuplicateQuestions(listQuestionContentDTO, newQuestion); + QaAction.logger.debug("duplicates: " + duplicates); + + if (!duplicates) { + QaQuestionContentDTO qaQuestionContentDTO = new QaQuestionContentDTO(); + qaQuestionContentDTO.setDisplayOrder(new Long(listSize + 1).toString()); + qaQuestionContentDTO.setFeedback(feedback); + qaQuestionContentDTO.setQuestion(newQuestion); + + listQuestionContentDTO.add(qaQuestionContentDTO); + QaAction.logger.debug("updated listQuestionContentDTO: " + listQuestionContentDTO); + } else { + QaAction.logger.debug("entry duplicate, not adding"); /* - if (qaContent == null) - { - logger.debug("using defaultContentIdStr: " + defaultContentIdStr); - qaContent=qaService.loadQa(new Long(defaultContentIdStr).longValue()); - } - logger.debug("final qaContent: " + qaContent); - */ - - QaGeneralAuthoringDTO qaGeneralAuthoringDTO= new QaGeneralAuthoringDTO(); - logger.debug("qaGeneralAuthoringDTO: " + qaGeneralAuthoringDTO); - qaGeneralAuthoringDTO.setContentFolderID(contentFolderID); - - qaGeneralAuthoringDTO.setSbmtSuccess(new Integer(0).toString()); - - AuthoringUtil authoringUtil= new AuthoringUtil(); - - List listQuestionContentDTO=(List)sessionMap.get(LIST_QUESTION_CONTENT_DTO_KEY); - logger.debug("listQuestionContentDTO: " + listQuestionContentDTO); - - String newQuestion=request.getParameter("newQuestion"); - logger.debug("newQuestion: " + newQuestion); - - String feedback=request.getParameter("feedback"); - logger.debug("feedback: " + feedback); - - - int listSize=listQuestionContentDTO.size(); - logger.debug("listSize: " + listSize); - - if ((newQuestion != null) && (newQuestion.length() > 0)) - { - boolean duplicates=AuthoringUtil.checkDuplicateQuestions(listQuestionContentDTO, newQuestion); - logger.debug("duplicates: " + duplicates); - - if (!duplicates) - { - QaQuestionContentDTO qaQuestionContentDTO=new QaQuestionContentDTO(); - qaQuestionContentDTO.setDisplayOrder(new Long(listSize+1).toString()); - qaQuestionContentDTO.setFeedback(feedback); - qaQuestionContentDTO.setQuestion(newQuestion); - - listQuestionContentDTO.add(qaQuestionContentDTO); - logger.debug("updated listQuestionContentDTO: " + listQuestionContentDTO); - } - else - { - logger.debug("entry duplicate, not adding"); - /* - ActionMessages errors = new ActionMessages(); - ActionMessage error = new ActionMessage("question.duplicate"); - errors.add(ActionMessages.GLOBAL_MESSAGE, error); - saveErrors(request, errors); - logger.debug("errors saved: " + errors); - */ - } + * ActionMessages errors = new ActionMessages(); ActionMessage error = new + * ActionMessage("question.duplicate"); errors.add(ActionMessages.GLOBAL_MESSAGE, error); + * saveErrors(request, errors); logger.debug("errors saved: " + errors); + */ } - else - { - logger.debug("entry blank, not adding"); - /* - ActionMessages errors = new ActionMessages(); - ActionMessage error = new ActionMessage("question.blank"); - errors.add(ActionMessages.GLOBAL_MESSAGE, error); - saveErrors(request, errors); - logger.debug("errors saved: " + errors); - */ - } - - - request.setAttribute(LIST_QUESTION_CONTENT_DTO,listQuestionContentDTO); - sessionMap.put(LIST_QUESTION_CONTENT_DTO_KEY, listQuestionContentDTO); + } else { + QaAction.logger.debug("entry blank, not adding"); + /* + * ActionMessages errors = new ActionMessages(); ActionMessage error = new ActionMessage("question.blank"); + * errors.add(ActionMessages.GLOBAL_MESSAGE, error); saveErrors(request, errors); logger.debug("errors + * saved: " + errors); + */ + } - - String richTextTitle = request.getParameter(TITLE); - String richTextInstructions = request.getParameter(INSTRUCTIONS); - - logger.debug("richTextTitle: " + richTextTitle); - logger.debug("richTextInstructions: " + richTextInstructions); - qaGeneralAuthoringDTO.setActivityTitle(richTextTitle); - qaAuthoringForm.setTitle(richTextTitle); - - qaGeneralAuthoringDTO.setActivityInstructions(richTextInstructions); - - sessionMap.put(ACTIVITY_TITLE_KEY, richTextTitle); - sessionMap.put(ACTIVITY_INSTRUCTIONS_KEY, richTextInstructions); - - logger.debug("activeModule: " + activeModule); - if (activeModule.equals(AUTHORING)) - { - String onlineInstructions=(String)sessionMap.get(ONLINE_INSTRUCTIONS_KEY); - logger.debug("onlineInstructions: " + onlineInstructions); - qaGeneralAuthoringDTO.setOnlineInstructions(onlineInstructions); - - String offlineInstructions=(String)sessionMap.get(OFFLINE_INSTRUCTIONS_KEY); - logger.debug("offlineInstructions: " + offlineInstructions); - qaGeneralAuthoringDTO.setOfflineInstructions(offlineInstructions); - - List attachmentList=(List)sessionMap.get(ATTACHMENT_LIST_KEY); - logger.debug("attachmentList: " + attachmentList); - - List deletedAttachmentList=(List)sessionMap.get(DELETED_ATTACHMENT_LIST_KEY); - logger.debug("deletedAttachmentList: " + deletedAttachmentList); - - qaGeneralAuthoringDTO.setAttachmentList(attachmentList); - qaGeneralAuthoringDTO.setDeletedAttachmentList(deletedAttachmentList); - - String strOnlineInstructions= request.getParameter("onlineInstructions"); - String strOfflineInstructions= request.getParameter("offlineInstructions"); - logger.debug("onlineInstructions: " + strOnlineInstructions); - logger.debug("offlineInstructions: " + strOfflineInstructions); - qaAuthoringForm.setOnlineInstructions(strOnlineInstructions); - qaAuthoringForm.setOfflineInstructions(strOfflineInstructions); - } + request.setAttribute(QaAppConstants.LIST_QUESTION_CONTENT_DTO, listQuestionContentDTO); + sessionMap.put(QaAppConstants.LIST_QUESTION_CONTENT_DTO_KEY, listQuestionContentDTO); - - qaGeneralAuthoringDTO.setEditActivityEditMode(new Boolean(true).toString()); - request.getSession().setAttribute(httpSessionID, sessionMap); - - QaUtils.setFormProperties(request, qaService, - qaAuthoringForm, qaGeneralAuthoringDTO, strToolContentID, defaultContentIdStr, activeModule, sessionMap, httpSessionID); - - - qaGeneralAuthoringDTO.setToolContentID(strToolContentID); - qaGeneralAuthoringDTO.setHttpSessionID(httpSessionID); - qaGeneralAuthoringDTO.setActiveModule(activeModule); - qaGeneralAuthoringDTO.setDefaultContentIdStr(defaultContentIdStr); - - qaAuthoringForm.setToolContentID(strToolContentID); - qaAuthoringForm.setHttpSessionID(httpSessionID); - qaAuthoringForm.setActiveModule(activeModule); - qaAuthoringForm.setDefaultContentIdStr(defaultContentIdStr); - qaAuthoringForm.setCurrentTab("1"); - - qaGeneralAuthoringDTO.setDefineLaterInEditMode(new Boolean(true).toString()); - - logger.debug("qaGeneralAuthoringDTO now: " + qaGeneralAuthoringDTO); - request.setAttribute(QA_GENERAL_AUTHORING_DTO, qaGeneralAuthoringDTO); - - logger.debug("httpSessionID: " + httpSessionID); - logger.debug("sessionMap: " + sessionMap); - - request.getSession().setAttribute(httpSessionID, sessionMap); + String richTextTitle = request.getParameter(QaAppConstants.TITLE); + String richTextInstructions = request.getParameter(QaAppConstants.INSTRUCTIONS); - logger.debug("qaGeneralAuthoringDTO.getMapQuestionContent(); " + qaGeneralAuthoringDTO.getMapQuestionContent()); - - request.setAttribute(TOTAL_QUESTION_COUNT, new Integer(listQuestionContentDTO.size())); - + QaAction.logger.debug("richTextTitle: " + richTextTitle); + QaAction.logger.debug("richTextInstructions: " + richTextInstructions); + qaGeneralAuthoringDTO.setActivityTitle(richTextTitle); + qaAuthoringForm.setTitle(richTextTitle); - logger.debug("fwd ing to LOAD_QUESTIONS: " + LOAD_QUESTIONS); - return (mapping.findForward(LOAD_QUESTIONS)); + qaGeneralAuthoringDTO.setActivityInstructions(richTextInstructions); + + sessionMap.put(QaAppConstants.ACTIVITY_TITLE_KEY, richTextTitle); + sessionMap.put(QaAppConstants.ACTIVITY_INSTRUCTIONS_KEY, richTextInstructions); + + QaAction.logger.debug("activeModule: " + activeModule); + if (activeModule.equals(QaAppConstants.AUTHORING)) { + String onlineInstructions = (String) sessionMap.get(QaAppConstants.ONLINE_INSTRUCTIONS_KEY); + QaAction.logger.debug("onlineInstructions: " + onlineInstructions); + qaGeneralAuthoringDTO.setOnlineInstructions(onlineInstructions); + + String offlineInstructions = (String) sessionMap.get(QaAppConstants.OFFLINE_INSTRUCTIONS_KEY); + QaAction.logger.debug("offlineInstructions: " + offlineInstructions); + qaGeneralAuthoringDTO.setOfflineInstructions(offlineInstructions); + + List attachmentList = (List) sessionMap.get(QaAppConstants.ATTACHMENT_LIST_KEY); + QaAction.logger.debug("attachmentList: " + attachmentList); + + List deletedAttachmentList = (List) sessionMap.get(QaAppConstants.DELETED_ATTACHMENT_LIST_KEY); + QaAction.logger.debug("deletedAttachmentList: " + deletedAttachmentList); + + qaGeneralAuthoringDTO.setAttachmentList(attachmentList); + qaGeneralAuthoringDTO.setDeletedAttachmentList(deletedAttachmentList); + + String strOnlineInstructions = request.getParameter("onlineInstructions"); + String strOfflineInstructions = request.getParameter("offlineInstructions"); + QaAction.logger.debug("onlineInstructions: " + strOnlineInstructions); + QaAction.logger.debug("offlineInstructions: " + strOfflineInstructions); + qaAuthoringForm.setOnlineInstructions(strOnlineInstructions); + qaAuthoringForm.setOfflineInstructions(strOfflineInstructions); } - + + qaGeneralAuthoringDTO.setEditActivityEditMode(new Boolean(true).toString()); + request.getSession().setAttribute(httpSessionID, sessionMap); + + QaUtils.setFormProperties(request, qaService, qaAuthoringForm, qaGeneralAuthoringDTO, strToolContentID, + defaultContentIdStr, activeModule, sessionMap, httpSessionID); + + qaGeneralAuthoringDTO.setToolContentID(strToolContentID); + qaGeneralAuthoringDTO.setHttpSessionID(httpSessionID); + qaGeneralAuthoringDTO.setActiveModule(activeModule); + qaGeneralAuthoringDTO.setDefaultContentIdStr(defaultContentIdStr); + + qaAuthoringForm.setToolContentID(strToolContentID); + qaAuthoringForm.setHttpSessionID(httpSessionID); + qaAuthoringForm.setActiveModule(activeModule); + qaAuthoringForm.setDefaultContentIdStr(defaultContentIdStr); + qaAuthoringForm.setCurrentTab("1"); + + qaGeneralAuthoringDTO.setDefineLaterInEditMode(new Boolean(true).toString()); + + QaAction.logger.debug("qaGeneralAuthoringDTO now: " + qaGeneralAuthoringDTO); + request.setAttribute(QaAppConstants.QA_GENERAL_AUTHORING_DTO, qaGeneralAuthoringDTO); + + QaAction.logger.debug("httpSessionID: " + httpSessionID); + QaAction.logger.debug("sessionMap: " + sessionMap); + + request.getSession().setAttribute(httpSessionID, sessionMap); + + QaAction.logger.debug("qaGeneralAuthoringDTO.getMapQuestionContent(); " + + qaGeneralAuthoringDTO.getMapQuestionContent()); + + request.setAttribute(QaAppConstants.TOTAL_QUESTION_COUNT, new Integer(listQuestionContentDTO.size())); + + QaAction.logger.debug("fwd ing to LOAD_QUESTIONS: " + QaAppConstants.LOAD_QUESTIONS); + return mapping.findForward(QaAppConstants.LOAD_QUESTIONS); + } + /** - * opens up an new screen within the current page for adding a new question - * newQuestionBox + * opens up an new screen within the current page for adding a new question newQuestionBox + * * @param mapping * @param form * @param request @@ -879,97 +833,86 @@ * @throws IOException * @throws ServletException */ - public ActionForward newQuestionBox(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) - throws IOException, ServletException - { - logger.debug("dispathcing newQuestionBox"); - QaAuthoringForm qaAuthoringForm = (QaAuthoringForm) form; - - IQaService qaService =QaServiceProxy.getQaService(getServlet().getServletContext()); - logger.debug("qaService: " + qaService); - - String httpSessionID=qaAuthoringForm.getHttpSessionID(); - logger.debug("httpSessionID: " + httpSessionID); - - SessionMap sessionMap=(SessionMap)request.getSession().getAttribute(httpSessionID); - logger.debug("sessionMap: " + sessionMap); - - String contentFolderID = WebUtil.readStrParam(request, AttributeNames.PARAM_CONTENT_FOLDER_ID); - logger.debug("contentFolderID: " + contentFolderID); - qaAuthoringForm.setContentFolderID(contentFolderID); + public ActionForward newQuestionBox(ActionMapping mapping, ActionForm form, HttpServletRequest request, + HttpServletResponse response) throws IOException, ServletException { + QaAction.logger.debug("dispathcing newQuestionBox"); + QaAuthoringForm qaAuthoringForm = (QaAuthoringForm) form; + IQaService qaService = QaServiceProxy.getQaService(getServlet().getServletContext()); + QaAction.logger.debug("qaService: " + qaService); - String activeModule=request.getParameter(ACTIVE_MODULE); - logger.debug("activeModule: " + activeModule); + String httpSessionID = qaAuthoringForm.getHttpSessionID(); + QaAction.logger.debug("httpSessionID: " + httpSessionID); - String strToolContentID=request.getParameter(AttributeNames.PARAM_TOOL_CONTENT_ID); - logger.debug("strToolContentID: " + strToolContentID); - - String defaultContentIdStr=request.getParameter(DEFAULT_CONTENT_ID_STR); - logger.debug("defaultContentIdStr: " + defaultContentIdStr); - - QaContent qaContent=qaService.loadQa(new Long(strToolContentID).longValue()); - logger.debug("qaContent: " + qaContent); - - /* - if (qaContent == null) - { - logger.debug("using defaultContentIdStr: " + defaultContentIdStr); - qaContent=qaService.loadQa(new Long(defaultContentIdStr).longValue()); - } - logger.debug("final qaContent: " + qaContent); - */ - - QaGeneralAuthoringDTO qaGeneralAuthoringDTO= new QaGeneralAuthoringDTO(); - logger.debug("qaGeneralAuthoringDTO: " + qaGeneralAuthoringDTO); - qaGeneralAuthoringDTO.setContentFolderID(contentFolderID); + SessionMap sessionMap = (SessionMap) request.getSession().getAttribute(httpSessionID); + QaAction.logger.debug("sessionMap: " + sessionMap); - String richTextTitle = request.getParameter(TITLE); - String richTextInstructions = request.getParameter(INSTRUCTIONS); - - logger.debug("richTextTitle: " + richTextTitle); - logger.debug("richTextInstructions: " + richTextInstructions); - qaGeneralAuthoringDTO.setActivityTitle(richTextTitle); - qaAuthoringForm.setTitle(richTextTitle); - - qaGeneralAuthoringDTO.setActivityInstructions(richTextInstructions); - - - QaUtils.setFormProperties(request, qaService, - qaAuthoringForm, qaGeneralAuthoringDTO, strToolContentID, defaultContentIdStr, activeModule, sessionMap, httpSessionID); + String contentFolderID = WebUtil.readStrParam(request, AttributeNames.PARAM_CONTENT_FOLDER_ID); + QaAction.logger.debug("contentFolderID: " + contentFolderID); + qaAuthoringForm.setContentFolderID(contentFolderID); - - logger.debug("activeModule: " + activeModule); - if (activeModule.equals(AUTHORING)) - { - String strOnlineInstructions= request.getParameter("onlineInstructions"); - String strOfflineInstructions= request.getParameter("offlineInstructions"); - logger.debug("onlineInstructions: " + strOnlineInstructions); - logger.debug("offlineInstructions: " + strOnlineInstructions); - qaAuthoringForm.setOnlineInstructions(strOnlineInstructions); - qaAuthoringForm.setOfflineInstructions(strOfflineInstructions); - } + String activeModule = request.getParameter(QaAppConstants.ACTIVE_MODULE); + QaAction.logger.debug("activeModule: " + activeModule); - - qaGeneralAuthoringDTO.setDefineLaterInEditMode(new Boolean(true).toString()); - - logger.debug("qaGeneralAuthoringDTO now: " + qaGeneralAuthoringDTO); - request.setAttribute(QA_GENERAL_AUTHORING_DTO, qaGeneralAuthoringDTO); + String strToolContentID = request.getParameter(AttributeNames.PARAM_TOOL_CONTENT_ID); + QaAction.logger.debug("strToolContentID: " + strToolContentID); - - List listQuestionContentDTO=(List)sessionMap.get(LIST_QUESTION_CONTENT_DTO_KEY); - logger.debug("listQuestionContentDTO: " + listQuestionContentDTO); + String defaultContentIdStr = request.getParameter(QaAppConstants.DEFAULT_CONTENT_ID_STR); + QaAction.logger.debug("defaultContentIdStr: " + defaultContentIdStr); - request.setAttribute(TOTAL_QUESTION_COUNT, new Integer(listQuestionContentDTO.size())); - - logger.debug("fwd ing to newQuestionBox: "); - return (mapping.findForward("newQuestionBox")); - } + QaContent qaContent = qaService.loadQa(new Long(strToolContentID).longValue()); + QaAction.logger.debug("qaContent: " + qaContent); + /* + * if (qaContent == null) { logger.debug("using defaultContentIdStr: " + defaultContentIdStr); + * qaContent=qaService.loadQa(new Long(defaultContentIdStr).longValue()); } logger.debug("final qaContent: " + + * qaContent); + */ + QaGeneralAuthoringDTO qaGeneralAuthoringDTO = new QaGeneralAuthoringDTO(); + QaAction.logger.debug("qaGeneralAuthoringDTO: " + qaGeneralAuthoringDTO); + qaGeneralAuthoringDTO.setContentFolderID(contentFolderID); + + String richTextTitle = request.getParameter(QaAppConstants.TITLE); + String richTextInstructions = request.getParameter(QaAppConstants.INSTRUCTIONS); + + QaAction.logger.debug("richTextTitle: " + richTextTitle); + QaAction.logger.debug("richTextInstructions: " + richTextInstructions); + qaGeneralAuthoringDTO.setActivityTitle(richTextTitle); + qaAuthoringForm.setTitle(richTextTitle); + + qaGeneralAuthoringDTO.setActivityInstructions(richTextInstructions); + + QaUtils.setFormProperties(request, qaService, qaAuthoringForm, qaGeneralAuthoringDTO, strToolContentID, + defaultContentIdStr, activeModule, sessionMap, httpSessionID); + + QaAction.logger.debug("activeModule: " + activeModule); + if (activeModule.equals(QaAppConstants.AUTHORING)) { + String strOnlineInstructions = request.getParameter("onlineInstructions"); + String strOfflineInstructions = request.getParameter("offlineInstructions"); + QaAction.logger.debug("onlineInstructions: " + strOnlineInstructions); + QaAction.logger.debug("offlineInstructions: " + strOnlineInstructions); + qaAuthoringForm.setOnlineInstructions(strOnlineInstructions); + qaAuthoringForm.setOfflineInstructions(strOfflineInstructions); + } + + qaGeneralAuthoringDTO.setDefineLaterInEditMode(new Boolean(true).toString()); + + QaAction.logger.debug("qaGeneralAuthoringDTO now: " + qaGeneralAuthoringDTO); + request.setAttribute(QaAppConstants.QA_GENERAL_AUTHORING_DTO, qaGeneralAuthoringDTO); + + List listQuestionContentDTO = (List) sessionMap.get(QaAppConstants.LIST_QUESTION_CONTENT_DTO_KEY); + QaAction.logger.debug("listQuestionContentDTO: " + listQuestionContentDTO); + + request.setAttribute(QaAppConstants.TOTAL_QUESTION_COUNT, new Integer(listQuestionContentDTO.size())); + + QaAction.logger.debug("fwd ing to newQuestionBox: "); + return mapping.findForward("newQuestionBox"); + } + /** - * opens up an new screen within the current page for editing a question - * newEditableQuestionBox + * opens up an new screen within the current page for editing a question newEditableQuestionBox + * * @param mapping * @param form * @param request @@ -978,125 +921,112 @@ * @throws IOException * @throws ServletException */ - public ActionForward newEditableQuestionBox(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) - throws IOException, ServletException - { - logger.debug("dispathcing newEditableQuestionBox"); - QaAuthoringForm qaAuthoringForm = (QaAuthoringForm) form; - - IQaService qaService =QaServiceProxy.getQaService(getServlet().getServletContext()); - logger.debug("qaService: " + qaService); - - String httpSessionID=qaAuthoringForm.getHttpSessionID(); - logger.debug("httpSessionID: " + httpSessionID); - - SessionMap sessionMap=(SessionMap)request.getSession().getAttribute(httpSessionID); - logger.debug("sessionMap: " + sessionMap); + public ActionForward newEditableQuestionBox(ActionMapping mapping, ActionForm form, HttpServletRequest request, + HttpServletResponse response) throws IOException, ServletException { + QaAction.logger.debug("dispathcing newEditableQuestionBox"); + QaAuthoringForm qaAuthoringForm = (QaAuthoringForm) form; - - String questionIndex=request.getParameter("questionIndex"); - logger.debug("questionIndex: " + questionIndex); - - qaAuthoringForm.setEditableQuestionIndex(questionIndex); - - List listQuestionContentDTO=(List)sessionMap.get(LIST_QUESTION_CONTENT_DTO_KEY); - logger.debug("listQuestionContentDTO: " + listQuestionContentDTO); + IQaService qaService = QaServiceProxy.getQaService(getServlet().getServletContext()); + QaAction.logger.debug("qaService: " + qaService); - String editableQuestion=""; - String editableFeedback=""; - Iterator listIterator=listQuestionContentDTO.iterator(); - while (listIterator.hasNext()) - { - QaQuestionContentDTO qaQuestionContentDTO= (QaQuestionContentDTO)listIterator.next(); - logger.debug("qaQuestionContentDTO:" + qaQuestionContentDTO); - logger.debug("qaQuestionContentDTO question:" + qaQuestionContentDTO.getQuestion()); - String question=qaQuestionContentDTO.getQuestion(); - String displayOrder=qaQuestionContentDTO.getDisplayOrder(); - - if ((displayOrder != null) && (!displayOrder.equals(""))) - { - if (displayOrder.equals(questionIndex)) - { - editableFeedback=qaQuestionContentDTO.getFeedback(); - editableQuestion=qaQuestionContentDTO.getQuestion(); - logger.debug("editableFeedback found :" + editableFeedback); - break; - } - - } - } - logger.debug("editableFeedback found :" + editableFeedback); - logger.debug("editableQuestion found :" + editableQuestion); + String httpSessionID = qaAuthoringForm.getHttpSessionID(); + QaAction.logger.debug("httpSessionID: " + httpSessionID); - - String contentFolderID = WebUtil.readStrParam(request, AttributeNames.PARAM_CONTENT_FOLDER_ID); - logger.debug("contentFolderID: " + contentFolderID); - qaAuthoringForm.setContentFolderID(contentFolderID); + SessionMap sessionMap = (SessionMap) request.getSession().getAttribute(httpSessionID); + QaAction.logger.debug("sessionMap: " + sessionMap); + String questionIndex = request.getParameter("questionIndex"); + QaAction.logger.debug("questionIndex: " + questionIndex); - String activeModule=request.getParameter(ACTIVE_MODULE); - logger.debug("activeModule: " + activeModule); + qaAuthoringForm.setEditableQuestionIndex(questionIndex); - String strToolContentID=request.getParameter(AttributeNames.PARAM_TOOL_CONTENT_ID); - logger.debug("strToolContentID: " + strToolContentID); - - String defaultContentIdStr=request.getParameter(DEFAULT_CONTENT_ID_STR); - logger.debug("defaultContentIdStr: " + defaultContentIdStr); - - QaContent qaContent=qaService.loadQa(new Long(strToolContentID).longValue()); - logger.debug("qaContent: " + qaContent); - + List listQuestionContentDTO = (List) sessionMap.get(QaAppConstants.LIST_QUESTION_CONTENT_DTO_KEY); + QaAction.logger.debug("listQuestionContentDTO: " + listQuestionContentDTO); - QaGeneralAuthoringDTO qaGeneralAuthoringDTO= new QaGeneralAuthoringDTO(); - logger.debug("qaGeneralAuthoringDTO: " + qaGeneralAuthoringDTO); - qaGeneralAuthoringDTO.setContentFolderID(contentFolderID); + String editableQuestion = ""; + String editableFeedback = ""; + Iterator listIterator = listQuestionContentDTO.iterator(); + while (listIterator.hasNext()) { + QaQuestionContentDTO qaQuestionContentDTO = (QaQuestionContentDTO) listIterator.next(); + QaAction.logger.debug("qaQuestionContentDTO:" + qaQuestionContentDTO); + QaAction.logger.debug("qaQuestionContentDTO question:" + qaQuestionContentDTO.getQuestion()); + String question = qaQuestionContentDTO.getQuestion(); + String displayOrder = qaQuestionContentDTO.getDisplayOrder(); - - String richTextTitle = request.getParameter(TITLE); - String richTextInstructions = request.getParameter(INSTRUCTIONS); - - logger.debug("richTextTitle: " + richTextTitle); - logger.debug("richTextInstructions: " + richTextInstructions); - qaGeneralAuthoringDTO.setActivityTitle(richTextTitle); - qaAuthoringForm.setTitle(richTextTitle); - - qaGeneralAuthoringDTO.setActivityInstructions(richTextInstructions); - - QaUtils.setFormProperties(request, qaService, - qaAuthoringForm, qaGeneralAuthoringDTO, strToolContentID, defaultContentIdStr, activeModule, sessionMap, httpSessionID); - - qaGeneralAuthoringDTO.setEditableQuestionText(editableQuestion); - qaGeneralAuthoringDTO.setEditableQuestionFeedback (editableFeedback); - qaAuthoringForm.setFeedback(editableFeedback); + if (displayOrder != null && !displayOrder.equals("")) { + if (displayOrder.equals(questionIndex)) { + editableFeedback = qaQuestionContentDTO.getFeedback(); + editableQuestion = qaQuestionContentDTO.getQuestion(); + QaAction.logger.debug("editableFeedback found :" + editableFeedback); + break; + } - qaGeneralAuthoringDTO.setDefineLaterInEditMode(new Boolean(true).toString()); - - logger.debug("qaGeneralAuthoringDTO now: " + qaGeneralAuthoringDTO); - request.setAttribute(QA_GENERAL_AUTHORING_DTO, qaGeneralAuthoringDTO); - - request.setAttribute(TOTAL_QUESTION_COUNT, new Integer(listQuestionContentDTO.size())); - - logger.debug("activeModule: " + activeModule); - if (activeModule.equals(AUTHORING)) - { - String strOnlineInstructions= request.getParameter("onlineInstructions"); - String strOfflineInstructions= request.getParameter("offlineInstructions"); - logger.debug("onlineInstructions: " + strOnlineInstructions); - logger.debug("offlineInstructions: " + strOnlineInstructions); - qaAuthoringForm.setOnlineInstructions(strOnlineInstructions); - qaAuthoringForm.setOfflineInstructions(strOfflineInstructions); } - - logger.debug("fwd ing to editQuestionBox: "); - return (mapping.findForward("editQuestionBox")); + } + QaAction.logger.debug("editableFeedback found :" + editableFeedback); + QaAction.logger.debug("editableQuestion found :" + editableQuestion); + + String contentFolderID = WebUtil.readStrParam(request, AttributeNames.PARAM_CONTENT_FOLDER_ID); + QaAction.logger.debug("contentFolderID: " + contentFolderID); + qaAuthoringForm.setContentFolderID(contentFolderID); + + String activeModule = request.getParameter(QaAppConstants.ACTIVE_MODULE); + QaAction.logger.debug("activeModule: " + activeModule); + + String strToolContentID = request.getParameter(AttributeNames.PARAM_TOOL_CONTENT_ID); + QaAction.logger.debug("strToolContentID: " + strToolContentID); + + String defaultContentIdStr = request.getParameter(QaAppConstants.DEFAULT_CONTENT_ID_STR); + QaAction.logger.debug("defaultContentIdStr: " + defaultContentIdStr); + + QaContent qaContent = qaService.loadQa(new Long(strToolContentID).longValue()); + QaAction.logger.debug("qaContent: " + qaContent); + + QaGeneralAuthoringDTO qaGeneralAuthoringDTO = new QaGeneralAuthoringDTO(); + QaAction.logger.debug("qaGeneralAuthoringDTO: " + qaGeneralAuthoringDTO); + qaGeneralAuthoringDTO.setContentFolderID(contentFolderID); + + String richTextTitle = request.getParameter(QaAppConstants.TITLE); + String richTextInstructions = request.getParameter(QaAppConstants.INSTRUCTIONS); + + QaAction.logger.debug("richTextTitle: " + richTextTitle); + QaAction.logger.debug("richTextInstructions: " + richTextInstructions); + qaGeneralAuthoringDTO.setActivityTitle(richTextTitle); + qaAuthoringForm.setTitle(richTextTitle); + + qaGeneralAuthoringDTO.setActivityInstructions(richTextInstructions); + + QaUtils.setFormProperties(request, qaService, qaAuthoringForm, qaGeneralAuthoringDTO, strToolContentID, + defaultContentIdStr, activeModule, sessionMap, httpSessionID); + + qaGeneralAuthoringDTO.setEditableQuestionText(editableQuestion); + qaGeneralAuthoringDTO.setEditableQuestionFeedback(editableFeedback); + qaAuthoringForm.setFeedback(editableFeedback); + + qaGeneralAuthoringDTO.setDefineLaterInEditMode(new Boolean(true).toString()); + + QaAction.logger.debug("qaGeneralAuthoringDTO now: " + qaGeneralAuthoringDTO); + request.setAttribute(QaAppConstants.QA_GENERAL_AUTHORING_DTO, qaGeneralAuthoringDTO); + + request.setAttribute(QaAppConstants.TOTAL_QUESTION_COUNT, new Integer(listQuestionContentDTO.size())); + + QaAction.logger.debug("activeModule: " + activeModule); + if (activeModule.equals(QaAppConstants.AUTHORING)) { + String strOnlineInstructions = request.getParameter("onlineInstructions"); + String strOfflineInstructions = request.getParameter("offlineInstructions"); + QaAction.logger.debug("onlineInstructions: " + strOnlineInstructions); + QaAction.logger.debug("offlineInstructions: " + strOnlineInstructions); + qaAuthoringForm.setOnlineInstructions(strOnlineInstructions); + qaAuthoringForm.setOfflineInstructions(strOfflineInstructions); + } + + QaAction.logger.debug("fwd ing to editQuestionBox: "); + return mapping.findForward("editQuestionBox"); } - - /** - * removes a question from the questions map - * ActionForward removeQuestion(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) - throws IOException, ServletException + * removes a question from the questions map ActionForward removeQuestion(ActionMapping mapping, ActionForm form, + * HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException * * @param mapping * @param form @@ -1106,172 +1036,173 @@ * @throws IOException * @throws ServletException */ - public ActionForward removeQuestion(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) - throws IOException, ServletException { - logger.debug("dispatching removeQuestion"); - QaAuthoringForm qaAuthoringForm = (QaAuthoringForm) form; - - IQaService qaService =QaServiceProxy.getQaService(getServlet().getServletContext()); - logger.debug("qaService: " + qaService); + public ActionForward removeQuestion(ActionMapping mapping, ActionForm form, HttpServletRequest request, + HttpServletResponse response) throws IOException, ServletException { + QaAction.logger.debug("dispatching removeQuestion"); + QaAuthoringForm qaAuthoringForm = (QaAuthoringForm) form; - String httpSessionID=qaAuthoringForm.getHttpSessionID(); - logger.debug("httpSessionID: " + httpSessionID); - - SessionMap sessionMap=(SessionMap)request.getSession().getAttribute(httpSessionID); - logger.debug("sessionMap: " + sessionMap); - - String questionIndex=request.getParameter("questionIndex"); - logger.debug("questionIndex: " + questionIndex); - - - List listQuestionContentDTO=(List)sessionMap.get(LIST_QUESTION_CONTENT_DTO_KEY); - logger.debug("listQuestionContentDTO: " + listQuestionContentDTO); + IQaService qaService = QaServiceProxy.getQaService(getServlet().getServletContext()); + QaAction.logger.debug("qaService: " + qaService); - QaQuestionContentDTO qaQuestionContentDTO= null; - Iterator listIterator=listQuestionContentDTO.iterator(); - while (listIterator.hasNext()) - { - qaQuestionContentDTO= (QaQuestionContentDTO)listIterator.next(); - logger.debug("qaQuestionContentDTO:" + qaQuestionContentDTO); - logger.debug("qaQuestionContentDTO question:" + qaQuestionContentDTO.getQuestion()); - - String question=qaQuestionContentDTO.getQuestion(); - String displayOrder=qaQuestionContentDTO.getDisplayOrder(); - logger.debug("displayOrder:" + displayOrder); - - if ((displayOrder != null) && (!displayOrder.equals(""))) - { - if (displayOrder.equals(questionIndex)) - { - break; - } - - } - } - - logger.debug("qaQuestionContentDTO found:" + qaQuestionContentDTO); - qaQuestionContentDTO.setQuestion(""); - logger.debug("listQuestionContentDTO after remove:" + listQuestionContentDTO); - - - listQuestionContentDTO=AuthoringUtil.reorderListQuestionContentDTO(listQuestionContentDTO, questionIndex ); - logger.debug("listQuestionContentDTO reordered:" + listQuestionContentDTO); - + String httpSessionID = qaAuthoringForm.getHttpSessionID(); + QaAction.logger.debug("httpSessionID: " + httpSessionID); - sessionMap.put(LIST_QUESTION_CONTENT_DTO_KEY, listQuestionContentDTO); - - String contentFolderID = WebUtil.readStrParam(request, AttributeNames.PARAM_CONTENT_FOLDER_ID); - logger.debug("contentFolderID: " + contentFolderID); - qaAuthoringForm.setContentFolderID(contentFolderID); + SessionMap sessionMap = (SessionMap) request.getSession().getAttribute(httpSessionID); + QaAction.logger.debug("sessionMap: " + sessionMap); - - String activeModule=request.getParameter(ACTIVE_MODULE); - logger.debug("activeModule: " + activeModule); + String questionIndex = request.getParameter("questionIndex"); + QaAction.logger.debug("questionIndex: " + questionIndex); - String richTextTitle = request.getParameter(TITLE); - logger.debug("richTextTitle: " + richTextTitle); - - String richTextInstructions = request.getParameter(INSTRUCTIONS); - logger.debug("richTextInstructions: " + richTextInstructions); - - - sessionMap.put(ACTIVITY_TITLE_KEY, richTextTitle); - sessionMap.put(ACTIVITY_INSTRUCTIONS_KEY, richTextInstructions); + List listQuestionContentDTO = (List) sessionMap.get(QaAppConstants.LIST_QUESTION_CONTENT_DTO_KEY); + QaAction.logger.debug("listQuestionContentDTO: " + listQuestionContentDTO); + QaQuestionContentDTO qaQuestionContentDTO = null; + Iterator listIterator = listQuestionContentDTO.iterator(); + while (listIterator.hasNext()) { + qaQuestionContentDTO = (QaQuestionContentDTO) listIterator.next(); + QaAction.logger.debug("qaQuestionContentDTO:" + qaQuestionContentDTO); + QaAction.logger.debug("qaQuestionContentDTO question:" + qaQuestionContentDTO.getQuestion()); - String strToolContentID=request.getParameter(AttributeNames.PARAM_TOOL_CONTENT_ID); - logger.debug("strToolContentID: " + strToolContentID); - - String defaultContentIdStr=request.getParameter(DEFAULT_CONTENT_ID_STR); - logger.debug("defaultContentIdStr: " + defaultContentIdStr); - - QaContent qaContent=qaService.loadQa(new Long(strToolContentID).longValue()); - logger.debug("qaContent: " + qaContent); - - if (qaContent == null) - { - logger.debug("using defaultContentIdStr: " + defaultContentIdStr); - qaContent=qaService.loadQa(new Long(defaultContentIdStr).longValue()); + String question = qaQuestionContentDTO.getQuestion(); + String displayOrder = qaQuestionContentDTO.getDisplayOrder(); + QaAction.logger.debug("displayOrder:" + displayOrder); + + if (displayOrder != null && !displayOrder.equals("")) { + if (displayOrder.equals(questionIndex)) { + break; } - logger.debug("final qaContent: " + qaContent); - QaGeneralAuthoringDTO qaGeneralAuthoringDTO= new QaGeneralAuthoringDTO(); - logger.debug("qaGeneralAuthoringDTO: " + qaGeneralAuthoringDTO); - qaGeneralAuthoringDTO.setContentFolderID(contentFolderID); - - qaGeneralAuthoringDTO.setActivityTitle(richTextTitle); - qaAuthoringForm.setTitle(richTextTitle); - - qaGeneralAuthoringDTO.setActivityInstructions(richTextInstructions); + } + } - logger.debug("activeModule: " + activeModule); - if (activeModule.equals(AUTHORING)) - { - String onlineInstructions=(String)sessionMap.get(ONLINE_INSTRUCTIONS_KEY); - logger.debug("onlineInstructions: " + onlineInstructions); - qaGeneralAuthoringDTO.setOnlineInstructions(onlineInstructions); + QaAction.logger.debug("qaQuestionContentDTO found:" + qaQuestionContentDTO); + qaQuestionContentDTO.setQuestion(""); - String offlineInstructions=(String)sessionMap.get(OFFLINE_INSTRUCTIONS_KEY); - logger.debug("offlineInstructions: " + offlineInstructions); - qaGeneralAuthoringDTO.setOfflineInstructions(offlineInstructions); - - - List attachmentList=(List)sessionMap.get(ATTACHMENT_LIST_KEY); - logger.debug("attachmentList: " + attachmentList); - List deletedAttachmentList=(List)sessionMap.get(DELETED_ATTACHMENT_LIST_KEY); - logger.debug("deletedAttachmentList: " + deletedAttachmentList); + SortedSet list = (SortedSet) sessionMap.get(QaAppConstants.ATTR_CONDITION_SET); + Iterator conditionIter = list.iterator(); - qaGeneralAuthoringDTO.setAttachmentList(attachmentList); - qaGeneralAuthoringDTO.setDeletedAttachmentList(deletedAttachmentList); - - String strOnlineInstructions= request.getParameter("onlineInstructions"); - String strOfflineInstructions= request.getParameter("offlineInstructions"); - logger.debug("onlineInstructions: " + strOnlineInstructions); - logger.debug("offlineInstructions: " + strOnlineInstructions); - qaAuthoringForm.setOnlineInstructions(strOnlineInstructions); - qaAuthoringForm.setOfflineInstructions(strOfflineInstructions); - } - - AuthoringUtil authoringUtil= new AuthoringUtil(); - - qaGeneralAuthoringDTO.setEditActivityEditMode(new Boolean(true).toString()); - - request.getSession().setAttribute(httpSessionID, sessionMap); + while (conditionIter.hasNext()) { + QaCondition condition = conditionIter.next(); + Iterator dtoIter = condition.temporaryQuestionDTOSet.iterator(); + while (dtoIter.hasNext()) { + if (dtoIter.next() == qaQuestionContentDTO) { + dtoIter.remove(); + } + } + if (condition.temporaryQuestionDTOSet.isEmpty()) { + conditionIter.remove(); + } + } + QaAction.logger.debug("listQuestionContentDTO after remove:" + listQuestionContentDTO); - QaUtils.setFormProperties(request, qaService, - qaAuthoringForm, qaGeneralAuthoringDTO, strToolContentID, defaultContentIdStr, activeModule, sessionMap, httpSessionID); + listQuestionContentDTO = AuthoringUtil.reorderListQuestionContentDTO(listQuestionContentDTO, questionIndex); + QaAction.logger.debug("listQuestionContentDTO reordered:" + listQuestionContentDTO); - - qaGeneralAuthoringDTO.setToolContentID(strToolContentID); - qaGeneralAuthoringDTO.setHttpSessionID(httpSessionID); - qaGeneralAuthoringDTO.setActiveModule(activeModule); - qaGeneralAuthoringDTO.setDefaultContentIdStr(defaultContentIdStr); - qaAuthoringForm.setToolContentID(strToolContentID); - qaAuthoringForm.setHttpSessionID(httpSessionID); - qaAuthoringForm.setActiveModule(activeModule); - qaAuthoringForm.setDefaultContentIdStr(defaultContentIdStr); - qaAuthoringForm.setCurrentTab("1"); + sessionMap.put(QaAppConstants.LIST_QUESTION_CONTENT_DTO_KEY, listQuestionContentDTO); - request.setAttribute(LIST_QUESTION_CONTENT_DTO,listQuestionContentDTO); - logger.debug("qaQuestionContentDTO now: " + qaQuestionContentDTO); - logger.debug("listQuestionContentDTO now: " + listQuestionContentDTO); - - qaGeneralAuthoringDTO.setDefineLaterInEditMode(new Boolean(true).toString()); - - logger.debug("before saving final qaGeneralAuthoringDTO: " + qaGeneralAuthoringDTO); - request.setAttribute(QA_GENERAL_AUTHORING_DTO, qaGeneralAuthoringDTO); + String contentFolderID = WebUtil.readStrParam(request, AttributeNames.PARAM_CONTENT_FOLDER_ID); + QaAction.logger.debug("contentFolderID: " + contentFolderID); + qaAuthoringForm.setContentFolderID(contentFolderID); - request.setAttribute(TOTAL_QUESTION_COUNT, new Integer(listQuestionContentDTO.size())); - - - logger.debug("fwd ing to LOAD_QUESTIONS: " + LOAD_QUESTIONS); - return (mapping.findForward(LOAD_QUESTIONS)); + String activeModule = request.getParameter(QaAppConstants.ACTIVE_MODULE); + QaAction.logger.debug("activeModule: " + activeModule); + + String richTextTitle = request.getParameter(QaAppConstants.TITLE); + QaAction.logger.debug("richTextTitle: " + richTextTitle); + + String richTextInstructions = request.getParameter(QaAppConstants.INSTRUCTIONS); + QaAction.logger.debug("richTextInstructions: " + richTextInstructions); + + sessionMap.put(QaAppConstants.ACTIVITY_TITLE_KEY, richTextTitle); + sessionMap.put(QaAppConstants.ACTIVITY_INSTRUCTIONS_KEY, richTextInstructions); + + String strToolContentID = request.getParameter(AttributeNames.PARAM_TOOL_CONTENT_ID); + QaAction.logger.debug("strToolContentID: " + strToolContentID); + + String defaultContentIdStr = request.getParameter(QaAppConstants.DEFAULT_CONTENT_ID_STR); + QaAction.logger.debug("defaultContentIdStr: " + defaultContentIdStr); + + QaContent qaContent = qaService.loadQa(new Long(strToolContentID).longValue()); + QaAction.logger.debug("qaContent: " + qaContent); + + if (qaContent == null) { + QaAction.logger.debug("using defaultContentIdStr: " + defaultContentIdStr); + qaContent = qaService.loadQa(new Long(defaultContentIdStr).longValue()); + } + QaAction.logger.debug("final qaContent: " + qaContent); + + QaGeneralAuthoringDTO qaGeneralAuthoringDTO = new QaGeneralAuthoringDTO(); + QaAction.logger.debug("qaGeneralAuthoringDTO: " + qaGeneralAuthoringDTO); + qaGeneralAuthoringDTO.setContentFolderID(contentFolderID); + + qaGeneralAuthoringDTO.setActivityTitle(richTextTitle); + qaAuthoringForm.setTitle(richTextTitle); + + qaGeneralAuthoringDTO.setActivityInstructions(richTextInstructions); + + QaAction.logger.debug("activeModule: " + activeModule); + if (activeModule.equals(QaAppConstants.AUTHORING)) { + String onlineInstructions = (String) sessionMap.get(QaAppConstants.ONLINE_INSTRUCTIONS_KEY); + QaAction.logger.debug("onlineInstructions: " + onlineInstructions); + qaGeneralAuthoringDTO.setOnlineInstructions(onlineInstructions); + + String offlineInstructions = (String) sessionMap.get(QaAppConstants.OFFLINE_INSTRUCTIONS_KEY); + QaAction.logger.debug("offlineInstructions: " + offlineInstructions); + qaGeneralAuthoringDTO.setOfflineInstructions(offlineInstructions); + + List attachmentList = (List) sessionMap.get(QaAppConstants.ATTACHMENT_LIST_KEY); + QaAction.logger.debug("attachmentList: " + attachmentList); + List deletedAttachmentList = (List) sessionMap.get(QaAppConstants.DELETED_ATTACHMENT_LIST_KEY); + QaAction.logger.debug("deletedAttachmentList: " + deletedAttachmentList); + + qaGeneralAuthoringDTO.setAttachmentList(attachmentList); + qaGeneralAuthoringDTO.setDeletedAttachmentList(deletedAttachmentList); + + String strOnlineInstructions = request.getParameter("onlineInstructions"); + String strOfflineInstructions = request.getParameter("offlineInstructions"); + QaAction.logger.debug("onlineInstructions: " + strOnlineInstructions); + QaAction.logger.debug("offlineInstructions: " + strOnlineInstructions); + qaAuthoringForm.setOnlineInstructions(strOnlineInstructions); + qaAuthoringForm.setOfflineInstructions(strOfflineInstructions); + } + + AuthoringUtil authoringUtil = new AuthoringUtil(); + + qaGeneralAuthoringDTO.setEditActivityEditMode(new Boolean(true).toString()); + + request.getSession().setAttribute(httpSessionID, sessionMap); + + QaUtils.setFormProperties(request, qaService, qaAuthoringForm, qaGeneralAuthoringDTO, strToolContentID, + defaultContentIdStr, activeModule, sessionMap, httpSessionID); + + qaGeneralAuthoringDTO.setToolContentID(strToolContentID); + qaGeneralAuthoringDTO.setHttpSessionID(httpSessionID); + qaGeneralAuthoringDTO.setActiveModule(activeModule); + qaGeneralAuthoringDTO.setDefaultContentIdStr(defaultContentIdStr); + qaAuthoringForm.setToolContentID(strToolContentID); + qaAuthoringForm.setHttpSessionID(httpSessionID); + qaAuthoringForm.setActiveModule(activeModule); + qaAuthoringForm.setDefaultContentIdStr(defaultContentIdStr); + qaAuthoringForm.setCurrentTab("1"); + + request.setAttribute(QaAppConstants.LIST_QUESTION_CONTENT_DTO, listQuestionContentDTO); + QaAction.logger.debug("qaQuestionContentDTO now: " + qaQuestionContentDTO); + QaAction.logger.debug("listQuestionContentDTO now: " + listQuestionContentDTO); + + qaGeneralAuthoringDTO.setDefineLaterInEditMode(new Boolean(true).toString()); + + QaAction.logger.debug("before saving final qaGeneralAuthoringDTO: " + qaGeneralAuthoringDTO); + request.setAttribute(QaAppConstants.QA_GENERAL_AUTHORING_DTO, qaGeneralAuthoringDTO); + + request.setAttribute(QaAppConstants.TOTAL_QUESTION_COUNT, new Integer(listQuestionContentDTO.size())); + + QaAction.logger.debug("fwd ing to LOAD_QUESTIONS: " + QaAppConstants.LOAD_QUESTIONS); + return mapping.findForward(QaAppConstants.LOAD_QUESTIONS); } - - + /** - * moves a question down in the list - * moveQuestionDown + * moves a question down in the list moveQuestionDown + * * @param mapping * @param form * @param request @@ -1280,141 +1211,133 @@ * @throws IOException * @throws ServletException */ - public ActionForward moveQuestionDown(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) - throws IOException, ServletException { - logger.debug("dispatching moveQuestionDown"); - QaAuthoringForm qaAuthoringForm = (QaAuthoringForm) form; - - IQaService qaService =QaServiceProxy.getQaService(getServlet().getServletContext()); - logger.debug("qaService: " + qaService); - - String httpSessionID=qaAuthoringForm.getHttpSessionID(); - logger.debug("httpSessionID: " + httpSessionID); - - SessionMap sessionMap=(SessionMap)request.getSession().getAttribute(httpSessionID); - logger.debug("sessionMap: " + sessionMap); - - String questionIndex=request.getParameter("questionIndex"); - logger.debug("questionIndex: " + questionIndex); - - - List listQuestionContentDTO=(List)sessionMap.get(LIST_QUESTION_CONTENT_DTO_KEY); - logger.debug("listQuestionContentDTO: " + listQuestionContentDTO); - - listQuestionContentDTO=AuthoringUtil.swapNodes(listQuestionContentDTO, questionIndex, "down"); - logger.debug("listQuestionContentDTO after swap: " + listQuestionContentDTO); - - listQuestionContentDTO=AuthoringUtil.reorderSimpleListQuestionContentDTO(listQuestionContentDTO); - logger.debug("listQuestionContentDTO after reordersimple: " + listQuestionContentDTO); + public ActionForward moveQuestionDown(ActionMapping mapping, ActionForm form, HttpServletRequest request, + HttpServletResponse response) throws IOException, ServletException { + QaAction.logger.debug("dispatching moveQuestionDown"); + QaAuthoringForm qaAuthoringForm = (QaAuthoringForm) form; - - sessionMap.put(LIST_QUESTION_CONTENT_DTO_KEY, listQuestionContentDTO); - - - String contentFolderID = WebUtil.readStrParam(request, AttributeNames.PARAM_CONTENT_FOLDER_ID); - logger.debug("contentFolderID: " + contentFolderID); - qaAuthoringForm.setContentFolderID(contentFolderID); - - - String activeModule=request.getParameter(ACTIVE_MODULE); - logger.debug("activeModule: " + activeModule); - - String richTextTitle = request.getParameter(TITLE); - logger.debug("richTextTitle: " + richTextTitle); - - String richTextInstructions = request.getParameter(INSTRUCTIONS); - logger.debug("richTextInstructions: " + richTextInstructions); - - - sessionMap.put(ACTIVITY_TITLE_KEY, richTextTitle); - sessionMap.put(ACTIVITY_INSTRUCTIONS_KEY, richTextInstructions); - - - String strToolContentID=request.getParameter(AttributeNames.PARAM_TOOL_CONTENT_ID); - logger.debug("strToolContentID: " + strToolContentID); - - String defaultContentIdStr=request.getParameter(DEFAULT_CONTENT_ID_STR); - logger.debug("defaultContentIdStr: " + defaultContentIdStr); - - QaContent qaContent=qaService.loadQa(new Long(strToolContentID).longValue()); - logger.debug("qaContent: " + qaContent); + IQaService qaService = QaServiceProxy.getQaService(getServlet().getServletContext()); + QaAction.logger.debug("qaService: " + qaService); - - QaGeneralAuthoringDTO qaGeneralAuthoringDTO= new QaGeneralAuthoringDTO(); - logger.debug("qaGeneralAuthoringDTO: " + qaGeneralAuthoringDTO); - qaGeneralAuthoringDTO.setContentFolderID(contentFolderID); - - qaGeneralAuthoringDTO.setActivityTitle(richTextTitle); - qaAuthoringForm.setTitle(richTextTitle); - - qaGeneralAuthoringDTO.setActivityInstructions(richTextInstructions); - - logger.debug("activeModule: " + activeModule); - if (activeModule.equals(AUTHORING)) - { - String onlineInstructions=(String)sessionMap.get(ONLINE_INSTRUCTIONS_KEY); - logger.debug("onlineInstructions: " + onlineInstructions); - qaGeneralAuthoringDTO.setOnlineInstructions(onlineInstructions); - - String offlineInstructions=(String)sessionMap.get(OFFLINE_INSTRUCTIONS_KEY); - logger.debug("offlineInstructions: " + offlineInstructions); - qaGeneralAuthoringDTO.setOfflineInstructions(offlineInstructions); - - List attachmentList=(List)sessionMap.get(ATTACHMENT_LIST_KEY); - logger.debug("attachmentList: " + attachmentList); - List deletedAttachmentList=(List)sessionMap.get(DELETED_ATTACHMENT_LIST_KEY); - logger.debug("deletedAttachmentList: " + deletedAttachmentList); - - qaGeneralAuthoringDTO.setAttachmentList(attachmentList); - qaGeneralAuthoringDTO.setDeletedAttachmentList(deletedAttachmentList); + String httpSessionID = qaAuthoringForm.getHttpSessionID(); + QaAction.logger.debug("httpSessionID: " + httpSessionID); - String strOnlineInstructions= request.getParameter("onlineInstructions"); - String strOfflineInstructions= request.getParameter("offlineInstructions"); - logger.debug("onlineInstructions: " + strOnlineInstructions); - logger.debug("offlineInstructions: " + strOnlineInstructions); - qaAuthoringForm.setOnlineInstructions(strOnlineInstructions); - qaAuthoringForm.setOfflineInstructions(strOfflineInstructions); - } - - AuthoringUtil authoringUtil= new AuthoringUtil(); - - qaGeneralAuthoringDTO.setEditActivityEditMode(new Boolean(true).toString()); - - request.getSession().setAttribute(httpSessionID, sessionMap); - - QaUtils.setFormProperties(request, qaService, - qaAuthoringForm, qaGeneralAuthoringDTO, strToolContentID, defaultContentIdStr, activeModule, sessionMap, httpSessionID); - - - qaGeneralAuthoringDTO.setToolContentID(strToolContentID); - qaGeneralAuthoringDTO.setHttpSessionID(httpSessionID); - qaGeneralAuthoringDTO.setActiveModule(activeModule); - qaGeneralAuthoringDTO.setDefaultContentIdStr(defaultContentIdStr); - qaAuthoringForm.setToolContentID(strToolContentID); - qaAuthoringForm.setHttpSessionID(httpSessionID); - qaAuthoringForm.setActiveModule(activeModule); - qaAuthoringForm.setDefaultContentIdStr(defaultContentIdStr); - qaAuthoringForm.setCurrentTab("1"); - - request.setAttribute(LIST_QUESTION_CONTENT_DTO,listQuestionContentDTO); - logger.debug("listQuestionContentDTO now: " + listQuestionContentDTO); - - qaGeneralAuthoringDTO.setDefineLaterInEditMode(new Boolean(true).toString()); - - logger.debug("before saving final qaGeneralAuthoringDTO: " + qaGeneralAuthoringDTO); - request.setAttribute(QA_GENERAL_AUTHORING_DTO, qaGeneralAuthoringDTO); - - request.setAttribute(TOTAL_QUESTION_COUNT, new Integer(listQuestionContentDTO.size())); - + SessionMap sessionMap = (SessionMap) request.getSession().getAttribute(httpSessionID); + QaAction.logger.debug("sessionMap: " + sessionMap); - logger.debug("fwd ing to LOAD_QUESTIONS: " + LOAD_QUESTIONS); - return (mapping.findForward(LOAD_QUESTIONS)); + String questionIndex = request.getParameter("questionIndex"); + QaAction.logger.debug("questionIndex: " + questionIndex); + + List listQuestionContentDTO = (List) sessionMap.get(QaAppConstants.LIST_QUESTION_CONTENT_DTO_KEY); + QaAction.logger.debug("listQuestionContentDTO: " + listQuestionContentDTO); + + SortedSet conditionSet = (SortedSet) sessionMap + .get(QaAppConstants.ATTR_CONDITION_SET); + + listQuestionContentDTO = AuthoringUtil.swapNodes(listQuestionContentDTO, questionIndex, "down", conditionSet); + QaAction.logger.debug("listQuestionContentDTO after swap: " + listQuestionContentDTO); + + listQuestionContentDTO = AuthoringUtil.reorderSimpleListQuestionContentDTO(listQuestionContentDTO); + QaAction.logger.debug("listQuestionContentDTO after reordersimple: " + listQuestionContentDTO); + + sessionMap.put(QaAppConstants.LIST_QUESTION_CONTENT_DTO_KEY, listQuestionContentDTO); + + String contentFolderID = WebUtil.readStrParam(request, AttributeNames.PARAM_CONTENT_FOLDER_ID); + QaAction.logger.debug("contentFolderID: " + contentFolderID); + qaAuthoringForm.setContentFolderID(contentFolderID); + + String activeModule = request.getParameter(QaAppConstants.ACTIVE_MODULE); + QaAction.logger.debug("activeModule: " + activeModule); + + String richTextTitle = request.getParameter(QaAppConstants.TITLE); + QaAction.logger.debug("richTextTitle: " + richTextTitle); + + String richTextInstructions = request.getParameter(QaAppConstants.INSTRUCTIONS); + QaAction.logger.debug("richTextInstructions: " + richTextInstructions); + + sessionMap.put(QaAppConstants.ACTIVITY_TITLE_KEY, richTextTitle); + sessionMap.put(QaAppConstants.ACTIVITY_INSTRUCTIONS_KEY, richTextInstructions); + + String strToolContentID = request.getParameter(AttributeNames.PARAM_TOOL_CONTENT_ID); + QaAction.logger.debug("strToolContentID: " + strToolContentID); + + String defaultContentIdStr = request.getParameter(QaAppConstants.DEFAULT_CONTENT_ID_STR); + QaAction.logger.debug("defaultContentIdStr: " + defaultContentIdStr); + + QaContent qaContent = qaService.loadQa(new Long(strToolContentID).longValue()); + QaAction.logger.debug("qaContent: " + qaContent); + + QaGeneralAuthoringDTO qaGeneralAuthoringDTO = new QaGeneralAuthoringDTO(); + QaAction.logger.debug("qaGeneralAuthoringDTO: " + qaGeneralAuthoringDTO); + qaGeneralAuthoringDTO.setContentFolderID(contentFolderID); + + qaGeneralAuthoringDTO.setActivityTitle(richTextTitle); + qaAuthoringForm.setTitle(richTextTitle); + + qaGeneralAuthoringDTO.setActivityInstructions(richTextInstructions); + + QaAction.logger.debug("activeModule: " + activeModule); + if (activeModule.equals(QaAppConstants.AUTHORING)) { + String onlineInstructions = (String) sessionMap.get(QaAppConstants.ONLINE_INSTRUCTIONS_KEY); + QaAction.logger.debug("onlineInstructions: " + onlineInstructions); + qaGeneralAuthoringDTO.setOnlineInstructions(onlineInstructions); + + String offlineInstructions = (String) sessionMap.get(QaAppConstants.OFFLINE_INSTRUCTIONS_KEY); + QaAction.logger.debug("offlineInstructions: " + offlineInstructions); + qaGeneralAuthoringDTO.setOfflineInstructions(offlineInstructions); + + List attachmentList = (List) sessionMap.get(QaAppConstants.ATTACHMENT_LIST_KEY); + QaAction.logger.debug("attachmentList: " + attachmentList); + List deletedAttachmentList = (List) sessionMap.get(QaAppConstants.DELETED_ATTACHMENT_LIST_KEY); + QaAction.logger.debug("deletedAttachmentList: " + deletedAttachmentList); + + qaGeneralAuthoringDTO.setAttachmentList(attachmentList); + qaGeneralAuthoringDTO.setDeletedAttachmentList(deletedAttachmentList); + + String strOnlineInstructions = request.getParameter("onlineInstructions"); + String strOfflineInstructions = request.getParameter("offlineInstructions"); + QaAction.logger.debug("onlineInstructions: " + strOnlineInstructions); + QaAction.logger.debug("offlineInstructions: " + strOnlineInstructions); + qaAuthoringForm.setOnlineInstructions(strOnlineInstructions); + qaAuthoringForm.setOfflineInstructions(strOfflineInstructions); + } + + AuthoringUtil authoringUtil = new AuthoringUtil(); + + qaGeneralAuthoringDTO.setEditActivityEditMode(new Boolean(true).toString()); + + request.getSession().setAttribute(httpSessionID, sessionMap); + + QaUtils.setFormProperties(request, qaService, qaAuthoringForm, qaGeneralAuthoringDTO, strToolContentID, + defaultContentIdStr, activeModule, sessionMap, httpSessionID); + + qaGeneralAuthoringDTO.setToolContentID(strToolContentID); + qaGeneralAuthoringDTO.setHttpSessionID(httpSessionID); + qaGeneralAuthoringDTO.setActiveModule(activeModule); + qaGeneralAuthoringDTO.setDefaultContentIdStr(defaultContentIdStr); + qaAuthoringForm.setToolContentID(strToolContentID); + qaAuthoringForm.setHttpSessionID(httpSessionID); + qaAuthoringForm.setActiveModule(activeModule); + qaAuthoringForm.setDefaultContentIdStr(defaultContentIdStr); + qaAuthoringForm.setCurrentTab("1"); + + request.setAttribute(QaAppConstants.LIST_QUESTION_CONTENT_DTO, listQuestionContentDTO); + QaAction.logger.debug("listQuestionContentDTO now: " + listQuestionContentDTO); + + qaGeneralAuthoringDTO.setDefineLaterInEditMode(new Boolean(true).toString()); + + QaAction.logger.debug("before saving final qaGeneralAuthoringDTO: " + qaGeneralAuthoringDTO); + request.setAttribute(QaAppConstants.QA_GENERAL_AUTHORING_DTO, qaGeneralAuthoringDTO); + + request.setAttribute(QaAppConstants.TOTAL_QUESTION_COUNT, new Integer(listQuestionContentDTO.size())); + + QaAction.logger.debug("fwd ing to LOAD_QUESTIONS: " + QaAppConstants.LOAD_QUESTIONS); + return mapping.findForward(QaAppConstants.LOAD_QUESTIONS); } - /** - * moves a question up in the list - * moveQuestionUp + * moves a question up in the list moveQuestionUp + * * @param mapping * @param form * @param request @@ -1423,142 +1346,132 @@ * @throws IOException * @throws ServletException */ - public ActionForward moveQuestionUp(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) - throws IOException, ServletException { - logger.debug("dispatching moveQuestionUp"); - QaAuthoringForm qaAuthoringForm = (QaAuthoringForm) form; - - IQaService qaService =QaServiceProxy.getQaService(getServlet().getServletContext()); - logger.debug("qaService: " + qaService); - - String httpSessionID=qaAuthoringForm.getHttpSessionID(); - logger.debug("httpSessionID: " + httpSessionID); - - SessionMap sessionMap=(SessionMap)request.getSession().getAttribute(httpSessionID); - logger.debug("sessionMap: " + sessionMap); - - String questionIndex=request.getParameter("questionIndex"); - logger.debug("questionIndex: " + questionIndex); - - - List listQuestionContentDTO=(List)sessionMap.get(LIST_QUESTION_CONTENT_DTO_KEY); - logger.debug("listQuestionContentDTO: " + listQuestionContentDTO); - - listQuestionContentDTO=AuthoringUtil.swapNodes(listQuestionContentDTO, questionIndex, "up"); - logger.debug("listQuestionContentDTO after swap: " + listQuestionContentDTO); - - listQuestionContentDTO=AuthoringUtil.reorderSimpleListQuestionContentDTO(listQuestionContentDTO); - logger.debug("listQuestionContentDTO after reordersimple: " + listQuestionContentDTO); - - sessionMap.put(LIST_QUESTION_CONTENT_DTO_KEY, listQuestionContentDTO); - - String contentFolderID = WebUtil.readStrParam(request, AttributeNames.PARAM_CONTENT_FOLDER_ID); - logger.debug("contentFolderID: " + contentFolderID); - qaAuthoringForm.setContentFolderID(contentFolderID); - - - String activeModule=request.getParameter(ACTIVE_MODULE); - logger.debug("activeModule: " + activeModule); - - String richTextTitle = request.getParameter(TITLE); - logger.debug("richTextTitle: " + richTextTitle); - - String richTextInstructions = request.getParameter(INSTRUCTIONS); - logger.debug("richTextInstructions: " + richTextInstructions); - - - sessionMap.put(ACTIVITY_TITLE_KEY, richTextTitle); - sessionMap.put(ACTIVITY_INSTRUCTIONS_KEY, richTextInstructions); - - - String strToolContentID=request.getParameter(AttributeNames.PARAM_TOOL_CONTENT_ID); - logger.debug("strToolContentID: " + strToolContentID); - - String defaultContentIdStr=request.getParameter(DEFAULT_CONTENT_ID_STR); - logger.debug("defaultContentIdStr: " + defaultContentIdStr); - - QaContent qaContent=qaService.loadQa(new Long(strToolContentID).longValue()); - logger.debug("qaContent: " + qaContent); - - - QaGeneralAuthoringDTO qaGeneralAuthoringDTO= new QaGeneralAuthoringDTO(); - logger.debug("qaGeneralAuthoringDTO: " + qaGeneralAuthoringDTO); - qaGeneralAuthoringDTO.setContentFolderID(contentFolderID); - - qaGeneralAuthoringDTO.setActivityTitle(richTextTitle); - qaAuthoringForm.setTitle(richTextTitle); - - qaGeneralAuthoringDTO.setActivityInstructions(richTextInstructions); - - logger.debug("activeModule: " + activeModule); - if (activeModule.equals(AUTHORING)) - { - String onlineInstructions=(String)sessionMap.get(ONLINE_INSTRUCTIONS_KEY); - logger.debug("onlineInstructions: " + onlineInstructions); - qaGeneralAuthoringDTO.setOnlineInstructions(onlineInstructions); - - String offlineInstructions=(String)sessionMap.get(OFFLINE_INSTRUCTIONS_KEY); - logger.debug("offlineInstructions: " + offlineInstructions); - qaGeneralAuthoringDTO.setOfflineInstructions(offlineInstructions); - - List attachmentList=(List)sessionMap.get(ATTACHMENT_LIST_KEY); - logger.debug("attachmentList: " + attachmentList); - List deletedAttachmentList=(List)sessionMap.get(DELETED_ATTACHMENT_LIST_KEY); - logger.debug("deletedAttachmentList: " + deletedAttachmentList); - - qaGeneralAuthoringDTO.setAttachmentList(attachmentList); - qaGeneralAuthoringDTO.setDeletedAttachmentList(deletedAttachmentList); - - String strOnlineInstructions= request.getParameter("onlineInstructions"); - String strOfflineInstructions= request.getParameter("offlineInstructions"); - logger.debug("onlineInstructions: " + strOnlineInstructions); - logger.debug("offlineInstructions: " + strOnlineInstructions); - qaAuthoringForm.setOnlineInstructions(strOnlineInstructions); - qaAuthoringForm.setOfflineInstructions(strOfflineInstructions); - } - - AuthoringUtil authoringUtil= new AuthoringUtil(); - - qaGeneralAuthoringDTO.setEditActivityEditMode(new Boolean(true).toString()); - - request.getSession().setAttribute(httpSessionID, sessionMap); - - QaUtils.setFormProperties(request, qaService, - qaAuthoringForm, qaGeneralAuthoringDTO, strToolContentID, defaultContentIdStr, activeModule, sessionMap, httpSessionID); - - - qaGeneralAuthoringDTO.setToolContentID(strToolContentID); - qaGeneralAuthoringDTO.setHttpSessionID(httpSessionID); - qaGeneralAuthoringDTO.setActiveModule(activeModule); - qaGeneralAuthoringDTO.setDefaultContentIdStr(defaultContentIdStr); - qaAuthoringForm.setToolContentID(strToolContentID); - qaAuthoringForm.setHttpSessionID(httpSessionID); - qaAuthoringForm.setActiveModule(activeModule); - qaAuthoringForm.setDefaultContentIdStr(defaultContentIdStr); - qaAuthoringForm.setCurrentTab("1"); - - request.setAttribute(LIST_QUESTION_CONTENT_DTO,listQuestionContentDTO); - logger.debug("listQuestionContentDTO now: " + listQuestionContentDTO); - - qaGeneralAuthoringDTO.setDefineLaterInEditMode(new Boolean(true).toString()); - - logger.debug("before saving final qaGeneralAuthoringDTO: " + qaGeneralAuthoringDTO); - request.setAttribute(QA_GENERAL_AUTHORING_DTO, qaGeneralAuthoringDTO); - - request.setAttribute(TOTAL_QUESTION_COUNT, new Integer(listQuestionContentDTO.size())); - + public ActionForward moveQuestionUp(ActionMapping mapping, ActionForm form, HttpServletRequest request, + HttpServletResponse response) throws IOException, ServletException { + QaAction.logger.debug("dispatching moveQuestionUp"); + QaAuthoringForm qaAuthoringForm = (QaAuthoringForm) form; - logger.debug("fwd ing to LOAD_QUESTIONS: " + LOAD_QUESTIONS); - return (mapping.findForward(LOAD_QUESTIONS)); - } + IQaService qaService = QaServiceProxy.getQaService(getServlet().getServletContext()); + QaAction.logger.debug("qaService: " + qaService); + String httpSessionID = qaAuthoringForm.getHttpSessionID(); + QaAction.logger.debug("httpSessionID: " + httpSessionID); - + SessionMap sessionMap = (SessionMap) request.getSession().getAttribute(httpSessionID); + QaAction.logger.debug("sessionMap: " + sessionMap); + + String questionIndex = request.getParameter("questionIndex"); + QaAction.logger.debug("questionIndex: " + questionIndex); + + List listQuestionContentDTO = (List) sessionMap.get(QaAppConstants.LIST_QUESTION_CONTENT_DTO_KEY); + QaAction.logger.debug("listQuestionContentDTO: " + listQuestionContentDTO); + SortedSet conditionSet = (SortedSet) sessionMap + .get(QaAppConstants.ATTR_CONDITION_SET); + listQuestionContentDTO = AuthoringUtil.swapNodes(listQuestionContentDTO, questionIndex, "up", conditionSet); + QaAction.logger.debug("listQuestionContentDTO after swap: " + listQuestionContentDTO); + + listQuestionContentDTO = AuthoringUtil.reorderSimpleListQuestionContentDTO(listQuestionContentDTO); + QaAction.logger.debug("listQuestionContentDTO after reordersimple: " + listQuestionContentDTO); + + sessionMap.put(QaAppConstants.LIST_QUESTION_CONTENT_DTO_KEY, listQuestionContentDTO); + + String contentFolderID = WebUtil.readStrParam(request, AttributeNames.PARAM_CONTENT_FOLDER_ID); + QaAction.logger.debug("contentFolderID: " + contentFolderID); + qaAuthoringForm.setContentFolderID(contentFolderID); + + String activeModule = request.getParameter(QaAppConstants.ACTIVE_MODULE); + QaAction.logger.debug("activeModule: " + activeModule); + + String richTextTitle = request.getParameter(QaAppConstants.TITLE); + QaAction.logger.debug("richTextTitle: " + richTextTitle); + + String richTextInstructions = request.getParameter(QaAppConstants.INSTRUCTIONS); + QaAction.logger.debug("richTextInstructions: " + richTextInstructions); + + sessionMap.put(QaAppConstants.ACTIVITY_TITLE_KEY, richTextTitle); + sessionMap.put(QaAppConstants.ACTIVITY_INSTRUCTIONS_KEY, richTextInstructions); + + String strToolContentID = request.getParameter(AttributeNames.PARAM_TOOL_CONTENT_ID); + QaAction.logger.debug("strToolContentID: " + strToolContentID); + + String defaultContentIdStr = request.getParameter(QaAppConstants.DEFAULT_CONTENT_ID_STR); + QaAction.logger.debug("defaultContentIdStr: " + defaultContentIdStr); + + QaContent qaContent = qaService.loadQa(new Long(strToolContentID).longValue()); + QaAction.logger.debug("qaContent: " + qaContent); + + QaGeneralAuthoringDTO qaGeneralAuthoringDTO = new QaGeneralAuthoringDTO(); + QaAction.logger.debug("qaGeneralAuthoringDTO: " + qaGeneralAuthoringDTO); + qaGeneralAuthoringDTO.setContentFolderID(contentFolderID); + + qaGeneralAuthoringDTO.setActivityTitle(richTextTitle); + qaAuthoringForm.setTitle(richTextTitle); + + qaGeneralAuthoringDTO.setActivityInstructions(richTextInstructions); + + QaAction.logger.debug("activeModule: " + activeModule); + if (activeModule.equals(QaAppConstants.AUTHORING)) { + String onlineInstructions = (String) sessionMap.get(QaAppConstants.ONLINE_INSTRUCTIONS_KEY); + QaAction.logger.debug("onlineInstructions: " + onlineInstructions); + qaGeneralAuthoringDTO.setOnlineInstructions(onlineInstructions); + + String offlineInstructions = (String) sessionMap.get(QaAppConstants.OFFLINE_INSTRUCTIONS_KEY); + QaAction.logger.debug("offlineInstructions: " + offlineInstructions); + qaGeneralAuthoringDTO.setOfflineInstructions(offlineInstructions); + + List attachmentList = (List) sessionMap.get(QaAppConstants.ATTACHMENT_LIST_KEY); + QaAction.logger.debug("attachmentList: " + attachmentList); + List deletedAttachmentList = (List) sessionMap.get(QaAppConstants.DELETED_ATTACHMENT_LIST_KEY); + QaAction.logger.debug("deletedAttachmentList: " + deletedAttachmentList); + + qaGeneralAuthoringDTO.setAttachmentList(attachmentList); + qaGeneralAuthoringDTO.setDeletedAttachmentList(deletedAttachmentList); + + String strOnlineInstructions = request.getParameter("onlineInstructions"); + String strOfflineInstructions = request.getParameter("offlineInstructions"); + QaAction.logger.debug("onlineInstructions: " + strOnlineInstructions); + QaAction.logger.debug("offlineInstructions: " + strOnlineInstructions); + qaAuthoringForm.setOnlineInstructions(strOnlineInstructions); + qaAuthoringForm.setOfflineInstructions(strOfflineInstructions); + } + + AuthoringUtil authoringUtil = new AuthoringUtil(); + + qaGeneralAuthoringDTO.setEditActivityEditMode(new Boolean(true).toString()); + + request.getSession().setAttribute(httpSessionID, sessionMap); + + QaUtils.setFormProperties(request, qaService, qaAuthoringForm, qaGeneralAuthoringDTO, strToolContentID, + defaultContentIdStr, activeModule, sessionMap, httpSessionID); + + qaGeneralAuthoringDTO.setToolContentID(strToolContentID); + qaGeneralAuthoringDTO.setHttpSessionID(httpSessionID); + qaGeneralAuthoringDTO.setActiveModule(activeModule); + qaGeneralAuthoringDTO.setDefaultContentIdStr(defaultContentIdStr); + qaAuthoringForm.setToolContentID(strToolContentID); + qaAuthoringForm.setHttpSessionID(httpSessionID); + qaAuthoringForm.setActiveModule(activeModule); + qaAuthoringForm.setDefaultContentIdStr(defaultContentIdStr); + qaAuthoringForm.setCurrentTab("1"); + + request.setAttribute(QaAppConstants.LIST_QUESTION_CONTENT_DTO, listQuestionContentDTO); + QaAction.logger.debug("listQuestionContentDTO now: " + listQuestionContentDTO); + + qaGeneralAuthoringDTO.setDefineLaterInEditMode(new Boolean(true).toString()); + + QaAction.logger.debug("before saving final qaGeneralAuthoringDTO: " + qaGeneralAuthoringDTO); + request.setAttribute(QaAppConstants.QA_GENERAL_AUTHORING_DTO, qaGeneralAuthoringDTO); + + request.setAttribute(QaAppConstants.TOTAL_QUESTION_COUNT, new Integer(listQuestionContentDTO.size())); + + QaAction.logger.debug("fwd ing to LOAD_QUESTIONS: " + QaAppConstants.LOAD_QUESTIONS); + return mapping.findForward(QaAppConstants.LOAD_QUESTIONS); + } + /** - * adds a new file to content repository - * ActionForward addNewFile(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) - throws IOException, ServletException - + * adds a new file to content repository ActionForward addNewFile(ActionMapping mapping, ActionForm form, + * HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException + * * @param mapping * @param form * @param request @@ -1567,132 +1480,123 @@ * @throws IOException * @throws ServletException */ - public ActionForward addNewFile(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) - throws IOException, ServletException { - logger.debug("dispathching addNewFile"); - QaAuthoringForm qaAuthoringForm = (QaAuthoringForm) form; - - IQaService qaService =QaServiceProxy.getQaService(getServlet().getServletContext()); - logger.debug("qaService: " + qaService); + public ActionForward addNewFile(ActionMapping mapping, ActionForm form, HttpServletRequest request, + HttpServletResponse response) throws IOException, ServletException { + QaAction.logger.debug("dispathching addNewFile"); + QaAuthoringForm qaAuthoringForm = (QaAuthoringForm) form; - String httpSessionID=qaAuthoringForm.getHttpSessionID(); - logger.debug("httpSessionID: " + httpSessionID); - - SessionMap sessionMap=(SessionMap)request.getSession().getAttribute(httpSessionID); - logger.debug("sessionMap: " + sessionMap); - - String contentFolderID = WebUtil.readStrParam(request, AttributeNames.PARAM_CONTENT_FOLDER_ID); - logger.debug("contentFolderID: " + contentFolderID); - qaAuthoringForm.setContentFolderID(contentFolderID); + IQaService qaService = QaServiceProxy.getQaService(getServlet().getServletContext()); + QaAction.logger.debug("qaService: " + qaService); + String httpSessionID = qaAuthoringForm.getHttpSessionID(); + QaAction.logger.debug("httpSessionID: " + httpSessionID); - String activeModule=request.getParameter(ACTIVE_MODULE); - logger.debug("activeModule: " + activeModule); - - String onlineInstructions=request.getParameter(ONLINE_INSTRUCTIONS); - logger.debug("onlineInstructions: " + onlineInstructions); - - String offlineInstructions=request.getParameter(OFFLINE_INSTRUCTIONS); - logger.debug("offlineInstructions: " + offlineInstructions); - - sessionMap.put(ONLINE_INSTRUCTIONS_KEY, onlineInstructions); - sessionMap.put(OFFLINE_INSTRUCTIONS, offlineInstructions); + SessionMap sessionMap = (SessionMap) request.getSession().getAttribute(httpSessionID); + QaAction.logger.debug("sessionMap: " + sessionMap); - List listQuestionContentDTO=(List)sessionMap.get(LIST_QUESTION_CONTENT_DTO_KEY); - logger.debug("listQuestionContentDTO: " + listQuestionContentDTO); - - request.setAttribute(LIST_QUESTION_CONTENT_DTO,listQuestionContentDTO); - - String strToolContentID=request.getParameter(AttributeNames.PARAM_TOOL_CONTENT_ID); - logger.debug("strToolContentID: " + strToolContentID); - - String defaultContentIdStr=request.getParameter(DEFAULT_CONTENT_ID_STR); - logger.debug("defaultContentIdStr: " + defaultContentIdStr); - - QaContent qaContent=qaService.loadQa(new Long(strToolContentID).longValue()); - logger.debug("qaContent: " + qaContent); - - - QaGeneralAuthoringDTO qaGeneralAuthoringDTO= new QaGeneralAuthoringDTO(); - logger.debug("qaGeneralAuthoringDTO: " + qaGeneralAuthoringDTO); - qaGeneralAuthoringDTO.setContentFolderID(contentFolderID); - - qaGeneralAuthoringDTO.setOnlineInstructions(onlineInstructions); - qaGeneralAuthoringDTO.setOfflineInstructions(offlineInstructions); + String contentFolderID = WebUtil.readStrParam(request, AttributeNames.PARAM_CONTENT_FOLDER_ID); + QaAction.logger.debug("contentFolderID: " + contentFolderID); + qaAuthoringForm.setContentFolderID(contentFolderID); - qaGeneralAuthoringDTO.setSbmtSuccess(new Integer(0).toString()); - - String richTextTitle = request.getParameter(TITLE); - String richTextInstructions = request.getParameter(INSTRUCTIONS); - - logger.debug("richTextTitle: " + richTextTitle); - logger.debug("richTextInstructions: " + richTextInstructions); - qaGeneralAuthoringDTO.setActivityTitle(richTextTitle); - qaAuthoringForm.setTitle(richTextTitle); - - qaGeneralAuthoringDTO.setActivityInstructions(richTextInstructions); - - sessionMap.put(ACTIVITY_TITLE_KEY, richTextTitle); - sessionMap.put(ACTIVITY_INSTRUCTIONS_KEY, richTextInstructions); + String activeModule = request.getParameter(QaAppConstants.ACTIVE_MODULE); + QaAction.logger.debug("activeModule: " + activeModule); - List attachmentList=(List)sessionMap.get(ATTACHMENT_LIST_KEY); - logger.debug("attachmentList: " + attachmentList); - List deletedAttachmentList=(List)sessionMap.get(DELETED_ATTACHMENT_LIST_KEY); - logger.debug("deletedAttachmentList: " + deletedAttachmentList); - - addFileToContentRepository(request, qaAuthoringForm, attachmentList, deletedAttachmentList, sessionMap, qaGeneralAuthoringDTO); - logger.debug("post addFileToContentRepository, attachmentList: " + attachmentList); - logger.debug("post addFileToContentRepository, deletedAttachmentList: " + deletedAttachmentList); + String onlineInstructions = request.getParameter(QaAppConstants.ONLINE_INSTRUCTIONS); + QaAction.logger.debug("onlineInstructions: " + onlineInstructions); - sessionMap.put(ATTACHMENT_LIST_KEY,attachmentList); - sessionMap.put(DELETED_ATTACHMENT_LIST_KEY,deletedAttachmentList); - - qaGeneralAuthoringDTO.setAttachmentList(attachmentList); - - request.getSession().setAttribute(httpSessionID, sessionMap); + String offlineInstructions = request.getParameter(QaAppConstants.OFFLINE_INSTRUCTIONS); + QaAction.logger.debug("offlineInstructions: " + offlineInstructions); - QaUtils.setFormProperties(request, qaService, - qaAuthoringForm, qaGeneralAuthoringDTO, strToolContentID, defaultContentIdStr, - activeModule, sessionMap, httpSessionID); + sessionMap.put(QaAppConstants.ONLINE_INSTRUCTIONS_KEY, onlineInstructions); + sessionMap.put(QaAppConstants.OFFLINE_INSTRUCTIONS, offlineInstructions); - - qaGeneralAuthoringDTO.setToolContentID(strToolContentID); - qaGeneralAuthoringDTO.setHttpSessionID(httpSessionID); - qaGeneralAuthoringDTO.setActiveModule(activeModule); - qaGeneralAuthoringDTO.setDefaultContentIdStr(defaultContentIdStr); - qaAuthoringForm.setToolContentID(strToolContentID); - qaAuthoringForm.setHttpSessionID(httpSessionID); - qaAuthoringForm.setActiveModule(activeModule); - qaAuthoringForm.setDefaultContentIdStr(defaultContentIdStr); - qaAuthoringForm.setCurrentTab("3"); - + List listQuestionContentDTO = (List) sessionMap.get(QaAppConstants.LIST_QUESTION_CONTENT_DTO_KEY); + QaAction.logger.debug("listQuestionContentDTO: " + listQuestionContentDTO); - logger.debug("before saving final qaGeneralAuthoringDTO: " + qaGeneralAuthoringDTO); - request.setAttribute(QA_GENERAL_AUTHORING_DTO, qaGeneralAuthoringDTO); + request.setAttribute(QaAppConstants.LIST_QUESTION_CONTENT_DTO, listQuestionContentDTO); - qaAuthoringForm.resetUserAction(); - - String strOnlineInstructions= request.getParameter("onlineInstructions"); - String strOfflineInstructions= request.getParameter("offlineInstructions"); - logger.debug("onlineInstructions: " + strOnlineInstructions); - logger.debug("offlineInstructions: " + strOnlineInstructions); - qaAuthoringForm.setOnlineInstructions(strOnlineInstructions); - qaAuthoringForm.setOfflineInstructions(strOfflineInstructions); + String strToolContentID = request.getParameter(AttributeNames.PARAM_TOOL_CONTENT_ID); + QaAction.logger.debug("strToolContentID: " + strToolContentID); - request.setAttribute(TOTAL_QUESTION_COUNT, new Integer(listQuestionContentDTO.size())); - - logger.debug("fwd ing to LOAD_QUESTIONS: " + LOAD_QUESTIONS); - return (mapping.findForward(LOAD_QUESTIONS)); + String defaultContentIdStr = request.getParameter(QaAppConstants.DEFAULT_CONTENT_ID_STR); + QaAction.logger.debug("defaultContentIdStr: " + defaultContentIdStr); + + QaContent qaContent = qaService.loadQa(new Long(strToolContentID).longValue()); + QaAction.logger.debug("qaContent: " + qaContent); + + QaGeneralAuthoringDTO qaGeneralAuthoringDTO = new QaGeneralAuthoringDTO(); + QaAction.logger.debug("qaGeneralAuthoringDTO: " + qaGeneralAuthoringDTO); + qaGeneralAuthoringDTO.setContentFolderID(contentFolderID); + + qaGeneralAuthoringDTO.setOnlineInstructions(onlineInstructions); + qaGeneralAuthoringDTO.setOfflineInstructions(offlineInstructions); + + qaGeneralAuthoringDTO.setSbmtSuccess(new Integer(0).toString()); + + String richTextTitle = request.getParameter(QaAppConstants.TITLE); + String richTextInstructions = request.getParameter(QaAppConstants.INSTRUCTIONS); + + QaAction.logger.debug("richTextTitle: " + richTextTitle); + QaAction.logger.debug("richTextInstructions: " + richTextInstructions); + qaGeneralAuthoringDTO.setActivityTitle(richTextTitle); + qaAuthoringForm.setTitle(richTextTitle); + + qaGeneralAuthoringDTO.setActivityInstructions(richTextInstructions); + + sessionMap.put(QaAppConstants.ACTIVITY_TITLE_KEY, richTextTitle); + sessionMap.put(QaAppConstants.ACTIVITY_INSTRUCTIONS_KEY, richTextInstructions); + + List attachmentList = (List) sessionMap.get(QaAppConstants.ATTACHMENT_LIST_KEY); + QaAction.logger.debug("attachmentList: " + attachmentList); + List deletedAttachmentList = (List) sessionMap.get(QaAppConstants.DELETED_ATTACHMENT_LIST_KEY); + QaAction.logger.debug("deletedAttachmentList: " + deletedAttachmentList); + + addFileToContentRepository(request, qaAuthoringForm, attachmentList, deletedAttachmentList, sessionMap, + qaGeneralAuthoringDTO); + QaAction.logger.debug("post addFileToContentRepository, attachmentList: " + attachmentList); + QaAction.logger.debug("post addFileToContentRepository, deletedAttachmentList: " + deletedAttachmentList); + + sessionMap.put(QaAppConstants.ATTACHMENT_LIST_KEY, attachmentList); + sessionMap.put(QaAppConstants.DELETED_ATTACHMENT_LIST_KEY, deletedAttachmentList); + + qaGeneralAuthoringDTO.setAttachmentList(attachmentList); + + request.getSession().setAttribute(httpSessionID, sessionMap); + + QaUtils.setFormProperties(request, qaService, qaAuthoringForm, qaGeneralAuthoringDTO, strToolContentID, + defaultContentIdStr, activeModule, sessionMap, httpSessionID); + + qaGeneralAuthoringDTO.setToolContentID(strToolContentID); + qaGeneralAuthoringDTO.setHttpSessionID(httpSessionID); + qaGeneralAuthoringDTO.setActiveModule(activeModule); + qaGeneralAuthoringDTO.setDefaultContentIdStr(defaultContentIdStr); + qaAuthoringForm.setToolContentID(strToolContentID); + qaAuthoringForm.setHttpSessionID(httpSessionID); + qaAuthoringForm.setActiveModule(activeModule); + qaAuthoringForm.setDefaultContentIdStr(defaultContentIdStr); + qaAuthoringForm.setCurrentTab("3"); + + QaAction.logger.debug("before saving final qaGeneralAuthoringDTO: " + qaGeneralAuthoringDTO); + request.setAttribute(QaAppConstants.QA_GENERAL_AUTHORING_DTO, qaGeneralAuthoringDTO); + + qaAuthoringForm.resetUserAction(); + + String strOnlineInstructions = request.getParameter("onlineInstructions"); + String strOfflineInstructions = request.getParameter("offlineInstructions"); + QaAction.logger.debug("onlineInstructions: " + strOnlineInstructions); + QaAction.logger.debug("offlineInstructions: " + strOnlineInstructions); + qaAuthoringForm.setOnlineInstructions(strOnlineInstructions); + qaAuthoringForm.setOfflineInstructions(strOfflineInstructions); + + request.setAttribute(QaAppConstants.TOTAL_QUESTION_COUNT, new Integer(listQuestionContentDTO.size())); + + QaAction.logger.debug("fwd ing to LOAD_QUESTIONS: " + QaAppConstants.LOAD_QUESTIONS); + return mapping.findForward(QaAppConstants.LOAD_QUESTIONS); } - - + /** - * deletes a file from the content repository - * ActionForward deleteFile(ActionMapping mapping, - ActionForm form, - HttpServletRequest request, - HttpServletResponse response) throws IOException, - ServletException + * deletes a file from the content repository ActionForward deleteFile(ActionMapping mapping, ActionForm form, + * HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException * * @param mapping * @param form @@ -1702,264 +1606,257 @@ * @throws IOException * @throws ServletException */ - public ActionForward deleteFile(ActionMapping mapping, - ActionForm form, - HttpServletRequest request, - HttpServletResponse response) throws IOException, - ServletException - { - logger.debug("dispatching deleteFile"); - QaAuthoringForm qaAuthoringForm = (QaAuthoringForm) form; - - IQaService qaService =QaServiceProxy.getQaService(getServlet().getServletContext()); - logger.debug("qaService: " + qaService); + public ActionForward deleteFile(ActionMapping mapping, ActionForm form, HttpServletRequest request, + HttpServletResponse response) throws IOException, ServletException { + QaAction.logger.debug("dispatching deleteFile"); + QaAuthoringForm qaAuthoringForm = (QaAuthoringForm) form; - String httpSessionID=qaAuthoringForm.getHttpSessionID(); - logger.debug("httpSessionID: " + httpSessionID); - - SessionMap sessionMap=(SessionMap)request.getSession().getAttribute(httpSessionID); - logger.debug("sessionMap: " + sessionMap); - - String contentFolderID = WebUtil.readStrParam(request, AttributeNames.PARAM_CONTENT_FOLDER_ID); - logger.debug("contentFolderID: " + contentFolderID); - qaAuthoringForm.setContentFolderID(contentFolderID); + IQaService qaService = QaServiceProxy.getQaService(getServlet().getServletContext()); + QaAction.logger.debug("qaService: " + qaService); + String httpSessionID = qaAuthoringForm.getHttpSessionID(); + QaAction.logger.debug("httpSessionID: " + httpSessionID); - String activeModule=request.getParameter(ACTIVE_MODULE); - logger.debug("activeModule: " + activeModule); - - - String strToolContentID=request.getParameter(AttributeNames.PARAM_TOOL_CONTENT_ID); - logger.debug("strToolContentID: " + strToolContentID); - - String defaultContentIdStr=request.getParameter(DEFAULT_CONTENT_ID_STR); - logger.debug("defaultContentIdStr: " + defaultContentIdStr); - - List listQuestionContentDTO=(List)sessionMap.get(LIST_QUESTION_CONTENT_DTO_KEY); - logger.debug("listQuestionContentDTO: " + listQuestionContentDTO); - - request.setAttribute(LIST_QUESTION_CONTENT_DTO,listQuestionContentDTO); - - QaContent qaContent=qaService.loadQa(new Long(strToolContentID).longValue()); - logger.debug("qaContent: " + qaContent); - + SessionMap sessionMap = (SessionMap) request.getSession().getAttribute(httpSessionID); + QaAction.logger.debug("sessionMap: " + sessionMap); - QaGeneralAuthoringDTO qaGeneralAuthoringDTO= new QaGeneralAuthoringDTO(); - logger.debug("qaGeneralAuthoringDTO: " + qaGeneralAuthoringDTO); - qaGeneralAuthoringDTO.setContentFolderID(contentFolderID); - - qaGeneralAuthoringDTO.setSbmtSuccess( new Integer(0).toString()); - - QaUtils.setFormProperties(request, qaService, - qaAuthoringForm, qaGeneralAuthoringDTO, strToolContentID, defaultContentIdStr, activeModule, sessionMap, httpSessionID); + String contentFolderID = WebUtil.readStrParam(request, AttributeNames.PARAM_CONTENT_FOLDER_ID); + QaAction.logger.debug("contentFolderID: " + contentFolderID); + qaAuthoringForm.setContentFolderID(contentFolderID); - - String onlineInstructions=(String) sessionMap.get(ONLINE_INSTRUCTIONS_KEY); - logger.debug("onlineInstructions: " + onlineInstructions); + String activeModule = request.getParameter(QaAppConstants.ACTIVE_MODULE); + QaAction.logger.debug("activeModule: " + activeModule); - String offlineInstructions=(String) sessionMap.get(OFFLINE_INSTRUCTIONS_KEY); - logger.debug("offlineInstructions: " + offlineInstructions); + String strToolContentID = request.getParameter(AttributeNames.PARAM_TOOL_CONTENT_ID); + QaAction.logger.debug("strToolContentID: " + strToolContentID); - qaGeneralAuthoringDTO.setOnlineInstructions(onlineInstructions); - qaGeneralAuthoringDTO.setOfflineInstructions(offlineInstructions); - qaAuthoringForm.setOnlineInstructions(onlineInstructions); - qaAuthoringForm.setOfflineInstructions(offlineInstructions); + String defaultContentIdStr = request.getParameter(QaAppConstants.DEFAULT_CONTENT_ID_STR); + QaAction.logger.debug("defaultContentIdStr: " + defaultContentIdStr); + List listQuestionContentDTO = (List) sessionMap.get(QaAppConstants.LIST_QUESTION_CONTENT_DTO_KEY); + QaAction.logger.debug("listQuestionContentDTO: " + listQuestionContentDTO); - String richTextTitle=(String)sessionMap.get(ACTIVITY_TITLE_KEY); - String richTextInstructions=(String)sessionMap.get(ACTIVITY_INSTRUCTIONS_KEY); - - logger.debug("richTextTitle: " + richTextTitle); - logger.debug("richTextInstructions: " + richTextInstructions); - qaGeneralAuthoringDTO.setActivityTitle(richTextTitle); - qaAuthoringForm.setTitle(richTextTitle); - - qaGeneralAuthoringDTO.setActivityInstructions(richTextInstructions); - - long uuid = WebUtil.readLongParam(request, UUID); + request.setAttribute(QaAppConstants.LIST_QUESTION_CONTENT_DTO, listQuestionContentDTO); - List attachmentList=(List)sessionMap.get(ATTACHMENT_LIST_KEY); - logger.debug("attachmentList: " + attachmentList); - - if(attachmentList == null) - attachmentList = new ArrayList(); + QaContent qaContent = qaService.loadQa(new Long(strToolContentID).longValue()); + QaAction.logger.debug("qaContent: " + qaContent); + QaGeneralAuthoringDTO qaGeneralAuthoringDTO = new QaGeneralAuthoringDTO(); + QaAction.logger.debug("qaGeneralAuthoringDTO: " + qaGeneralAuthoringDTO); + qaGeneralAuthoringDTO.setContentFolderID(contentFolderID); - List deletedAttachmentList=(List)sessionMap.get(DELETED_ATTACHMENT_LIST_KEY); - logger.debug("deletedAttachmentList: " + deletedAttachmentList); + qaGeneralAuthoringDTO.setSbmtSuccess(new Integer(0).toString()); - if(deletedAttachmentList == null) - deletedAttachmentList = new ArrayList(); - - /* move the file's details from the attachment collection to the deleted attachments collection - the attachment will be delete on saving. */ - - deletedAttachmentList = QaUtils.moveToDelete(Long.toString(uuid), attachmentList, deletedAttachmentList ); + QaUtils.setFormProperties(request, qaService, qaAuthoringForm, qaGeneralAuthoringDTO, strToolContentID, + defaultContentIdStr, activeModule, sessionMap, httpSessionID); - - sessionMap.put(ATTACHMENT_LIST_KEY,attachmentList); - sessionMap.put(DELETED_ATTACHMENT_LIST_KEY,deletedAttachmentList); - - qaGeneralAuthoringDTO.setAttachmentList(attachmentList); - - request.getSession().setAttribute(httpSessionID, sessionMap); + String onlineInstructions = (String) sessionMap.get(QaAppConstants.ONLINE_INSTRUCTIONS_KEY); + QaAction.logger.debug("onlineInstructions: " + onlineInstructions); - qaGeneralAuthoringDTO.setToolContentID(strToolContentID); - qaGeneralAuthoringDTO.setHttpSessionID(httpSessionID); - qaGeneralAuthoringDTO.setActiveModule(activeModule); - qaGeneralAuthoringDTO.setDefaultContentIdStr(defaultContentIdStr); - qaAuthoringForm.setToolContentID(strToolContentID); - qaAuthoringForm.setHttpSessionID(httpSessionID); - qaAuthoringForm.setActiveModule(activeModule); - qaAuthoringForm.setDefaultContentIdStr(defaultContentIdStr); - qaAuthoringForm.setCurrentTab("3"); - + String offlineInstructions = (String) sessionMap.get(QaAppConstants.OFFLINE_INSTRUCTIONS_KEY); + QaAction.logger.debug("offlineInstructions: " + offlineInstructions); - logger.debug("before saving final qaGeneralAuthoringDTO: " + qaGeneralAuthoringDTO); - request.setAttribute(QA_GENERAL_AUTHORING_DTO, qaGeneralAuthoringDTO); + qaGeneralAuthoringDTO.setOnlineInstructions(onlineInstructions); + qaGeneralAuthoringDTO.setOfflineInstructions(offlineInstructions); + qaAuthoringForm.setOnlineInstructions(onlineInstructions); + qaAuthoringForm.setOfflineInstructions(offlineInstructions); - request.setAttribute(TOTAL_QUESTION_COUNT, new Integer(listQuestionContentDTO.size())); - - qaAuthoringForm.resetUserAction(); - logger.debug("fwd ing to LOAD_QUESTIONS: " + LOAD_QUESTIONS); - - return (mapping.findForward(LOAD_QUESTIONS)); + String richTextTitle = (String) sessionMap.get(QaAppConstants.ACTIVITY_TITLE_KEY); + String richTextInstructions = (String) sessionMap.get(QaAppConstants.ACTIVITY_INSTRUCTIONS_KEY); + + QaAction.logger.debug("richTextTitle: " + richTextTitle); + QaAction.logger.debug("richTextInstructions: " + richTextInstructions); + qaGeneralAuthoringDTO.setActivityTitle(richTextTitle); + qaAuthoringForm.setTitle(richTextTitle); + + qaGeneralAuthoringDTO.setActivityInstructions(richTextInstructions); + + long uuid = WebUtil.readLongParam(request, QaAppConstants.UUID); + + List attachmentList = (List) sessionMap.get(QaAppConstants.ATTACHMENT_LIST_KEY); + QaAction.logger.debug("attachmentList: " + attachmentList); + + if (attachmentList == null) { + attachmentList = new ArrayList(); + } + + List deletedAttachmentList = (List) sessionMap.get(QaAppConstants.DELETED_ATTACHMENT_LIST_KEY); + QaAction.logger.debug("deletedAttachmentList: " + deletedAttachmentList); + + if (deletedAttachmentList == null) { + deletedAttachmentList = new ArrayList(); + } + + /* + * move the file's details from the attachment collection to the deleted attachments collection the attachment + * will be delete on saving. + */ + + deletedAttachmentList = QaUtils.moveToDelete(Long.toString(uuid), attachmentList, deletedAttachmentList); + + sessionMap.put(QaAppConstants.ATTACHMENT_LIST_KEY, attachmentList); + sessionMap.put(QaAppConstants.DELETED_ATTACHMENT_LIST_KEY, deletedAttachmentList); + + qaGeneralAuthoringDTO.setAttachmentList(attachmentList); + + request.getSession().setAttribute(httpSessionID, sessionMap); + + qaGeneralAuthoringDTO.setToolContentID(strToolContentID); + qaGeneralAuthoringDTO.setHttpSessionID(httpSessionID); + qaGeneralAuthoringDTO.setActiveModule(activeModule); + qaGeneralAuthoringDTO.setDefaultContentIdStr(defaultContentIdStr); + qaAuthoringForm.setToolContentID(strToolContentID); + qaAuthoringForm.setHttpSessionID(httpSessionID); + qaAuthoringForm.setActiveModule(activeModule); + qaAuthoringForm.setDefaultContentIdStr(defaultContentIdStr); + qaAuthoringForm.setCurrentTab("3"); + + QaAction.logger.debug("before saving final qaGeneralAuthoringDTO: " + qaGeneralAuthoringDTO); + request.setAttribute(QaAppConstants.QA_GENERAL_AUTHORING_DTO, qaGeneralAuthoringDTO); + + request.setAttribute(QaAppConstants.TOTAL_QUESTION_COUNT, new Integer(listQuestionContentDTO.size())); + + qaAuthoringForm.resetUserAction(); + QaAction.logger.debug("fwd ing to LOAD_QUESTIONS: " + QaAppConstants.LOAD_QUESTIONS); + + return mapping.findForward(QaAppConstants.LOAD_QUESTIONS); } - - + /** * persists error messages to request scope * * persistError(HttpServletRequest request, String message) + * * @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("add " + message +" to ActionMessages:"); - saveErrors(request,errors); - } - - + public void persistError(HttpServletRequest request, String message) { + ActionMessages errors = new ActionMessages(); + errors.add(Globals.ERROR_KEY, new ActionMessage(message)); + QaAction.logger.debug("add " + message + " to ActionMessages:"); + saveErrors(request, errors); + } + /** * addFileToContentRepository(HttpServletRequest request, QaAuthoringForm qaAuthoringForm) + * * @param request * @param qaAuthoringForm */ - public void addFileToContentRepository(HttpServletRequest request, QaAuthoringForm qaAuthoringForm, - List attachmentList, List deletedAttachmentList, SessionMap sessionMap, - QaGeneralAuthoringDTO qaGeneralAuthoringDTO) - { - logger.debug("attempt addFileToContentRepository"); - logger.debug("attachmentList: " + attachmentList); - logger.debug("deletedAttachmentList: " + deletedAttachmentList); - IQaService qaService = QaServiceProxy.getQaService(getServlet().getServletContext()); - logger.debug("qaService: " + qaService); - - if(attachmentList == null) - attachmentList = new ArrayList(); - - if(deletedAttachmentList == null) - deletedAttachmentList = new ArrayList(); - - FormFile uploadedFile = null; - boolean isOnlineFile = false; - String fileType = null; - if(qaAuthoringForm.getTheOfflineFile() != null && qaAuthoringForm.getTheOfflineFile().getFileSize() > 0 ){ - logger.debug("theOfflineFile is available: "); - uploadedFile = qaAuthoringForm.getTheOfflineFile(); - logger.debug("uploadedFile: " + uploadedFile); - fileType = IToolContentHandler.TYPE_OFFLINE; - } - else if(qaAuthoringForm.getTheOnlineFile() != null && qaAuthoringForm.getTheOnlineFile().getFileSize() > 0 ){ - logger.debug("theOnlineFile is available: "); - uploadedFile = qaAuthoringForm.getTheOnlineFile(); - logger.debug("uploadedFile: " + uploadedFile); - isOnlineFile = true; - fileType = IToolContentHandler.TYPE_ONLINE; - } - else - /*no file uploaded*/ - return; - - - //validate upload file size. - ActionMessages errors = new ActionMessages(); - FileValidatorUtil.validateFileSize(uploadedFile, true, errors ); - if(!errors.isEmpty()){ - this.saveErrors(request, errors); - return; - } - - logger.debug("uploadedFile.getFileName(): " + uploadedFile.getFileName()); - - /* if a file with the same name already exists then move the old one to deleted */ - deletedAttachmentList = QaUtils.moveToDelete(uploadedFile.getFileName(), isOnlineFile, attachmentList, deletedAttachmentList ); - logger.debug("deletedAttachmentList: " + deletedAttachmentList); + public void addFileToContentRepository(HttpServletRequest request, QaAuthoringForm qaAuthoringForm, + List attachmentList, List deletedAttachmentList, SessionMap sessionMap, + QaGeneralAuthoringDTO qaGeneralAuthoringDTO) { + QaAction.logger.debug("attempt addFileToContentRepository"); + QaAction.logger.debug("attachmentList: " + attachmentList); + QaAction.logger.debug("deletedAttachmentList: " + deletedAttachmentList); + IQaService qaService = QaServiceProxy.getQaService(getServlet().getServletContext()); + QaAction.logger.debug("qaService: " + qaService); - try - { - /* This is a new file and so is saved to the content repository. Add it to the - attachments collection, but don't add it to the tool's tables yet. - */ - NodeKey node = getToolContentHandler().uploadFile(uploadedFile.getInputStream(), uploadedFile.getFileName(), - uploadedFile.getContentType(), fileType); - QaUploadedFile file = new QaUploadedFile(); - String fileName=uploadedFile.getFileName(); - logger.debug("fileName: " + fileName); - logger.debug("fileName length: " + fileName.length()); - - if ((fileName != null) && (fileName.length() > 30)) - { - fileName=fileName.substring(0, 31); - logger.debug("shortened fileName: " + fileName); - } - - file.setFileName(fileName); - file.setFileOnline(isOnlineFile); - file.setUuid(node.getUuid().toString()); - /* file.setVersionId(node.getVersion()); */ - - /* add the files to the attachment collection - if one existed, it should have already been removed. */ - attachmentList.add(file); - - /* reset the fields so that more files can be uploaded */ - qaAuthoringForm.setTheOfflineFile(null); - qaAuthoringForm.setTheOnlineFile(null); - } - catch (FileNotFoundException e) { - logger.error("Unable to uploadfile",e); - throw new RuntimeException("Unable to upload file, exception was "+e.getMessage()); - } catch (IOException e) { - logger.error("Unable to uploadfile",e); - throw new RuntimeException("Unable to upload file, exception was "+e.getMessage()); - } catch (RepositoryCheckedException e) { - logger.error("Unable to uploadfile",e); - throw new RuntimeException("Unable to upload file, exception was "+e.getMessage()); - } + if (attachmentList == null) { + attachmentList = new ArrayList(); + } + + if (deletedAttachmentList == null) { + deletedAttachmentList = new ArrayList(); + } + + FormFile uploadedFile = null; + boolean isOnlineFile = false; + String fileType = null; + if (qaAuthoringForm.getTheOfflineFile() != null && qaAuthoringForm.getTheOfflineFile().getFileSize() > 0) { + QaAction.logger.debug("theOfflineFile is available: "); + uploadedFile = qaAuthoringForm.getTheOfflineFile(); + QaAction.logger.debug("uploadedFile: " + uploadedFile); + fileType = IToolContentHandler.TYPE_OFFLINE; + } else if (qaAuthoringForm.getTheOnlineFile() != null && qaAuthoringForm.getTheOnlineFile().getFileSize() > 0) { + QaAction.logger.debug("theOnlineFile is available: "); + uploadedFile = qaAuthoringForm.getTheOnlineFile(); + QaAction.logger.debug("uploadedFile: " + uploadedFile); + isOnlineFile = true; + fileType = IToolContentHandler.TYPE_ONLINE; + } else { + /* no file uploaded */ + return; + } + + // validate upload file size. + ActionMessages errors = new ActionMessages(); + FileValidatorUtil.validateFileSize(uploadedFile, true, errors); + if (!errors.isEmpty()) { + this.saveErrors(request, errors); + return; + } + + QaAction.logger.debug("uploadedFile.getFileName(): " + uploadedFile.getFileName()); + + /* + * if a file with the same name already exists then move the old one to deleted + */ + deletedAttachmentList = QaUtils.moveToDelete(uploadedFile.getFileName(), isOnlineFile, attachmentList, + deletedAttachmentList); + QaAction.logger.debug("deletedAttachmentList: " + deletedAttachmentList); + + try { + /* + * This is a new file and so is saved to the content repository. Add it to the attachments collection, but + * don't add it to the tool's tables yet. + */ + NodeKey node = getToolContentHandler().uploadFile(uploadedFile.getInputStream(), + uploadedFile.getFileName(), uploadedFile.getContentType(), fileType); + QaUploadedFile file = new QaUploadedFile(); + String fileName = uploadedFile.getFileName(); + QaAction.logger.debug("fileName: " + fileName); + QaAction.logger.debug("fileName length: " + fileName.length()); + + if (fileName != null && fileName.length() > 30) { + fileName = fileName.substring(0, 31); + QaAction.logger.debug("shortened fileName: " + fileName); + } + + file.setFileName(fileName); + file.setFileOnline(isOnlineFile); + file.setUuid(node.getUuid().toString()); + /* file.setVersionId(node.getVersion()); */ + + /* + * add the files to the attachment collection - if one existed, it should have already been removed. + */ + attachmentList.add(file); + + /* reset the fields so that more files can be uploaded */ + qaAuthoringForm.setTheOfflineFile(null); + qaAuthoringForm.setTheOnlineFile(null); + } catch (FileNotFoundException e) { + QaAction.logger.error("Unable to uploadfile", e); + throw new RuntimeException("Unable to upload file, exception was " + e.getMessage()); + } catch (IOException e) { + QaAction.logger.error("Unable to uploadfile", e); + throw new RuntimeException("Unable to upload file, exception was " + e.getMessage()); + } catch (RepositoryCheckedException e) { + QaAction.logger.error("Unable to uploadfile", e); + throw new RuntimeException("Unable to upload file, exception was " + e.getMessage()); + } } - - + /** * QaToolContentHandler getToolContentHandler() + * * @return */ - private QaToolContentHandler getToolContentHandler() - { - if ( toolContentHandler == null ) { - WebApplicationContext wac = WebApplicationContextUtils.getRequiredWebApplicationContext(getServlet().getServletContext()); - toolContentHandler = (QaToolContentHandler) wac.getBean("qaToolContentHandler"); - } - return toolContentHandler; + private QaToolContentHandler getToolContentHandler() { + if (toolContentHandler == null) { + WebApplicationContext wac = WebApplicationContextUtils.getRequiredWebApplicationContext(getServlet() + .getServletContext()); + toolContentHandler = (QaToolContentHandler) wac.getBean("qaToolContentHandler"); + } + return toolContentHandler; } /** * - * Go through the attachments collections. Remove any content repository or tool objects - * matching entries in the the deletedAttachments collection, add any new attachments in the - * attachments collection. Clear the deletedAttachments collection, ready for new editing. + * Go through the attachments collections. Remove any content repository or tool objects matching entries in the the + * deletedAttachments collection, add any new attachments in the attachments collection. Clear the + * deletedAttachments collection, ready for new editing. * * @param qaContent * @param attachmentList @@ -1968,75 +1865,66 @@ * @param request * @return */ - private List saveAttachments (QaContent qaContent, - List attachmentList, List deletedAttachmentList, - ActionMapping mapping, HttpServletRequest request) { + private List saveAttachments(QaContent qaContent, List attachmentList, List deletedAttachmentList, + ActionMapping mapping, HttpServletRequest request) { - logger.debug("start saveAttachments, attachmentList " + attachmentList); - logger.debug("start deletedAttachmentList, deletedAttachmentList " + deletedAttachmentList); - - if(attachmentList==null || deletedAttachmentList==null) - return null; - - IQaService qaService = QaServiceProxy.getQaService(getServlet().getServletContext()); - logger.debug("qaService: " + qaService); - - if ( deletedAttachmentList != null ) { - logger.debug("deletedAttachmentList is iterated..."); - Iterator iter = deletedAttachmentList.iterator(); - while (iter.hasNext()) { - QaUploadedFile attachment = (QaUploadedFile) iter.next(); - logger.debug("attachment: " + attachment); - - /* remove entry from db, leave in content repository. */ + QaAction.logger.debug("start saveAttachments, attachmentList " + attachmentList); + QaAction.logger.debug("start deletedAttachmentList, deletedAttachmentList " + deletedAttachmentList); - if ( attachment.getSubmissionId() != null ) { - qaService.removeFile(attachment.getSubmissionId()); - } - } - deletedAttachmentList.clear(); - logger.error("cleared attachment list."); - } - - if ( attachmentList != null ) - { - logger.debug("attachmentList is iterated..."); - Iterator iter = attachmentList.iterator(); - while (iter.hasNext()) { - QaUploadedFile attachment = (QaUploadedFile) iter.next(); - logger.debug("attachment: " + attachment); - logger.debug("attachment submission id: " + attachment.getSubmissionId()); + if (attachmentList == null || deletedAttachmentList == null) { + return null; + } - if ( attachment.getSubmissionId() == null ) { - /* add entry to tool table - file already in content repository */ - logger.debug("calling persistFile with attachment: " + attachment); - qaService.persistFile(qaContent, attachment); - } - } - } - - return deletedAttachmentList; - } - - - public ActionForward editActivity(ActionMapping mapping, - ActionForm form, - HttpServletRequest request, - HttpServletResponse response) throws IOException, - ServletException - { - logger.debug("dispatching proxy editActivity..."); - return null; + IQaService qaService = QaServiceProxy.getQaService(getServlet().getServletContext()); + QaAction.logger.debug("qaService: " + qaService); + + if (deletedAttachmentList != null) { + QaAction.logger.debug("deletedAttachmentList is iterated..."); + Iterator iter = deletedAttachmentList.iterator(); + while (iter.hasNext()) { + QaUploadedFile attachment = (QaUploadedFile) iter.next(); + QaAction.logger.debug("attachment: " + attachment); + + /* remove entry from db, leave in content repository. */ + + if (attachment.getSubmissionId() != null) { + qaService.removeFile(attachment.getSubmissionId()); + } + } + deletedAttachmentList.clear(); + QaAction.logger.error("cleared attachment list."); } - + if (attachmentList != null) { + QaAction.logger.debug("attachmentList is iterated..."); + Iterator iter = attachmentList.iterator(); + while (iter.hasNext()) { + QaUploadedFile attachment = (QaUploadedFile) iter.next(); + QaAction.logger.debug("attachment: " + attachment); + QaAction.logger.debug("attachment submission id: " + attachment.getSubmissionId()); + + if (attachment.getSubmissionId() == null) { + /* + * add entry to tool table - file already in content repository + */ + QaAction.logger.debug("calling persistFile with attachment: " + attachment); + qaService.persistFile(qaContent, attachment); + } + } + } + + return deletedAttachmentList; + } + + public ActionForward editActivity(ActionMapping mapping, ActionForm form, HttpServletRequest request, + HttpServletResponse response) throws IOException, ServletException { + QaAction.logger.debug("dispatching proxy editActivity..."); + return null; + } + /** - * calls monitoring action summary screen generation - * ActionForward getSummary(ActionMapping mapping, - ActionForm form, - HttpServletRequest request, - HttpServletResponse response) throws IOException, - ServletException + * calls monitoring action summary screen generation ActionForward getSummary(ActionMapping mapping, ActionForm + * form, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException * * @param mapping * @param form @@ -2046,25 +1934,16 @@ * @throws IOException * @throws ServletException */ - public ActionForward getSummary(ActionMapping mapping, - ActionForm form, - HttpServletRequest request, - HttpServletResponse response) throws IOException, - ServletException - { - logger.debug("dispatching proxy getSummary...start with monitoringStarter" + request); - QaMonitoringAction qaMonitoringAction= new QaMonitoringAction(); - return qaMonitoringAction.getSummary(mapping, form, request, response); - } + public ActionForward getSummary(ActionMapping mapping, ActionForm form, HttpServletRequest request, + HttpServletResponse response) throws IOException, ServletException { + QaAction.logger.debug("dispatching proxy getSummary...start with monitoringStarter" + request); + QaMonitoringAction qaMonitoringAction = new QaMonitoringAction(); + return qaMonitoringAction.getSummary(mapping, form, request, response); + } - /** - * calls monitoring action instructions screen generation - * ActionForward getInstructions(ActionMapping mapping, - ActionForm form, - HttpServletRequest request, - HttpServletResponse response) throws IOException, - ServletException + * calls monitoring action instructions screen generation ActionForward getInstructions(ActionMapping mapping, + * ActionForm form, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException * * @param mapping * @param form @@ -2074,25 +1953,18 @@ * @throws IOException * @throws ServletException */ - public ActionForward getInstructions(ActionMapping mapping, - ActionForm form, - HttpServletRequest request, - HttpServletResponse response) throws IOException, - ServletException - { - logger.debug("dispatching proxy getInstructions..." + request); - QaMonitoringAction qaMonitoringAction= new QaMonitoringAction(); - return qaMonitoringAction.getInstructions(mapping, form, request, response); - } + public ActionForward getInstructions(ActionMapping mapping, ActionForm form, HttpServletRequest request, + HttpServletResponse response) throws IOException, ServletException { + QaAction.logger.debug("dispatching proxy getInstructions..." + request); + QaMonitoringAction qaMonitoringAction = new QaMonitoringAction(); + return qaMonitoringAction.getInstructions(mapping, form, request, response); + } /** * calls monitoring action stats screen generation * - * ActionForward getStats(ActionMapping mapping, - ActionForm form, - HttpServletRequest request, - HttpServletResponse response) throws IOException, - ServletException + * ActionForward getStats(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse + * response) throws IOException, ServletException * * @param mapping * @param form @@ -2102,27 +1974,18 @@ * @throws IOException * @throws ServletException */ - public ActionForward getStats(ActionMapping mapping, - ActionForm form, - HttpServletRequest request, - HttpServletResponse response) throws IOException, - ServletException - { - logger.debug("dispatching proxy getStats..." + request); - QaMonitoringAction qaMonitoringAction= new QaMonitoringAction(); - //return qaMonitoringAction.getStats(mapping, form, request, response, "All"); - return null; - } + public ActionForward getStats(ActionMapping mapping, ActionForm form, HttpServletRequest request, + HttpServletResponse response) throws IOException, ServletException { + QaAction.logger.debug("dispatching proxy getStats..." + request); + QaMonitoringAction qaMonitoringAction = new QaMonitoringAction(); + // return qaMonitoringAction.getStats(mapping, form, request, response, + // "All"); + return null; + } - /** - * generates Edit Activity screen - * ActionForward editActivityQuestions(ActionMapping mapping, - ActionForm form, - HttpServletRequest request, - HttpServletResponse response) throws IOException, - ServletException, - ToolException + * generates Edit Activity screen ActionForward editActivityQuestions(ActionMapping mapping, ActionForm form, + * HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException, ToolException * * @param mapping * @param form @@ -2133,150 +1996,137 @@ * @throws ServletException * @throws ToolException */ - public ActionForward editActivityQuestions(ActionMapping mapping, - ActionForm form, - HttpServletRequest request, - HttpServletResponse response) throws IOException, - ServletException, - ToolException - { - logger.debug("dispatching editActivityQuestions..."); - - QaAuthoringForm qaAuthoringForm = (QaAuthoringForm) form; - logger.debug("qaAuthoringForm: " + qaAuthoringForm); - - IQaService qaService =QaServiceProxy.getQaService(getServlet().getServletContext()); - logger.debug("qaService: " + qaService); + public ActionForward editActivityQuestions(ActionMapping mapping, ActionForm form, HttpServletRequest request, + HttpServletResponse response) throws IOException, ServletException, ToolException { + QaAction.logger.debug("dispatching editActivityQuestions..."); - String httpSessionID=qaAuthoringForm.getHttpSessionID(); - logger.debug("httpSessionID: " + httpSessionID); - - SessionMap sessionMap=(SessionMap)request.getSession().getAttribute(httpSessionID); - logger.debug("sessionMap: " + sessionMap); - - String contentFolderID = WebUtil.readStrParam(request, AttributeNames.PARAM_CONTENT_FOLDER_ID); - logger.debug("contentFolderID: " + contentFolderID); - qaAuthoringForm.setContentFolderID(contentFolderID); + QaAuthoringForm qaAuthoringForm = (QaAuthoringForm) form; + QaAction.logger.debug("qaAuthoringForm: " + qaAuthoringForm); + IQaService qaService = QaServiceProxy.getQaService(getServlet().getServletContext()); + QaAction.logger.debug("qaService: " + qaService); - String activeModule=request.getParameter(ACTIVE_MODULE); - logger.debug("activeModule: " + activeModule); - - String strToolContentID=request.getParameter(AttributeNames.PARAM_TOOL_CONTENT_ID); - logger.debug("strToolContentID: " + strToolContentID); - - String defaultContentIdStr=request.getParameter(DEFAULT_CONTENT_ID_STR); - logger.debug("defaultContentIdStr: " + defaultContentIdStr); - - QaContent qaContent=qaService.loadQa(new Long(strToolContentID).longValue()); - logger.debug("qaContent: " + qaContent); - - QaGeneralAuthoringDTO qaGeneralAuthoringDTO= new QaGeneralAuthoringDTO(); - logger.debug("qaGeneralAuthoringDTO: " + qaGeneralAuthoringDTO); - qaGeneralAuthoringDTO.setContentFolderID(contentFolderID); + String httpSessionID = qaAuthoringForm.getHttpSessionID(); + QaAction.logger.debug("httpSessionID: " + httpSessionID); - - logger.debug("title: " + qaContent.getTitle()); - logger.debug("instructions: " + qaContent.getInstructions()); - - qaGeneralAuthoringDTO.setActivityTitle(qaContent.getTitle()); - qaAuthoringForm.setTitle(qaContent.getTitle()); - - qaGeneralAuthoringDTO.setActivityInstructions(qaContent.getInstructions()); - - sessionMap.put(ACTIVITY_TITLE_KEY, qaContent.getTitle()); - sessionMap.put(ACTIVITY_INSTRUCTIONS_KEY, qaContent.getInstructions()); - - - - /* determine whether the request is from Monitoring url Edit Activity*/ - String sourceMcStarter = (String) request.getAttribute(SOURCE_MC_STARTER); - logger.debug("sourceMcStarter: " + sourceMcStarter); + SessionMap sessionMap = (SessionMap) request.getSession().getAttribute(httpSessionID); + QaAction.logger.debug("sessionMap: " + sessionMap); - qaAuthoringForm.setDefineLaterInEditMode(new Boolean(true).toString()); - qaGeneralAuthoringDTO.setDefineLaterInEditMode(new Boolean(true).toString()); - - boolean isContentInUse=QaUtils.isContentInUse(qaContent); - logger.debug("isContentInUse:" + isContentInUse); - - qaGeneralAuthoringDTO.setMonitoredContentInUse(new Boolean(false).toString()); - if (isContentInUse == true) - { - logger.debug("monitoring url does not allow editActivity since the content is in use."); - persistError(request,"error.content.inUse"); - qaGeneralAuthoringDTO.setMonitoredContentInUse(new Boolean(true).toString()); - } - - EditActivityDTO editActivityDTO = new EditActivityDTO(); - logger.debug("isContentInUse:" + isContentInUse); - if (isContentInUse == true) - { - editActivityDTO.setMonitoredContentInUse(new Boolean(true).toString()); - } - request.setAttribute(EDIT_ACTIVITY_DTO, editActivityDTO); + String contentFolderID = WebUtil.readStrParam(request, AttributeNames.PARAM_CONTENT_FOLDER_ID); + QaAction.logger.debug("contentFolderID: " + contentFolderID); + qaAuthoringForm.setContentFolderID(contentFolderID); - QaUtils.setDefineLater(request, true, strToolContentID, qaService); + String activeModule = request.getParameter(QaAppConstants.ACTIVE_MODULE); + QaAction.logger.debug("activeModule: " + activeModule); - QaUtils.setFormProperties(request, qaService, - qaAuthoringForm, qaGeneralAuthoringDTO, strToolContentID, defaultContentIdStr, activeModule, sessionMap, httpSessionID); + String strToolContentID = request.getParameter(AttributeNames.PARAM_TOOL_CONTENT_ID); + QaAction.logger.debug("strToolContentID: " + strToolContentID); + String defaultContentIdStr = request.getParameter(QaAppConstants.DEFAULT_CONTENT_ID_STR); + QaAction.logger.debug("defaultContentIdStr: " + defaultContentIdStr); - qaGeneralAuthoringDTO.setToolContentID(strToolContentID); - qaGeneralAuthoringDTO.setActiveModule(activeModule); - qaGeneralAuthoringDTO.setDefaultContentIdStr(defaultContentIdStr); - qaAuthoringForm.setToolContentID(strToolContentID); - qaAuthoringForm.setActiveModule(activeModule); - qaAuthoringForm.setDefaultContentIdStr(defaultContentIdStr); - qaAuthoringForm.setCurrentTab("1"); + QaContent qaContent = qaService.loadQa(new Long(strToolContentID).longValue()); + QaAction.logger.debug("qaContent: " + qaContent); - List listQuestionContentDTO= new LinkedList(); + QaGeneralAuthoringDTO qaGeneralAuthoringDTO = new QaGeneralAuthoringDTO(); + QaAction.logger.debug("qaGeneralAuthoringDTO: " + qaGeneralAuthoringDTO); + qaGeneralAuthoringDTO.setContentFolderID(contentFolderID); - Iterator queIterator=qaContent.getQaQueContents().iterator(); - while (queIterator.hasNext()) - { - QaQuestionContentDTO qaQuestionContentDTO=new QaQuestionContentDTO(); - - QaQueContent qaQueContent=(QaQueContent) queIterator.next(); - if (qaQueContent != null) - { - logger.debug("question: " + qaQueContent.getQuestion()); - logger.debug("displayorder: " + new Integer(qaQueContent.getDisplayOrder()).toString()); - logger.debug("feedback: " + qaQueContent.getFeedback()); - - qaQuestionContentDTO.setQuestion(qaQueContent.getQuestion()); - qaQuestionContentDTO.setDisplayOrder(new Integer(qaQueContent.getDisplayOrder()).toString()); - qaQuestionContentDTO.setFeedback(qaQueContent.getFeedback()); - listQuestionContentDTO.add(qaQuestionContentDTO); - } - } - logger.debug("listQuestionContentDTO: " + listQuestionContentDTO); - request.setAttribute(LIST_QUESTION_CONTENT_DTO,listQuestionContentDTO); - sessionMap.put(LIST_QUESTION_CONTENT_DTO_KEY, listQuestionContentDTO); - - request.setAttribute(TOTAL_QUESTION_COUNT, new Integer(listQuestionContentDTO.size())); - request.getSession().setAttribute(httpSessionID, sessionMap); - - logger.debug("before fwding to jsp, qaAuthoringForm: " + qaAuthoringForm); - logger.debug("before saving final qaGeneralAuthoringDTO: " + qaGeneralAuthoringDTO); - request.setAttribute(QA_GENERAL_AUTHORING_DTO, qaGeneralAuthoringDTO); + QaAction.logger.debug("title: " + qaContent.getTitle()); + QaAction.logger.debug("instructions: " + qaContent.getInstructions()); - logger.debug("forwarding to : " + LOAD_QUESTIONS); - return mapping.findForward(LOAD_QUESTIONS); + qaGeneralAuthoringDTO.setActivityTitle(qaContent.getTitle()); + qaAuthoringForm.setTitle(qaContent.getTitle()); + + qaGeneralAuthoringDTO.setActivityInstructions(qaContent.getInstructions()); + + sessionMap.put(QaAppConstants.ACTIVITY_TITLE_KEY, qaContent.getTitle()); + sessionMap.put(QaAppConstants.ACTIVITY_INSTRUCTIONS_KEY, qaContent.getInstructions()); + + /* determine whether the request is from Monitoring url Edit Activity */ + String sourceMcStarter = (String) request.getAttribute(QaAppConstants.SOURCE_MC_STARTER); + QaAction.logger.debug("sourceMcStarter: " + sourceMcStarter); + + qaAuthoringForm.setDefineLaterInEditMode(new Boolean(true).toString()); + qaGeneralAuthoringDTO.setDefineLaterInEditMode(new Boolean(true).toString()); + + boolean isContentInUse = QaUtils.isContentInUse(qaContent); + QaAction.logger.debug("isContentInUse:" + isContentInUse); + + qaGeneralAuthoringDTO.setMonitoredContentInUse(new Boolean(false).toString()); + if (isContentInUse == true) { + QaAction.logger.debug("monitoring url does not allow editActivity since the content is in use."); + persistError(request, "error.content.inUse"); + qaGeneralAuthoringDTO.setMonitoredContentInUse(new Boolean(true).toString()); + } + + EditActivityDTO editActivityDTO = new EditActivityDTO(); + QaAction.logger.debug("isContentInUse:" + isContentInUse); + if (isContentInUse == true) { + editActivityDTO.setMonitoredContentInUse(new Boolean(true).toString()); + } + request.setAttribute(QaAppConstants.EDIT_ACTIVITY_DTO, editActivityDTO); + + QaUtils.setDefineLater(request, true, strToolContentID, qaService); + + QaUtils.setFormProperties(request, qaService, qaAuthoringForm, qaGeneralAuthoringDTO, strToolContentID, + defaultContentIdStr, activeModule, sessionMap, httpSessionID); + + qaGeneralAuthoringDTO.setToolContentID(strToolContentID); + qaGeneralAuthoringDTO.setActiveModule(activeModule); + qaGeneralAuthoringDTO.setDefaultContentIdStr(defaultContentIdStr); + qaAuthoringForm.setToolContentID(strToolContentID); + qaAuthoringForm.setActiveModule(activeModule); + qaAuthoringForm.setDefaultContentIdStr(defaultContentIdStr); + qaAuthoringForm.setCurrentTab("1"); + + List listQuestionContentDTO = new LinkedList(); + + Iterator queIterator = qaContent.getQaQueContents().iterator(); + while (queIterator.hasNext()) { + QaQuestionContentDTO qaQuestionContentDTO = new QaQuestionContentDTO(); + + QaQueContent qaQueContent = (QaQueContent) queIterator.next(); + if (qaQueContent != null) { + QaAction.logger.debug("question: " + qaQueContent.getQuestion()); + QaAction.logger.debug("displayorder: " + new Integer(qaQueContent.getDisplayOrder()).toString()); + QaAction.logger.debug("feedback: " + qaQueContent.getFeedback()); + + qaQuestionContentDTO.setQuestion(qaQueContent.getQuestion()); + qaQuestionContentDTO.setDisplayOrder(new Integer(qaQueContent.getDisplayOrder()).toString()); + qaQuestionContentDTO.setFeedback(qaQueContent.getFeedback()); + listQuestionContentDTO.add(qaQuestionContentDTO); + } + } + QaAction.logger.debug("listQuestionContentDTO: " + listQuestionContentDTO); + request.setAttribute(QaAppConstants.LIST_QUESTION_CONTENT_DTO, listQuestionContentDTO); + sessionMap.put(QaAppConstants.LIST_QUESTION_CONTENT_DTO_KEY, listQuestionContentDTO); + + request.setAttribute(QaAppConstants.TOTAL_QUESTION_COUNT, new Integer(listQuestionContentDTO.size())); + request.getSession().setAttribute(httpSessionID, sessionMap); + + QaAction.logger.debug("before fwding to jsp, qaAuthoringForm: " + qaAuthoringForm); + QaAction.logger.debug("before saving final qaGeneralAuthoringDTO: " + qaGeneralAuthoringDTO); + request.setAttribute(QaAppConstants.QA_GENERAL_AUTHORING_DTO, qaGeneralAuthoringDTO); + + QaAction.logger.debug("forwarding to : " + QaAppConstants.LOAD_QUESTIONS); + return mapping.findForward(QaAppConstants.LOAD_QUESTIONS); } /** * existsContent + * * @param toolContentID * @param qaService * @return */ - protected boolean existsContent(long toolContentID, IQaService qaService) - { - QaContent qaContent=qaService.loadQa(toolContentID); - if (qaContent == null) - return false; - - return true; + protected boolean existsContent(long toolContentID, IQaService qaService) { + QaContent qaContent = qaService.loadQa(toolContentID); + if (qaContent == null) { + return false; } - + + return true; + } + } Index: lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/QaAuthoringConditionAction.java =================================================================== diff -u --- lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/QaAuthoringConditionAction.java (revision 0) +++ lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/QaAuthoringConditionAction.java (revision 0af4ed13b963a588f3499b080801863d57f8ad95) @@ -0,0 +1,484 @@ +/**************************************************************** + * Copyright (C) 2005 LAMS Foundation (http://lamsfoundation.org) + * ============================================================= + * License Information: http://lamsfoundation.org/licensing/lams/2.0/ + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2.0 + * as published by the Free Software Foundation. + * + * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 * USA + * + * http://www.gnu.org/licenses/gpl.txt + * **************************************************************** + */ + +/* $$Id$$ */ +package org.lamsfoundation.lams.tool.qa.web; + +import java.util.ArrayList; +import java.util.LinkedList; +import java.util.List; +import java.util.SortedSet; +import java.util.TreeSet; + +import javax.servlet.ServletException; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.apache.commons.lang.StringUtils; +import org.apache.commons.lang.math.NumberUtils; +import org.apache.struts.action.Action; +import org.apache.struts.action.ActionErrors; +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.util.LabelValueBean; +import org.lamsfoundation.lams.tool.qa.QaAppConstants; +import org.lamsfoundation.lams.tool.qa.QaCondition; +import org.lamsfoundation.lams.tool.qa.QaQuestionContentDTO; +import org.lamsfoundation.lams.tool.qa.service.IQaService; +import org.lamsfoundation.lams.tool.qa.service.QaServiceProxy; +import org.lamsfoundation.lams.tool.qa.util.QaConditionComparator; +import org.lamsfoundation.lams.util.WebUtil; +import org.lamsfoundation.lams.web.util.SessionMap; +import org.springframework.web.context.WebApplicationContext; +import org.springframework.web.context.support.WebApplicationContextUtils; + +/** + * Auxiliary action in author mode. It contains operations with QaCondition. The rest of operations are located in + * QaAction action. + * + * @author Marcin Cieslak + * @see org.lamsfoundation.lams.tool.qa.web.QaAction + */ +public class QaAuthoringConditionAction extends Action { + + @Override + public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, + HttpServletResponse response) throws Exception { + + String param = mapping.getParameter(); + + if (param.equals("newConditionInit")) { + return newConditionInit(mapping, form, request, response); + } + if (param.equals("editCondition")) { + return editCondition(mapping, form, request, response); + } + if (param.equals("saveOrUpdateCondition")) { + return saveOrUpdateCondition(mapping, form, request, response); + } + if (param.equals("removeCondition")) { + return removeCondition(mapping, form, request, response); + } + if (param.equals("upCondition")) { + return upCondition(mapping, form, request, response); + } + if (param.equals("downCondition")) { + return downCondition(mapping, form, request, response); + } + return null; + } + + /** + * Display empty page for a new condition. + * + * @param mapping + * @param form + * @param request + * @param response + * @return + */ + private ActionForward newConditionInit(ActionMapping mapping, ActionForm form, HttpServletRequest request, + HttpServletResponse response) { + + populateFormWithPossibleItems(form, request); + ((QaConditionForm) form).setOrderId(-1); + return mapping.findForward("addcondition"); + } + + /** + * Display edit page for an existing condition. + * + * @param mapping + * @param form + * @param request + * @param response + * @return + */ + private ActionForward editCondition(ActionMapping mapping, ActionForm form, HttpServletRequest request, + HttpServletResponse response) { + + QaConditionForm qaConditionForm = (QaConditionForm) form; + String sessionMapID = qaConditionForm.getSessionMapID(); + SessionMap sessionMap = (SessionMap) request.getSession().getAttribute(sessionMapID); + + int orderId = NumberUtils.stringToInt(request.getParameter(QaAppConstants.PARAM_ORDER_ID), -1); + QaCondition condition = null; + if (orderId != -1) { + SortedSet conditionSet = getQaConditionSet(sessionMap); + List conditionList = new ArrayList(conditionSet); + condition = conditionList.get(orderId); + if (condition != null) { + populateConditionToForm(orderId, condition, qaConditionForm, request); + } + } + + populateFormWithPossibleItems(form, request); + return condition == null ? null : mapping.findForward("addcondition"); + } + + /** + * This method will get necessary information from condition form and save or update into HttpSession + * condition list. Notice, this save is not persist them into database, just save HttpSession + * temporarily. Only they will be persist when the entire authoring page is being persisted. + * + * @param mapping + * @param form + * @param request + * @param response + * @return + * @throws ServletException + */ + private ActionForward saveOrUpdateCondition(ActionMapping mapping, ActionForm form, HttpServletRequest request, + HttpServletResponse response) { + + QaConditionForm conditionForm = (QaConditionForm) form; + ActionErrors errors = validateQaCondition(conditionForm, request); + + if (!errors.isEmpty()) { + populateFormWithPossibleItems(form, request); + this.addErrors(request, errors); + return mapping.findForward("addcondition"); + } + + try { + extractFormToQaCondition(request, conditionForm); + } catch (Exception e) { + + errors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("error.condition", e.getMessage())); + if (!errors.isEmpty()) { + populateFormWithPossibleItems(form, request); + this.addErrors(request, errors); + return mapping.findForward("addcondition"); + } + } + + request.setAttribute(QaAppConstants.ATTR_SESSION_MAP_ID, conditionForm.getSessionMapID()); + + return mapping.findForward(QaAppConstants.SUCCESS); + } + + /** + * Remove condition from HttpSession list and update page display. As authoring rule, all persist only happen when + * user submit whole page. So this remove is just impact HttpSession values. + * + * @param mapping + * @param form + * @param request + * @param response + * @return + */ + private ActionForward removeCondition(ActionMapping mapping, ActionForm form, HttpServletRequest request, + HttpServletResponse response) { + + // get back sessionMAP + String sessionMapID = WebUtil.readStrParam(request, QaAppConstants.ATTR_SESSION_MAP_ID); + SessionMap sessionMap = (SessionMap) request.getSession().getAttribute(sessionMapID); + + int orderId = NumberUtils.stringToInt(request.getParameter(QaAppConstants.PARAM_ORDER_ID), -1); + if (orderId != -1) { + SortedSet conditionSet = getQaConditionSet(sessionMap); + List conditionList = new ArrayList(conditionSet); + QaCondition condition = conditionList.remove(orderId); + conditionSet.clear(); + conditionSet.addAll(conditionList); + // add to delList + List deletedList = getDeletedQaConditionList(sessionMap); + deletedList.add(condition); + } + + request.setAttribute(QaAppConstants.ATTR_SESSION_MAP_ID, sessionMapID); + return mapping.findForward(QaAppConstants.SUCCESS); + } + + /** + * Move up current item. + * + * @param mapping + * @param form + * @param request + * @param response + * @return + */ + private ActionForward upCondition(ActionMapping mapping, ActionForm form, HttpServletRequest request, + HttpServletResponse response) { + return switchItem(mapping, request, true); + } + + /** + * Move down current item. + * + * @param mapping + * @param form + * @param request + * @param response + * @return + */ + private ActionForward downCondition(ActionMapping mapping, ActionForm form, HttpServletRequest request, + HttpServletResponse response) { + return switchItem(mapping, request, false); + } + + private ActionForward switchItem(ActionMapping mapping, HttpServletRequest request, boolean up) { + // get back sessionMAP + String sessionMapID = WebUtil.readStrParam(request, QaAppConstants.ATTR_SESSION_MAP_ID); + SessionMap sessionMap = (SessionMap) request.getSession().getAttribute(sessionMapID); + + int orderId = NumberUtils.stringToInt(request.getParameter(QaAppConstants.PARAM_ORDER_ID), -1); + if (orderId != -1) { + SortedSet conditionSet = getQaConditionSet(sessionMap); + List conditionList = new ArrayList(conditionSet); + // get current and the target item, and switch their sequnece + QaCondition condition = conditionList.get(orderId); + QaCondition repCondition; + if (up) { + repCondition = conditionList.get(--orderId); + } else { + repCondition = conditionList.get(++orderId); + } + int upSeqId = repCondition.getOrderId(); + repCondition.setOrderId(condition.getOrderId()); + condition.setOrderId(upSeqId); + + // put back list, it will be sorted again + conditionSet.clear(); + conditionSet.addAll(conditionList); + } + + request.setAttribute(QaAppConstants.ATTR_SESSION_MAP_ID, sessionMapID); + return mapping.findForward(QaAppConstants.SUCCESS); + } + + // ************************************************************************************* + // Private methods for internal needs + // ************************************************************************************* + /** + * Return QaService bean. + */ + private IQaService getQaService() { + WebApplicationContext wac = WebApplicationContextUtils.getRequiredWebApplicationContext(getServlet() + .getServletContext()); + return QaServiceProxy.getQaService(getServlet().getServletContext()); + } + + /** + * List save current taskList items. + * + * @param request + * @return + */ + private SortedSet getQaConditionSet(SessionMap sessionMap) { + SortedSet list = (SortedSet) sessionMap.get(QaAppConstants.ATTR_CONDITION_SET); + if (list == null) { + list = new TreeSet(new QaConditionComparator()); + sessionMap.put(QaAppConstants.ATTR_CONDITION_SET, list); + } + return list; + } + + /** + * List save current taskList items. + * + * @param request + * @return + */ + private List getQuestionList(SessionMap sessionMap) { + List list = (List) sessionMap + .get(QaAppConstants.LIST_QUESTION_CONTENT_DTO_KEY); + if (list == null) { + list = new LinkedList(); + sessionMap.put(QaAppConstants.LIST_QUESTION_CONTENT_DTO_KEY, list); + } + return list; + } + + /** + * Get the deleted condition list, which could be persisted or non-persisted items. + * + * @param request + * @return + */ + private List getDeletedQaConditionList(SessionMap sessionMap) { + return getListFromSession(sessionMap, QaAppConstants.ATTR_DELETED_CONDITION_LIST); + } + + /** + * Get java.util.List from HttpSession by given name. + * + * @param request + * @param name + * @return + */ + private List getListFromSession(SessionMap sessionMap, String name) { + List list = (List) sessionMap.get(name); + if (list == null) { + list = new ArrayList(); + sessionMap.put(name, list); + } + return list; + } + + /** + * This method will populate condition information to its form for edit use. + * + * @param orderId + * @param condition + * @param form + * @param request + */ + private void populateConditionToForm(int orderId, QaCondition condition, QaConditionForm form, + HttpServletRequest request) { + form.populateForm(condition); + if (orderId >= 0) { + form.setOrderId(new Integer(orderId)); + } + + Integer[] selectedItems = new Integer[condition.temporaryQuestionDTOSet.size()]; + int i = 0; + for (QaQuestionContentDTO question : condition.temporaryQuestionDTOSet) { + selectedItems[i++] = new Integer(question.getDisplayOrder()); + } + form.setSelectedItems(selectedItems); + } + + /** + * This method will populate questions to choose to the form for edit use. + * + * @param sequenceId + * @param condition + * @param form + * @param request + */ + private void populateFormWithPossibleItems(ActionForm form, HttpServletRequest request) { + QaConditionForm conditionForm = (QaConditionForm) form; + // get back sessionMAP + String sessionMapID = conditionForm.getSessionMapID(); + SessionMap sessionMap = (SessionMap) request.getSession().getAttribute(sessionMapID); + + List questions = getQuestionList(sessionMap); + + // Initialise the LabelValueBeans in the possibleOptions array. + LabelValueBean[] lvBeans = new LabelValueBean[questions.size()]; + + int i = 0; + for (QaQuestionContentDTO question : questions) { + String nonHTMLQuestion = question.getQuestion(); + if (nonHTMLQuestion != null) { + nonHTMLQuestion = nonHTMLQuestion.replaceAll(QaAppConstants.HTML_TAG_REGEX, ""); + if (nonHTMLQuestion.length() > QaAppConstants.QUESTION_CUTOFF_INDEX) { + nonHTMLQuestion = nonHTMLQuestion.substring(0, QaAppConstants.QUESTION_CUTOFF_INDEX) + "..."; + } + } + lvBeans[i++] = new LabelValueBean(nonHTMLQuestion, new Integer(question.getDisplayOrder()).toString()); + } + conditionForm.setPossibleItems(lvBeans); + } + + /** + * Extract form content to QaCondition. + * + * @param request + * @param form + * @throws QaException + */ + private void extractFormToQaCondition(HttpServletRequest request, QaConditionForm form) throws Exception { + + SessionMap sessionMap = (SessionMap) request.getSession().getAttribute(form.getSessionMapID()); + // check whether it is "edit(old item)" or "add(new item)" + SortedSet conditionSet = getQaConditionSet(sessionMap); + int orderId = form.getOrderId(); + QaCondition condition = null; + + if (orderId == -1) { // add + String properConditionName = getQaService().createConditionName(conditionSet); + condition = form.extractCondition(); + condition.setName(properConditionName); + int maxOrderId = 1; + if (conditionSet != null && conditionSet.size() > 0) { + QaCondition last = conditionSet.last(); + maxOrderId = last.getOrderId() + 1; + } + condition.setOrderId(maxOrderId); + conditionSet.add(condition); + } else { // edit + List conditionList = new ArrayList(conditionSet); + condition = conditionList.get(orderId); + } + + Integer[] selectedItems = form.getSelectedItems(); + List questions = getQuestionList(sessionMap); + + condition.temporaryQuestionDTOSet.clear(); + for (Integer selectedItem : selectedItems) { + for (QaQuestionContentDTO question : questions) { + if (selectedItem.equals(new Integer(question.getDisplayOrder()))) { + condition.temporaryQuestionDTOSet.add(question); + } + } + } + } + + /** + * Validate QaCondition + * + * @param conditionForm + * @return + */ + private ActionErrors validateQaCondition(QaConditionForm conditionForm, HttpServletRequest request) { + ActionErrors errors = new ActionErrors(); + + String formConditionName = conditionForm.getDisplayName(); + if (StringUtils.isBlank(formConditionName)) { + + errors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("error.condition.name.blank")); + } else { + + Integer formConditionOrderId = conditionForm.getOrderId(); + + String sessionMapID = conditionForm.getSessionMapID(); + SessionMap sessionMap = (SessionMap) request.getSession().getAttribute(sessionMapID); + SortedSet conditionSet = getQaConditionSet(sessionMap); + for (QaCondition condition : conditionSet) { + if (formConditionName.equals(condition.getDisplayName()) + && !formConditionOrderId.equals(condition.getOrderId() - 1)) { + + errors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("error.condition.duplicated.name")); + break; + } + } + } + + // should be selected at least one question + Integer[] selectedItems = conditionForm.getSelectedItems(); + if (selectedItems == null || selectedItems.length == 0) { + errors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("error.condition.no.questions.selected")); + } + + return errors; + } + + private ActionMessages validate(QaConditionForm form, ActionMapping mapping, HttpServletRequest request) { + return new ActionMessages(); + } +} \ No newline at end of file Index: lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/QaConditionForm.java =================================================================== diff -u --- lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/QaConditionForm.java (revision 0) +++ lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/QaConditionForm.java (revision 0af4ed13b963a588f3499b080801863d57f8ad95) @@ -0,0 +1,107 @@ +/**************************************************************** + * Copyright (C) 2005 LAMS Foundation (http://lamsfoundation.org) + * ============================================================= + * License Information: http://lamsfoundation.org/licensing/lams/2.0/ + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2.0 + * as published by the Free Software Foundation. + * + * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 * USA + * + * http://www.gnu.org/licenses/gpl.txt + * **************************************************************** + */ + +/* $$Id$$ */ +package org.lamsfoundation.lams.tool.qa.web; + +import org.apache.struts.util.LabelValueBean; +import org.lamsfoundation.lams.tool.qa.QaCondition; +import org.lamsfoundation.lams.tool.qa.QaQuestionContentDTO; +import org.lamsfoundation.lams.web.TextSearchActionForm; + +/** + * A text search form with additional parameters for Q&A needs. + * + * @author Marcin Cieslak + * + */ +public class QaConditionForm extends TextSearchActionForm { + /** + * Names of the questions that could be selected by a user. + */ + private LabelValueBean[] possibleItems; + /** + * Numbers of questions that were selected by a user. + */ + private Integer[] selectedItems; + private Integer orderId; + private String displayName; + + public String getDisplayName() { + return displayName; + } + + public void setDisplayName(String name) { + displayName = name; + } + + public QaConditionForm() { + } + + public void populateForm(QaCondition condition) { + super.populateForm(condition); + setOrderId(condition.getOrderId()); + setDisplayName(condition.getDisplayName()); + Integer[] selectedItems = new Integer[condition.temporaryQuestionDTOSet.size()]; + int questionIndex = 0; + for (QaQuestionContentDTO question : condition.temporaryQuestionDTOSet) { + selectedItems[questionIndex] = new Integer(question.getDisplayOrder()); + questionIndex++; + } + setSelectedItems(selectedItems); + } + + public LabelValueBean[] getPossibleItems() { + return possibleItems; + } + + public void setPossibleItems(LabelValueBean[] possibleItems) { + this.possibleItems = possibleItems; + } + + public Integer[] getSelectedItems() { + return selectedItems; + } + + public void setSelectedItems(Integer[] selectedItems) { + this.selectedItems = selectedItems; + } + + public Integer getOrderId() { + return orderId; + } + + public void setOrderId(Integer orderId) { + this.orderId = orderId; + } + + /** + * Fills a new QaCondition with data contained in this form. Note that some cruicial data is missing, so the + * condition is NOT complete. + * + * @return created condition + */ + public QaCondition extractCondition() { + return new QaCondition(null, null, getOrderId(), null, getDisplayName(), "OUTPUT_COMPLEX", null, null, null, + getAllWords(), getPhrase(), getAnyWords(), getExcludedWords(), null); + } +} \ No newline at end of file Index: lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/QaMonitoringAction.java =================================================================== diff -u -r6cdc71ebb9a54565ad1c47f9750963b3aeda942d -r0af4ed13b963a588f3499b080801863d57f8ad95 --- lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/QaMonitoringAction.java (.../QaMonitoringAction.java) (revision 6cdc71ebb9a54565ad1c47f9750963b3aeda942d) +++ lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/QaMonitoringAction.java (.../QaMonitoringAction.java) (revision 0af4ed13b963a588f3499b080801863d57f8ad95) @@ -17,77 +17,77 @@ USA http://www.gnu.org/licenses/gpl.txt -* ***********************************************************************/ + * ***********************************************************************/ - /** +/** * @author Ozgur Demirtas * - - - - - + - - - + - + - - - - + - + - - + + + + + + + + + + + */ /* $$Id$$ */ @@ -135,141 +135,117 @@ import org.lamsfoundation.lams.web.util.AttributeNames; import org.lamsfoundation.lams.web.util.SessionMap; +public class QaMonitoringAction extends LamsDispatchAction implements QaAppConstants { + static Logger logger = Logger.getLogger(QaMonitoringAction.class.getName()); -public class QaMonitoringAction extends LamsDispatchAction 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 static String SELECTBOX_SELECTED_TOOL_SESSION ="selectBoxSelectedToolSession"; - public static Integer READABLE_TOOL_SESSION_COUNT = new Integer(1); - - public ActionForward unspecified(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) - throws IOException, ServletException, ToolException{ - logger.debug("dispatching unspecified..."); - return null; + @Override + public ActionForward unspecified(ActionMapping mapping, ActionForm form, HttpServletRequest request, + HttpServletResponse response) throws IOException, ServletException, ToolException { + QaMonitoringAction.logger.debug("dispatching unspecified..."); + return null; } - - - public void initStatsContent(ActionMapping mapping, - ActionForm form, - HttpServletRequest request, - HttpServletResponse response, GeneralMonitoringDTO generalMonitoringDTO) throws IOException, - ServletException - { - logger.debug("starting initStatsContent..."); - - - QaMonitoringForm qaMonitoringForm = (QaMonitoringForm) form; - logger.debug("qaMonitoringForm: " + qaMonitoringForm); - - IQaService qaService = null; - if (getServlet() != null) - qaService = QaServiceProxy.getQaService(getServlet().getServletContext()); - else - qaService=qaMonitoringForm.getQaService(); - - logger.debug("qaService: " + qaService); - String strToolContentID=request.getParameter(AttributeNames.PARAM_TOOL_CONTENT_ID); - logger.debug("strToolContentID: " + strToolContentID); - qaMonitoringForm.setToolContentID(strToolContentID); - - - String contentFolderID = WebUtil.readStrParam(request, AttributeNames.PARAM_CONTENT_FOLDER_ID); - logger.debug("contentFolderID: " + contentFolderID); - qaMonitoringForm.setContentFolderID(contentFolderID); - + public void initStatsContent(ActionMapping mapping, ActionForm form, HttpServletRequest request, + HttpServletResponse response, GeneralMonitoringDTO generalMonitoringDTO) throws IOException, + ServletException { + QaMonitoringAction.logger.debug("starting initStatsContent..."); - String editResponse=request.getParameter(EDIT_RESPONSE); - logger.debug("editResponse: " + editResponse); - qaMonitoringForm.setEditResponse(editResponse); + QaMonitoringForm qaMonitoringForm = (QaMonitoringForm) form; + QaMonitoringAction.logger.debug("qaMonitoringForm: " + qaMonitoringForm); - - QaContent qaContent=qaService.loadQa(new Long(strToolContentID).longValue()); - logger.debug("existing qaContent:" + qaContent); + IQaService qaService = null; + if (getServlet() != null) { + qaService = QaServiceProxy.getQaService(getServlet().getServletContext()); + } else { + qaService = qaMonitoringForm.getQaService(); + } - - Map summaryToolSessions=MonitoringUtil.populateToolSessions(request, qaContent, qaService); - logger.debug("summaryToolSessions: " + summaryToolSessions); - request.setAttribute(SUMMARY_TOOL_SESSIONS, summaryToolSessions); - logger.debug("SUMMARY_TOOL_SESSIONS: " + request.getAttribute(SUMMARY_TOOL_SESSIONS)); - - Map summaryToolSessionsId=MonitoringUtil.populateToolSessionsId(request, qaContent, qaService); - logger.debug("summaryToolSessionsId: " + summaryToolSessionsId); - request.setAttribute(SUMMARY_TOOL_SESSIONS_ID, summaryToolSessionsId); + QaMonitoringAction.logger.debug("qaService: " + qaService); - - if (qaService.studentActivityOccurredGlobal(qaContent)) - { - generalMonitoringDTO.setUserExceptionNoToolSessions(new Boolean(false).toString()); - logger.debug("USER_EXCEPTION_NO_TOOL_SESSIONS is set to false"); - } - else - { - generalMonitoringDTO.setUserExceptionNoToolSessions(new Boolean(true).toString()); - logger.debug("USER_EXCEPTION_NO_TOOL_SESSIONS is set to true"); - } + String strToolContentID = request.getParameter(AttributeNames.PARAM_TOOL_CONTENT_ID); + QaMonitoringAction.logger.debug("strToolContentID: " + strToolContentID); + qaMonitoringForm.setToolContentID(strToolContentID); - refreshStatsData(request, qaMonitoringForm, qaService, generalMonitoringDTO); - generalMonitoringDTO.setEditResponse(new Boolean(false).toString()); + String contentFolderID = WebUtil.readStrParam(request, AttributeNames.PARAM_CONTENT_FOLDER_ID); + QaMonitoringAction.logger.debug("contentFolderID: " + contentFolderID); + qaMonitoringForm.setContentFolderID(contentFolderID); - EditActivityDTO editActivityDTO = new EditActivityDTO(); - boolean isContentInUse=QaUtils.isContentInUse(qaContent); - logger.debug("isContentInUse:" + isContentInUse); - if (isContentInUse == true) - { - editActivityDTO.setMonitoredContentInUse(new Boolean(true).toString()); - } - request.setAttribute(EDIT_ACTIVITY_DTO, editActivityDTO); - - prepareReflectionData(request, qaContent, qaService, null, false, "All"); - - prepareEditActivityScreenData(request, qaContent); + String editResponse = request.getParameter(QaAppConstants.EDIT_RESPONSE); + QaMonitoringAction.logger.debug("editResponse: " + editResponse); + qaMonitoringForm.setEditResponse(editResponse); + QaContent qaContent = qaService.loadQa(new Long(strToolContentID).longValue()); + QaMonitoringAction.logger.debug("existing qaContent:" + qaContent); - /*find out if there are any reflection entries, from here*/ - boolean notebookEntriesExist=MonitoringUtil.notebookEntriesExist(qaService, qaContent); - logger.debug("notebookEntriesExist : " + notebookEntriesExist); - - if (notebookEntriesExist) - { - request.setAttribute(NOTEBOOK_ENTRIES_EXIST, new Boolean(true).toString()); - } - else - { - request.setAttribute(NOTEBOOK_ENTRIES_EXIST, new Boolean(false).toString()); - } - /* ... till here*/ - - - /**getting instructions screen content from here... */ - generalMonitoringDTO.setOnlineInstructions(qaContent.getOnlineInstructions()); - generalMonitoringDTO.setOfflineInstructions(qaContent.getOfflineInstructions()); - - List attachmentList = qaService.retrieveQaUploadedFiles(qaContent); - logger.debug("attachmentList: " + attachmentList); - generalMonitoringDTO.setAttachmentList(attachmentList); - generalMonitoringDTO.setDeletedAttachmentList(new ArrayList()); - /** ...till here **/ + Map summaryToolSessions = MonitoringUtil.populateToolSessions(request, qaContent, qaService); + QaMonitoringAction.logger.debug("summaryToolSessions: " + summaryToolSessions); + request.setAttribute(QaAppConstants.SUMMARY_TOOL_SESSIONS, summaryToolSessions); + QaMonitoringAction.logger.debug("SUMMARY_TOOL_SESSIONS: " + + request.getAttribute(QaAppConstants.SUMMARY_TOOL_SESSIONS)); - - logger.debug("final generalMonitoringDTO: " + generalMonitoringDTO ); - request.setAttribute(QA_GENERAL_MONITORING_DTO, generalMonitoringDTO); - logger.debug("ending initStatsContent..."); - - MonitoringUtil.buildQaStatsDTO(request,qaService, qaContent); - MonitoringUtil.generateGroupsSessionData(request, qaService, qaContent, false); - + Map summaryToolSessionsId = MonitoringUtil.populateToolSessionsId(request, qaContent, qaService); + QaMonitoringAction.logger.debug("summaryToolSessionsId: " + summaryToolSessionsId); + request.setAttribute(QaAppConstants.SUMMARY_TOOL_SESSIONS_ID, summaryToolSessionsId); + + if (qaService.studentActivityOccurredGlobal(qaContent)) { + generalMonitoringDTO.setUserExceptionNoToolSessions(new Boolean(false).toString()); + QaMonitoringAction.logger.debug("USER_EXCEPTION_NO_TOOL_SESSIONS is set to false"); + } else { + generalMonitoringDTO.setUserExceptionNoToolSessions(new Boolean(true).toString()); + QaMonitoringAction.logger.debug("USER_EXCEPTION_NO_TOOL_SESSIONS is set to true"); } - + refreshStatsData(request, qaMonitoringForm, qaService, generalMonitoringDTO); + generalMonitoringDTO.setEditResponse(new Boolean(false).toString()); + + EditActivityDTO editActivityDTO = new EditActivityDTO(); + boolean isContentInUse = QaUtils.isContentInUse(qaContent); + QaMonitoringAction.logger.debug("isContentInUse:" + isContentInUse); + if (isContentInUse == true) { + editActivityDTO.setMonitoredContentInUse(new Boolean(true).toString()); + } + request.setAttribute(QaAppConstants.EDIT_ACTIVITY_DTO, editActivityDTO); + + prepareReflectionData(request, qaContent, qaService, null, false, "All"); + + prepareEditActivityScreenData(request, qaContent); + + /* find out if there are any reflection entries, from here */ + boolean notebookEntriesExist = MonitoringUtil.notebookEntriesExist(qaService, qaContent); + QaMonitoringAction.logger.debug("notebookEntriesExist : " + notebookEntriesExist); + + if (notebookEntriesExist) { + request.setAttribute(QaAppConstants.NOTEBOOK_ENTRIES_EXIST, new Boolean(true).toString()); + } else { + request.setAttribute(QaAppConstants.NOTEBOOK_ENTRIES_EXIST, new Boolean(false).toString()); + } + /* ... till here */ + + /** getting instructions screen content from here... */ + generalMonitoringDTO.setOnlineInstructions(qaContent.getOnlineInstructions()); + generalMonitoringDTO.setOfflineInstructions(qaContent.getOfflineInstructions()); + + List attachmentList = qaService.retrieveQaUploadedFiles(qaContent); + QaMonitoringAction.logger.debug("attachmentList: " + attachmentList); + generalMonitoringDTO.setAttachmentList(attachmentList); + generalMonitoringDTO.setDeletedAttachmentList(new ArrayList()); + /** ...till here * */ + + QaMonitoringAction.logger.debug("final generalMonitoringDTO: " + generalMonitoringDTO); + request.setAttribute(QaAppConstants.QA_GENERAL_MONITORING_DTO, generalMonitoringDTO); + QaMonitoringAction.logger.debug("ending initStatsContent..."); + + MonitoringUtil.buildQaStatsDTO(request, qaService, qaContent); + MonitoringUtil.generateGroupsSessionData(request, qaService, qaContent, false); + + } + /** - * switches to instructions tab of the monitoring url. - * getInstructions(ActionMapping mapping, - ActionForm form, - HttpServletRequest request, - HttpServletResponse response) throws IOException, - ServletException + * switches to instructions tab of the monitoring url. getInstructions(ActionMapping mapping, ActionForm form, + * HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException * * @param mapping * @param form @@ -279,137 +255,113 @@ * @throws IOException * @throws ServletException */ - public ActionForward getInstructions(ActionMapping mapping, - ActionForm form, - HttpServletRequest request, - HttpServletResponse response) throws IOException, - ServletException - { - logger.debug("dispatching getInstructions..." + request); - initInstructionsContent(mapping, form, request, response); + public ActionForward getInstructions(ActionMapping mapping, ActionForm form, HttpServletRequest request, + HttpServletResponse response) throws IOException, ServletException { + QaMonitoringAction.logger.debug("dispatching getInstructions..." + request); + initInstructionsContent(mapping, form, request, response); - return (mapping.findForward(LOAD_MONITORING)); + return mapping.findForward(QaAppConstants.LOAD_MONITORING); + } + + public void initInstructionsContent(ActionMapping mapping, ActionForm form, HttpServletRequest request, + HttpServletResponse response) throws IOException, ServletException { + QaMonitoringAction.logger.debug("starting initInstructionsContent..."); + QaMonitoringAction.logger.debug("dispatching getInstructions..." + request); + + QaMonitoringForm qaMonitoringForm = (QaMonitoringForm) form; + QaMonitoringAction.logger.debug("qaMonitoringForm: " + qaMonitoringForm); + + GeneralMonitoringDTO generalMonitoringDTO = new GeneralMonitoringDTO(); + + IQaService qaService = null; + if (getServlet() != null) { + qaService = QaServiceProxy.getQaService(getServlet().getServletContext()); + } else { + qaService = qaMonitoringForm.getQaService(); } - - public void initInstructionsContent(ActionMapping mapping, - ActionForm form, - HttpServletRequest request, - HttpServletResponse response) throws IOException, - ServletException - { - logger.debug("starting initInstructionsContent..."); - logger.debug("dispatching getInstructions..." + request); - - QaMonitoringForm qaMonitoringForm = (QaMonitoringForm) form; - logger.debug("qaMonitoringForm: " + qaMonitoringForm); + QaMonitoringAction.logger.debug("qaService: " + qaService); - GeneralMonitoringDTO generalMonitoringDTO= new GeneralMonitoringDTO(); + String strToolContentID = request.getParameter(AttributeNames.PARAM_TOOL_CONTENT_ID); + QaMonitoringAction.logger.debug("strToolContentID: " + strToolContentID); + qaMonitoringForm.setToolContentID(strToolContentID); - IQaService qaService = null; - if (getServlet() != null) - qaService = QaServiceProxy.getQaService(getServlet().getServletContext()); - else - qaService=qaMonitoringForm.getQaService(); - - logger.debug("qaService: " + qaService); + String contentFolderID = WebUtil.readStrParam(request, AttributeNames.PARAM_CONTENT_FOLDER_ID); + QaMonitoringAction.logger.debug("contentFolderID: " + contentFolderID); + qaMonitoringForm.setContentFolderID(contentFolderID); - - String strToolContentID=request.getParameter(AttributeNames.PARAM_TOOL_CONTENT_ID); - logger.debug("strToolContentID: " + strToolContentID); - qaMonitoringForm.setToolContentID(strToolContentID); - - String contentFolderID = WebUtil.readStrParam(request, AttributeNames.PARAM_CONTENT_FOLDER_ID); - logger.debug("contentFolderID: " + contentFolderID); - qaMonitoringForm.setContentFolderID(contentFolderID); + String editResponse = request.getParameter(QaAppConstants.EDIT_RESPONSE); + QaMonitoringAction.logger.debug("editResponse: " + editResponse); + qaMonitoringForm.setEditResponse(editResponse); - - String editResponse=request.getParameter(EDIT_RESPONSE); - logger.debug("editResponse: " + editResponse); - qaMonitoringForm.setEditResponse(editResponse); + QaContent qaContent = qaService.loadQa(new Long(strToolContentID).longValue()); + QaMonitoringAction.logger.debug("existing qaContent:" + qaContent); + Map summaryToolSessions = MonitoringUtil.populateToolSessions(request, qaContent, qaService); + QaMonitoringAction.logger.debug("summaryToolSessions: " + summaryToolSessions); + request.setAttribute(QaAppConstants.SUMMARY_TOOL_SESSIONS, summaryToolSessions); + QaMonitoringAction.logger.debug("SUMMARY_TOOL_SESSIONS: " + + request.getAttribute(QaAppConstants.SUMMARY_TOOL_SESSIONS)); - QaContent qaContent=qaService.loadQa(new Long(strToolContentID).longValue()); - logger.debug("existing qaContent:" + qaContent); - - Map summaryToolSessions=MonitoringUtil.populateToolSessions(request, qaContent, qaService); - logger.debug("summaryToolSessions: " + summaryToolSessions); - request.setAttribute(SUMMARY_TOOL_SESSIONS, summaryToolSessions); - logger.debug("SUMMARY_TOOL_SESSIONS: " + request.getAttribute(SUMMARY_TOOL_SESSIONS)); + Map summaryToolSessionsId = MonitoringUtil.populateToolSessionsId(request, qaContent, qaService); + QaMonitoringAction.logger.debug("summaryToolSessionsId: " + summaryToolSessionsId); + request.setAttribute(QaAppConstants.SUMMARY_TOOL_SESSIONS_ID, summaryToolSessionsId); - - Map summaryToolSessionsId=MonitoringUtil.populateToolSessionsId(request, qaContent, qaService); - logger.debug("summaryToolSessionsId: " + summaryToolSessionsId); - request.setAttribute(SUMMARY_TOOL_SESSIONS_ID, summaryToolSessionsId); + if (qaService.studentActivityOccurredGlobal(qaContent)) { + QaMonitoringAction.logger.debug("USER_EXCEPTION_NO_TOOL_SESSIONS is set to false"); + generalMonitoringDTO.setUserExceptionNoToolSessions(new Boolean(false).toString()); + } else { + QaMonitoringAction.logger.debug("USER_EXCEPTION_NO_TOOL_SESSIONS is set to true"); + generalMonitoringDTO.setUserExceptionNoToolSessions(new Boolean(true).toString()); + } - - if (qaService.studentActivityOccurredGlobal(qaContent)) - { - logger.debug("USER_EXCEPTION_NO_TOOL_SESSIONS is set to false"); - generalMonitoringDTO.setUserExceptionNoToolSessions(new Boolean(false).toString()); - } - else - { - logger.debug("USER_EXCEPTION_NO_TOOL_SESSIONS is set to true"); - generalMonitoringDTO.setUserExceptionNoToolSessions(new Boolean(true).toString()); - } - - generalMonitoringDTO.setEditResponse(new Boolean(false).toString()); - - prepareReflectionData(request, qaContent, qaService,null, false, "All"); - - prepareEditActivityScreenData(request, qaContent); + generalMonitoringDTO.setEditResponse(new Boolean(false).toString()); - EditActivityDTO editActivityDTO = new EditActivityDTO(); - boolean isContentInUse=QaUtils.isContentInUse(qaContent); - logger.debug("isContentInUse:" + isContentInUse); - if (isContentInUse == true) - { - editActivityDTO.setMonitoredContentInUse(new Boolean(true).toString()); - } - request.setAttribute(EDIT_ACTIVITY_DTO, editActivityDTO); + prepareReflectionData(request, qaContent, qaService, null, false, "All"); - /*find out if there are any reflection entries, from here*/ - boolean notebookEntriesExist=MonitoringUtil.notebookEntriesExist(qaService, qaContent); - logger.debug("notebookEntriesExist : " + notebookEntriesExist); - - if (notebookEntriesExist) - { - request.setAttribute(NOTEBOOK_ENTRIES_EXIST, new Boolean(true).toString()); - } - else - { - request.setAttribute(NOTEBOOK_ENTRIES_EXIST, new Boolean(false).toString()); - } - /* ... till here*/ + prepareEditActivityScreenData(request, qaContent); - /**getting instructions screen content from here... */ - generalMonitoringDTO.setOnlineInstructions(qaContent.getOnlineInstructions()); - generalMonitoringDTO.setOfflineInstructions(qaContent.getOfflineInstructions()); - - List attachmentList = qaService.retrieveQaUploadedFiles(qaContent); - logger.debug("attachmentList: " + attachmentList); - generalMonitoringDTO.setAttachmentList(attachmentList); - generalMonitoringDTO.setDeletedAttachmentList(new ArrayList()); - /** ...till here **/ + EditActivityDTO editActivityDTO = new EditActivityDTO(); + boolean isContentInUse = QaUtils.isContentInUse(qaContent); + QaMonitoringAction.logger.debug("isContentInUse:" + isContentInUse); + if (isContentInUse == true) { + editActivityDTO.setMonitoredContentInUse(new Boolean(true).toString()); + } + request.setAttribute(QaAppConstants.EDIT_ACTIVITY_DTO, editActivityDTO); - - logger.debug("final generalMonitoringDTO: " + generalMonitoringDTO ); - request.setAttribute(QA_GENERAL_MONITORING_DTO, generalMonitoringDTO); - - MonitoringUtil.buildQaStatsDTO(request,qaService, qaContent); + /* find out if there are any reflection entries, from here */ + boolean notebookEntriesExist = MonitoringUtil.notebookEntriesExist(qaService, qaContent); + QaMonitoringAction.logger.debug("notebookEntriesExist : " + notebookEntriesExist); - MonitoringUtil.generateGroupsSessionData(request, qaService, qaContent, false); - logger.debug("ending initInstructionsContent..."); + if (notebookEntriesExist) { + request.setAttribute(QaAppConstants.NOTEBOOK_ENTRIES_EXIST, new Boolean(true).toString()); + } else { + request.setAttribute(QaAppConstants.NOTEBOOK_ENTRIES_EXIST, new Boolean(false).toString()); } + /* ... till here */ + /** getting instructions screen content from here... */ + generalMonitoringDTO.setOnlineInstructions(qaContent.getOnlineInstructions()); + generalMonitoringDTO.setOfflineInstructions(qaContent.getOfflineInstructions()); + + List attachmentList = qaService.retrieveQaUploadedFiles(qaContent); + QaMonitoringAction.logger.debug("attachmentList: " + attachmentList); + generalMonitoringDTO.setAttachmentList(attachmentList); + generalMonitoringDTO.setDeletedAttachmentList(new ArrayList()); + /** ...till here * */ + + QaMonitoringAction.logger.debug("final generalMonitoringDTO: " + generalMonitoringDTO); + request.setAttribute(QaAppConstants.QA_GENERAL_MONITORING_DTO, generalMonitoringDTO); + + MonitoringUtil.buildQaStatsDTO(request, qaService, qaContent); + + MonitoringUtil.generateGroupsSessionData(request, qaService, qaContent, false); + QaMonitoringAction.logger.debug("ending initInstructionsContent..."); + } + /** - * activates editActivity screen - * ActionForward editActivity(ActionMapping mapping, - ActionForm form, - HttpServletRequest request, - HttpServletResponse response) throws IOException, - ServletException + * activates editActivity screen ActionForward editActivity(ActionMapping mapping, ActionForm form, + * HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException * * @param mapping * @param form @@ -419,139 +371,123 @@ * @throws IOException * @throws ServletException */ - public ActionForward editActivity(ActionMapping mapping, - ActionForm form, - HttpServletRequest request, - HttpServletResponse response) throws IOException, - ServletException - { - logger.debug("dispatching editActivity..."); - QaMonitoringForm qaMonitoringForm = (QaMonitoringForm) form; - logger.debug("qaMonitoringForm: " + qaMonitoringForm); + public ActionForward editActivity(ActionMapping mapping, ActionForm form, HttpServletRequest request, + HttpServletResponse response) throws IOException, ServletException { + QaMonitoringAction.logger.debug("dispatching editActivity..."); + QaMonitoringForm qaMonitoringForm = (QaMonitoringForm) form; + QaMonitoringAction.logger.debug("qaMonitoringForm: " + qaMonitoringForm); - IQaService qaService = QaServiceProxy.getQaService(getServlet().getServletContext()); - logger.debug("qaService: " + qaService); - - if (qaService == null) - qaService=qaMonitoringForm.getQaService(); + IQaService qaService = QaServiceProxy.getQaService(getServlet().getServletContext()); + QaMonitoringAction.logger.debug("qaService: " + qaService); + if (qaService == null) { + qaService = qaMonitoringForm.getQaService(); + } - QaStarterAction qaStarterAction= new QaStarterAction(); - - String strToolContentID=request.getParameter(AttributeNames.PARAM_TOOL_CONTENT_ID); - logger.debug("strToolContentID: " + strToolContentID); - qaMonitoringForm.setToolContentID(strToolContentID); - - String contentFolderID = WebUtil.readStrParam(request, AttributeNames.PARAM_CONTENT_FOLDER_ID); - logger.debug("contentFolderID: " + contentFolderID); - qaMonitoringForm.setContentFolderID(contentFolderID); + QaStarterAction qaStarterAction = new QaStarterAction(); - - String editResponse=request.getParameter(EDIT_RESPONSE); - logger.debug("editResponse: " + editResponse); - qaMonitoringForm.setEditResponse(editResponse); + String strToolContentID = request.getParameter(AttributeNames.PARAM_TOOL_CONTENT_ID); + QaMonitoringAction.logger.debug("strToolContentID: " + strToolContentID); + qaMonitoringForm.setToolContentID(strToolContentID); - - request.setAttribute(SOURCE_MC_STARTER, "monitoring"); - logger.debug("SOURCE_MC_STARTER: monitoring"); - - /* it is possible that the content is being used by some learners. In this situation, the content is marked as "in use" and - content in use is not modifiable*/ - QaContent qaContent=qaService.loadQa(new Long(strToolContentID).longValue()); - logger.debug("qaContent:" + qaContent); - - Map summaryToolSessions=MonitoringUtil.populateToolSessions(request, qaContent, qaService); - logger.debug("summaryToolSessions: " + summaryToolSessions); - request.setAttribute(SUMMARY_TOOL_SESSIONS, summaryToolSessions); - logger.debug("SUMMARY_TOOL_SESSIONS: " + request.getAttribute(SUMMARY_TOOL_SESSIONS)); + String contentFolderID = WebUtil.readStrParam(request, AttributeNames.PARAM_CONTENT_FOLDER_ID); + QaMonitoringAction.logger.debug("contentFolderID: " + contentFolderID); + qaMonitoringForm.setContentFolderID(contentFolderID); - Map summaryToolSessionsId=MonitoringUtil.populateToolSessionsId(request, qaContent, qaService); - logger.debug("summaryToolSessionsId: " + summaryToolSessionsId); - request.setAttribute(SUMMARY_TOOL_SESSIONS_ID, summaryToolSessionsId); + String editResponse = request.getParameter(QaAppConstants.EDIT_RESPONSE); + QaMonitoringAction.logger.debug("editResponse: " + editResponse); + qaMonitoringForm.setEditResponse(editResponse); - GeneralMonitoringDTO generalMonitoringDTO= new GeneralMonitoringDTO(); - if (qaService.studentActivityOccurredGlobal(qaContent)) - { - logger.debug("student activity occurred on this content:" + qaContent); - generalMonitoringDTO.setUserExceptionContentInUse(new Boolean(true).toString()); - logger.debug("forwarding to: " + LOAD_MONITORING); - return (mapping.findForward(LOAD_MONITORING)); - } - - if (qaContent.getTitle() == null) - { - generalMonitoringDTO.setActivityTitle("Questions and Answers"); - generalMonitoringDTO.setActivityInstructions("Please answer the questions."); - } - else - { - generalMonitoringDTO.setActivityTitle(qaContent.getTitle()); - generalMonitoringDTO.setActivityInstructions(qaContent.getInstructions()); - } - - logger.debug("final generalMonitoringDTO: " + generalMonitoringDTO ); - request.setAttribute(QA_GENERAL_MONITORING_DTO, generalMonitoringDTO); + request.setAttribute(QaAppConstants.SOURCE_MC_STARTER, "monitoring"); + QaMonitoringAction.logger.debug("SOURCE_MC_STARTER: monitoring"); - EditActivityDTO editActivityDTO = new EditActivityDTO(); - boolean isContentInUse=QaUtils.isContentInUse(qaContent); - logger.debug("isContentInUse:" + isContentInUse); - if (isContentInUse == true) - { - editActivityDTO.setMonitoredContentInUse(new Boolean(true).toString()); - } - request.setAttribute(EDIT_ACTIVITY_DTO, editActivityDTO); + /* + * it is possible that the content is being used by some learners. In this situation, the content is marked as + * "in use" and content in use is not modifiable + */ + QaContent qaContent = qaService.loadQa(new Long(strToolContentID).longValue()); + QaMonitoringAction.logger.debug("qaContent:" + qaContent); - /**getting instructions screen content from here... */ - generalMonitoringDTO.setOnlineInstructions(qaContent.getOnlineInstructions()); - generalMonitoringDTO.setOfflineInstructions(qaContent.getOfflineInstructions()); - - List attachmentList = qaService.retrieveQaUploadedFiles(qaContent); - logger.debug("attachmentList: " + attachmentList); - generalMonitoringDTO.setAttachmentList(attachmentList); - generalMonitoringDTO.setDeletedAttachmentList(new ArrayList()); - /** ...till here **/ + Map summaryToolSessions = MonitoringUtil.populateToolSessions(request, qaContent, qaService); + QaMonitoringAction.logger.debug("summaryToolSessions: " + summaryToolSessions); + request.setAttribute(QaAppConstants.SUMMARY_TOOL_SESSIONS, summaryToolSessions); + QaMonitoringAction.logger.debug("SUMMARY_TOOL_SESSIONS: " + + request.getAttribute(QaAppConstants.SUMMARY_TOOL_SESSIONS)); - logger.debug("final generalMonitoringDTO: " + generalMonitoringDTO ); - request.setAttribute(QA_GENERAL_MONITORING_DTO, generalMonitoringDTO); - - prepareReflectionData(request, qaContent, qaService,null, false, "All"); - - prepareEditActivityScreenData(request, qaContent); + Map summaryToolSessionsId = MonitoringUtil.populateToolSessionsId(request, qaContent, qaService); + QaMonitoringAction.logger.debug("summaryToolSessionsId: " + summaryToolSessionsId); + request.setAttribute(QaAppConstants.SUMMARY_TOOL_SESSIONS_ID, summaryToolSessionsId); + GeneralMonitoringDTO generalMonitoringDTO = new GeneralMonitoringDTO(); + if (qaService.studentActivityOccurredGlobal(qaContent)) { + QaMonitoringAction.logger.debug("student activity occurred on this content:" + qaContent); + generalMonitoringDTO.setUserExceptionContentInUse(new Boolean(true).toString()); + QaMonitoringAction.logger.debug("forwarding to: " + QaAppConstants.LOAD_MONITORING); + return mapping.findForward(QaAppConstants.LOAD_MONITORING); + } - /*find out if there are any reflection entries, from here*/ - boolean notebookEntriesExist=MonitoringUtil.notebookEntriesExist(qaService, qaContent); - logger.debug("notebookEntriesExist : " + notebookEntriesExist); - - if (notebookEntriesExist) - { - request.setAttribute(NOTEBOOK_ENTRIES_EXIST, new Boolean(true).toString()); - } - else - { - request.setAttribute(NOTEBOOK_ENTRIES_EXIST, new Boolean(false).toString()); - } - /* ... till here*/ + if (qaContent.getTitle() == null) { + generalMonitoringDTO.setActivityTitle("Questions and Answers"); + generalMonitoringDTO.setActivityInstructions("Please answer the questions."); + } else { + generalMonitoringDTO.setActivityTitle(qaContent.getTitle()); + generalMonitoringDTO.setActivityInstructions(qaContent.getInstructions()); + } - MonitoringUtil.buildQaStatsDTO(request,qaService, qaContent); - - MonitoringUtil.generateGroupsSessionData(request, qaService, qaContent, false); - - /* note that we are casting monitoring form subclass into Authoring form*/ - logger.debug("watch here: note that we are casting monitoring form subclass into Authoring form"); - return qaStarterAction.executeDefineLater(mapping, qaMonitoringForm, request, response, qaService); + QaMonitoringAction.logger.debug("final generalMonitoringDTO: " + generalMonitoringDTO); + request.setAttribute(QaAppConstants.QA_GENERAL_MONITORING_DTO, generalMonitoringDTO); + + EditActivityDTO editActivityDTO = new EditActivityDTO(); + boolean isContentInUse = QaUtils.isContentInUse(qaContent); + QaMonitoringAction.logger.debug("isContentInUse:" + isContentInUse); + if (isContentInUse == true) { + editActivityDTO.setMonitoredContentInUse(new Boolean(true).toString()); } + request.setAttribute(QaAppConstants.EDIT_ACTIVITY_DTO, editActivityDTO); - - + /** getting instructions screen content from here... */ + generalMonitoringDTO.setOnlineInstructions(qaContent.getOnlineInstructions()); + generalMonitoringDTO.setOfflineInstructions(qaContent.getOfflineInstructions()); + + List attachmentList = qaService.retrieveQaUploadedFiles(qaContent); + QaMonitoringAction.logger.debug("attachmentList: " + attachmentList); + generalMonitoringDTO.setAttachmentList(attachmentList); + generalMonitoringDTO.setDeletedAttachmentList(new ArrayList()); + /** ...till here * */ + + QaMonitoringAction.logger.debug("final generalMonitoringDTO: " + generalMonitoringDTO); + request.setAttribute(QaAppConstants.QA_GENERAL_MONITORING_DTO, generalMonitoringDTO); + + prepareReflectionData(request, qaContent, qaService, null, false, "All"); + + prepareEditActivityScreenData(request, qaContent); + + /* find out if there are any reflection entries, from here */ + boolean notebookEntriesExist = MonitoringUtil.notebookEntriesExist(qaService, qaContent); + QaMonitoringAction.logger.debug("notebookEntriesExist : " + notebookEntriesExist); + + if (notebookEntriesExist) { + request.setAttribute(QaAppConstants.NOTEBOOK_ENTRIES_EXIST, new Boolean(true).toString()); + } else { + request.setAttribute(QaAppConstants.NOTEBOOK_ENTRIES_EXIST, new Boolean(false).toString()); + } + /* ... till here */ + + MonitoringUtil.buildQaStatsDTO(request, qaService, qaContent); + + MonitoringUtil.generateGroupsSessionData(request, qaService, qaContent, false); + + /* note that we are casting monitoring form subclass into Authoring form */ + QaMonitoringAction.logger + .debug("watch here: note that we are casting monitoring form subclass into Authoring form"); + return qaStarterAction.executeDefineLater(mapping, qaMonitoringForm, request, response, qaService); + } + /** * switches to summary tab of the monitoring url * - * getSummary(ActionMapping mapping, - ActionForm form, - HttpServletRequest request, - HttpServletResponse response) throws IOException, - ServletException + * getSummary(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) + * throws IOException, ServletException * * @param mapping * @param form @@ -561,293 +497,249 @@ * @throws IOException * @throws ServletException */ - public ActionForward getSummary(ActionMapping mapping, - ActionForm form, - HttpServletRequest request, - HttpServletResponse response) throws IOException, - ServletException - { - logger.debug("start getSummary..."); - initSummaryContent(mapping, form, request, response); - return (mapping.findForward(LOAD_MONITORING)); + public ActionForward getSummary(ActionMapping mapping, ActionForm form, HttpServletRequest request, + HttpServletResponse response) throws IOException, ServletException { + QaMonitoringAction.logger.debug("start getSummary..."); + initSummaryContent(mapping, form, request, response); + return mapping.findForward(QaAppConstants.LOAD_MONITORING); + } + + public void initSummaryContent(ActionMapping mapping, ActionForm form, HttpServletRequest request, + HttpServletResponse response) throws IOException, ServletException { + QaMonitoringAction.logger.debug("initSummaryContent..."); + QaMonitoringForm qaMonitoringForm = (QaMonitoringForm) form; + QaMonitoringAction.logger.debug("qaMonitoringForm: " + qaMonitoringForm); + + GeneralMonitoringDTO generalMonitoringDTO = new GeneralMonitoringDTO(); + + IQaService qaService = null; + if (getServlet() != null) { + qaService = QaServiceProxy.getQaService(getServlet().getServletContext()); + } else { + qaService = qaMonitoringForm.getQaService(); } - - - public void initSummaryContent(ActionMapping mapping, - ActionForm form, - HttpServletRequest request, - HttpServletResponse response) throws IOException, - ServletException - { - logger.debug("initSummaryContent..."); - QaMonitoringForm qaMonitoringForm = (QaMonitoringForm) form; - logger.debug("qaMonitoringForm: " + qaMonitoringForm); + QaMonitoringAction.logger.debug("qaService: " + qaService); - GeneralMonitoringDTO generalMonitoringDTO= new GeneralMonitoringDTO(); - - IQaService qaService = null; - if (getServlet() != null) - qaService = QaServiceProxy.getQaService(getServlet().getServletContext()); - else - qaService=qaMonitoringForm.getQaService(); - - logger.debug("qaService: " + qaService); - - - String strToolContentID=request.getParameter(AttributeNames.PARAM_TOOL_CONTENT_ID); - logger.debug("strToolContentID: " + strToolContentID); - qaMonitoringForm.setToolContentID(strToolContentID); - - String contentFolderID = WebUtil.readStrParam(request, AttributeNames.PARAM_CONTENT_FOLDER_ID); - logger.debug("contentFolderID: " + contentFolderID); - qaMonitoringForm.setContentFolderID(contentFolderID); + String strToolContentID = request.getParameter(AttributeNames.PARAM_TOOL_CONTENT_ID); + QaMonitoringAction.logger.debug("strToolContentID: " + strToolContentID); + qaMonitoringForm.setToolContentID(strToolContentID); - - String editResponse=request.getParameter(EDIT_RESPONSE); - logger.debug("editResponse: " + editResponse); - qaMonitoringForm.setEditResponse(editResponse); + String contentFolderID = WebUtil.readStrParam(request, AttributeNames.PARAM_CONTENT_FOLDER_ID); + QaMonitoringAction.logger.debug("contentFolderID: " + contentFolderID); + qaMonitoringForm.setContentFolderID(contentFolderID); + String editResponse = request.getParameter(QaAppConstants.EDIT_RESPONSE); + QaMonitoringAction.logger.debug("editResponse: " + editResponse); + qaMonitoringForm.setEditResponse(editResponse); - QaContent qaContent=qaService.loadQa(new Long(strToolContentID).longValue()); - logger.debug("existing qaContent:" + qaContent); - - - /* this section is related to summary tab. Starts here. */ - Map summaryToolSessions=MonitoringUtil.populateToolSessions(request, qaContent, qaService); - logger.debug("summaryToolSessions: " + summaryToolSessions); + QaContent qaContent = qaService.loadQa(new Long(strToolContentID).longValue()); + QaMonitoringAction.logger.debug("existing qaContent:" + qaContent); - request.setAttribute(SUMMARY_TOOL_SESSIONS, summaryToolSessions); - logger.debug("SUMMARY_TOOL_SESSIONS: " + request.getAttribute(SUMMARY_TOOL_SESSIONS)); - - Map summaryToolSessionsId=MonitoringUtil.populateToolSessionsId(request, qaContent, qaService); - logger.debug("summaryToolSessionsId: " + summaryToolSessionsId); - request.setAttribute(SUMMARY_TOOL_SESSIONS_ID, summaryToolSessionsId); + /* this section is related to summary tab. Starts here. */ + Map summaryToolSessions = MonitoringUtil.populateToolSessions(request, qaContent, qaService); + QaMonitoringAction.logger.debug("summaryToolSessions: " + summaryToolSessions); - - /*true means there is at least 1 response*/ - if (qaService.studentActivityOccurredGlobal(qaContent)) - { - logger.debug("USER_EXCEPTION_NO_TOOL_SESSIONS is set to false"); - generalMonitoringDTO.setUserExceptionNoToolSessions(new Boolean(false).toString()); - } - else - { - logger.debug("USER_EXCEPTION_NO_TOOL_SESSIONS is set to true"); - generalMonitoringDTO.setUserExceptionNoToolSessions(new Boolean(true).toString()); - } + request.setAttribute(QaAppConstants.SUMMARY_TOOL_SESSIONS, summaryToolSessions); + QaMonitoringAction.logger.debug("SUMMARY_TOOL_SESSIONS: " + + request.getAttribute(QaAppConstants.SUMMARY_TOOL_SESSIONS)); - generalMonitoringDTO.setEditResponse(new Boolean(false).toString()); + Map summaryToolSessionsId = MonitoringUtil.populateToolSessionsId(request, qaContent, qaService); + QaMonitoringAction.logger.debug("summaryToolSessionsId: " + summaryToolSessionsId); + request.setAttribute(QaAppConstants.SUMMARY_TOOL_SESSIONS_ID, summaryToolSessionsId); - EditActivityDTO editActivityDTO = new EditActivityDTO(); - boolean isContentInUse=QaUtils.isContentInUse(qaContent); - logger.debug("isContentInUse:" + isContentInUse); - if (isContentInUse == true) - { - editActivityDTO.setMonitoredContentInUse(new Boolean(true).toString()); - } - request.setAttribute(EDIT_ACTIVITY_DTO, editActivityDTO); + /* true means there is at least 1 response */ + if (qaService.studentActivityOccurredGlobal(qaContent)) { + QaMonitoringAction.logger.debug("USER_EXCEPTION_NO_TOOL_SESSIONS is set to false"); + generalMonitoringDTO.setUserExceptionNoToolSessions(new Boolean(false).toString()); + } else { + QaMonitoringAction.logger.debug("USER_EXCEPTION_NO_TOOL_SESSIONS is set to true"); + generalMonitoringDTO.setUserExceptionNoToolSessions(new Boolean(true).toString()); + } - prepareReflectionData(request, qaContent, qaService,null, false, "All"); - - prepareEditActivityScreenData(request, qaContent); + generalMonitoringDTO.setEditResponse(new Boolean(false).toString()); - - /*find out if there are any reflection entries, from here*/ - boolean notebookEntriesExist=MonitoringUtil.notebookEntriesExist(qaService, qaContent); - logger.debug("notebookEntriesExist : " + notebookEntriesExist); - - if (notebookEntriesExist) - { - request.setAttribute(NOTEBOOK_ENTRIES_EXIST, new Boolean(true).toString()); - } - else - { - request.setAttribute(NOTEBOOK_ENTRIES_EXIST, new Boolean(false).toString()); - } - /* ... till here*/ + EditActivityDTO editActivityDTO = new EditActivityDTO(); + boolean isContentInUse = QaUtils.isContentInUse(qaContent); + QaMonitoringAction.logger.debug("isContentInUse:" + isContentInUse); + if (isContentInUse == true) { + editActivityDTO.setMonitoredContentInUse(new Boolean(true).toString()); + } + request.setAttribute(QaAppConstants.EDIT_ACTIVITY_DTO, editActivityDTO); - /*getting instructions screen content from here... */ - generalMonitoringDTO.setOnlineInstructions(qaContent.getOnlineInstructions()); - generalMonitoringDTO.setOfflineInstructions(qaContent.getOfflineInstructions()); - - List attachmentList = qaService.retrieveQaUploadedFiles(qaContent); - logger.debug("attachmentList: " + attachmentList); - generalMonitoringDTO.setAttachmentList(attachmentList); - generalMonitoringDTO.setDeletedAttachmentList(new ArrayList()); - /* ...till here */ + prepareReflectionData(request, qaContent, qaService, null, false, "All"); - // setting up the advanced summary for LDEV-1662 - request.setAttribute("showOtherAnswers", qaContent.isShowOtherAnswers()); - request.setAttribute("usernameVisible", qaContent.isUsernameVisible()); - request.setAttribute("questionsSequenced", qaContent.isQuestionsSequenced()); - request.setAttribute("lockWhenFinished", qaContent.isLockWhenFinished()); - request.setAttribute("reflect", qaContent.isReflect()); - request.setAttribute("reflectionSubject", qaContent.getReflectionSubject()); - - logger.debug("final generalMonitoringDTO: " + generalMonitoringDTO ); - request.setAttribute(QA_GENERAL_MONITORING_DTO, generalMonitoringDTO); + prepareEditActivityScreenData(request, qaContent); - MonitoringUtil.buildQaStatsDTO(request,qaService, qaContent); - MonitoringUtil.generateGroupsSessionData(request, qaService, qaContent, false); - - logger.debug("end initSummaryContent..."); + /* find out if there are any reflection entries, from here */ + boolean notebookEntriesExist = MonitoringUtil.notebookEntriesExist(qaService, qaContent); + QaMonitoringAction.logger.debug("notebookEntriesExist : " + notebookEntriesExist); + + if (notebookEntriesExist) { + request.setAttribute(QaAppConstants.NOTEBOOK_ENTRIES_EXIST, new Boolean(true).toString()); + } else { + request.setAttribute(QaAppConstants.NOTEBOOK_ENTRIES_EXIST, new Boolean(false).toString()); } + /* ... till here */ - - public ActionForward editActivityQuestions(ActionMapping mapping, - ActionForm form, - HttpServletRequest request, - HttpServletResponse response) throws IOException, - ServletException, - ToolException - { - logger.debug("dispatching editActivityQuestions..."); - - QaMonitoringForm qaMonitoringForm = (QaMonitoringForm) form; - logger.debug("qaMonitoringForm: " + qaMonitoringForm); + /* getting instructions screen content from here... */ + generalMonitoringDTO.setOnlineInstructions(qaContent.getOnlineInstructions()); + generalMonitoringDTO.setOfflineInstructions(qaContent.getOfflineInstructions()); - IQaService qaService = QaServiceProxy.getQaService(getServlet().getServletContext()); - logger.debug("qaService: " + qaService); - - GeneralMonitoringDTO generalMonitoringDTO = new GeneralMonitoringDTO(); - - generalMonitoringDTO.setMonitoredContentInUse(new Boolean(false).toString()); - - EditActivityDTO editActivityDTO = new EditActivityDTO(); - editActivityDTO.setMonitoredContentInUse(new Boolean(false).toString()); - request.setAttribute(EDIT_ACTIVITY_DTO, editActivityDTO); - - generalMonitoringDTO.setDefineLaterInEditMode(new Boolean(true).toString()); - - - logger.debug("final generalMonitoringDTO: " + generalMonitoringDTO ); - request.setAttribute(QA_GENERAL_MONITORING_DTO, generalMonitoringDTO); + List attachmentList = qaService.retrieveQaUploadedFiles(qaContent); + QaMonitoringAction.logger.debug("attachmentList: " + attachmentList); + generalMonitoringDTO.setAttachmentList(attachmentList); + generalMonitoringDTO.setDeletedAttachmentList(new ArrayList()); + /* ...till here */ - String strToolContentID=request.getParameter(AttributeNames.PARAM_TOOL_CONTENT_ID); - logger.debug("strToolContentID: " + strToolContentID); - qaMonitoringForm.setToolContentID(strToolContentID); - - String contentFolderID = WebUtil.readStrParam(request, AttributeNames.PARAM_CONTENT_FOLDER_ID); - logger.debug("contentFolderID: " + contentFolderID); - qaMonitoringForm.setContentFolderID(contentFolderID); - - String httpSessionID=request.getParameter("httpSessionID"); - logger.debug("httpSessionID: " + httpSessionID); - qaMonitoringForm.setHttpSessionID(httpSessionID); + // setting up the advanced summary for LDEV-1662 + request.setAttribute("showOtherAnswers", qaContent.isShowOtherAnswers()); + request.setAttribute("usernameVisible", qaContent.isUsernameVisible()); + request.setAttribute("questionsSequenced", qaContent.isQuestionsSequenced()); + request.setAttribute("lockWhenFinished", qaContent.isLockWhenFinished()); + request.setAttribute("reflect", qaContent.isReflect()); + request.setAttribute("reflectionSubject", qaContent.getReflectionSubject()); - - QaContent qaContent=qaService.loadQa(new Long(strToolContentID).longValue()); - logger.debug("existing qaContent:" + qaContent); - - qaMonitoringForm.setTitle(qaContent.getTitle()); + QaMonitoringAction.logger.debug("final generalMonitoringDTO: " + generalMonitoringDTO); + request.setAttribute(QaAppConstants.QA_GENERAL_MONITORING_DTO, generalMonitoringDTO); - QaUtils.setDefineLater(request, true,strToolContentID, qaService); + MonitoringUtil.buildQaStatsDTO(request, qaService, qaContent); + MonitoringUtil.generateGroupsSessionData(request, qaService, qaContent, false); - prepareEditActivityScreenData(request, qaContent); - - prepareReflectionData(request, qaContent, qaService, null, false, "All"); - - if (qaService.studentActivityOccurredGlobal(qaContent)) - { - logger.debug("USER_EXCEPTION_NO_TOOL_SESSIONS is set to false"); - generalMonitoringDTO.setUserExceptionNoToolSessions(new Boolean(false).toString()); - } - else - { - logger.debug("USER_EXCEPTION_NO_TOOL_SESSIONS is set to true"); - generalMonitoringDTO.setUserExceptionNoToolSessions(new Boolean(true).toString()); - } - - /**getting instructions screen content from here... */ - generalMonitoringDTO.setOnlineInstructions(qaContent.getOnlineInstructions()); - generalMonitoringDTO.setOfflineInstructions(qaContent.getOfflineInstructions()); - - List attachmentList = qaService.retrieveQaUploadedFiles(qaContent); - logger.debug("attachmentList: " + attachmentList); - generalMonitoringDTO.setAttachmentList(attachmentList); - generalMonitoringDTO.setDeletedAttachmentList(new ArrayList()); - /** ...till here **/ + QaMonitoringAction.logger.debug("end initSummaryContent..."); + } - - - logger.debug("final generalMonitoringDTO: " + generalMonitoringDTO ); - request.setAttribute(QA_GENERAL_MONITORING_DTO, generalMonitoringDTO); - - - List listQuestionContentDTO= new LinkedList(); + public ActionForward editActivityQuestions(ActionMapping mapping, ActionForm form, HttpServletRequest request, + HttpServletResponse response) throws IOException, ServletException, ToolException { + QaMonitoringAction.logger.debug("dispatching editActivityQuestions..."); - Iterator queIterator=qaContent.getQaQueContents().iterator(); - while (queIterator.hasNext()) - { - QaQuestionContentDTO qaQuestionContentDTO=new QaQuestionContentDTO(); - - QaQueContent qaQueContent=(QaQueContent) queIterator.next(); - if (qaQueContent != null) - { - logger.debug("question: " + qaQueContent.getQuestion()); - logger.debug("displayorder: " + new Integer(qaQueContent.getDisplayOrder()).toString()); - logger.debug("feedback: " + qaQueContent.getFeedback()); - - qaQuestionContentDTO.setQuestion(qaQueContent.getQuestion()); - qaQuestionContentDTO.setDisplayOrder(new Integer(qaQueContent.getDisplayOrder()).toString()); - qaQuestionContentDTO.setFeedback(qaQueContent.getFeedback()); - listQuestionContentDTO.add(qaQuestionContentDTO); - } - } - logger.debug("listQuestionContentDTO: " + listQuestionContentDTO); - request.setAttribute(LIST_QUESTION_CONTENT_DTO,listQuestionContentDTO); + QaMonitoringForm qaMonitoringForm = (QaMonitoringForm) form; + QaMonitoringAction.logger.debug("qaMonitoringForm: " + qaMonitoringForm); - request.setAttribute(TOTAL_QUESTION_COUNT, new Integer(listQuestionContentDTO.size())); - - QaGeneralAuthoringDTO qaGeneralAuthoringDTO = (QaGeneralAuthoringDTO)request.getAttribute(QA_GENERAL_AUTHORING_DTO); - qaGeneralAuthoringDTO.setActiveModule(MONITORING); - - qaGeneralAuthoringDTO.setToolContentID(strToolContentID); - qaGeneralAuthoringDTO.setContentFolderID(contentFolderID); - qaGeneralAuthoringDTO.setHttpSessionID(httpSessionID); + IQaService qaService = QaServiceProxy.getQaService(getServlet().getServletContext()); + QaMonitoringAction.logger.debug("qaService: " + qaService); - request.setAttribute(QA_GENERAL_AUTHORING_DTO, qaGeneralAuthoringDTO); - - - /*find out if there are any reflection entries, from here*/ - boolean notebookEntriesExist=MonitoringUtil.notebookEntriesExist(qaService, qaContent); - logger.debug("notebookEntriesExist : " + notebookEntriesExist); - - if (notebookEntriesExist) - { - request.setAttribute(NOTEBOOK_ENTRIES_EXIST, new Boolean(true).toString()); - - String userExceptionNoToolSessions=(String)generalMonitoringDTO.getUserExceptionNoToolSessions(); - logger.debug("userExceptionNoToolSessions : " + userExceptionNoToolSessions); - - if (userExceptionNoToolSessions.equals("true")) - { - logger.debug("there are no online student activity but there are reflections : "); - request.setAttribute(NO_SESSIONS_NOTEBOOK_ENTRIES_EXIST, new Boolean(true).toString()); - } - } - else - { - request.setAttribute(NOTEBOOK_ENTRIES_EXIST, new Boolean(false).toString()); - } - /* ... till here*/ + GeneralMonitoringDTO generalMonitoringDTO = new GeneralMonitoringDTO(); - MonitoringUtil.buildQaStatsDTO(request,qaService, qaContent); - MonitoringUtil.generateGroupsSessionData(request, qaService, qaContent, false); - - return (mapping.findForward(LOAD_MONITORING)); + generalMonitoringDTO.setMonitoredContentInUse(new Boolean(false).toString()); + + EditActivityDTO editActivityDTO = new EditActivityDTO(); + editActivityDTO.setMonitoredContentInUse(new Boolean(false).toString()); + request.setAttribute(QaAppConstants.EDIT_ACTIVITY_DTO, editActivityDTO); + + generalMonitoringDTO.setDefineLaterInEditMode(new Boolean(true).toString()); + + QaMonitoringAction.logger.debug("final generalMonitoringDTO: " + generalMonitoringDTO); + request.setAttribute(QaAppConstants.QA_GENERAL_MONITORING_DTO, generalMonitoringDTO); + + String strToolContentID = request.getParameter(AttributeNames.PARAM_TOOL_CONTENT_ID); + QaMonitoringAction.logger.debug("strToolContentID: " + strToolContentID); + qaMonitoringForm.setToolContentID(strToolContentID); + + String contentFolderID = WebUtil.readStrParam(request, AttributeNames.PARAM_CONTENT_FOLDER_ID); + QaMonitoringAction.logger.debug("contentFolderID: " + contentFolderID); + qaMonitoringForm.setContentFolderID(contentFolderID); + + String httpSessionID = request.getParameter("httpSessionID"); + QaMonitoringAction.logger.debug("httpSessionID: " + httpSessionID); + qaMonitoringForm.setHttpSessionID(httpSessionID); + + QaContent qaContent = qaService.loadQa(new Long(strToolContentID).longValue()); + QaMonitoringAction.logger.debug("existing qaContent:" + qaContent); + + qaMonitoringForm.setTitle(qaContent.getTitle()); + + QaUtils.setDefineLater(request, true, strToolContentID, qaService); + + prepareEditActivityScreenData(request, qaContent); + + prepareReflectionData(request, qaContent, qaService, null, false, "All"); + + if (qaService.studentActivityOccurredGlobal(qaContent)) { + QaMonitoringAction.logger.debug("USER_EXCEPTION_NO_TOOL_SESSIONS is set to false"); + generalMonitoringDTO.setUserExceptionNoToolSessions(new Boolean(false).toString()); + } else { + QaMonitoringAction.logger.debug("USER_EXCEPTION_NO_TOOL_SESSIONS is set to true"); + generalMonitoringDTO.setUserExceptionNoToolSessions(new Boolean(true).toString()); + } + + /** getting instructions screen content from here... */ + generalMonitoringDTO.setOnlineInstructions(qaContent.getOnlineInstructions()); + generalMonitoringDTO.setOfflineInstructions(qaContent.getOfflineInstructions()); + + List attachmentList = qaService.retrieveQaUploadedFiles(qaContent); + QaMonitoringAction.logger.debug("attachmentList: " + attachmentList); + generalMonitoringDTO.setAttachmentList(attachmentList); + generalMonitoringDTO.setDeletedAttachmentList(new ArrayList()); + /** ...till here * */ + + QaMonitoringAction.logger.debug("final generalMonitoringDTO: " + generalMonitoringDTO); + request.setAttribute(QaAppConstants.QA_GENERAL_MONITORING_DTO, generalMonitoringDTO); + + List listQuestionContentDTO = new LinkedList(); + + Iterator queIterator = qaContent.getQaQueContents().iterator(); + while (queIterator.hasNext()) { + QaQuestionContentDTO qaQuestionContentDTO = new QaQuestionContentDTO(); + + QaQueContent qaQueContent = (QaQueContent) queIterator.next(); + if (qaQueContent != null) { + QaMonitoringAction.logger.debug("question: " + qaQueContent.getQuestion()); + QaMonitoringAction.logger.debug("displayorder: " + + new Integer(qaQueContent.getDisplayOrder()).toString()); + QaMonitoringAction.logger.debug("feedback: " + qaQueContent.getFeedback()); + + qaQuestionContentDTO.setQuestion(qaQueContent.getQuestion()); + qaQuestionContentDTO.setDisplayOrder(new Integer(qaQueContent.getDisplayOrder()).toString()); + qaQuestionContentDTO.setFeedback(qaQueContent.getFeedback()); + listQuestionContentDTO.add(qaQuestionContentDTO); + } + } + QaMonitoringAction.logger.debug("listQuestionContentDTO: " + listQuestionContentDTO); + request.setAttribute(QaAppConstants.LIST_QUESTION_CONTENT_DTO, listQuestionContentDTO); + + request.setAttribute(QaAppConstants.TOTAL_QUESTION_COUNT, new Integer(listQuestionContentDTO.size())); + + QaGeneralAuthoringDTO qaGeneralAuthoringDTO = (QaGeneralAuthoringDTO) request + .getAttribute(QaAppConstants.QA_GENERAL_AUTHORING_DTO); + qaGeneralAuthoringDTO.setActiveModule(QaAppConstants.MONITORING); + + qaGeneralAuthoringDTO.setToolContentID(strToolContentID); + qaGeneralAuthoringDTO.setContentFolderID(contentFolderID); + qaGeneralAuthoringDTO.setHttpSessionID(httpSessionID); + + request.setAttribute(QaAppConstants.QA_GENERAL_AUTHORING_DTO, qaGeneralAuthoringDTO); + + /* find out if there are any reflection entries, from here */ + boolean notebookEntriesExist = MonitoringUtil.notebookEntriesExist(qaService, qaContent); + QaMonitoringAction.logger.debug("notebookEntriesExist : " + notebookEntriesExist); + + if (notebookEntriesExist) { + request.setAttribute(QaAppConstants.NOTEBOOK_ENTRIES_EXIST, new Boolean(true).toString()); + + String userExceptionNoToolSessions = generalMonitoringDTO.getUserExceptionNoToolSessions(); + QaMonitoringAction.logger.debug("userExceptionNoToolSessions : " + userExceptionNoToolSessions); + + if (userExceptionNoToolSessions.equals("true")) { + QaMonitoringAction.logger.debug("there are no online student activity but there are reflections : "); + request.setAttribute(QaAppConstants.NO_SESSIONS_NOTEBOOK_ENTRIES_EXIST, new Boolean(true).toString()); + } + } else { + request.setAttribute(QaAppConstants.NOTEBOOK_ENTRIES_EXIST, new Boolean(false).toString()); + } + /* ... till here */ + + MonitoringUtil.buildQaStatsDTO(request, qaService, qaContent); + MonitoringUtil.generateGroupsSessionData(request, qaService, qaContent, false); + + return mapping.findForward(QaAppConstants.LOAD_MONITORING); } - - + /** - * gets called when the user selects a group from dropdown box in the summary tab + * gets called when the user selects a group from dropdown box in the summary tab * - * submitSession(ActionMapping mapping, - ActionForm form, - HttpServletRequest request, - HttpServletResponse response) throws IOException, - ServletException + * submitSession(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) + * throws IOException, ServletException * * @param mapping * @param form @@ -857,352 +749,296 @@ * @throws IOException * @throws ServletException */ - public ActionForward submitSession(ActionMapping mapping, - ActionForm form, - HttpServletRequest request, - HttpServletResponse response) throws IOException, - ServletException - { - logger.debug("dispatching submitSession..."); - - IQaService qaService = QaServiceProxy.getQaService(getServlet().getServletContext()); - logger.debug("qaService: " + qaService); - - QaMonitoringForm qaMonitoringForm = (QaMonitoringForm) form; + public ActionForward submitSession(ActionMapping mapping, ActionForm form, HttpServletRequest request, + HttpServletResponse response) throws IOException, ServletException { + QaMonitoringAction.logger.debug("dispatching submitSession..."); - String currentMonitoredToolSession=qaMonitoringForm.getSelectedToolSessionId(); - logger.debug("currentMonitoredToolSession: " + currentMonitoredToolSession); - - if (currentMonitoredToolSession.equals("All")) - { - request.setAttribute(SELECTION_CASE, new Long(2)); - } - else - { - request.setAttribute(SELECTION_CASE, new Long(1)); - - QaSession qaSession=qaService.retrieveQaSessionOrNullById(new Long(currentMonitoredToolSession).longValue()); - logger.debug("retrieving qaSession name: " + qaSession.getSession_name()); - request.setAttribute(CURRENT_SESSION_NAME, qaSession.getSession_name()); - } + IQaService qaService = QaServiceProxy.getQaService(getServlet().getServletContext()); + QaMonitoringAction.logger.debug("qaService: " + qaService); - logger.debug("SELECTION_CASE: " + request.getAttribute(SELECTION_CASE)); - request.setAttribute(CURRENT_MONITORED_TOOL_SESSION, currentMonitoredToolSession); + QaMonitoringForm qaMonitoringForm = (QaMonitoringForm) form; - String strToolContentID=request.getParameter(AttributeNames.PARAM_TOOL_CONTENT_ID); - logger.debug("strToolContentID: " + strToolContentID); - qaMonitoringForm.setToolContentID(strToolContentID); + String currentMonitoredToolSession = qaMonitoringForm.getSelectedToolSessionId(); + QaMonitoringAction.logger.debug("currentMonitoredToolSession: " + currentMonitoredToolSession); - String contentFolderID = WebUtil.readStrParam(request, AttributeNames.PARAM_CONTENT_FOLDER_ID); - logger.debug("contentFolderID: " + contentFolderID); - qaMonitoringForm.setContentFolderID(contentFolderID); + if (currentMonitoredToolSession.equals("All")) { + request.setAttribute(QaAppConstants.SELECTION_CASE, new Long(2)); + } else { + request.setAttribute(QaAppConstants.SELECTION_CASE, new Long(1)); - - String editResponse=request.getParameter(EDIT_RESPONSE); - logger.debug("editResponse: " + editResponse); - qaMonitoringForm.setEditResponse(editResponse); + QaSession qaSession = qaService.retrieveQaSessionOrNullById(new Long(currentMonitoredToolSession) + .longValue()); + QaMonitoringAction.logger.debug("retrieving qaSession name: " + qaSession.getSession_name()); + request.setAttribute(QaAppConstants.CURRENT_SESSION_NAME, qaSession.getSession_name()); + } - - QaContent qaContent=qaService.loadQa(new Long(strToolContentID).longValue()); - logger.debug("existing qaContent:" + qaContent); - - Map summaryToolSessions=MonitoringUtil.populateToolSessions(request, qaContent, qaService); - logger.debug("summaryToolSessions: " + summaryToolSessions); - request.setAttribute(SUMMARY_TOOL_SESSIONS, summaryToolSessions); - logger.debug("SUMMARY_TOOL_SESSIONS: " + request.getAttribute(SUMMARY_TOOL_SESSIONS)); + QaMonitoringAction.logger.debug("SELECTION_CASE: " + request.getAttribute(QaAppConstants.SELECTION_CASE)); + request.setAttribute(QaAppConstants.CURRENT_MONITORED_TOOL_SESSION, currentMonitoredToolSession); + String strToolContentID = request.getParameter(AttributeNames.PARAM_TOOL_CONTENT_ID); + QaMonitoringAction.logger.debug("strToolContentID: " + strToolContentID); + qaMonitoringForm.setToolContentID(strToolContentID); - Map summaryToolSessionsId=MonitoringUtil.populateToolSessionsId(request, qaContent, qaService); - logger.debug("summaryToolSessionsId: " + summaryToolSessionsId); - request.setAttribute(SUMMARY_TOOL_SESSIONS_ID, summaryToolSessionsId); + String contentFolderID = WebUtil.readStrParam(request, AttributeNames.PARAM_CONTENT_FOLDER_ID); + QaMonitoringAction.logger.debug("contentFolderID: " + contentFolderID); + qaMonitoringForm.setContentFolderID(contentFolderID); - - GeneralLearnerFlowDTO generalLearnerFlowDTO= LearningUtil.buildGeneralLearnerFlowDTO(qaContent); - logger.debug("generalLearnerFlowDTO: " + generalLearnerFlowDTO); - - prepareReflectionData(request, qaContent, qaService,null, false, currentMonitoredToolSession); - - prepareEditActivityScreenData(request, qaContent); + String editResponse = request.getParameter(QaAppConstants.EDIT_RESPONSE); + QaMonitoringAction.logger.debug("editResponse: " + editResponse); + qaMonitoringForm.setEditResponse(editResponse); - EditActivityDTO editActivityDTO = new EditActivityDTO(); - boolean isContentInUse=QaUtils.isContentInUse(qaContent); - logger.debug("isContentInUse:" + isContentInUse); - if (isContentInUse == true) - { - editActivityDTO.setMonitoredContentInUse(new Boolean(true).toString()); - } - request.setAttribute(EDIT_ACTIVITY_DTO, editActivityDTO); + QaContent qaContent = qaService.loadQa(new Long(strToolContentID).longValue()); + QaMonitoringAction.logger.debug("existing qaContent:" + qaContent); - refreshSummaryData(request, qaContent, qaService, true, false, null, null, generalLearnerFlowDTO, false, currentMonitoredToolSession); + Map summaryToolSessions = MonitoringUtil.populateToolSessions(request, qaContent, qaService); + QaMonitoringAction.logger.debug("summaryToolSessions: " + summaryToolSessions); + request.setAttribute(QaAppConstants.SUMMARY_TOOL_SESSIONS, summaryToolSessions); + QaMonitoringAction.logger.debug("SUMMARY_TOOL_SESSIONS: " + + request.getAttribute(QaAppConstants.SUMMARY_TOOL_SESSIONS)); - - /*find out if there are any reflection entries, from here*/ - boolean notebookEntriesExist=MonitoringUtil.notebookEntriesExist(qaService, qaContent); - logger.debug("notebookEntriesExist : " + notebookEntriesExist); - - if (notebookEntriesExist) - { - request.setAttribute(NOTEBOOK_ENTRIES_EXIST, new Boolean(true).toString()); - } - else - { - request.setAttribute(NOTEBOOK_ENTRIES_EXIST, new Boolean(false).toString()); - } - /* ... till here*/ + Map summaryToolSessionsId = MonitoringUtil.populateToolSessionsId(request, qaContent, qaService); + QaMonitoringAction.logger.debug("summaryToolSessionsId: " + summaryToolSessionsId); + request.setAttribute(QaAppConstants.SUMMARY_TOOL_SESSIONS_ID, summaryToolSessionsId); - MonitoringUtil.buildQaStatsDTO(request,qaService, qaContent); - MonitoringUtil.generateGroupsSessionData(request, qaService, qaContent, false); - - return (mapping.findForward(LOAD_MONITORING)); + GeneralLearnerFlowDTO generalLearnerFlowDTO = LearningUtil.buildGeneralLearnerFlowDTO(qaContent); + QaMonitoringAction.logger.debug("generalLearnerFlowDTO: " + generalLearnerFlowDTO); + + prepareReflectionData(request, qaContent, qaService, null, false, currentMonitoredToolSession); + + prepareEditActivityScreenData(request, qaContent); + + EditActivityDTO editActivityDTO = new EditActivityDTO(); + boolean isContentInUse = QaUtils.isContentInUse(qaContent); + QaMonitoringAction.logger.debug("isContentInUse:" + isContentInUse); + if (isContentInUse == true) { + editActivityDTO.setMonitoredContentInUse(new Boolean(true).toString()); } + request.setAttribute(QaAppConstants.EDIT_ACTIVITY_DTO, editActivityDTO); - - /** - * enables the user to edit responses - * ActionForward editResponse(ActionMapping mapping, - ActionForm form, - HttpServletRequest request, - HttpServletResponse response) throws IOException, - ServletException - * @param mapping - * @param form - * @param request - * @param response - * @return - * @throws IOException - * @throws ServletException - */ - public ActionForward editResponse(ActionMapping mapping, - ActionForm form, - HttpServletRequest request, - HttpServletResponse response) throws IOException, - ServletException - { - logger.debug("dispatching editResponse..."); + refreshSummaryData(request, qaContent, qaService, true, false, null, null, generalLearnerFlowDTO, false, + currentMonitoredToolSession); - IQaService qaService = QaServiceProxy.getQaService(getServlet().getServletContext()); - logger.debug("qaService: " + qaService); - - QaMonitoringForm qaMonitoringForm = (QaMonitoringForm) form; - - String editResponse=request.getParameter(EDIT_RESPONSE); - logger.debug("editResponse: " + editResponse); - qaMonitoringForm.setEditResponse(editResponse); + /* find out if there are any reflection entries, from here */ + boolean notebookEntriesExist = MonitoringUtil.notebookEntriesExist(qaService, qaContent); + QaMonitoringAction.logger.debug("notebookEntriesExist : " + notebookEntriesExist); + if (notebookEntriesExist) { + request.setAttribute(QaAppConstants.NOTEBOOK_ENTRIES_EXIST, new Boolean(true).toString()); + } else { + request.setAttribute(QaAppConstants.NOTEBOOK_ENTRIES_EXIST, new Boolean(false).toString()); + } + /* ... till here */ - String contentFolderID = WebUtil.readStrParam(request, AttributeNames.PARAM_CONTENT_FOLDER_ID); - logger.debug("contentFolderID: " + contentFolderID); - qaMonitoringForm.setContentFolderID(contentFolderID); + MonitoringUtil.buildQaStatsDTO(request, qaService, qaContent); + MonitoringUtil.generateGroupsSessionData(request, qaService, qaContent, false); - - String responseId=qaMonitoringForm.getResponseId(); - logger.debug("responseId: " + responseId); - request.getSession().setAttribute(EDITABLE_RESPONSE_ID, responseId); + return mapping.findForward(QaAppConstants.LOAD_MONITORING); + } - QaUsrResp qaUsrResp= qaService.retrieveQaUsrResp(new Long(responseId).longValue()); - logger.debug("qaUsrResp: " + qaUsrResp); + /** + * enables the user to edit responses ActionForward editResponse(ActionMapping mapping, ActionForm form, + * HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException + * + * @param mapping + * @param form + * @param request + * @param response + * @return + * @throws IOException + * @throws ServletException + */ + public ActionForward editResponse(ActionMapping mapping, ActionForm form, HttpServletRequest request, + HttpServletResponse response) throws IOException, ServletException { + QaMonitoringAction.logger.debug("dispatching editResponse..."); - refreshUserInput(request, qaMonitoringForm); + IQaService qaService = QaServiceProxy.getQaService(getServlet().getServletContext()); + QaMonitoringAction.logger.debug("qaService: " + qaService); - QaContent qaContent=qaUsrResp.getQaQueContent().getQaContent(); - logger.debug("qaContent: " + qaContent); - - String currentMonitoredToolSession=qaMonitoringForm.getSelectedToolSessionId(); - logger.debug("currentMonitoredToolSession: " + currentMonitoredToolSession); + QaMonitoringForm qaMonitoringForm = (QaMonitoringForm) form; - if (currentMonitoredToolSession.equals("")) - { - currentMonitoredToolSession="All"; - } + String editResponse = request.getParameter(QaAppConstants.EDIT_RESPONSE); + QaMonitoringAction.logger.debug("editResponse: " + editResponse); + qaMonitoringForm.setEditResponse(editResponse); - if (currentMonitoredToolSession.equals("All")) - { - request.setAttribute(SELECTION_CASE, new Long(2)); - } - else - { - request.setAttribute(SELECTION_CASE, new Long(1)); - - QaSession qaSession=qaService.retrieveQaSessionOrNullById(new Long(currentMonitoredToolSession).longValue()); - logger.debug("retrieving qaSession name: " + qaSession.getSession_name()); - request.setAttribute(CURRENT_SESSION_NAME, qaSession.getSession_name()); - } + String contentFolderID = WebUtil.readStrParam(request, AttributeNames.PARAM_CONTENT_FOLDER_ID); + QaMonitoringAction.logger.debug("contentFolderID: " + contentFolderID); + qaMonitoringForm.setContentFolderID(contentFolderID); - logger.debug("SELECTION_CASE: " + request.getAttribute(SELECTION_CASE)); - request.setAttribute(CURRENT_MONITORED_TOOL_SESSION, currentMonitoredToolSession); - - - Map summaryToolSessions=MonitoringUtil.populateToolSessions(request, qaContent, qaService); - logger.debug("summaryToolSessions: " + summaryToolSessions); - request.setAttribute(SUMMARY_TOOL_SESSIONS, summaryToolSessions); - logger.debug("SUMMARY_TOOL_SESSIONS: " + request.getAttribute(SUMMARY_TOOL_SESSIONS)); + String responseId = qaMonitoringForm.getResponseId(); + QaMonitoringAction.logger.debug("responseId: " + responseId); + request.getSession().setAttribute(QaAppConstants.EDITABLE_RESPONSE_ID, responseId); + QaUsrResp qaUsrResp = qaService.retrieveQaUsrResp(new Long(responseId).longValue()); + QaMonitoringAction.logger.debug("qaUsrResp: " + qaUsrResp); - Map summaryToolSessionsId=MonitoringUtil.populateToolSessionsId(request, qaContent, qaService); - logger.debug("summaryToolSessionsId: " + summaryToolSessionsId); - request.setAttribute(SUMMARY_TOOL_SESSIONS_ID, summaryToolSessionsId); - - GeneralLearnerFlowDTO generalLearnerFlowDTO= LearningUtil.buildGeneralLearnerFlowDTO(qaContent); - logger.debug("generalLearnerFlowDTO: " + generalLearnerFlowDTO); - - refreshSummaryData(request, qaContent, qaService, true, false, null, null, generalLearnerFlowDTO, true, currentMonitoredToolSession); + refreshUserInput(request, qaMonitoringForm); - prepareReflectionData(request, qaContent, qaService,null, false, currentMonitoredToolSession); - - prepareEditActivityScreenData(request, qaContent); + QaContent qaContent = qaUsrResp.getQaQueContent().getQaContent(); + QaMonitoringAction.logger.debug("qaContent: " + qaContent); - EditActivityDTO editActivityDTO = new EditActivityDTO(); - boolean isContentInUse=QaUtils.isContentInUse(qaContent); - logger.debug("isContentInUse:" + isContentInUse); - if (isContentInUse == true) - { - editActivityDTO.setMonitoredContentInUse(new Boolean(true).toString()); - } - request.setAttribute(EDIT_ACTIVITY_DTO, editActivityDTO); - - - /*find out if there are any reflection entries, from here*/ - boolean notebookEntriesExist=MonitoringUtil.notebookEntriesExist(qaService, qaContent); - logger.debug("notebookEntriesExist : " + notebookEntriesExist); - - if (notebookEntriesExist) - { - request.setAttribute(NOTEBOOK_ENTRIES_EXIST, new Boolean(true).toString()); - } - else - { - request.setAttribute(NOTEBOOK_ENTRIES_EXIST, new Boolean(false).toString()); - } - /* ... till here*/ + String currentMonitoredToolSession = qaMonitoringForm.getSelectedToolSessionId(); + QaMonitoringAction.logger.debug("currentMonitoredToolSession: " + currentMonitoredToolSession); - MonitoringUtil.buildQaStatsDTO(request,qaService, qaContent); - MonitoringUtil.generateGroupsSessionData(request, qaService, qaContent, false); - - return (mapping.findForward(LOAD_MONITORING)); + if (currentMonitoredToolSession.equals("")) { + currentMonitoredToolSession = "All"; } - - - - public ActionForward editGroupResponse(ActionMapping mapping, - ActionForm form, - HttpServletRequest request, - HttpServletResponse response) throws IOException, - ServletException - { - logger.debug("dispatching editGroupResponse..."); + if (currentMonitoredToolSession.equals("All")) { + request.setAttribute(QaAppConstants.SELECTION_CASE, new Long(2)); + } else { + request.setAttribute(QaAppConstants.SELECTION_CASE, new Long(1)); - IQaService qaService = QaServiceProxy.getQaService(getServlet().getServletContext()); - logger.debug("qaService: " + qaService); - - QaMonitoringForm qaMonitoringForm = (QaMonitoringForm) form; - - String editResponse=request.getParameter(EDIT_RESPONSE); - logger.debug("editResponse: " + editResponse); - qaMonitoringForm.setEditResponse(editResponse); - - String editableSessionId=request.getParameter("sessionId"); - logger.debug("editableSessionId: " + editableSessionId); - request.setAttribute("editableSessionId", editableSessionId); - - - String contentFolderID = WebUtil.readStrParam(request, AttributeNames.PARAM_CONTENT_FOLDER_ID); - logger.debug("contentFolderID: " + contentFolderID); - qaMonitoringForm.setContentFolderID(contentFolderID); + QaSession qaSession = qaService.retrieveQaSessionOrNullById(new Long(currentMonitoredToolSession) + .longValue()); + QaMonitoringAction.logger.debug("retrieving qaSession name: " + qaSession.getSession_name()); + request.setAttribute(QaAppConstants.CURRENT_SESSION_NAME, qaSession.getSession_name()); + } - - String responseId=qaMonitoringForm.getResponseId(); - logger.debug("responseId: " + responseId); - request.getSession().setAttribute(EDITABLE_RESPONSE_ID, responseId); + QaMonitoringAction.logger.debug("SELECTION_CASE: " + request.getAttribute(QaAppConstants.SELECTION_CASE)); + request.setAttribute(QaAppConstants.CURRENT_MONITORED_TOOL_SESSION, currentMonitoredToolSession); - QaUsrResp qaUsrResp= qaService.retrieveQaUsrResp(new Long(responseId).longValue()); - logger.debug("qaUsrResp: " + qaUsrResp); + Map summaryToolSessions = MonitoringUtil.populateToolSessions(request, qaContent, qaService); + QaMonitoringAction.logger.debug("summaryToolSessions: " + summaryToolSessions); + request.setAttribute(QaAppConstants.SUMMARY_TOOL_SESSIONS, summaryToolSessions); + QaMonitoringAction.logger.debug("SUMMARY_TOOL_SESSIONS: " + + request.getAttribute(QaAppConstants.SUMMARY_TOOL_SESSIONS)); - refreshUserInput(request, qaMonitoringForm); + Map summaryToolSessionsId = MonitoringUtil.populateToolSessionsId(request, qaContent, qaService); + QaMonitoringAction.logger.debug("summaryToolSessionsId: " + summaryToolSessionsId); + request.setAttribute(QaAppConstants.SUMMARY_TOOL_SESSIONS_ID, summaryToolSessionsId); - QaContent qaContent=qaUsrResp.getQaQueContent().getQaContent(); - logger.debug("qaContent: " + qaContent); - - String currentMonitoredToolSession=qaMonitoringForm.getSelectedToolSessionId(); - logger.debug("currentMonitoredToolSession: " + currentMonitoredToolSession); + GeneralLearnerFlowDTO generalLearnerFlowDTO = LearningUtil.buildGeneralLearnerFlowDTO(qaContent); + QaMonitoringAction.logger.debug("generalLearnerFlowDTO: " + generalLearnerFlowDTO); - if (currentMonitoredToolSession.equals("")) - { - currentMonitoredToolSession="All"; - } + refreshSummaryData(request, qaContent, qaService, true, false, null, null, generalLearnerFlowDTO, true, + currentMonitoredToolSession); - if (currentMonitoredToolSession.equals("All")) - { - request.setAttribute(SELECTION_CASE, new Long(2)); - } - else - { - request.setAttribute(SELECTION_CASE, new Long(1)); - } + prepareReflectionData(request, qaContent, qaService, null, false, currentMonitoredToolSession); - logger.debug("SELECTION_CASE: " + request.getAttribute(SELECTION_CASE)); + prepareEditActivityScreenData(request, qaContent); - - Map summaryToolSessions=MonitoringUtil.populateToolSessions(request, qaContent, qaService); - logger.debug("summaryToolSessions: " + summaryToolSessions); - request.setAttribute(SUMMARY_TOOL_SESSIONS, summaryToolSessions); - logger.debug("SUMMARY_TOOL_SESSIONS: " + request.getAttribute(SUMMARY_TOOL_SESSIONS)); + EditActivityDTO editActivityDTO = new EditActivityDTO(); + boolean isContentInUse = QaUtils.isContentInUse(qaContent); + QaMonitoringAction.logger.debug("isContentInUse:" + isContentInUse); + if (isContentInUse == true) { + editActivityDTO.setMonitoredContentInUse(new Boolean(true).toString()); + } + request.setAttribute(QaAppConstants.EDIT_ACTIVITY_DTO, editActivityDTO); + /* find out if there are any reflection entries, from here */ + boolean notebookEntriesExist = MonitoringUtil.notebookEntriesExist(qaService, qaContent); + QaMonitoringAction.logger.debug("notebookEntriesExist : " + notebookEntriesExist); - Map summaryToolSessionsId=MonitoringUtil.populateToolSessionsId(request, qaContent, qaService); - logger.debug("summaryToolSessionsId: " + summaryToolSessionsId); - request.setAttribute(SUMMARY_TOOL_SESSIONS_ID, summaryToolSessionsId); - - GeneralLearnerFlowDTO generalLearnerFlowDTO= LearningUtil.buildGeneralLearnerFlowDTO(qaContent); - logger.debug("generalLearnerFlowDTO: " + generalLearnerFlowDTO); - - refreshSummaryData(request, qaContent, qaService, true, false, null, null, generalLearnerFlowDTO, true, currentMonitoredToolSession); + if (notebookEntriesExist) { + request.setAttribute(QaAppConstants.NOTEBOOK_ENTRIES_EXIST, new Boolean(true).toString()); + } else { + request.setAttribute(QaAppConstants.NOTEBOOK_ENTRIES_EXIST, new Boolean(false).toString()); + } + /* ... till here */ - prepareReflectionData(request, qaContent, qaService,null, false, currentMonitoredToolSession); - - prepareEditActivityScreenData(request, qaContent); + MonitoringUtil.buildQaStatsDTO(request, qaService, qaContent); + MonitoringUtil.generateGroupsSessionData(request, qaService, qaContent, false); - EditActivityDTO editActivityDTO = new EditActivityDTO(); - boolean isContentInUse=QaUtils.isContentInUse(qaContent); - logger.debug("isContentInUse:" + isContentInUse); - if (isContentInUse == true) - { - editActivityDTO.setMonitoredContentInUse(new Boolean(true).toString()); - } - request.setAttribute(EDIT_ACTIVITY_DTO, editActivityDTO); - - - /*find out if there are any reflection entries, from here*/ - boolean notebookEntriesExist=MonitoringUtil.notebookEntriesExist(qaService, qaContent); - logger.debug("notebookEntriesExist : " + notebookEntriesExist); - - if (notebookEntriesExist) - { - request.setAttribute(NOTEBOOK_ENTRIES_EXIST, new Boolean(true).toString()); - } - else - { - request.setAttribute(NOTEBOOK_ENTRIES_EXIST, new Boolean(false).toString()); - } - /* ... till here*/ + return mapping.findForward(QaAppConstants.LOAD_MONITORING); + } - MonitoringUtil.buildQaStatsDTO(request,qaService, qaContent); - MonitoringUtil.generateGroupsSessionData(request, qaService, qaContent, false); - request.setAttribute("currentMonitoredToolSession", "All"); - - return (mapping.findForward(LOAD_MONITORING)); + public ActionForward editGroupResponse(ActionMapping mapping, ActionForm form, HttpServletRequest request, + HttpServletResponse response) throws IOException, ServletException { + QaMonitoringAction.logger.debug("dispatching editGroupResponse..."); + + IQaService qaService = QaServiceProxy.getQaService(getServlet().getServletContext()); + QaMonitoringAction.logger.debug("qaService: " + qaService); + + QaMonitoringForm qaMonitoringForm = (QaMonitoringForm) form; + + String editResponse = request.getParameter(QaAppConstants.EDIT_RESPONSE); + QaMonitoringAction.logger.debug("editResponse: " + editResponse); + qaMonitoringForm.setEditResponse(editResponse); + + String editableSessionId = request.getParameter("sessionId"); + QaMonitoringAction.logger.debug("editableSessionId: " + editableSessionId); + request.setAttribute("editableSessionId", editableSessionId); + + String contentFolderID = WebUtil.readStrParam(request, AttributeNames.PARAM_CONTENT_FOLDER_ID); + QaMonitoringAction.logger.debug("contentFolderID: " + contentFolderID); + qaMonitoringForm.setContentFolderID(contentFolderID); + + String responseId = qaMonitoringForm.getResponseId(); + QaMonitoringAction.logger.debug("responseId: " + responseId); + request.getSession().setAttribute(QaAppConstants.EDITABLE_RESPONSE_ID, responseId); + + QaUsrResp qaUsrResp = qaService.retrieveQaUsrResp(new Long(responseId).longValue()); + QaMonitoringAction.logger.debug("qaUsrResp: " + qaUsrResp); + + refreshUserInput(request, qaMonitoringForm); + + QaContent qaContent = qaUsrResp.getQaQueContent().getQaContent(); + QaMonitoringAction.logger.debug("qaContent: " + qaContent); + + String currentMonitoredToolSession = qaMonitoringForm.getSelectedToolSessionId(); + QaMonitoringAction.logger.debug("currentMonitoredToolSession: " + currentMonitoredToolSession); + + if (currentMonitoredToolSession.equals("")) { + currentMonitoredToolSession = "All"; } - - - - + + if (currentMonitoredToolSession.equals("All")) { + request.setAttribute(QaAppConstants.SELECTION_CASE, new Long(2)); + } else { + request.setAttribute(QaAppConstants.SELECTION_CASE, new Long(1)); + } + + QaMonitoringAction.logger.debug("SELECTION_CASE: " + request.getAttribute(QaAppConstants.SELECTION_CASE)); + + Map summaryToolSessions = MonitoringUtil.populateToolSessions(request, qaContent, qaService); + QaMonitoringAction.logger.debug("summaryToolSessions: " + summaryToolSessions); + request.setAttribute(QaAppConstants.SUMMARY_TOOL_SESSIONS, summaryToolSessions); + QaMonitoringAction.logger.debug("SUMMARY_TOOL_SESSIONS: " + + request.getAttribute(QaAppConstants.SUMMARY_TOOL_SESSIONS)); + + Map summaryToolSessionsId = MonitoringUtil.populateToolSessionsId(request, qaContent, qaService); + QaMonitoringAction.logger.debug("summaryToolSessionsId: " + summaryToolSessionsId); + request.setAttribute(QaAppConstants.SUMMARY_TOOL_SESSIONS_ID, summaryToolSessionsId); + + GeneralLearnerFlowDTO generalLearnerFlowDTO = LearningUtil.buildGeneralLearnerFlowDTO(qaContent); + QaMonitoringAction.logger.debug("generalLearnerFlowDTO: " + generalLearnerFlowDTO); + + refreshSummaryData(request, qaContent, qaService, true, false, null, null, generalLearnerFlowDTO, true, + currentMonitoredToolSession); + + prepareReflectionData(request, qaContent, qaService, null, false, currentMonitoredToolSession); + + prepareEditActivityScreenData(request, qaContent); + + EditActivityDTO editActivityDTO = new EditActivityDTO(); + boolean isContentInUse = QaUtils.isContentInUse(qaContent); + QaMonitoringAction.logger.debug("isContentInUse:" + isContentInUse); + if (isContentInUse == true) { + editActivityDTO.setMonitoredContentInUse(new Boolean(true).toString()); + } + request.setAttribute(QaAppConstants.EDIT_ACTIVITY_DTO, editActivityDTO); + + /* find out if there are any reflection entries, from here */ + boolean notebookEntriesExist = MonitoringUtil.notebookEntriesExist(qaService, qaContent); + QaMonitoringAction.logger.debug("notebookEntriesExist : " + notebookEntriesExist); + + if (notebookEntriesExist) { + request.setAttribute(QaAppConstants.NOTEBOOK_ENTRIES_EXIST, new Boolean(true).toString()); + } else { + request.setAttribute(QaAppConstants.NOTEBOOK_ENTRIES_EXIST, new Boolean(false).toString()); + } + /* ... till here */ + + MonitoringUtil.buildQaStatsDTO(request, qaService, qaContent); + MonitoringUtil.generateGroupsSessionData(request, qaService, qaContent, false); + request.setAttribute("currentMonitoredToolSession", "All"); + + return mapping.findForward(QaAppConstants.LOAD_MONITORING); + } + /** - * enables the user to update responses - * ActionForward updateResponse(ActionMapping mapping, - ActionForm form, - HttpServletRequest request, - HttpServletResponse response) throws IOException, - ServletException + * enables the user to update responses ActionForward updateResponse(ActionMapping mapping, ActionForm form, + * HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException * * @param mapping * @param form @@ -1212,254 +1048,216 @@ * @throws IOException * @throws ServletException */ - public ActionForward updateResponse(ActionMapping mapping, - ActionForm form, - HttpServletRequest request, - HttpServletResponse response) throws IOException, - ServletException - { - logger.debug("dispatching updateResponse..."); + public ActionForward updateResponse(ActionMapping mapping, ActionForm form, HttpServletRequest request, + HttpServletResponse response) throws IOException, ServletException { + QaMonitoringAction.logger.debug("dispatching updateResponse..."); - IQaService qaService = QaServiceProxy.getQaService(getServlet().getServletContext()); - logger.debug("qaService: " + qaService); + IQaService qaService = QaServiceProxy.getQaService(getServlet().getServletContext()); + QaMonitoringAction.logger.debug("qaService: " + qaService); - QaMonitoringForm qaMonitoringForm = (QaMonitoringForm) form; + QaMonitoringForm qaMonitoringForm = (QaMonitoringForm) form; + String contentFolderID = WebUtil.readStrParam(request, AttributeNames.PARAM_CONTENT_FOLDER_ID); + QaMonitoringAction.logger.debug("contentFolderID: " + contentFolderID); + qaMonitoringForm.setContentFolderID(contentFolderID); - String contentFolderID = WebUtil.readStrParam(request, AttributeNames.PARAM_CONTENT_FOLDER_ID); - logger.debug("contentFolderID: " + contentFolderID); - qaMonitoringForm.setContentFolderID(contentFolderID); + String editResponse = request.getParameter(QaAppConstants.EDIT_RESPONSE); + QaMonitoringAction.logger.debug("editResponse: " + editResponse); + qaMonitoringForm.setEditResponse(editResponse); - - String editResponse=request.getParameter(EDIT_RESPONSE); - logger.debug("editResponse: " + editResponse); - qaMonitoringForm.setEditResponse(editResponse); + String responseId = qaMonitoringForm.getResponseId(); + QaMonitoringAction.logger.debug("responseId: " + responseId); - - String responseId=qaMonitoringForm.getResponseId(); - logger.debug("responseId: " + responseId); - - String updatedResponse=request.getParameter("updatedResponse"); - logger.debug("updatedResponse: " + updatedResponse); - QaUsrResp qaUsrResp= qaService.retrieveQaUsrResp(new Long(responseId).longValue()); - logger.debug("qaUsrResp: " + qaUsrResp); - - /* write out the audit log entry. If you move this after the update of the response, - then make sure you update the audit call to use a copy of the original answer */ - qaService.getAuditService().logChange(MY_SIGNATURE, - qaUsrResp.getQaQueUser().getQueUsrId(),qaUsrResp.getQaQueUser().getUsername(), - qaUsrResp.getAnswer(), updatedResponse); + String updatedResponse = request.getParameter("updatedResponse"); + QaMonitoringAction.logger.debug("updatedResponse: " + updatedResponse); + QaUsrResp qaUsrResp = qaService.retrieveQaUsrResp(new Long(responseId).longValue()); + QaMonitoringAction.logger.debug("qaUsrResp: " + qaUsrResp); - qaUsrResp.setAnswer(updatedResponse); - qaService.updateQaUsrResp(qaUsrResp); - logger.debug("response updated."); - - refreshUserInput(request, qaMonitoringForm); - - - String currentMonitoredToolSession=qaMonitoringForm.getSelectedToolSessionId(); - logger.debug("currentMonitoredToolSession: " + currentMonitoredToolSession); + /* + * write out the audit log entry. If you move this after the update of the response, then make sure you update + * the audit call to use a copy of the original answer + */ + qaService.getAuditService().logChange(QaAppConstants.MY_SIGNATURE, qaUsrResp.getQaQueUser().getQueUsrId(), + qaUsrResp.getQaQueUser().getUsername(), qaUsrResp.getAnswer(), updatedResponse); - if (currentMonitoredToolSession.equals("")) - { - currentMonitoredToolSession="All"; - } + qaUsrResp.setAnswer(updatedResponse); + qaService.updateQaUsrResp(qaUsrResp); + QaMonitoringAction.logger.debug("response updated."); - if (currentMonitoredToolSession.equals("All")) - { - request.setAttribute(SELECTION_CASE, new Long(2)); - - QaSession qaSession=qaService.retrieveQaSessionOrNullById(new Long(currentMonitoredToolSession).longValue()); - logger.debug("retrieving qaSession name: " + qaSession.getSession_name()); - request.setAttribute(CURRENT_SESSION_NAME, qaSession.getSession_name()); - } - else - { - request.setAttribute(SELECTION_CASE, new Long(1)); - } - logger.debug("SELECTION_CASE: " + request.getAttribute(SELECTION_CASE)); - request.setAttribute(CURRENT_MONITORED_TOOL_SESSION, currentMonitoredToolSession); - + refreshUserInput(request, qaMonitoringForm); - QaContent qaContent=qaUsrResp.getQaQueContent().getQaContent(); - logger.debug("qaContent: " + qaContent); + String currentMonitoredToolSession = qaMonitoringForm.getSelectedToolSessionId(); + QaMonitoringAction.logger.debug("currentMonitoredToolSession: " + currentMonitoredToolSession); - Map summaryToolSessions=MonitoringUtil.populateToolSessions(request, qaContent, qaService); - logger.debug("summaryToolSessions: " + summaryToolSessions); - request.setAttribute(SUMMARY_TOOL_SESSIONS, summaryToolSessions); - logger.debug("SUMMARY_TOOL_SESSIONS: " + request.getAttribute(SUMMARY_TOOL_SESSIONS)); + if (currentMonitoredToolSession.equals("")) { + currentMonitoredToolSession = "All"; + } + if (currentMonitoredToolSession.equals("All")) { + request.setAttribute(QaAppConstants.SELECTION_CASE, new Long(2)); - Map summaryToolSessionsId=MonitoringUtil.populateToolSessionsId(request, qaContent, qaService); - logger.debug("summaryToolSessionsId: " + summaryToolSessionsId); - request.setAttribute(SUMMARY_TOOL_SESSIONS_ID, summaryToolSessionsId); + QaSession qaSession = qaService.retrieveQaSessionOrNullById(new Long(currentMonitoredToolSession) + .longValue()); + QaMonitoringAction.logger.debug("retrieving qaSession name: " + qaSession.getSession_name()); + request.setAttribute(QaAppConstants.CURRENT_SESSION_NAME, qaSession.getSession_name()); + } else { + request.setAttribute(QaAppConstants.SELECTION_CASE, new Long(1)); + } + QaMonitoringAction.logger.debug("SELECTION_CASE: " + request.getAttribute(QaAppConstants.SELECTION_CASE)); + request.setAttribute(QaAppConstants.CURRENT_MONITORED_TOOL_SESSION, currentMonitoredToolSession); - GeneralLearnerFlowDTO generalLearnerFlowDTO= LearningUtil.buildGeneralLearnerFlowDTO(qaContent); - logger.debug("generalLearnerFlowDTO: " + generalLearnerFlowDTO); - - refreshSummaryData(request, qaContent, qaService, true, false, null, null, generalLearnerFlowDTO, false, currentMonitoredToolSession); - - prepareReflectionData(request, qaContent, qaService,null, false, currentMonitoredToolSession); - - prepareEditActivityScreenData(request, qaContent); - - EditActivityDTO editActivityDTO = new EditActivityDTO(); - boolean isContentInUse=QaUtils.isContentInUse(qaContent); - logger.debug("isContentInUse:" + isContentInUse); - if (isContentInUse == true) - { - editActivityDTO.setMonitoredContentInUse(new Boolean(true).toString()); - } - request.setAttribute(EDIT_ACTIVITY_DTO, editActivityDTO); - - - /*find out if there are any reflection entries, from here*/ - boolean notebookEntriesExist=MonitoringUtil.notebookEntriesExist(qaService, qaContent); - logger.debug("notebookEntriesExist : " + notebookEntriesExist); - - if (notebookEntriesExist) - { - request.setAttribute(NOTEBOOK_ENTRIES_EXIST, new Boolean(true).toString()); - } - else - { - request.setAttribute(NOTEBOOK_ENTRIES_EXIST, new Boolean(false).toString()); - } - /* ... till here*/ - - MonitoringUtil.buildQaStatsDTO(request,qaService, qaContent); - MonitoringUtil.generateGroupsSessionData(request, qaService, qaContent, false); - - return (mapping.findForward(LOAD_MONITORING)); + QaContent qaContent = qaUsrResp.getQaQueContent().getQaContent(); + QaMonitoringAction.logger.debug("qaContent: " + qaContent); + + Map summaryToolSessions = MonitoringUtil.populateToolSessions(request, qaContent, qaService); + QaMonitoringAction.logger.debug("summaryToolSessions: " + summaryToolSessions); + request.setAttribute(QaAppConstants.SUMMARY_TOOL_SESSIONS, summaryToolSessions); + QaMonitoringAction.logger.debug("SUMMARY_TOOL_SESSIONS: " + + request.getAttribute(QaAppConstants.SUMMARY_TOOL_SESSIONS)); + + Map summaryToolSessionsId = MonitoringUtil.populateToolSessionsId(request, qaContent, qaService); + QaMonitoringAction.logger.debug("summaryToolSessionsId: " + summaryToolSessionsId); + request.setAttribute(QaAppConstants.SUMMARY_TOOL_SESSIONS_ID, summaryToolSessionsId); + + GeneralLearnerFlowDTO generalLearnerFlowDTO = LearningUtil.buildGeneralLearnerFlowDTO(qaContent); + QaMonitoringAction.logger.debug("generalLearnerFlowDTO: " + generalLearnerFlowDTO); + + refreshSummaryData(request, qaContent, qaService, true, false, null, null, generalLearnerFlowDTO, false, + currentMonitoredToolSession); + + prepareReflectionData(request, qaContent, qaService, null, false, currentMonitoredToolSession); + + prepareEditActivityScreenData(request, qaContent); + + EditActivityDTO editActivityDTO = new EditActivityDTO(); + boolean isContentInUse = QaUtils.isContentInUse(qaContent); + QaMonitoringAction.logger.debug("isContentInUse:" + isContentInUse); + if (isContentInUse == true) { + editActivityDTO.setMonitoredContentInUse(new Boolean(true).toString()); } + request.setAttribute(QaAppConstants.EDIT_ACTIVITY_DTO, editActivityDTO); - - - - public ActionForward updateGroupResponse(ActionMapping mapping, - ActionForm form, - HttpServletRequest request, - HttpServletResponse response) throws IOException, - ServletException - { - logger.debug("dispatching updateGroupResponse..."); + /* find out if there are any reflection entries, from here */ + boolean notebookEntriesExist = MonitoringUtil.notebookEntriesExist(qaService, qaContent); + QaMonitoringAction.logger.debug("notebookEntriesExist : " + notebookEntriesExist); - IQaService qaService = QaServiceProxy.getQaService(getServlet().getServletContext()); - logger.debug("qaService: " + qaService); + if (notebookEntriesExist) { + request.setAttribute(QaAppConstants.NOTEBOOK_ENTRIES_EXIST, new Boolean(true).toString()); + } else { + request.setAttribute(QaAppConstants.NOTEBOOK_ENTRIES_EXIST, new Boolean(false).toString()); + } + /* ... till here */ - QaMonitoringForm qaMonitoringForm = (QaMonitoringForm) form; + MonitoringUtil.buildQaStatsDTO(request, qaService, qaContent); + MonitoringUtil.generateGroupsSessionData(request, qaService, qaContent, false); + return mapping.findForward(QaAppConstants.LOAD_MONITORING); + } - String contentFolderID = WebUtil.readStrParam(request, AttributeNames.PARAM_CONTENT_FOLDER_ID); - logger.debug("contentFolderID: " + contentFolderID); - qaMonitoringForm.setContentFolderID(contentFolderID); + public ActionForward updateGroupResponse(ActionMapping mapping, ActionForm form, HttpServletRequest request, + HttpServletResponse response) throws IOException, ServletException { + QaMonitoringAction.logger.debug("dispatching updateGroupResponse..."); - - String editResponse=request.getParameter(EDIT_RESPONSE); - logger.debug("editResponse: " + editResponse); - qaMonitoringForm.setEditResponse(editResponse); + IQaService qaService = QaServiceProxy.getQaService(getServlet().getServletContext()); + QaMonitoringAction.logger.debug("qaService: " + qaService); - - String responseId=qaMonitoringForm.getResponseId(); - logger.debug("responseId: " + responseId); - - String updatedResponse=request.getParameter("updatedResponse"); - logger.debug("updatedResponse: " + updatedResponse); - QaUsrResp qaUsrResp= qaService.retrieveQaUsrResp(new Long(responseId).longValue()); - logger.debug("qaUsrResp: " + qaUsrResp); - - /* write out the audit log entry. If you move this after the update of the response, - then make sure you update the audit call to use a copy of the original answer */ - qaService.getAuditService().logChange(MY_SIGNATURE, - qaUsrResp.getQaQueUser().getQueUsrId(),qaUsrResp.getQaQueUser().getUsername(), - qaUsrResp.getAnswer(), updatedResponse); + QaMonitoringForm qaMonitoringForm = (QaMonitoringForm) form; - qaUsrResp.setAnswer(updatedResponse); - qaService.updateQaUsrResp(qaUsrResp); - logger.debug("response updated."); - - refreshUserInput(request, qaMonitoringForm); - - - String currentMonitoredToolSession=qaMonitoringForm.getSelectedToolSessionId(); - logger.debug("currentMonitoredToolSession: " + currentMonitoredToolSession); + String contentFolderID = WebUtil.readStrParam(request, AttributeNames.PARAM_CONTENT_FOLDER_ID); + QaMonitoringAction.logger.debug("contentFolderID: " + contentFolderID); + qaMonitoringForm.setContentFolderID(contentFolderID); - if (currentMonitoredToolSession.equals("")) - { - currentMonitoredToolSession="All"; - } + String editResponse = request.getParameter(QaAppConstants.EDIT_RESPONSE); + QaMonitoringAction.logger.debug("editResponse: " + editResponse); + qaMonitoringForm.setEditResponse(editResponse); - if (currentMonitoredToolSession.equals("All")) - { - request.setAttribute(SELECTION_CASE, new Long(2)); - } - else - { - request.setAttribute(SELECTION_CASE, new Long(1)); - } - logger.debug("SELECTION_CASE: " + request.getAttribute(SELECTION_CASE)); + String responseId = qaMonitoringForm.getResponseId(); + QaMonitoringAction.logger.debug("responseId: " + responseId); - QaContent qaContent=qaUsrResp.getQaQueContent().getQaContent(); - logger.debug("qaContent: " + qaContent); + String updatedResponse = request.getParameter("updatedResponse"); + QaMonitoringAction.logger.debug("updatedResponse: " + updatedResponse); + QaUsrResp qaUsrResp = qaService.retrieveQaUsrResp(new Long(responseId).longValue()); + QaMonitoringAction.logger.debug("qaUsrResp: " + qaUsrResp); - Map summaryToolSessions=MonitoringUtil.populateToolSessions(request, qaContent, qaService); - logger.debug("summaryToolSessions: " + summaryToolSessions); - request.setAttribute(SUMMARY_TOOL_SESSIONS, summaryToolSessions); - logger.debug("SUMMARY_TOOL_SESSIONS: " + request.getAttribute(SUMMARY_TOOL_SESSIONS)); + /* + * write out the audit log entry. If you move this after the update of the response, then make sure you update + * the audit call to use a copy of the original answer + */ + qaService.getAuditService().logChange(QaAppConstants.MY_SIGNATURE, qaUsrResp.getQaQueUser().getQueUsrId(), + qaUsrResp.getQaQueUser().getUsername(), qaUsrResp.getAnswer(), updatedResponse); + qaUsrResp.setAnswer(updatedResponse); + qaService.updateQaUsrResp(qaUsrResp); + QaMonitoringAction.logger.debug("response updated."); - Map summaryToolSessionsId=MonitoringUtil.populateToolSessionsId(request, qaContent, qaService); - logger.debug("summaryToolSessionsId: " + summaryToolSessionsId); - request.setAttribute(SUMMARY_TOOL_SESSIONS_ID, summaryToolSessionsId); + refreshUserInput(request, qaMonitoringForm); - GeneralLearnerFlowDTO generalLearnerFlowDTO= LearningUtil.buildGeneralLearnerFlowDTO(qaContent); - logger.debug("generalLearnerFlowDTO: " + generalLearnerFlowDTO); - - refreshSummaryData(request, qaContent, qaService, true, false, null, null, generalLearnerFlowDTO, false, currentMonitoredToolSession); - - prepareReflectionData(request, qaContent, qaService,null, false, currentMonitoredToolSession); - - prepareEditActivityScreenData(request, qaContent); - - EditActivityDTO editActivityDTO = new EditActivityDTO(); - boolean isContentInUse=QaUtils.isContentInUse(qaContent); - logger.debug("isContentInUse:" + isContentInUse); - if (isContentInUse == true) - { - editActivityDTO.setMonitoredContentInUse(new Boolean(true).toString()); - } - request.setAttribute(EDIT_ACTIVITY_DTO, editActivityDTO); - - - /*find out if there are any reflection entries, from here*/ - boolean notebookEntriesExist=MonitoringUtil.notebookEntriesExist(qaService, qaContent); - logger.debug("notebookEntriesExist : " + notebookEntriesExist); - - if (notebookEntriesExist) - { - request.setAttribute(NOTEBOOK_ENTRIES_EXIST, new Boolean(true).toString()); - } - else - { - request.setAttribute(NOTEBOOK_ENTRIES_EXIST, new Boolean(false).toString()); - } - /* ... till here*/ - - MonitoringUtil.buildQaStatsDTO(request,qaService, qaContent); - MonitoringUtil.generateGroupsSessionData(request, qaService, qaContent, false); - request.setAttribute("currentMonitoredToolSession", "All"); - - return (mapping.findForward(LOAD_MONITORING)); + String currentMonitoredToolSession = qaMonitoringForm.getSelectedToolSessionId(); + QaMonitoringAction.logger.debug("currentMonitoredToolSession: " + currentMonitoredToolSession); + + if (currentMonitoredToolSession.equals("")) { + currentMonitoredToolSession = "All"; } - - + + if (currentMonitoredToolSession.equals("All")) { + request.setAttribute(QaAppConstants.SELECTION_CASE, new Long(2)); + } else { + request.setAttribute(QaAppConstants.SELECTION_CASE, new Long(1)); + } + QaMonitoringAction.logger.debug("SELECTION_CASE: " + request.getAttribute(QaAppConstants.SELECTION_CASE)); + + QaContent qaContent = qaUsrResp.getQaQueContent().getQaContent(); + QaMonitoringAction.logger.debug("qaContent: " + qaContent); + + Map summaryToolSessions = MonitoringUtil.populateToolSessions(request, qaContent, qaService); + QaMonitoringAction.logger.debug("summaryToolSessions: " + summaryToolSessions); + request.setAttribute(QaAppConstants.SUMMARY_TOOL_SESSIONS, summaryToolSessions); + QaMonitoringAction.logger.debug("SUMMARY_TOOL_SESSIONS: " + + request.getAttribute(QaAppConstants.SUMMARY_TOOL_SESSIONS)); + + Map summaryToolSessionsId = MonitoringUtil.populateToolSessionsId(request, qaContent, qaService); + QaMonitoringAction.logger.debug("summaryToolSessionsId: " + summaryToolSessionsId); + request.setAttribute(QaAppConstants.SUMMARY_TOOL_SESSIONS_ID, summaryToolSessionsId); + + GeneralLearnerFlowDTO generalLearnerFlowDTO = LearningUtil.buildGeneralLearnerFlowDTO(qaContent); + QaMonitoringAction.logger.debug("generalLearnerFlowDTO: " + generalLearnerFlowDTO); + + refreshSummaryData(request, qaContent, qaService, true, false, null, null, generalLearnerFlowDTO, false, + currentMonitoredToolSession); + + prepareReflectionData(request, qaContent, qaService, null, false, currentMonitoredToolSession); + + prepareEditActivityScreenData(request, qaContent); + + EditActivityDTO editActivityDTO = new EditActivityDTO(); + boolean isContentInUse = QaUtils.isContentInUse(qaContent); + QaMonitoringAction.logger.debug("isContentInUse:" + isContentInUse); + if (isContentInUse == true) { + editActivityDTO.setMonitoredContentInUse(new Boolean(true).toString()); + } + request.setAttribute(QaAppConstants.EDIT_ACTIVITY_DTO, editActivityDTO); + + /* find out if there are any reflection entries, from here */ + boolean notebookEntriesExist = MonitoringUtil.notebookEntriesExist(qaService, qaContent); + QaMonitoringAction.logger.debug("notebookEntriesExist : " + notebookEntriesExist); + + if (notebookEntriesExist) { + request.setAttribute(QaAppConstants.NOTEBOOK_ENTRIES_EXIST, new Boolean(true).toString()); + } else { + request.setAttribute(QaAppConstants.NOTEBOOK_ENTRIES_EXIST, new Boolean(false).toString()); + } + /* ... till here */ + + MonitoringUtil.buildQaStatsDTO(request, qaService, qaContent); + MonitoringUtil.generateGroupsSessionData(request, qaService, qaContent, false); + request.setAttribute("currentMonitoredToolSession", "All"); + + return mapping.findForward(QaAppConstants.LOAD_MONITORING); + } + /** - * enables the user to delete responses - * ActionForward deleteResponse(ActionMapping mapping, - ActionForm form, - HttpServletRequest request, - HttpServletResponse response) throws IOException, - ServletException + * enables the user to delete responses ActionForward deleteResponse(ActionMapping mapping, ActionForm form, + * HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException * * @param mapping * @param form @@ -1469,209 +1267,183 @@ * @throws IOException * @throws ServletException */ - public ActionForward deleteResponse(ActionMapping mapping, - ActionForm form, - HttpServletRequest request, - HttpServletResponse response) throws IOException, - ServletException - { - logger.debug("dispatching deleteResponse..."); + public ActionForward deleteResponse(ActionMapping mapping, ActionForm form, HttpServletRequest request, + HttpServletResponse response) throws IOException, ServletException { + QaMonitoringAction.logger.debug("dispatching deleteResponse..."); - IQaService qaService = QaServiceProxy.getQaService(getServlet().getServletContext()); - logger.debug("qaService: " + qaService); + IQaService qaService = QaServiceProxy.getQaService(getServlet().getServletContext()); + QaMonitoringAction.logger.debug("qaService: " + qaService); - QaMonitoringForm qaMonitoringForm = (QaMonitoringForm) form; - - String contentFolderID = WebUtil.readStrParam(request, AttributeNames.PARAM_CONTENT_FOLDER_ID); - logger.debug("contentFolderID: " + contentFolderID); - qaMonitoringForm.setContentFolderID(contentFolderID); + QaMonitoringForm qaMonitoringForm = (QaMonitoringForm) form; + String contentFolderID = WebUtil.readStrParam(request, AttributeNames.PARAM_CONTENT_FOLDER_ID); + QaMonitoringAction.logger.debug("contentFolderID: " + contentFolderID); + qaMonitoringForm.setContentFolderID(contentFolderID); - String editResponse=request.getParameter(EDIT_RESPONSE); - logger.debug("editResponse: " + editResponse); - qaMonitoringForm.setEditResponse(editResponse); + String editResponse = request.getParameter(QaAppConstants.EDIT_RESPONSE); + QaMonitoringAction.logger.debug("editResponse: " + editResponse); + qaMonitoringForm.setEditResponse(editResponse); - - String currentMonitoredToolSession=qaMonitoringForm.getSelectedToolSessionId(); - logger.debug("currentMonitoredToolSession: " + currentMonitoredToolSession); + String currentMonitoredToolSession = qaMonitoringForm.getSelectedToolSessionId(); + QaMonitoringAction.logger.debug("currentMonitoredToolSession: " + currentMonitoredToolSession); - if (currentMonitoredToolSession.equals("")) - { - currentMonitoredToolSession="All"; - } + if (currentMonitoredToolSession.equals("")) { + currentMonitoredToolSession = "All"; + } - if (currentMonitoredToolSession.equals("All")) - { - request.setAttribute(SELECTION_CASE, new Long(2)); - } - else - { - request.setAttribute(SELECTION_CASE, new Long(1)); - } + if (currentMonitoredToolSession.equals("All")) { + request.setAttribute(QaAppConstants.SELECTION_CASE, new Long(2)); + } else { + request.setAttribute(QaAppConstants.SELECTION_CASE, new Long(1)); + } - logger.debug("SELECTION_CASE: " + request.getAttribute(SELECTION_CASE)); - - String responseId=qaMonitoringForm.getResponseId(); - logger.debug("responseId: " + responseId); - - QaUsrResp qaUsrResp= qaService.retrieveQaUsrResp(new Long(responseId).longValue()); - logger.debug("qaUsrResp: " + qaUsrResp); - - qaService.removeUserResponse(qaUsrResp); - logger.debug("response deleted."); - - refreshUserInput(request, qaMonitoringForm); - - QaContent qaContent=qaUsrResp.getQaQueContent().getQaContent(); - logger.debug("qaContent: " + qaContent); + QaMonitoringAction.logger.debug("SELECTION_CASE: " + request.getAttribute(QaAppConstants.SELECTION_CASE)); - - Map summaryToolSessions=MonitoringUtil.populateToolSessions(request, qaContent, qaService); - logger.debug("summaryToolSessions: " + summaryToolSessions); - request.setAttribute(SUMMARY_TOOL_SESSIONS, summaryToolSessions); - logger.debug("SUMMARY_TOOL_SESSIONS: " + request.getAttribute(SUMMARY_TOOL_SESSIONS)); + String responseId = qaMonitoringForm.getResponseId(); + QaMonitoringAction.logger.debug("responseId: " + responseId); + QaUsrResp qaUsrResp = qaService.retrieveQaUsrResp(new Long(responseId).longValue()); + QaMonitoringAction.logger.debug("qaUsrResp: " + qaUsrResp); - Map summaryToolSessionsId=MonitoringUtil.populateToolSessionsId(request, qaContent, qaService); - logger.debug("summaryToolSessionsId: " + summaryToolSessionsId); - request.setAttribute(SUMMARY_TOOL_SESSIONS_ID, summaryToolSessionsId); + qaService.removeUserResponse(qaUsrResp); + QaMonitoringAction.logger.debug("response deleted."); - - GeneralLearnerFlowDTO generalLearnerFlowDTO= LearningUtil.buildGeneralLearnerFlowDTO(qaContent); - logger.debug("generalLearnerFlowDTO: " + generalLearnerFlowDTO); - - refreshSummaryData(request, qaContent, qaService, true, false, null, null, generalLearnerFlowDTO, false ,currentMonitoredToolSession); - - prepareReflectionData(request, qaContent, qaService,null, false, currentMonitoredToolSession); - - prepareEditActivityScreenData(request, qaContent); - - EditActivityDTO editActivityDTO = new EditActivityDTO(); - boolean isContentInUse=QaUtils.isContentInUse(qaContent); - logger.debug("isContentInUse:" + isContentInUse); - if (isContentInUse == true) - { - editActivityDTO.setMonitoredContentInUse(new Boolean(true).toString()); - } - request.setAttribute(EDIT_ACTIVITY_DTO, editActivityDTO); - - - /*find out if there are any reflection entries, from here*/ - boolean notebookEntriesExist=MonitoringUtil.notebookEntriesExist(qaService, qaContent); - logger.debug("notebookEntriesExist : " + notebookEntriesExist); - - if (notebookEntriesExist) - { - request.setAttribute(NOTEBOOK_ENTRIES_EXIST, new Boolean(true).toString()); - } - else - { - request.setAttribute(NOTEBOOK_ENTRIES_EXIST, new Boolean(false).toString()); - } - /* ... till here*/ - - MonitoringUtil.buildQaStatsDTO(request,qaService, qaContent); - MonitoringUtil.generateGroupsSessionData(request, qaService, qaContent, false); - - return (mapping.findForward(LOAD_MONITORING)); + refreshUserInput(request, qaMonitoringForm); + + QaContent qaContent = qaUsrResp.getQaQueContent().getQaContent(); + QaMonitoringAction.logger.debug("qaContent: " + qaContent); + + Map summaryToolSessions = MonitoringUtil.populateToolSessions(request, qaContent, qaService); + QaMonitoringAction.logger.debug("summaryToolSessions: " + summaryToolSessions); + request.setAttribute(QaAppConstants.SUMMARY_TOOL_SESSIONS, summaryToolSessions); + QaMonitoringAction.logger.debug("SUMMARY_TOOL_SESSIONS: " + + request.getAttribute(QaAppConstants.SUMMARY_TOOL_SESSIONS)); + + Map summaryToolSessionsId = MonitoringUtil.populateToolSessionsId(request, qaContent, qaService); + QaMonitoringAction.logger.debug("summaryToolSessionsId: " + summaryToolSessionsId); + request.setAttribute(QaAppConstants.SUMMARY_TOOL_SESSIONS_ID, summaryToolSessionsId); + + GeneralLearnerFlowDTO generalLearnerFlowDTO = LearningUtil.buildGeneralLearnerFlowDTO(qaContent); + QaMonitoringAction.logger.debug("generalLearnerFlowDTO: " + generalLearnerFlowDTO); + + refreshSummaryData(request, qaContent, qaService, true, false, null, null, generalLearnerFlowDTO, false, + currentMonitoredToolSession); + + prepareReflectionData(request, qaContent, qaService, null, false, currentMonitoredToolSession); + + prepareEditActivityScreenData(request, qaContent); + + EditActivityDTO editActivityDTO = new EditActivityDTO(); + boolean isContentInUse = QaUtils.isContentInUse(qaContent); + QaMonitoringAction.logger.debug("isContentInUse:" + isContentInUse); + if (isContentInUse == true) { + editActivityDTO.setMonitoredContentInUse(new Boolean(true).toString()); } + request.setAttribute(QaAppConstants.EDIT_ACTIVITY_DTO, editActivityDTO); - + /* find out if there are any reflection entries, from here */ + boolean notebookEntriesExist = MonitoringUtil.notebookEntriesExist(qaService, qaContent); + QaMonitoringAction.logger.debug("notebookEntriesExist : " + notebookEntriesExist); + + if (notebookEntriesExist) { + request.setAttribute(QaAppConstants.NOTEBOOK_ENTRIES_EXIST, new Boolean(true).toString()); + } else { + request.setAttribute(QaAppConstants.NOTEBOOK_ENTRIES_EXIST, new Boolean(false).toString()); + } + /* ... till here */ + + MonitoringUtil.buildQaStatsDTO(request, qaService, qaContent); + MonitoringUtil.generateGroupsSessionData(request, qaService, qaContent, false); + + return mapping.findForward(QaAppConstants.LOAD_MONITORING); + } + /** * refreshUserInput(HttpServletRequest request) + * * @param request */ - public void refreshUserInput(HttpServletRequest request, QaMonitoringForm qaMonitoringForm) - { - logger.debug("starting refreshUserInput: " + qaMonitoringForm); + public void refreshUserInput(HttpServletRequest request, QaMonitoringForm qaMonitoringForm) { + QaMonitoringAction.logger.debug("starting refreshUserInput: " + qaMonitoringForm); - IQaService qaService = null; - if (getServlet() != null) - qaService = QaServiceProxy.getQaService(getServlet().getServletContext()); - else - qaService=qaMonitoringForm.getQaService(); - - logger.debug("qaService: " + qaService); - logger.debug("qaMonitoringForm: " + qaMonitoringForm); - - String strToolContentID=request.getParameter(AttributeNames.PARAM_TOOL_CONTENT_ID); - logger.debug("strToolContentID: " + strToolContentID); - qaMonitoringForm.setToolContentID(strToolContentID); - - String contentFolderID = WebUtil.readStrParam(request, AttributeNames.PARAM_CONTENT_FOLDER_ID); - logger.debug("contentFolderID: " + contentFolderID); - qaMonitoringForm.setContentFolderID(contentFolderID); + IQaService qaService = null; + if (getServlet() != null) { + qaService = QaServiceProxy.getQaService(getServlet().getServletContext()); + } else { + qaService = qaMonitoringForm.getQaService(); + } + QaMonitoringAction.logger.debug("qaService: " + qaService); + QaMonitoringAction.logger.debug("qaMonitoringForm: " + qaMonitoringForm); - QaContent qaContent=qaService.loadQa(new Long(strToolContentID).longValue()); - logger.debug("existing qaContent:" + qaContent); - - Map summaryToolSessions=MonitoringUtil.populateToolSessions(request, qaContent, qaService); - logger.debug("summaryToolSessions: " + summaryToolSessions); - request.setAttribute(SUMMARY_TOOL_SESSIONS, summaryToolSessions); - logger.debug("SUMMARY_TOOL_SESSIONS: " + request.getAttribute(SUMMARY_TOOL_SESSIONS)); + String strToolContentID = request.getParameter(AttributeNames.PARAM_TOOL_CONTENT_ID); + QaMonitoringAction.logger.debug("strToolContentID: " + strToolContentID); + qaMonitoringForm.setToolContentID(strToolContentID); - Map summaryToolSessionsId=MonitoringUtil.populateToolSessionsId(request, qaContent, qaService); - logger.debug("summaryToolSessionsId: " + summaryToolSessionsId); - - //prepareReflectionData(request, qaContent, qaService,null, false); - - prepareEditActivityScreenData(request, qaContent); - + String contentFolderID = WebUtil.readStrParam(request, AttributeNames.PARAM_CONTENT_FOLDER_ID); + QaMonitoringAction.logger.debug("contentFolderID: " + contentFolderID); + qaMonitoringForm.setContentFolderID(contentFolderID); - EditActivityDTO editActivityDTO = new EditActivityDTO(); - boolean isContentInUse=QaUtils.isContentInUse(qaContent); - logger.debug("isContentInUse:" + isContentInUse); - if (isContentInUse == true) - { - editActivityDTO.setMonitoredContentInUse(new Boolean(true).toString()); - } - request.setAttribute(EDIT_ACTIVITY_DTO, editActivityDTO); + QaContent qaContent = qaService.loadQa(new Long(strToolContentID).longValue()); + QaMonitoringAction.logger.debug("existing qaContent:" + qaContent); - /*find out if there are any reflection entries, from here*/ - boolean notebookEntriesExist=MonitoringUtil.notebookEntriesExist(qaService, qaContent); - logger.debug("notebookEntriesExist : " + notebookEntriesExist); - - if (notebookEntriesExist) - { - request.setAttribute(NOTEBOOK_ENTRIES_EXIST, new Boolean(true).toString()); - } - else - { - request.setAttribute(NOTEBOOK_ENTRIES_EXIST, new Boolean(false).toString()); - } - /* ... till here*/ - - request.setAttribute(SUMMARY_TOOL_SESSIONS_ID, summaryToolSessionsId); - - MonitoringUtil.generateGroupsSessionData(request, qaService, qaContent, false); - MonitoringUtil.buildQaStatsDTO(request,qaService, qaContent); + Map summaryToolSessions = MonitoringUtil.populateToolSessions(request, qaContent, qaService); + QaMonitoringAction.logger.debug("summaryToolSessions: " + summaryToolSessions); + request.setAttribute(QaAppConstants.SUMMARY_TOOL_SESSIONS, summaryToolSessions); + QaMonitoringAction.logger.debug("SUMMARY_TOOL_SESSIONS: " + + request.getAttribute(QaAppConstants.SUMMARY_TOOL_SESSIONS)); + + Map summaryToolSessionsId = MonitoringUtil.populateToolSessionsId(request, qaContent, qaService); + QaMonitoringAction.logger.debug("summaryToolSessionsId: " + summaryToolSessionsId); + + // prepareReflectionData(request, qaContent, qaService,null, false); + + prepareEditActivityScreenData(request, qaContent); + + EditActivityDTO editActivityDTO = new EditActivityDTO(); + boolean isContentInUse = QaUtils.isContentInUse(qaContent); + QaMonitoringAction.logger.debug("isContentInUse:" + isContentInUse); + if (isContentInUse == true) { + editActivityDTO.setMonitoredContentInUse(new Boolean(true).toString()); + } + request.setAttribute(QaAppConstants.EDIT_ACTIVITY_DTO, editActivityDTO); + + /* find out if there are any reflection entries, from here */ + boolean notebookEntriesExist = MonitoringUtil.notebookEntriesExist(qaService, qaContent); + QaMonitoringAction.logger.debug("notebookEntriesExist : " + notebookEntriesExist); + + if (notebookEntriesExist) { + request.setAttribute(QaAppConstants.NOTEBOOK_ENTRIES_EXIST, new Boolean(true).toString()); + } else { + request.setAttribute(QaAppConstants.NOTEBOOK_ENTRIES_EXIST, new Boolean(false).toString()); + } + /* ... till here */ + + request.setAttribute(QaAppConstants.SUMMARY_TOOL_SESSIONS_ID, summaryToolSessionsId); + + MonitoringUtil.generateGroupsSessionData(request, qaService, qaContent, false); + MonitoringUtil.buildQaStatsDTO(request, qaService, qaContent); } - - - - /** - * persists error messages to request scope - * persistError(HttpServletRequest request, String message) + + /** + * persists error messages to request scope persistError(HttpServletRequest request, String message) + * * @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("add " + message +" to ActionMessages:"); - saveErrors(request,errors); - } - - - + public void persistError(HttpServletRequest request, String message) { + ActionMessages errors = new ActionMessages(); + errors.add(Globals.ERROR_KEY, new ActionMessage(message)); + QaMonitoringAction.logger.debug("add " + message + " to ActionMessages:"); + saveErrors(request, errors); + } + /** * populates data for summary screen, view all results screen and export portfolio. - * - * User id is needed if isUserNamesVisible is false && learnerRequest is true, - * as it is required to work out if the data being analysed is the current user. - * + * + * User id is needed if isUserNamesVisible is false && learnerRequest is true, as it is required to work out if the + * data being analysed is the current user. + * * @param request * @param qaContent * @param qaService @@ -1680,2553 +1452,2244 @@ * @param currentSessionId * @param userId */ - public void refreshSummaryData(HttpServletRequest request, QaContent qaContent, IQaService qaService, - boolean isUserNamesVisible, boolean isLearnerRequest, String currentSessionId, String userId, - GeneralLearnerFlowDTO generalLearnerFlowDTO, boolean setEditResponse, String currentMonitoredToolSession) - { - logger.debug("starting refreshSummaryData: setEditResponse + " + setEditResponse); - logger.debug("currentMonitoredToolSession: " + currentMonitoredToolSession); - logger.debug("generalLearnerFlowDTO: " + generalLearnerFlowDTO); - logger.debug("qaService: " + isUserNamesVisible); - - logger.debug("isUserNamesVisible: " + isUserNamesVisible); - logger.debug("isLearnerRequest: " + isLearnerRequest); - - GeneralMonitoringDTO generalMonitoringDTO= new GeneralMonitoringDTO(); - - /* this section is related to summary tab. Starts here. */ - Map summaryToolSessions=MonitoringUtil.populateToolSessions(request, qaContent, qaService); - logger.debug("summaryToolSessions: " + summaryToolSessions); - request.setAttribute(SUMMARY_TOOL_SESSIONS, summaryToolSessions); - - if (qaContent.getTitle() == null) - { - generalMonitoringDTO.setActivityTitle("Questions and Answers"); - generalMonitoringDTO.setActivityInstructions("Please answer the questions."); - } - else - { - generalMonitoringDTO.setActivityTitle(qaContent.getTitle()); - generalMonitoringDTO.setActivityInstructions(qaContent.getInstructions()); - } + public void refreshSummaryData(HttpServletRequest request, QaContent qaContent, IQaService qaService, + boolean isUserNamesVisible, boolean isLearnerRequest, String currentSessionId, String userId, + GeneralLearnerFlowDTO generalLearnerFlowDTO, boolean setEditResponse, String currentMonitoredToolSession) { + QaMonitoringAction.logger.debug("starting refreshSummaryData: setEditResponse + " + setEditResponse); + QaMonitoringAction.logger.debug("currentMonitoredToolSession: " + currentMonitoredToolSession); + QaMonitoringAction.logger.debug("generalLearnerFlowDTO: " + generalLearnerFlowDTO); + QaMonitoringAction.logger.debug("qaService: " + isUserNamesVisible); - if (qaService.studentActivityOccurredGlobal(qaContent)) - { - logger.debug("USER_EXCEPTION_NO_TOOL_SESSIONS is set to false"); - generalMonitoringDTO.setUserExceptionNoToolSessions(new Boolean(false).toString()); - } - else - { - logger.debug("USER_EXCEPTION_NO_TOOL_SESSIONS is set to true"); - generalMonitoringDTO.setUserExceptionNoToolSessions(new Boolean(true).toString()); - } - - - boolean isContentInUse=QaUtils.isContentInUse(qaContent); - logger.debug("isContentInUse:" + isContentInUse); - - generalMonitoringDTO.setMonitoredContentInUse(new Boolean(false).toString()); - if (isContentInUse == true) - { - logger.debug("monitoring url does not allow editActivity since the content is in use."); - persistError(request,"error.content.inUse"); - generalMonitoringDTO.setMonitoredContentInUse(new Boolean(true).toString()); - } + QaMonitoringAction.logger.debug("isUserNamesVisible: " + isUserNamesVisible); + QaMonitoringAction.logger.debug("isLearnerRequest: " + isLearnerRequest); - EditActivityDTO editActivityDTO = new EditActivityDTO(); - if (isContentInUse == true) - { - editActivityDTO.setMonitoredContentInUse(new Boolean(true).toString()); - } - request.setAttribute(EDIT_ACTIVITY_DTO, editActivityDTO); - - Map summaryToolSessionsId=MonitoringUtil.populateToolSessionsId(request, qaContent, qaService); - logger.debug("summaryToolSessionsId: " + summaryToolSessionsId); - request.setAttribute(SUMMARY_TOOL_SESSIONS_ID, summaryToolSessionsId); - - currentSessionId=currentMonitoredToolSession; - - logger.debug("using allUsersData to retrieve data: " + isUserNamesVisible); - List listMonitoredAnswersContainerDTO=MonitoringUtil.buildGroupsQuestionData(request, qaContent, qaService, - isUserNamesVisible, isLearnerRequest, currentSessionId, userId); - - logger.debug("listMonitoredAnswersContainerDTO: " + listMonitoredAnswersContainerDTO); - - - /*getting stats screen content from here... */ - int countAllUsers=qaService.getTotalNumberOfUsers(qaContent); - logger.debug("countAllUsers: " + countAllUsers); - - if (countAllUsers == 0) - { - logger.debug("error: countAllUsers is 0"); - generalMonitoringDTO.setUserExceptionNoStudentActivity(new Boolean(true).toString()); - } - + GeneralMonitoringDTO generalMonitoringDTO = new GeneralMonitoringDTO(); - generalMonitoringDTO.setCountAllUsers(new Integer(countAllUsers).toString()); - - int countSessionComplete=qaService.countSessionComplete(qaContent); - logger.debug("countSessionComplete: " + countSessionComplete); + /* this section is related to summary tab. Starts here. */ + Map summaryToolSessions = MonitoringUtil.populateToolSessions(request, qaContent, qaService); + QaMonitoringAction.logger.debug("summaryToolSessions: " + summaryToolSessions); + request.setAttribute(QaAppConstants.SUMMARY_TOOL_SESSIONS, summaryToolSessions); - generalMonitoringDTO.setCountSessionComplete(new Integer(countSessionComplete).toString()); - logger.debug("ending refreshStatsData with generalMonitoringDTO: " + generalMonitoringDTO); - /* till here*/ + if (qaContent.getTitle() == null) { + generalMonitoringDTO.setActivityTitle("Questions and Answers"); + generalMonitoringDTO.setActivityInstructions("Please answer the questions."); + } else { + generalMonitoringDTO.setActivityTitle(qaContent.getTitle()); + generalMonitoringDTO.setActivityInstructions(qaContent.getInstructions()); + } - - generalMonitoringDTO.setEditResponse(new Boolean(setEditResponse).toString()); - - /*getting instructions screen content from here... */ - generalMonitoringDTO.setOnlineInstructions(qaContent.getOnlineInstructions()); - generalMonitoringDTO.setOfflineInstructions(qaContent.getOfflineInstructions()); - + if (qaService.studentActivityOccurredGlobal(qaContent)) { + QaMonitoringAction.logger.debug("USER_EXCEPTION_NO_TOOL_SESSIONS is set to false"); + generalMonitoringDTO.setUserExceptionNoToolSessions(new Boolean(false).toString()); + } else { + QaMonitoringAction.logger.debug("USER_EXCEPTION_NO_TOOL_SESSIONS is set to true"); + generalMonitoringDTO.setUserExceptionNoToolSessions(new Boolean(true).toString()); + } - List attachmentList = qaService.retrieveQaUploadedFiles(qaContent); - logger.debug("attachmentList: " + attachmentList); - generalMonitoringDTO.setAttachmentList(attachmentList); - generalMonitoringDTO.setDeletedAttachmentList(new ArrayList()); - /* ...till here **/ + boolean isContentInUse = QaUtils.isContentInUse(qaContent); + QaMonitoringAction.logger.debug("isContentInUse:" + isContentInUse); - - if (generalLearnerFlowDTO != null) - { - logger.debug("final generalLearnerFlowDTO: " + generalLearnerFlowDTO); - logger.debug("placing LIST_MONITORED_ANSWERS_CONTAINER_DTO within generalLearnerFlowDTO"); - generalLearnerFlowDTO.setListMonitoredAnswersContainerDTO(listMonitoredAnswersContainerDTO); - - - if (isLearnerRequest) - { - logger.debug("isLearnerRequest is true."); - generalLearnerFlowDTO.setRequestLearningReportProgress(new Boolean(true).toString()); - } - - logger.debug("end of refreshSummaryData, generalLearnerFlowDTO : " + generalLearnerFlowDTO); - request.setAttribute(GENERAL_LEARNER_FLOW_DTO, generalLearnerFlowDTO); + generalMonitoringDTO.setMonitoredContentInUse(new Boolean(false).toString()); + if (isContentInUse == true) { + QaMonitoringAction.logger.debug("monitoring url does not allow editActivity since the content is in use."); + persistError(request, "error.content.inUse"); + generalMonitoringDTO.setMonitoredContentInUse(new Boolean(true).toString()); + } + + EditActivityDTO editActivityDTO = new EditActivityDTO(); + if (isContentInUse == true) { + editActivityDTO.setMonitoredContentInUse(new Boolean(true).toString()); + } + request.setAttribute(QaAppConstants.EDIT_ACTIVITY_DTO, editActivityDTO); + + Map summaryToolSessionsId = MonitoringUtil.populateToolSessionsId(request, qaContent, qaService); + QaMonitoringAction.logger.debug("summaryToolSessionsId: " + summaryToolSessionsId); + request.setAttribute(QaAppConstants.SUMMARY_TOOL_SESSIONS_ID, summaryToolSessionsId); + + currentSessionId = currentMonitoredToolSession; + + QaMonitoringAction.logger.debug("using allUsersData to retrieve data: " + isUserNamesVisible); + List listMonitoredAnswersContainerDTO = MonitoringUtil.buildGroupsQuestionData(request, qaContent, qaService, + isUserNamesVisible, isLearnerRequest, currentSessionId, userId); + + QaMonitoringAction.logger.debug("listMonitoredAnswersContainerDTO: " + listMonitoredAnswersContainerDTO); + + /* getting stats screen content from here... */ + int countAllUsers = qaService.getTotalNumberOfUsers(qaContent); + QaMonitoringAction.logger.debug("countAllUsers: " + countAllUsers); + + if (countAllUsers == 0) { + QaMonitoringAction.logger.debug("error: countAllUsers is 0"); + generalMonitoringDTO.setUserExceptionNoStudentActivity(new Boolean(true).toString()); + } + + generalMonitoringDTO.setCountAllUsers(new Integer(countAllUsers).toString()); + + int countSessionComplete = qaService.countSessionComplete(qaContent); + QaMonitoringAction.logger.debug("countSessionComplete: " + countSessionComplete); + + generalMonitoringDTO.setCountSessionComplete(new Integer(countSessionComplete).toString()); + QaMonitoringAction.logger.debug("ending refreshStatsData with generalMonitoringDTO: " + generalMonitoringDTO); + /* till here */ + + generalMonitoringDTO.setEditResponse(new Boolean(setEditResponse).toString()); + + /* getting instructions screen content from here... */ + generalMonitoringDTO.setOnlineInstructions(qaContent.getOnlineInstructions()); + generalMonitoringDTO.setOfflineInstructions(qaContent.getOfflineInstructions()); + + List attachmentList = qaService.retrieveQaUploadedFiles(qaContent); + QaMonitoringAction.logger.debug("attachmentList: " + attachmentList); + generalMonitoringDTO.setAttachmentList(attachmentList); + generalMonitoringDTO.setDeletedAttachmentList(new ArrayList()); + /* ...till here * */ + + if (generalLearnerFlowDTO != null) { + QaMonitoringAction.logger.debug("final generalLearnerFlowDTO: " + generalLearnerFlowDTO); + QaMonitoringAction.logger + .debug("placing LIST_MONITORED_ANSWERS_CONTAINER_DTO within generalLearnerFlowDTO"); + generalLearnerFlowDTO.setListMonitoredAnswersContainerDTO(listMonitoredAnswersContainerDTO); + + if (isLearnerRequest) { + QaMonitoringAction.logger.debug("isLearnerRequest is true."); + generalLearnerFlowDTO.setRequestLearningReportProgress(new Boolean(true).toString()); } - - prepareReflectionData(request, qaContent, qaService,null, false, currentMonitoredToolSession); - prepareEditActivityScreenData(request, qaContent); - - /*find out if there are any reflection entries, from here*/ - boolean notebookEntriesExist=MonitoringUtil.notebookEntriesExist(qaService, qaContent); - logger.debug("notebookEntriesExist : " + notebookEntriesExist); - - if (notebookEntriesExist) - { - request.setAttribute(NOTEBOOK_ENTRIES_EXIST, new Boolean(true).toString()); - } - else - { - request.setAttribute(NOTEBOOK_ENTRIES_EXIST, new Boolean(false).toString()); - } - /* ... till here*/ - - - logger.debug("final generalMonitoringDTO: " + generalMonitoringDTO ); - request.setAttribute(QA_GENERAL_MONITORING_DTO, generalMonitoringDTO); - - MonitoringUtil.buildQaStatsDTO(request,qaService, qaContent); - MonitoringUtil.generateGroupsSessionData(request, qaService, qaContent, false); + QaMonitoringAction.logger.debug("end of refreshSummaryData, generalLearnerFlowDTO : " + + generalLearnerFlowDTO); + request.setAttribute(QaAppConstants.GENERAL_LEARNER_FLOW_DTO, generalLearnerFlowDTO); } - + prepareReflectionData(request, qaContent, qaService, null, false, currentMonitoredToolSession); + + prepareEditActivityScreenData(request, qaContent); + + /* find out if there are any reflection entries, from here */ + boolean notebookEntriesExist = MonitoringUtil.notebookEntriesExist(qaService, qaContent); + QaMonitoringAction.logger.debug("notebookEntriesExist : " + notebookEntriesExist); + + if (notebookEntriesExist) { + request.setAttribute(QaAppConstants.NOTEBOOK_ENTRIES_EXIST, new Boolean(true).toString()); + } else { + request.setAttribute(QaAppConstants.NOTEBOOK_ENTRIES_EXIST, new Boolean(false).toString()); + } + /* ... till here */ + + QaMonitoringAction.logger.debug("final generalMonitoringDTO: " + generalMonitoringDTO); + request.setAttribute(QaAppConstants.QA_GENERAL_MONITORING_DTO, generalMonitoringDTO); + + MonitoringUtil.buildQaStatsDTO(request, qaService, qaContent); + MonitoringUtil.generateGroupsSessionData(request, qaService, qaContent, false); + } + /** - * populates data for stats screen - * refreshStatsData(HttpServletRequest request) + * populates data for stats screen refreshStatsData(HttpServletRequest request) + * * @param request */ - public void refreshStatsData(HttpServletRequest request , QaMonitoringForm qaMonitoringForm, IQaService qaService, - GeneralMonitoringDTO generalMonitoringDTO) - { - logger.debug("starting refreshStatsData: " + qaService); - logger.debug("starting refreshStatsData with generalMonitoringDTO: " + generalMonitoringDTO); - /* it is possible that no users has ever logged in for the activity yet*/ + public void refreshStatsData(HttpServletRequest request, QaMonitoringForm qaMonitoringForm, IQaService qaService, + GeneralMonitoringDTO generalMonitoringDTO) { + QaMonitoringAction.logger.debug("starting refreshStatsData: " + qaService); + QaMonitoringAction.logger.debug("starting refreshStatsData with generalMonitoringDTO: " + generalMonitoringDTO); + /* it is possible that no users has ever logged in for the activity yet */ - String strToolContentID=request.getParameter(AttributeNames.PARAM_TOOL_CONTENT_ID); - logger.debug("strToolContentID: " + strToolContentID); - qaMonitoringForm.setToolContentID(strToolContentID); + String strToolContentID = request.getParameter(AttributeNames.PARAM_TOOL_CONTENT_ID); + QaMonitoringAction.logger.debug("strToolContentID: " + strToolContentID); + qaMonitoringForm.setToolContentID(strToolContentID); - QaContent qaContent=qaService.loadQa(new Long(strToolContentID).longValue()); - logger.debug("existing qaContent:" + qaContent); + QaContent qaContent = qaService.loadQa(new Long(strToolContentID).longValue()); + QaMonitoringAction.logger.debug("existing qaContent:" + qaContent); - Map summaryToolSessions=MonitoringUtil.populateToolSessions(request, qaContent, qaService); - logger.debug("summaryToolSessions: " + summaryToolSessions); - request.setAttribute(SUMMARY_TOOL_SESSIONS, summaryToolSessions); - logger.debug("SUMMARY_TOOL_SESSIONS: " + request.getAttribute(SUMMARY_TOOL_SESSIONS)); + Map summaryToolSessions = MonitoringUtil.populateToolSessions(request, qaContent, qaService); + QaMonitoringAction.logger.debug("summaryToolSessions: " + summaryToolSessions); + request.setAttribute(QaAppConstants.SUMMARY_TOOL_SESSIONS, summaryToolSessions); + QaMonitoringAction.logger.debug("SUMMARY_TOOL_SESSIONS: " + + request.getAttribute(QaAppConstants.SUMMARY_TOOL_SESSIONS)); + Map summaryToolSessionsId = MonitoringUtil.populateToolSessionsId(request, qaContent, qaService); + QaMonitoringAction.logger.debug("summaryToolSessionsId: " + summaryToolSessionsId); + request.setAttribute(QaAppConstants.SUMMARY_TOOL_SESSIONS_ID, summaryToolSessionsId); - Map summaryToolSessionsId=MonitoringUtil.populateToolSessionsId(request, qaContent, qaService); - logger.debug("summaryToolSessionsId: " + summaryToolSessionsId); - request.setAttribute(SUMMARY_TOOL_SESSIONS_ID, summaryToolSessionsId); + int countAllUsers = qaService.getTotalNumberOfUsers(qaContent); + QaMonitoringAction.logger.debug("countAllUsers: " + countAllUsers); + if (countAllUsers == 0) { + QaMonitoringAction.logger.debug("error: countAllUsers is 0"); + generalMonitoringDTO.setUserExceptionNoStudentActivity(new Boolean(true).toString()); + } - int countAllUsers=qaService.getTotalNumberOfUsers(qaContent); - logger.debug("countAllUsers: " + countAllUsers); - - if (countAllUsers == 0) - { - logger.debug("error: countAllUsers is 0"); - generalMonitoringDTO.setUserExceptionNoStudentActivity(new Boolean(true).toString()); - } - + generalMonitoringDTO.setCountAllUsers(new Integer(countAllUsers).toString()); - generalMonitoringDTO.setCountAllUsers(new Integer(countAllUsers).toString()); - - int countSessionComplete=qaService.countSessionComplete(qaContent); - logger.debug("countSessionComplete: " + countSessionComplete); + int countSessionComplete = qaService.countSessionComplete(qaContent); + QaMonitoringAction.logger.debug("countSessionComplete: " + countSessionComplete); - generalMonitoringDTO.setCountSessionComplete(new Integer(countSessionComplete).toString()); - - prepareReflectionData(request, qaContent, qaService,null, false, "All"); - - prepareEditActivityScreenData(request, qaContent); + generalMonitoringDTO.setCountSessionComplete(new Integer(countSessionComplete).toString()); - EditActivityDTO editActivityDTO = new EditActivityDTO(); - boolean isContentInUse=QaUtils.isContentInUse(qaContent); - logger.debug("isContentInUse:" + isContentInUse); - if (isContentInUse == true) - { - editActivityDTO.setMonitoredContentInUse(new Boolean(true).toString()); - } - - - List attachmentList = qaService.retrieveQaUploadedFiles(qaContent); - logger.debug("attachmentList: " + attachmentList); - generalMonitoringDTO.setAttachmentList(attachmentList); - logger.debug("final generalMonitoringDTO: " + generalMonitoringDTO ); - - - request.setAttribute(EDIT_ACTIVITY_DTO, editActivityDTO); - logger.debug("ending refreshStatsData with generalMonitoringDTO: " + generalMonitoringDTO); - request.setAttribute(QA_GENERAL_MONITORING_DTO, generalMonitoringDTO); - - /*find out if there are any reflection entries, from here*/ - boolean notebookEntriesExist=MonitoringUtil.notebookEntriesExist(qaService, qaContent); - logger.debug("notebookEntriesExist : " + notebookEntriesExist); - - if (notebookEntriesExist) - { - request.setAttribute(NOTEBOOK_ENTRIES_EXIST, new Boolean(true).toString()); - } - else - { - request.setAttribute(NOTEBOOK_ENTRIES_EXIST, new Boolean(false).toString()); - } - /* ... till here*/ - - MonitoringUtil.buildQaStatsDTO(request,qaService, qaContent); - MonitoringUtil.generateGroupsSessionData(request, qaService, qaContent, false); + prepareReflectionData(request, qaContent, qaService, null, false, "All"); + + prepareEditActivityScreenData(request, qaContent); + + EditActivityDTO editActivityDTO = new EditActivityDTO(); + boolean isContentInUse = QaUtils.isContentInUse(qaContent); + QaMonitoringAction.logger.debug("isContentInUse:" + isContentInUse); + if (isContentInUse == true) { + editActivityDTO.setMonitoredContentInUse(new Boolean(true).toString()); } - - - public ActionForward showResponse(ActionMapping mapping, - ActionForm form, - HttpServletRequest request, - HttpServletResponse response) throws IOException, - ServletException, ToolException - { - logger.debug("dispatching showResponse..."); - IQaService qaService = QaServiceProxy.getQaService(getServlet().getServletContext()); - logger.debug("qaService: " + qaService); - - QaMonitoringForm qaMonitoringForm = (QaMonitoringForm) form; - - String currentUid=qaMonitoringForm.getCurrentUid(); - logger.debug("currentUid: " + currentUid); - QaUsrResp qaUsrResp =qaService.getAttemptByUID(new Long(currentUid)); - logger.debug("qaUsrResp: " + qaUsrResp); - qaUsrResp.setVisible(true); - qaService.updateUserResponse(qaUsrResp); - qaService.showResponse(qaUsrResp); - logger.debug("qaUsrResp: " + qaUsrResp); + List attachmentList = qaService.retrieveQaUploadedFiles(qaContent); + QaMonitoringAction.logger.debug("attachmentList: " + attachmentList); + generalMonitoringDTO.setAttachmentList(attachmentList); + QaMonitoringAction.logger.debug("final generalMonitoringDTO: " + generalMonitoringDTO); - - String strToolContentID=request.getParameter(AttributeNames.PARAM_TOOL_CONTENT_ID); - logger.debug("strToolContentID: " + strToolContentID); - qaMonitoringForm.setToolContentID(strToolContentID); - - String contentFolderID = WebUtil.readStrParam(request, AttributeNames.PARAM_CONTENT_FOLDER_ID); - logger.debug("contentFolderID: " + contentFolderID); - qaMonitoringForm.setContentFolderID(contentFolderID); + request.setAttribute(QaAppConstants.EDIT_ACTIVITY_DTO, editActivityDTO); + QaMonitoringAction.logger.debug("ending refreshStatsData with generalMonitoringDTO: " + generalMonitoringDTO); + request.setAttribute(QaAppConstants.QA_GENERAL_MONITORING_DTO, generalMonitoringDTO); - - String editResponse=request.getParameter(EDIT_RESPONSE); - logger.debug("editResponse: " + editResponse); - qaMonitoringForm.setEditResponse(editResponse); + /* find out if there are any reflection entries, from here */ + boolean notebookEntriesExist = MonitoringUtil.notebookEntriesExist(qaService, qaContent); + QaMonitoringAction.logger.debug("notebookEntriesExist : " + notebookEntriesExist); + if (notebookEntriesExist) { + request.setAttribute(QaAppConstants.NOTEBOOK_ENTRIES_EXIST, new Boolean(true).toString()); + } else { + request.setAttribute(QaAppConstants.NOTEBOOK_ENTRIES_EXIST, new Boolean(false).toString()); + } + /* ... till here */ - QaContent qaContent=qaService.loadQa(new Long(strToolContentID).longValue()); - logger.debug("existing qaContent:" + qaContent); + MonitoringUtil.buildQaStatsDTO(request, qaService, qaContent); + MonitoringUtil.generateGroupsSessionData(request, qaService, qaContent, false); + } - Map summaryToolSessions=MonitoringUtil.populateToolSessions(request, qaContent, qaService); - logger.debug("summaryToolSessions: " + summaryToolSessions); - request.setAttribute(SUMMARY_TOOL_SESSIONS, summaryToolSessions); - logger.debug("SUMMARY_TOOL_SESSIONS: " + request.getAttribute(SUMMARY_TOOL_SESSIONS)); + public ActionForward showResponse(ActionMapping mapping, ActionForm form, HttpServletRequest request, + HttpServletResponse response) throws IOException, ServletException, ToolException { + QaMonitoringAction.logger.debug("dispatching showResponse..."); - Map summaryToolSessionsId=MonitoringUtil.populateToolSessionsId(request, qaContent, qaService); - logger.debug("summaryToolSessionsId: " + summaryToolSessionsId); - request.setAttribute(SUMMARY_TOOL_SESSIONS_ID, summaryToolSessionsId); + IQaService qaService = QaServiceProxy.getQaService(getServlet().getServletContext()); + QaMonitoringAction.logger.debug("qaService: " + qaService); + QaMonitoringForm qaMonitoringForm = (QaMonitoringForm) form; - String currentMonitoredToolSession=qaMonitoringForm.getSelectedToolSessionId(); - logger.debug("currentMonitoredToolSession: " + currentMonitoredToolSession); + String currentUid = qaMonitoringForm.getCurrentUid(); + QaMonitoringAction.logger.debug("currentUid: " + currentUid); + QaUsrResp qaUsrResp = qaService.getAttemptByUID(new Long(currentUid)); + QaMonitoringAction.logger.debug("qaUsrResp: " + qaUsrResp); + qaUsrResp.setVisible(true); + qaService.updateUserResponse(qaUsrResp); + qaService.showResponse(qaUsrResp); + QaMonitoringAction.logger.debug("qaUsrResp: " + qaUsrResp); - if (currentMonitoredToolSession.equals("")) - { - currentMonitoredToolSession="All"; - } + String strToolContentID = request.getParameter(AttributeNames.PARAM_TOOL_CONTENT_ID); + QaMonitoringAction.logger.debug("strToolContentID: " + strToolContentID); + qaMonitoringForm.setToolContentID(strToolContentID); - GeneralLearnerFlowDTO generalLearnerFlowDTO= LearningUtil.buildGeneralLearnerFlowDTO(qaContent); - logger.debug("generalLearnerFlowDTO: " + generalLearnerFlowDTO); - - refreshSummaryData(request, qaContent, qaService, true, false, null, null, generalLearnerFlowDTO, false, currentMonitoredToolSession); - - logger.debug("currentMonitoredToolSession: " + currentMonitoredToolSession); - if (currentMonitoredToolSession.equals("All")) - { - request.setAttribute(SELECTION_CASE, new Long(2)); - } - else - { - request.setAttribute(SELECTION_CASE, new Long(1)); - - QaSession qaSession=qaService.retrieveQaSessionOrNullById(new Long(currentMonitoredToolSession).longValue()); - logger.debug("retrieving qaSession name: " + qaSession.getSession_name()); - request.setAttribute(CURRENT_SESSION_NAME, qaSession.getSession_name()); - } + String contentFolderID = WebUtil.readStrParam(request, AttributeNames.PARAM_CONTENT_FOLDER_ID); + QaMonitoringAction.logger.debug("contentFolderID: " + contentFolderID); + qaMonitoringForm.setContentFolderID(contentFolderID); - logger.debug("SELECTION_CASE: " + request.getAttribute(SELECTION_CASE)); - request.setAttribute(CURRENT_MONITORED_TOOL_SESSION, currentMonitoredToolSession); - - prepareReflectionData(request, qaContent, qaService,null, false, currentMonitoredToolSession); - - prepareEditActivityScreenData(request, qaContent); + String editResponse = request.getParameter(QaAppConstants.EDIT_RESPONSE); + QaMonitoringAction.logger.debug("editResponse: " + editResponse); + qaMonitoringForm.setEditResponse(editResponse); - EditActivityDTO editActivityDTO = new EditActivityDTO(); - boolean isContentInUse=QaUtils.isContentInUse(qaContent); - logger.debug("isContentInUse:" + isContentInUse); - if (isContentInUse == true) - { - editActivityDTO.setMonitoredContentInUse(new Boolean(true).toString()); - } - request.setAttribute(EDIT_ACTIVITY_DTO, editActivityDTO); + QaContent qaContent = qaService.loadQa(new Long(strToolContentID).longValue()); + QaMonitoringAction.logger.debug("existing qaContent:" + qaContent); - /*find out if there are any reflection entries, from here*/ - boolean notebookEntriesExist=MonitoringUtil.notebookEntriesExist(qaService, qaContent); - logger.debug("notebookEntriesExist : " + notebookEntriesExist); - - if (notebookEntriesExist) - { - request.setAttribute(NOTEBOOK_ENTRIES_EXIST, new Boolean(true).toString()); - } - else - { - request.setAttribute(NOTEBOOK_ENTRIES_EXIST, new Boolean(false).toString()); - } - /* ... till here*/ + Map summaryToolSessions = MonitoringUtil.populateToolSessions(request, qaContent, qaService); + QaMonitoringAction.logger.debug("summaryToolSessions: " + summaryToolSessions); + request.setAttribute(QaAppConstants.SUMMARY_TOOL_SESSIONS, summaryToolSessions); + QaMonitoringAction.logger.debug("SUMMARY_TOOL_SESSIONS: " + + request.getAttribute(QaAppConstants.SUMMARY_TOOL_SESSIONS)); - - MonitoringUtil.buildQaStatsDTO(request,qaService, qaContent); - MonitoringUtil.generateGroupsSessionData(request, qaService, qaContent, false); - - logger.debug("submitting session to refresh the data from the database: "); - return (mapping.findForward(LOAD_MONITORING)); - } + Map summaryToolSessionsId = MonitoringUtil.populateToolSessionsId(request, qaContent, qaService); + QaMonitoringAction.logger.debug("summaryToolSessionsId: " + summaryToolSessionsId); + request.setAttribute(QaAppConstants.SUMMARY_TOOL_SESSIONS_ID, summaryToolSessionsId); - - - public ActionForward showGroupResponse(ActionMapping mapping, - ActionForm form, - HttpServletRequest request, - HttpServletResponse response) throws IOException, - ServletException, ToolException - { - logger.debug("dispatching showGroupResponse..."); + String currentMonitoredToolSession = qaMonitoringForm.getSelectedToolSessionId(); + QaMonitoringAction.logger.debug("currentMonitoredToolSession: " + currentMonitoredToolSession); - IQaService qaService = QaServiceProxy.getQaService(getServlet().getServletContext()); - logger.debug("qaService: " + qaService); - - QaMonitoringForm qaMonitoringForm = (QaMonitoringForm) form; - - String currentUid=qaMonitoringForm.getCurrentUid(); - logger.debug("currentUid: " + currentUid); - QaUsrResp qaUsrResp =qaService.getAttemptByUID(new Long(currentUid)); - logger.debug("qaUsrResp: " + qaUsrResp); - qaUsrResp.setVisible(true); - qaService.updateUserResponse(qaUsrResp); - qaService.showResponse(qaUsrResp); - logger.debug("qaUsrResp: " + qaUsrResp); + if (currentMonitoredToolSession.equals("")) { + currentMonitoredToolSession = "All"; + } - - String strToolContentID=request.getParameter(AttributeNames.PARAM_TOOL_CONTENT_ID); - logger.debug("strToolContentID: " + strToolContentID); - qaMonitoringForm.setToolContentID(strToolContentID); - - String contentFolderID = WebUtil.readStrParam(request, AttributeNames.PARAM_CONTENT_FOLDER_ID); - logger.debug("contentFolderID: " + contentFolderID); - qaMonitoringForm.setContentFolderID(contentFolderID); + GeneralLearnerFlowDTO generalLearnerFlowDTO = LearningUtil.buildGeneralLearnerFlowDTO(qaContent); + QaMonitoringAction.logger.debug("generalLearnerFlowDTO: " + generalLearnerFlowDTO); - - String editResponse=request.getParameter(EDIT_RESPONSE); - logger.debug("editResponse: " + editResponse); - qaMonitoringForm.setEditResponse(editResponse); + refreshSummaryData(request, qaContent, qaService, true, false, null, null, generalLearnerFlowDTO, false, + currentMonitoredToolSession); + QaMonitoringAction.logger.debug("currentMonitoredToolSession: " + currentMonitoredToolSession); + if (currentMonitoredToolSession.equals("All")) { + request.setAttribute(QaAppConstants.SELECTION_CASE, new Long(2)); + } else { + request.setAttribute(QaAppConstants.SELECTION_CASE, new Long(1)); - QaContent qaContent=qaService.loadQa(new Long(strToolContentID).longValue()); - logger.debug("existing qaContent:" + qaContent); + QaSession qaSession = qaService.retrieveQaSessionOrNullById(new Long(currentMonitoredToolSession) + .longValue()); + QaMonitoringAction.logger.debug("retrieving qaSession name: " + qaSession.getSession_name()); + request.setAttribute(QaAppConstants.CURRENT_SESSION_NAME, qaSession.getSession_name()); + } - Map summaryToolSessions=MonitoringUtil.populateToolSessions(request, qaContent, qaService); - logger.debug("summaryToolSessions: " + summaryToolSessions); - request.setAttribute(SUMMARY_TOOL_SESSIONS, summaryToolSessions); - logger.debug("SUMMARY_TOOL_SESSIONS: " + request.getAttribute(SUMMARY_TOOL_SESSIONS)); + QaMonitoringAction.logger.debug("SELECTION_CASE: " + request.getAttribute(QaAppConstants.SELECTION_CASE)); + request.setAttribute(QaAppConstants.CURRENT_MONITORED_TOOL_SESSION, currentMonitoredToolSession); - Map summaryToolSessionsId=MonitoringUtil.populateToolSessionsId(request, qaContent, qaService); - logger.debug("summaryToolSessionsId: " + summaryToolSessionsId); - request.setAttribute(SUMMARY_TOOL_SESSIONS_ID, summaryToolSessionsId); + prepareReflectionData(request, qaContent, qaService, null, false, currentMonitoredToolSession); + prepareEditActivityScreenData(request, qaContent); - String currentMonitoredToolSession=qaMonitoringForm.getSelectedToolSessionId(); - logger.debug("currentMonitoredToolSession: " + currentMonitoredToolSession); + EditActivityDTO editActivityDTO = new EditActivityDTO(); + boolean isContentInUse = QaUtils.isContentInUse(qaContent); + QaMonitoringAction.logger.debug("isContentInUse:" + isContentInUse); + if (isContentInUse == true) { + editActivityDTO.setMonitoredContentInUse(new Boolean(true).toString()); + } + request.setAttribute(QaAppConstants.EDIT_ACTIVITY_DTO, editActivityDTO); - if (currentMonitoredToolSession.equals("")) - { - currentMonitoredToolSession="All"; - } + /* find out if there are any reflection entries, from here */ + boolean notebookEntriesExist = MonitoringUtil.notebookEntriesExist(qaService, qaContent); + QaMonitoringAction.logger.debug("notebookEntriesExist : " + notebookEntriesExist); - GeneralLearnerFlowDTO generalLearnerFlowDTO= LearningUtil.buildGeneralLearnerFlowDTO(qaContent); - logger.debug("generalLearnerFlowDTO: " + generalLearnerFlowDTO); - - refreshSummaryData(request, qaContent, qaService, true, false, null, null, generalLearnerFlowDTO, false, currentMonitoredToolSession); - - logger.debug("currentMonitoredToolSession: " + currentMonitoredToolSession); - if (currentMonitoredToolSession.equals("All")) - { - request.setAttribute(SELECTION_CASE, new Long(2)); - } - else - { - request.setAttribute(SELECTION_CASE, new Long(1)); - } + if (notebookEntriesExist) { + request.setAttribute(QaAppConstants.NOTEBOOK_ENTRIES_EXIST, new Boolean(true).toString()); + } else { + request.setAttribute(QaAppConstants.NOTEBOOK_ENTRIES_EXIST, new Boolean(false).toString()); + } + /* ... till here */ - logger.debug("SELECTION_CASE: " + request.getAttribute(SELECTION_CASE)); - - prepareReflectionData(request, qaContent, qaService,null, false, currentMonitoredToolSession); - - prepareEditActivityScreenData(request, qaContent); + MonitoringUtil.buildQaStatsDTO(request, qaService, qaContent); + MonitoringUtil.generateGroupsSessionData(request, qaService, qaContent, false); - EditActivityDTO editActivityDTO = new EditActivityDTO(); - boolean isContentInUse=QaUtils.isContentInUse(qaContent); - logger.debug("isContentInUse:" + isContentInUse); - if (isContentInUse == true) - { - editActivityDTO.setMonitoredContentInUse(new Boolean(true).toString()); - } - request.setAttribute(EDIT_ACTIVITY_DTO, editActivityDTO); + QaMonitoringAction.logger.debug("submitting session to refresh the data from the database: "); + return mapping.findForward(QaAppConstants.LOAD_MONITORING); + } - /*find out if there are any reflection entries, from here*/ - boolean notebookEntriesExist=MonitoringUtil.notebookEntriesExist(qaService, qaContent); - logger.debug("notebookEntriesExist : " + notebookEntriesExist); - - if (notebookEntriesExist) - { - request.setAttribute(NOTEBOOK_ENTRIES_EXIST, new Boolean(true).toString()); - } - else - { - request.setAttribute(NOTEBOOK_ENTRIES_EXIST, new Boolean(false).toString()); - } - /* ... till here*/ + public ActionForward showGroupResponse(ActionMapping mapping, ActionForm form, HttpServletRequest request, + HttpServletResponse response) throws IOException, ServletException, ToolException { + QaMonitoringAction.logger.debug("dispatching showGroupResponse..."); - - MonitoringUtil.buildQaStatsDTO(request,qaService, qaContent); - MonitoringUtil.generateGroupsSessionData(request, qaService, qaContent, false); - request.setAttribute("currentMonitoredToolSession", "All"); - - logger.debug("submitting session to refresh the data from the database: "); - return (mapping.findForward(LOAD_MONITORING)); - } - - + IQaService qaService = QaServiceProxy.getQaService(getServlet().getServletContext()); + QaMonitoringAction.logger.debug("qaService: " + qaService); - public ActionForward hideResponse(ActionMapping mapping, - ActionForm form, - HttpServletRequest request, - HttpServletResponse response) throws IOException, - ServletException, ToolException - { - logger.debug("dispatching hideResponse..."); - IQaService qaService = QaServiceProxy.getQaService(getServlet().getServletContext()); - logger.debug("qaService: " + qaService); - - QaMonitoringForm qaMonitoringForm = (QaMonitoringForm) form; - - String contentFolderID = WebUtil.readStrParam(request, AttributeNames.PARAM_CONTENT_FOLDER_ID); - logger.debug("contentFolderID: " + contentFolderID); - qaMonitoringForm.setContentFolderID(contentFolderID); + QaMonitoringForm qaMonitoringForm = (QaMonitoringForm) form; + String currentUid = qaMonitoringForm.getCurrentUid(); + QaMonitoringAction.logger.debug("currentUid: " + currentUid); + QaUsrResp qaUsrResp = qaService.getAttemptByUID(new Long(currentUid)); + QaMonitoringAction.logger.debug("qaUsrResp: " + qaUsrResp); + qaUsrResp.setVisible(true); + qaService.updateUserResponse(qaUsrResp); + qaService.showResponse(qaUsrResp); + QaMonitoringAction.logger.debug("qaUsrResp: " + qaUsrResp); - String currentUid=qaMonitoringForm.getCurrentUid(); - logger.debug("currentUid: " + currentUid); - QaUsrResp qaUsrResp =qaService.getAttemptByUID(new Long(currentUid)); - logger.debug("qaUsrResp: " + qaUsrResp); - qaUsrResp.setVisible(false); - qaService.updateUserResponse(qaUsrResp); - qaService.hideResponse(qaUsrResp); - logger.debug("qaUsrResp: " + qaUsrResp); - - String strToolContentID=request.getParameter(AttributeNames.PARAM_TOOL_CONTENT_ID); - logger.debug("strToolContentID: " + strToolContentID); - qaMonitoringForm.setToolContentID(strToolContentID); - - String editResponse=request.getParameter(EDIT_RESPONSE); - logger.debug("editResponse: " + editResponse); - qaMonitoringForm.setEditResponse(editResponse); + String strToolContentID = request.getParameter(AttributeNames.PARAM_TOOL_CONTENT_ID); + QaMonitoringAction.logger.debug("strToolContentID: " + strToolContentID); + qaMonitoringForm.setToolContentID(strToolContentID); + String contentFolderID = WebUtil.readStrParam(request, AttributeNames.PARAM_CONTENT_FOLDER_ID); + QaMonitoringAction.logger.debug("contentFolderID: " + contentFolderID); + qaMonitoringForm.setContentFolderID(contentFolderID); - QaContent qaContent=qaService.loadQa(new Long(strToolContentID).longValue()); - logger.debug("existing qaContent:" + qaContent); - - Map summaryToolSessions=MonitoringUtil.populateToolSessions(request, qaContent, qaService); - logger.debug("summaryToolSessions: " + summaryToolSessions); - request.setAttribute(SUMMARY_TOOL_SESSIONS, summaryToolSessions); - logger.debug("SUMMARY_TOOL_SESSIONS: " + request.getAttribute(SUMMARY_TOOL_SESSIONS)); + String editResponse = request.getParameter(QaAppConstants.EDIT_RESPONSE); + QaMonitoringAction.logger.debug("editResponse: " + editResponse); + qaMonitoringForm.setEditResponse(editResponse); + QaContent qaContent = qaService.loadQa(new Long(strToolContentID).longValue()); + QaMonitoringAction.logger.debug("existing qaContent:" + qaContent); - Map summaryToolSessionsId=MonitoringUtil.populateToolSessionsId(request, qaContent, qaService); - logger.debug("summaryToolSessionsId: " + summaryToolSessionsId); - request.setAttribute(SUMMARY_TOOL_SESSIONS_ID, summaryToolSessionsId); + Map summaryToolSessions = MonitoringUtil.populateToolSessions(request, qaContent, qaService); + QaMonitoringAction.logger.debug("summaryToolSessions: " + summaryToolSessions); + request.setAttribute(QaAppConstants.SUMMARY_TOOL_SESSIONS, summaryToolSessions); + QaMonitoringAction.logger.debug("SUMMARY_TOOL_SESSIONS: " + + request.getAttribute(QaAppConstants.SUMMARY_TOOL_SESSIONS)); + Map summaryToolSessionsId = MonitoringUtil.populateToolSessionsId(request, qaContent, qaService); + QaMonitoringAction.logger.debug("summaryToolSessionsId: " + summaryToolSessionsId); + request.setAttribute(QaAppConstants.SUMMARY_TOOL_SESSIONS_ID, summaryToolSessionsId); - String currentMonitoredToolSession=qaMonitoringForm.getSelectedToolSessionId(); - logger.debug("currentMonitoredToolSession: " + currentMonitoredToolSession); + String currentMonitoredToolSession = qaMonitoringForm.getSelectedToolSessionId(); + QaMonitoringAction.logger.debug("currentMonitoredToolSession: " + currentMonitoredToolSession); - if (currentMonitoredToolSession.equals("")) - { - currentMonitoredToolSession="All"; - } + if (currentMonitoredToolSession.equals("")) { + currentMonitoredToolSession = "All"; + } - if (currentMonitoredToolSession.equals("All")) - { - request.setAttribute(SELECTION_CASE, new Long(2)); - - QaSession qaSession=qaService.retrieveQaSessionOrNullById(new Long(currentMonitoredToolSession).longValue()); - logger.debug("retrieving qaSession name: " + qaSession.getSession_name()); - request.setAttribute(CURRENT_SESSION_NAME, qaSession.getSession_name()); - } - else - { - request.setAttribute(SELECTION_CASE, new Long(1)); - } + GeneralLearnerFlowDTO generalLearnerFlowDTO = LearningUtil.buildGeneralLearnerFlowDTO(qaContent); + QaMonitoringAction.logger.debug("generalLearnerFlowDTO: " + generalLearnerFlowDTO); - logger.debug("SELECTION_CASE: " + request.getAttribute(SELECTION_CASE)); - request.setAttribute(CURRENT_MONITORED_TOOL_SESSION, currentMonitoredToolSession); + refreshSummaryData(request, qaContent, qaService, true, false, null, null, generalLearnerFlowDTO, false, + currentMonitoredToolSession); - GeneralLearnerFlowDTO generalLearnerFlowDTO= LearningUtil.buildGeneralLearnerFlowDTO(qaContent); - logger.debug("generalLearnerFlowDTO: " + generalLearnerFlowDTO); - - refreshSummaryData(request, qaContent, qaService, true, false, null, null, generalLearnerFlowDTO, false, currentMonitoredToolSession); - - prepareReflectionData(request, qaContent, qaService,null, false, currentMonitoredToolSession); - - prepareEditActivityScreenData(request, qaContent); - - EditActivityDTO editActivityDTO = new EditActivityDTO(); - boolean isContentInUse=QaUtils.isContentInUse(qaContent); - logger.debug("isContentInUse:" + isContentInUse); - if (isContentInUse == true) - { - editActivityDTO.setMonitoredContentInUse(new Boolean(true).toString()); - } - request.setAttribute(EDIT_ACTIVITY_DTO, editActivityDTO); + QaMonitoringAction.logger.debug("currentMonitoredToolSession: " + currentMonitoredToolSession); + if (currentMonitoredToolSession.equals("All")) { + request.setAttribute(QaAppConstants.SELECTION_CASE, new Long(2)); + } else { + request.setAttribute(QaAppConstants.SELECTION_CASE, new Long(1)); + } - /*find out if there are any reflection entries, from here*/ - boolean notebookEntriesExist=MonitoringUtil.notebookEntriesExist(qaService, qaContent); - logger.debug("notebookEntriesExist : " + notebookEntriesExist); - - if (notebookEntriesExist) - { - request.setAttribute(NOTEBOOK_ENTRIES_EXIST, new Boolean(true).toString()); - } - else - { - request.setAttribute(NOTEBOOK_ENTRIES_EXIST, new Boolean(false).toString()); - } - - MonitoringUtil.buildQaStatsDTO(request,qaService, qaContent); - MonitoringUtil.generateGroupsSessionData(request, qaService, qaContent, false); - - logger.debug("submitting session to refresh the data from the database: "); - return (mapping.findForward(LOAD_MONITORING)); - } - - - public ActionForward hideGroupResponse(ActionMapping mapping, - ActionForm form, - HttpServletRequest request, - HttpServletResponse response) throws IOException, - ServletException, ToolException - { - logger.debug("dispatching hideGroupResponse..."); - IQaService qaService = QaServiceProxy.getQaService(getServlet().getServletContext()); - logger.debug("qaService: " + qaService); - - QaMonitoringForm qaMonitoringForm = (QaMonitoringForm) form; - - String contentFolderID = WebUtil.readStrParam(request, AttributeNames.PARAM_CONTENT_FOLDER_ID); - logger.debug("contentFolderID: " + contentFolderID); - qaMonitoringForm.setContentFolderID(contentFolderID); + QaMonitoringAction.logger.debug("SELECTION_CASE: " + request.getAttribute(QaAppConstants.SELECTION_CASE)); + prepareReflectionData(request, qaContent, qaService, null, false, currentMonitoredToolSession); - String currentUid=qaMonitoringForm.getCurrentUid(); - logger.debug("currentUid: " + currentUid); - QaUsrResp qaUsrResp =qaService.getAttemptByUID(new Long(currentUid)); - logger.debug("qaUsrResp: " + qaUsrResp); - qaUsrResp.setVisible(false); - qaService.updateUserResponse(qaUsrResp); - qaService.hideResponse(qaUsrResp); - logger.debug("qaUsrResp: " + qaUsrResp); - - String strToolContentID=request.getParameter(AttributeNames.PARAM_TOOL_CONTENT_ID); - logger.debug("strToolContentID: " + strToolContentID); - qaMonitoringForm.setToolContentID(strToolContentID); - - String editResponse=request.getParameter(EDIT_RESPONSE); - logger.debug("editResponse: " + editResponse); - qaMonitoringForm.setEditResponse(editResponse); + prepareEditActivityScreenData(request, qaContent); + EditActivityDTO editActivityDTO = new EditActivityDTO(); + boolean isContentInUse = QaUtils.isContentInUse(qaContent); + QaMonitoringAction.logger.debug("isContentInUse:" + isContentInUse); + if (isContentInUse == true) { + editActivityDTO.setMonitoredContentInUse(new Boolean(true).toString()); + } + request.setAttribute(QaAppConstants.EDIT_ACTIVITY_DTO, editActivityDTO); - QaContent qaContent=qaService.loadQa(new Long(strToolContentID).longValue()); - logger.debug("existing qaContent:" + qaContent); - - Map summaryToolSessions=MonitoringUtil.populateToolSessions(request, qaContent, qaService); - logger.debug("summaryToolSessions: " + summaryToolSessions); - request.setAttribute(SUMMARY_TOOL_SESSIONS, summaryToolSessions); - logger.debug("SUMMARY_TOOL_SESSIONS: " + request.getAttribute(SUMMARY_TOOL_SESSIONS)); + /* find out if there are any reflection entries, from here */ + boolean notebookEntriesExist = MonitoringUtil.notebookEntriesExist(qaService, qaContent); + QaMonitoringAction.logger.debug("notebookEntriesExist : " + notebookEntriesExist); + if (notebookEntriesExist) { + request.setAttribute(QaAppConstants.NOTEBOOK_ENTRIES_EXIST, new Boolean(true).toString()); + } else { + request.setAttribute(QaAppConstants.NOTEBOOK_ENTRIES_EXIST, new Boolean(false).toString()); + } + /* ... till here */ - Map summaryToolSessionsId=MonitoringUtil.populateToolSessionsId(request, qaContent, qaService); - logger.debug("summaryToolSessionsId: " + summaryToolSessionsId); - request.setAttribute(SUMMARY_TOOL_SESSIONS_ID, summaryToolSessionsId); + MonitoringUtil.buildQaStatsDTO(request, qaService, qaContent); + MonitoringUtil.generateGroupsSessionData(request, qaService, qaContent, false); + request.setAttribute("currentMonitoredToolSession", "All"); + QaMonitoringAction.logger.debug("submitting session to refresh the data from the database: "); + return mapping.findForward(QaAppConstants.LOAD_MONITORING); + } - String currentMonitoredToolSession=qaMonitoringForm.getSelectedToolSessionId(); - logger.debug("currentMonitoredToolSession: " + currentMonitoredToolSession); + public ActionForward hideResponse(ActionMapping mapping, ActionForm form, HttpServletRequest request, + HttpServletResponse response) throws IOException, ServletException, ToolException { + QaMonitoringAction.logger.debug("dispatching hideResponse..."); + IQaService qaService = QaServiceProxy.getQaService(getServlet().getServletContext()); + QaMonitoringAction.logger.debug("qaService: " + qaService); - if (currentMonitoredToolSession.equals("")) - { - currentMonitoredToolSession="All"; - } + QaMonitoringForm qaMonitoringForm = (QaMonitoringForm) form; - if (currentMonitoredToolSession.equals("All")) - { - request.setAttribute(SELECTION_CASE, new Long(2)); - } - else - { - request.setAttribute(SELECTION_CASE, new Long(1)); - } + String contentFolderID = WebUtil.readStrParam(request, AttributeNames.PARAM_CONTENT_FOLDER_ID); + QaMonitoringAction.logger.debug("contentFolderID: " + contentFolderID); + qaMonitoringForm.setContentFolderID(contentFolderID); - logger.debug("SELECTION_CASE: " + request.getAttribute(SELECTION_CASE)); + String currentUid = qaMonitoringForm.getCurrentUid(); + QaMonitoringAction.logger.debug("currentUid: " + currentUid); + QaUsrResp qaUsrResp = qaService.getAttemptByUID(new Long(currentUid)); + QaMonitoringAction.logger.debug("qaUsrResp: " + qaUsrResp); + qaUsrResp.setVisible(false); + qaService.updateUserResponse(qaUsrResp); + qaService.hideResponse(qaUsrResp); + QaMonitoringAction.logger.debug("qaUsrResp: " + qaUsrResp); - GeneralLearnerFlowDTO generalLearnerFlowDTO= LearningUtil.buildGeneralLearnerFlowDTO(qaContent); - logger.debug("generalLearnerFlowDTO: " + generalLearnerFlowDTO); - - refreshSummaryData(request, qaContent, qaService, true, false, null, null, generalLearnerFlowDTO, false , currentMonitoredToolSession); - - prepareReflectionData(request, qaContent, qaService,null, false, currentMonitoredToolSession); - - prepareEditActivityScreenData(request, qaContent); - - EditActivityDTO editActivityDTO = new EditActivityDTO(); - boolean isContentInUse=QaUtils.isContentInUse(qaContent); - logger.debug("isContentInUse:" + isContentInUse); - if (isContentInUse == true) - { - editActivityDTO.setMonitoredContentInUse(new Boolean(true).toString()); - } - request.setAttribute(EDIT_ACTIVITY_DTO, editActivityDTO); + String strToolContentID = request.getParameter(AttributeNames.PARAM_TOOL_CONTENT_ID); + QaMonitoringAction.logger.debug("strToolContentID: " + strToolContentID); + qaMonitoringForm.setToolContentID(strToolContentID); - /*find out if there are any reflection entries, from here*/ - boolean notebookEntriesExist=MonitoringUtil.notebookEntriesExist(qaService, qaContent); - logger.debug("notebookEntriesExist : " + notebookEntriesExist); - - if (notebookEntriesExist) - { - request.setAttribute(NOTEBOOK_ENTRIES_EXIST, new Boolean(true).toString()); - } - else - { - request.setAttribute(NOTEBOOK_ENTRIES_EXIST, new Boolean(false).toString()); - } - - MonitoringUtil.buildQaStatsDTO(request,qaService, qaContent); - MonitoringUtil.generateGroupsSessionData(request, qaService, qaContent, false); - request.setAttribute("currentMonitoredToolSession", "All"); - - logger.debug("submitting session to refresh the data from the database: "); - return (mapping.findForward(LOAD_MONITORING)); - } - - - - public ActionForward openNotebook(ActionMapping mapping, - ActionForm form, HttpServletRequest request, - HttpServletResponse response) throws IOException, - ServletException, ToolException - { - logger.debug("dispatching openNotebook..."); - QaMonitoringForm qaMonitoringForm = (QaMonitoringForm) form; - - IQaService qaService = QaServiceProxy.getQaService(getServlet().getServletContext()); - logger.debug("qaService: " + qaService); + String editResponse = request.getParameter(QaAppConstants.EDIT_RESPONSE); + QaMonitoringAction.logger.debug("editResponse: " + editResponse); + qaMonitoringForm.setEditResponse(editResponse); + QaContent qaContent = qaService.loadQa(new Long(strToolContentID).longValue()); + QaMonitoringAction.logger.debug("existing qaContent:" + qaContent); - String contentFolderID = WebUtil.readStrParam(request, AttributeNames.PARAM_CONTENT_FOLDER_ID); - logger.debug("contentFolderID: " + contentFolderID); - qaMonitoringForm.setContentFolderID(contentFolderID); + Map summaryToolSessions = MonitoringUtil.populateToolSessions(request, qaContent, qaService); + QaMonitoringAction.logger.debug("summaryToolSessions: " + summaryToolSessions); + request.setAttribute(QaAppConstants.SUMMARY_TOOL_SESSIONS, summaryToolSessions); + QaMonitoringAction.logger.debug("SUMMARY_TOOL_SESSIONS: " + + request.getAttribute(QaAppConstants.SUMMARY_TOOL_SESSIONS)); - - String uid=request.getParameter("uid"); - logger.debug("uid: " + uid); - - String userId=request.getParameter("userId"); - logger.debug("userId: " + userId); - - String userName=request.getParameter("userName"); - logger.debug("userName: " + userName); + Map summaryToolSessionsId = MonitoringUtil.populateToolSessionsId(request, qaContent, qaService); + QaMonitoringAction.logger.debug("summaryToolSessionsId: " + summaryToolSessionsId); + request.setAttribute(QaAppConstants.SUMMARY_TOOL_SESSIONS_ID, summaryToolSessionsId); - String sessionId=request.getParameter("sessionId"); - logger.debug("sessionId: " + sessionId); - - - NotebookEntry notebookEntry = qaService.getEntry(new Long(sessionId), - CoreNotebookConstants.NOTEBOOK_TOOL, - MY_SIGNATURE, new Integer(userId)); - - logger.debug("notebookEntry: " + notebookEntry); - - GeneralLearnerFlowDTO generalLearnerFlowDTO= new GeneralLearnerFlowDTO(); - if (notebookEntry != null) { - String notebookEntryPresentable=QaUtils.replaceNewLines(notebookEntry.getEntry()); - generalLearnerFlowDTO.setNotebookEntry(notebookEntryPresentable); - generalLearnerFlowDTO.setUserName(userName); - } + String currentMonitoredToolSession = qaMonitoringForm.getSelectedToolSessionId(); + QaMonitoringAction.logger.debug("currentMonitoredToolSession: " + currentMonitoredToolSession); - logger.debug("generalLearnerFlowDTO: " + generalLearnerFlowDTO); - request.setAttribute(GENERAL_LEARNER_FLOW_DTO, generalLearnerFlowDTO); - - QaSession qaSession=qaService.retrieveQaSessionOrNullById(new Long(sessionId).longValue()); - logger.debug("qaSession: " + qaSession); - - QaContent qaContent=qaSession.getQaContent(); - logger.debug("qaContent: " + qaContent); - - prepareEditActivityScreenData(request, qaContent); - - GeneralMonitoringDTO generalMonitoringDTO= new GeneralMonitoringDTO(); - List attachmentList = qaService.retrieveQaUploadedFiles(qaContent); - logger.debug("attachmentList: " + attachmentList); - generalMonitoringDTO.setAttachmentList(attachmentList); - - - - if (qaService.studentActivityOccurredGlobal(qaContent)) - { - logger.debug("USER_EXCEPTION_NO_TOOL_SESSIONS is set to false"); - generalMonitoringDTO.setUserExceptionNoToolSessions(new Boolean(false).toString()); - } - else - { - logger.debug("USER_EXCEPTION_NO_TOOL_SESSIONS is set to true"); - generalMonitoringDTO.setUserExceptionNoToolSessions(new Boolean(true).toString()); - } + if (currentMonitoredToolSession.equals("")) { + currentMonitoredToolSession = "All"; + } - - logger.debug("final generalMonitoringDTO: " + generalMonitoringDTO ); - request.setAttribute(QA_GENERAL_MONITORING_DTO, generalMonitoringDTO); + if (currentMonitoredToolSession.equals("All")) { + request.setAttribute(QaAppConstants.SELECTION_CASE, new Long(2)); - + QaSession qaSession = qaService.retrieveQaSessionOrNullById(new Long(currentMonitoredToolSession) + .longValue()); + QaMonitoringAction.logger.debug("retrieving qaSession name: " + qaSession.getSession_name()); + request.setAttribute(QaAppConstants.CURRENT_SESSION_NAME, qaSession.getSession_name()); + } else { + request.setAttribute(QaAppConstants.SELECTION_CASE, new Long(1)); + } - /*find out if there are any reflection entries, from here*/ - boolean notebookEntriesExist=MonitoringUtil.notebookEntriesExist(qaService, qaContent); - logger.debug("notebookEntriesExist : " + notebookEntriesExist); - - if (notebookEntriesExist) - { - request.setAttribute(NOTEBOOK_ENTRIES_EXIST, new Boolean(true).toString()); - - String userExceptionNoToolSessions=(String)generalMonitoringDTO.getUserExceptionNoToolSessions(); - logger.debug("userExceptionNoToolSessions : " + userExceptionNoToolSessions); - - if (userExceptionNoToolSessions.equals("true")) - { - logger.debug("there are no online student activity but there are reflections : "); - request.setAttribute(NO_SESSIONS_NOTEBOOK_ENTRIES_EXIST, new Boolean(true).toString()); - } - } - else - { - request.setAttribute(NOTEBOOK_ENTRIES_EXIST, new Boolean(false).toString()); - } - /* ... till here*/ - - MonitoringUtil.buildQaStatsDTO(request,qaService, qaContent); - MonitoringUtil.generateGroupsSessionData(request, qaService, qaContent, false); - - return mapping.findForward(LEARNER_NOTEBOOK); + QaMonitoringAction.logger.debug("SELECTION_CASE: " + request.getAttribute(QaAppConstants.SELECTION_CASE)); + request.setAttribute(QaAppConstants.CURRENT_MONITORED_TOOL_SESSION, currentMonitoredToolSession); + + GeneralLearnerFlowDTO generalLearnerFlowDTO = LearningUtil.buildGeneralLearnerFlowDTO(qaContent); + QaMonitoringAction.logger.debug("generalLearnerFlowDTO: " + generalLearnerFlowDTO); + + refreshSummaryData(request, qaContent, qaService, true, false, null, null, generalLearnerFlowDTO, false, + currentMonitoredToolSession); + + prepareReflectionData(request, qaContent, qaService, null, false, currentMonitoredToolSession); + + prepareEditActivityScreenData(request, qaContent); + + EditActivityDTO editActivityDTO = new EditActivityDTO(); + boolean isContentInUse = QaUtils.isContentInUse(qaContent); + QaMonitoringAction.logger.debug("isContentInUse:" + isContentInUse); + if (isContentInUse == true) { + editActivityDTO.setMonitoredContentInUse(new Boolean(true).toString()); } - - - public void prepareEditActivityScreenData(HttpServletRequest request, QaContent qaContent) - { - logger.debug("starting prepareEditActivityScreenData: " + qaContent); - QaGeneralAuthoringDTO qaGeneralAuthoringDTO= new QaGeneralAuthoringDTO(); - - qaGeneralAuthoringDTO.setActivityTitle(qaContent.getTitle()); - qaGeneralAuthoringDTO.setActivityInstructions(qaContent.getInstructions()); - - logger.debug("final qaGeneralAuthoringDTO: " + qaGeneralAuthoringDTO); - request.setAttribute(QA_GENERAL_AUTHORING_DTO, qaGeneralAuthoringDTO); + request.setAttribute(QaAppConstants.EDIT_ACTIVITY_DTO, editActivityDTO); + + /* find out if there are any reflection entries, from here */ + boolean notebookEntriesExist = MonitoringUtil.notebookEntriesExist(qaService, qaContent); + QaMonitoringAction.logger.debug("notebookEntriesExist : " + notebookEntriesExist); + + if (notebookEntriesExist) { + request.setAttribute(QaAppConstants.NOTEBOOK_ENTRIES_EXIST, new Boolean(true).toString()); + } else { + request.setAttribute(QaAppConstants.NOTEBOOK_ENTRIES_EXIST, new Boolean(false).toString()); } - - - public ActionForward submitAllContent(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) - throws IOException, ServletException { - logger.debug("dispatching proxy submitAllContent..."); + MonitoringUtil.buildQaStatsDTO(request, qaService, qaContent); + MonitoringUtil.generateGroupsSessionData(request, qaService, qaContent, false); - /*start authoring code*/ - QaAuthoringForm qaAuthoringForm = (QaMonitoringForm) form; - logger.debug("dispathcing submitAllContent :" +form); + QaMonitoringAction.logger.debug("submitting session to refresh the data from the database: "); + return mapping.findForward(QaAppConstants.LOAD_MONITORING); + } - IQaService qaService =QaServiceProxy.getQaService(getServlet().getServletContext()); - logger.debug("qaService: " + qaService); - - String httpSessionID=request.getParameter("httpSessionID"); - logger.debug("httpSessionID: " + httpSessionID); - - SessionMap sessionMap=(SessionMap)request.getSession().getAttribute(httpSessionID); - logger.debug("sessionMap: " + sessionMap); + public ActionForward hideGroupResponse(ActionMapping mapping, ActionForm form, HttpServletRequest request, + HttpServletResponse response) throws IOException, ServletException, ToolException { + QaMonitoringAction.logger.debug("dispatching hideGroupResponse..."); + IQaService qaService = QaServiceProxy.getQaService(getServlet().getServletContext()); + QaMonitoringAction.logger.debug("qaService: " + qaService); - String contentFolderID = WebUtil.readStrParam(request, AttributeNames.PARAM_CONTENT_FOLDER_ID); - logger.debug("contentFolderID: " + contentFolderID); - qaAuthoringForm.setContentFolderID(contentFolderID); + QaMonitoringForm qaMonitoringForm = (QaMonitoringForm) form; - String activeModule=request.getParameter(ACTIVE_MODULE); - logger.debug("activeModule: " + activeModule); + String contentFolderID = WebUtil.readStrParam(request, AttributeNames.PARAM_CONTENT_FOLDER_ID); + QaMonitoringAction.logger.debug("contentFolderID: " + contentFolderID); + qaMonitoringForm.setContentFolderID(contentFolderID); - String strToolContentID=request.getParameter(AttributeNames.PARAM_TOOL_CONTENT_ID); - logger.debug("strToolContentID: " + strToolContentID); + String currentUid = qaMonitoringForm.getCurrentUid(); + QaMonitoringAction.logger.debug("currentUid: " + currentUid); + QaUsrResp qaUsrResp = qaService.getAttemptByUID(new Long(currentUid)); + QaMonitoringAction.logger.debug("qaUsrResp: " + qaUsrResp); + qaUsrResp.setVisible(false); + qaService.updateUserResponse(qaUsrResp); + qaService.hideResponse(qaUsrResp); + QaMonitoringAction.logger.debug("qaUsrResp: " + qaUsrResp); - String defaultContentIdStr=request.getParameter(DEFAULT_CONTENT_ID_STR); - logger.debug("defaultContentIdStr: " + defaultContentIdStr); - - List listQuestionContentDTO=(List)sessionMap.get(LIST_QUESTION_CONTENT_DTO_KEY); - logger.debug("listQuestionContentDTO: " + listQuestionContentDTO); - - Map mapQuestionContent=AuthoringUtil.extractMapQuestionContent(listQuestionContentDTO); - logger.debug("extracted mapQuestionContent: " + mapQuestionContent); - + String strToolContentID = request.getParameter(AttributeNames.PARAM_TOOL_CONTENT_ID); + QaMonitoringAction.logger.debug("strToolContentID: " + strToolContentID); + qaMonitoringForm.setToolContentID(strToolContentID); - Map mapFeedback=AuthoringUtil.extractMapFeedback(listQuestionContentDTO); - logger.debug("extracted mapFeedback: " + mapFeedback); + String editResponse = request.getParameter(QaAppConstants.EDIT_RESPONSE); + QaMonitoringAction.logger.debug("editResponse: " + editResponse); + qaMonitoringForm.setEditResponse(editResponse); - ActionMessages errors = new ActionMessages(); - logger.debug("mapQuestionContent size: " + mapQuestionContent.size()); - - if (mapQuestionContent.size() == 0) - { - ActionMessage error = new ActionMessage("questions.none.submitted"); - errors.add(ActionMessages.GLOBAL_MESSAGE, error); - } - logger.debug("errors: " + errors); - - AuthoringUtil authoringUtil= new AuthoringUtil(); - - QaGeneralAuthoringDTO qaGeneralAuthoringDTO= new QaGeneralAuthoringDTO(); - qaGeneralAuthoringDTO.setContentFolderID(contentFolderID); - - String richTextTitle = request.getParameter(TITLE); - String richTextInstructions = request.getParameter(INSTRUCTIONS); - - logger.debug("richTextTitle: " + richTextTitle); - logger.debug("richTextInstructions: " + richTextInstructions); - - qaGeneralAuthoringDTO.setActivityTitle(richTextTitle); - qaAuthoringForm.setTitle(richTextTitle); - - qaGeneralAuthoringDTO.setActivityInstructions(richTextInstructions); - - sessionMap.put(ACTIVITY_TITLE_KEY, richTextTitle); - sessionMap.put(ACTIVITY_INSTRUCTIONS_KEY, richTextInstructions); - - qaGeneralAuthoringDTO.setMapQuestionContent(mapQuestionContent); - logger.debug("qaGeneralAuthoringDTO: " + qaGeneralAuthoringDTO); - - - logger.debug("qaGeneralAuthoringDTO now: " + qaGeneralAuthoringDTO); - request.setAttribute(QA_GENERAL_AUTHORING_DTO, qaGeneralAuthoringDTO); - - logger.debug("there are no issues with input, continue and submit data"); + QaContent qaContent = qaService.loadQa(new Long(strToolContentID).longValue()); + QaMonitoringAction.logger.debug("existing qaContent:" + qaContent); - QaContent qaContentTest=qaService.loadQa(new Long(strToolContentID).longValue()); - logger.debug("qaContentTest: " + qaContentTest); + Map summaryToolSessions = MonitoringUtil.populateToolSessions(request, qaContent, qaService); + QaMonitoringAction.logger.debug("summaryToolSessions: " + summaryToolSessions); + request.setAttribute(QaAppConstants.SUMMARY_TOOL_SESSIONS, summaryToolSessions); + QaMonitoringAction.logger.debug("SUMMARY_TOOL_SESSIONS: " + + request.getAttribute(QaAppConstants.SUMMARY_TOOL_SESSIONS)); - logger.debug("errors: " + errors); - if(!errors.isEmpty()){ - saveErrors(request, errors); - logger.debug("errors saved: " + errors); - } - + Map summaryToolSessionsId = MonitoringUtil.populateToolSessionsId(request, qaContent, qaService); + QaMonitoringAction.logger.debug("summaryToolSessionsId: " + summaryToolSessionsId); + request.setAttribute(QaAppConstants.SUMMARY_TOOL_SESSIONS_ID, summaryToolSessionsId); - GeneralMonitoringDTO qaGeneralMonitoringDTO=new GeneralMonitoringDTO(); - - QaContent qaContent=qaContentTest; - if(errors.isEmpty()){ - logger.debug("errors is empty: " + errors); - /*to remove deleted entries in the questions table based on mapQuestionContent */ - authoringUtil.removeRedundantQuestions(mapQuestionContent, qaService, qaAuthoringForm, request, strToolContentID); - logger.debug("end of removing unused entries... "); + String currentMonitoredToolSession = qaMonitoringForm.getSelectedToolSessionId(); + QaMonitoringAction.logger.debug("currentMonitoredToolSession: " + currentMonitoredToolSession); - qaContent=authoringUtil.saveOrUpdateQaContent(mapQuestionContent, mapFeedback, qaService, qaAuthoringForm, request, qaContentTest, strToolContentID); - logger.debug("qaContent: " + qaContent); - - - long defaultContentID=0; - logger.debug("attempt retrieving tool with signatute : " + MY_SIGNATURE); - defaultContentID=qaService.getToolDefaultContentIdBySignature(MY_SIGNATURE); - logger.debug("retrieved tool default contentId: " + defaultContentID); - - if (qaContent != null) - { - qaGeneralAuthoringDTO.setDefaultContentIdStr(new Long(defaultContentID).toString()); - } - logger.debug("updated qaGeneralAuthoringDTO to: " + qaGeneralAuthoringDTO); - - authoringUtil.reOrganizeDisplayOrder(mapQuestionContent, qaService, qaAuthoringForm, qaContent); - - logger.debug("strToolContentID: " + strToolContentID); - QaUtils.setDefineLater(request, false, strToolContentID, qaService); - logger.debug("define later set to false"); - - QaUtils.setFormProperties(request, qaService, - qaAuthoringForm, qaGeneralAuthoringDTO, strToolContentID, defaultContentIdStr, activeModule, sessionMap, httpSessionID); + if (currentMonitoredToolSession.equals("")) { + currentMonitoredToolSession = "All"; + } - qaGeneralMonitoringDTO.setDefineLaterInEditMode(new Boolean(false).toString()); - } - else - { - logger.debug("errors is not empty: " + errors); - - if (qaContent != null) - { - long defaultContentID=0; - logger.debug("attempt retrieving tool with signatute : " + MY_SIGNATURE); - defaultContentID=qaService.getToolDefaultContentIdBySignature(MY_SIGNATURE); - logger.debug("retrieved tool default contentId: " + defaultContentID); - - if (qaContent != null) - { - qaGeneralAuthoringDTO.setDefaultContentIdStr(new Long(defaultContentID).toString()); - } + if (currentMonitoredToolSession.equals("All")) { + request.setAttribute(QaAppConstants.SELECTION_CASE, new Long(2)); + } else { + request.setAttribute(QaAppConstants.SELECTION_CASE, new Long(1)); + } - QaUtils.setFormProperties(request, qaService, - qaAuthoringForm, qaGeneralAuthoringDTO, strToolContentID, defaultContentIdStr, activeModule, sessionMap, httpSessionID); - - } - qaGeneralMonitoringDTO.setDefineLaterInEditMode(new Boolean(true).toString()); - } - - qaGeneralAuthoringDTO.setSbmtSuccess(new Integer(1).toString()); - - qaAuthoringForm.resetUserAction(); - qaGeneralAuthoringDTO.setMapQuestionContent(mapQuestionContent); - - logger.debug("before saving final qaGeneralAuthoringDTO: " + qaGeneralAuthoringDTO); - request.setAttribute(QA_GENERAL_AUTHORING_DTO, qaGeneralAuthoringDTO); + QaMonitoringAction.logger.debug("SELECTION_CASE: " + request.getAttribute(QaAppConstants.SELECTION_CASE)); - request.setAttribute(LIST_QUESTION_CONTENT_DTO,listQuestionContentDTO); - sessionMap.put(LIST_QUESTION_CONTENT_DTO_KEY, listQuestionContentDTO); - request.getSession().setAttribute(httpSessionID, sessionMap); - - request.setAttribute(TOTAL_QUESTION_COUNT, new Integer(listQuestionContentDTO.size())); - - - qaGeneralAuthoringDTO.setToolContentID(strToolContentID); - qaGeneralAuthoringDTO.setHttpSessionID(httpSessionID); - qaGeneralAuthoringDTO.setActiveModule(activeModule); - qaGeneralAuthoringDTO.setDefaultContentIdStr(defaultContentIdStr); - - qaAuthoringForm.setToolContentID(strToolContentID); - qaAuthoringForm.setHttpSessionID(httpSessionID); - qaAuthoringForm.setActiveModule(activeModule); - qaAuthoringForm.setDefaultContentIdStr(defaultContentIdStr); - qaAuthoringForm.setCurrentTab("3"); - + GeneralLearnerFlowDTO generalLearnerFlowDTO = LearningUtil.buildGeneralLearnerFlowDTO(qaContent); + QaMonitoringAction.logger.debug("generalLearnerFlowDTO: " + generalLearnerFlowDTO); - /*start monitoring code*/ + refreshSummaryData(request, qaContent, qaService, true, false, null, null, generalLearnerFlowDTO, false, + currentMonitoredToolSession); - if (qaService.studentActivityOccurredGlobal(qaContent)) - { - logger.debug("USER_EXCEPTION_NO_TOOL_SESSIONS is set to false"); - qaGeneralMonitoringDTO.setUserExceptionNoToolSessions(new Boolean(false).toString()); - } - else - { - logger.debug("USER_EXCEPTION_NO_TOOL_SESSIONS is set to true"); - qaGeneralMonitoringDTO.setUserExceptionNoToolSessions(new Boolean(true).toString()); - } + prepareReflectionData(request, qaContent, qaService, null, false, currentMonitoredToolSession); - qaGeneralMonitoringDTO.setOnlineInstructions(qaContent.getOnlineInstructions()); - qaGeneralMonitoringDTO.setOfflineInstructions(qaContent.getOfflineInstructions()); + prepareEditActivityScreenData(request, qaContent); - List attachmentList = qaService.retrieveQaUploadedFiles(qaContent); - logger.debug("attachmentList: " + attachmentList); - qaGeneralMonitoringDTO.setAttachmentList(attachmentList); - logger.debug("final qaGeneralMonitoringDTO: " + qaGeneralMonitoringDTO ); - - logger.debug("final generalMonitoringDTO: " + qaGeneralMonitoringDTO ); - request.setAttribute(QA_GENERAL_MONITORING_DTO, qaGeneralMonitoringDTO); + EditActivityDTO editActivityDTO = new EditActivityDTO(); + boolean isContentInUse = QaUtils.isContentInUse(qaContent); + QaMonitoringAction.logger.debug("isContentInUse:" + isContentInUse); + if (isContentInUse == true) { + editActivityDTO.setMonitoredContentInUse(new Boolean(true).toString()); + } + request.setAttribute(QaAppConstants.EDIT_ACTIVITY_DTO, editActivityDTO); - prepareReflectionData(request, qaContent, qaService, null, false , "All"); - - /*find out if there are any reflection entries, from here*/ - boolean notebookEntriesExist=MonitoringUtil.notebookEntriesExist(qaService, qaContent); - logger.debug("notebookEntriesExist : " + notebookEntriesExist); - - if (notebookEntriesExist) - { - request.setAttribute(NOTEBOOK_ENTRIES_EXIST, new Boolean(true).toString()); - - String userExceptionNoToolSessions=(String)qaGeneralMonitoringDTO.getUserExceptionNoToolSessions(); - logger.debug("userExceptionNoToolSessions : " + userExceptionNoToolSessions); - - if (userExceptionNoToolSessions.equals("true")) - { - logger.debug("there are no online student activity but there are reflections : "); - request.setAttribute(NO_SESSIONS_NOTEBOOK_ENTRIES_EXIST, new Boolean(true).toString()); - } - } - else - { - request.setAttribute(NOTEBOOK_ENTRIES_EXIST, new Boolean(false).toString()); - } - /* ... till here*/ - - MonitoringUtil.buildQaStatsDTO(request,qaService, qaContent); - MonitoringUtil.generateGroupsSessionData(request, qaService, qaContent, false); + /* find out if there are any reflection entries, from here */ + boolean notebookEntriesExist = MonitoringUtil.notebookEntriesExist(qaService, qaContent); + QaMonitoringAction.logger.debug("notebookEntriesExist : " + notebookEntriesExist); - return mapping.findForward(LOAD_MONITORING); + if (notebookEntriesExist) { + request.setAttribute(QaAppConstants.NOTEBOOK_ENTRIES_EXIST, new Boolean(true).toString()); + } else { + request.setAttribute(QaAppConstants.NOTEBOOK_ENTRIES_EXIST, new Boolean(false).toString()); + } + + MonitoringUtil.buildQaStatsDTO(request, qaService, qaContent); + MonitoringUtil.generateGroupsSessionData(request, qaService, qaContent, false); + request.setAttribute("currentMonitoredToolSession", "All"); + + QaMonitoringAction.logger.debug("submitting session to refresh the data from the database: "); + return mapping.findForward(QaAppConstants.LOAD_MONITORING); } - - - - public ActionForward saveSingleQuestion(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) - throws IOException, ServletException { - - logger.debug("dispathcing proxy saveSingleQuestion"); - - /*start authoring code*/ - QaAuthoringForm qaAuthoringForm = (QaMonitoringForm) form; - logger.debug("dispathcing saveSingleQuestion"); - - IQaService qaService =QaServiceProxy.getQaService(getServlet().getServletContext()); - logger.debug("qaService: " + qaService); - - String httpSessionID=request.getParameter("httpSessionID"); - logger.debug("httpSessionID: " + httpSessionID); - - - SessionMap sessionMap=(SessionMap)request.getSession().getAttribute(httpSessionID); - logger.debug("sessionMap: " + sessionMap); - - String contentFolderID = WebUtil.readStrParam(request, AttributeNames.PARAM_CONTENT_FOLDER_ID); - logger.debug("contentFolderID: " + contentFolderID); - qaAuthoringForm.setContentFolderID(contentFolderID); - - String editQuestionBoxRequest=request.getParameter("editQuestionBoxRequest"); - logger.debug("editQuestionBoxRequest: " + editQuestionBoxRequest); - - - String activeModule=request.getParameter(ACTIVE_MODULE); - logger.debug("activeModule: " + activeModule); - - String strToolContentID=request.getParameter(AttributeNames.PARAM_TOOL_CONTENT_ID); - logger.debug("strToolContentID: " + strToolContentID); - - String defaultContentIdStr=request.getParameter(DEFAULT_CONTENT_ID_STR); - logger.debug("defaultContentIdStr: " + defaultContentIdStr); - - QaContent qaContent=qaService.loadQa(new Long(strToolContentID).longValue()); - logger.debug("qaContent: " + qaContent); - - if (qaContent == null) - { - logger.debug("using defaultContentIdStr: " + defaultContentIdStr); - qaContent=qaService.loadQa(new Long(defaultContentIdStr).longValue()); - } - logger.debug("final qaContent: " + qaContent); - - QaGeneralAuthoringDTO qaGeneralAuthoringDTO= new QaGeneralAuthoringDTO(); - - logger.debug("qaGeneralAuthoringDTO: " + qaGeneralAuthoringDTO); - qaGeneralAuthoringDTO.setContentFolderID(contentFolderID); - - qaGeneralAuthoringDTO.setSbmtSuccess(new Integer(0).toString()); - - AuthoringUtil authoringUtil= new AuthoringUtil(); - - List listQuestionContentDTO=(List)sessionMap.get(LIST_QUESTION_CONTENT_DTO_KEY); - logger.debug("listQuestionContentDTO: " + listQuestionContentDTO); - - - String newQuestion=request.getParameter("newQuestion"); - logger.debug("newQuestion: " + newQuestion); - - String feedback=request.getParameter("feedback"); - logger.debug("feedback: " + feedback); - - String editableQuestionIndex=request.getParameter("editableQuestionIndex"); - logger.debug("editableQuestionIndex: " + editableQuestionIndex); - + public ActionForward openNotebook(ActionMapping mapping, ActionForm form, HttpServletRequest request, + HttpServletResponse response) throws IOException, ServletException, ToolException { + QaMonitoringAction.logger.debug("dispatching openNotebook..."); + QaMonitoringForm qaMonitoringForm = (QaMonitoringForm) form; - if ((newQuestion != null) && (newQuestion.length() > 0)) - { - if ((editQuestionBoxRequest != null) && (editQuestionBoxRequest.equals("false"))) - { - logger.debug("request for add and save"); - boolean duplicates=AuthoringUtil.checkDuplicateQuestions(listQuestionContentDTO, newQuestion); - logger.debug("duplicates: " + duplicates); - - if (!duplicates) - { - QaQuestionContentDTO qaQuestionContentDTO= null; - Iterator listIterator=listQuestionContentDTO.iterator(); - while (listIterator.hasNext()) - { - qaQuestionContentDTO= (QaQuestionContentDTO)listIterator.next(); - logger.debug("qaQuestionContentDTO:" + qaQuestionContentDTO); - logger.debug("qaQuestionContentDTO question:" + qaQuestionContentDTO.getQuestion()); - - String question=qaQuestionContentDTO.getQuestion(); - String displayOrder=qaQuestionContentDTO.getDisplayOrder(); - logger.debug("displayOrder:" + displayOrder); - - if ((displayOrder != null) && (!displayOrder.equals(""))) - { - if (displayOrder.equals(editableQuestionIndex)) - { - break; - } - - } - } - logger.debug("qaQuestionContentDTO found:" + qaQuestionContentDTO); - - qaQuestionContentDTO.setQuestion(newQuestion); - qaQuestionContentDTO.setFeedback(feedback); - qaQuestionContentDTO.setDisplayOrder(editableQuestionIndex); - - listQuestionContentDTO=AuthoringUtil.reorderUpdateListQuestionContentDTO(listQuestionContentDTO, qaQuestionContentDTO, editableQuestionIndex); - logger.debug("post reorderUpdateListQuestionContentDTO listQuestionContentDTO: " + listQuestionContentDTO); - } - else - { - logger.debug("duplicate question entry, not adding"); - } - } - else - { - logger.debug("request for edit and save."); - QaQuestionContentDTO qaQuestionContentDTO= null; - Iterator listIterator=listQuestionContentDTO.iterator(); - while (listIterator.hasNext()) - { - qaQuestionContentDTO= (QaQuestionContentDTO)listIterator.next(); - logger.debug("qaQuestionContentDTO:" + qaQuestionContentDTO); - logger.debug("qaQuestionContentDTO question:" + qaQuestionContentDTO.getQuestion()); - - String question=qaQuestionContentDTO.getQuestion(); - String displayOrder=qaQuestionContentDTO.getDisplayOrder(); - logger.debug("displayOrder:" + displayOrder); - - if ((displayOrder != null) && (!displayOrder.equals(""))) - { - if (displayOrder.equals(editableQuestionIndex)) - { - break; - } - - } - } - logger.debug("qaQuestionContentDTO found:" + qaQuestionContentDTO); - - qaQuestionContentDTO.setQuestion(newQuestion); - qaQuestionContentDTO.setFeedback(feedback); - qaQuestionContentDTO.setDisplayOrder(editableQuestionIndex); - - listQuestionContentDTO=AuthoringUtil.reorderUpdateListQuestionContentDTO(listQuestionContentDTO, qaQuestionContentDTO, editableQuestionIndex); - logger.debug("post reorderUpdateListQuestionContentDTO listQuestionContentDTO: " + listQuestionContentDTO); - } + IQaService qaService = QaServiceProxy.getQaService(getServlet().getServletContext()); + QaMonitoringAction.logger.debug("qaService: " + qaService); + + String contentFolderID = WebUtil.readStrParam(request, AttributeNames.PARAM_CONTENT_FOLDER_ID); + QaMonitoringAction.logger.debug("contentFolderID: " + contentFolderID); + qaMonitoringForm.setContentFolderID(contentFolderID); + + String uid = request.getParameter("uid"); + QaMonitoringAction.logger.debug("uid: " + uid); + + String userId = request.getParameter("userId"); + QaMonitoringAction.logger.debug("userId: " + userId); + + String userName = request.getParameter("userName"); + QaMonitoringAction.logger.debug("userName: " + userName); + + String sessionId = request.getParameter("sessionId"); + QaMonitoringAction.logger.debug("sessionId: " + sessionId); + + NotebookEntry notebookEntry = qaService.getEntry(new Long(sessionId), CoreNotebookConstants.NOTEBOOK_TOOL, + QaAppConstants.MY_SIGNATURE, new Integer(userId)); + + QaMonitoringAction.logger.debug("notebookEntry: " + notebookEntry); + + GeneralLearnerFlowDTO generalLearnerFlowDTO = new GeneralLearnerFlowDTO(); + if (notebookEntry != null) { + String notebookEntryPresentable = QaUtils.replaceNewLines(notebookEntry.getEntry()); + generalLearnerFlowDTO.setNotebookEntry(notebookEntryPresentable); + generalLearnerFlowDTO.setUserName(userName); + } + + QaMonitoringAction.logger.debug("generalLearnerFlowDTO: " + generalLearnerFlowDTO); + request.setAttribute(QaAppConstants.GENERAL_LEARNER_FLOW_DTO, generalLearnerFlowDTO); + + QaSession qaSession = qaService.retrieveQaSessionOrNullById(new Long(sessionId).longValue()); + QaMonitoringAction.logger.debug("qaSession: " + qaSession); + + QaContent qaContent = qaSession.getQaContent(); + QaMonitoringAction.logger.debug("qaContent: " + qaContent); + + prepareEditActivityScreenData(request, qaContent); + + GeneralMonitoringDTO generalMonitoringDTO = new GeneralMonitoringDTO(); + List attachmentList = qaService.retrieveQaUploadedFiles(qaContent); + QaMonitoringAction.logger.debug("attachmentList: " + attachmentList); + generalMonitoringDTO.setAttachmentList(attachmentList); + + if (qaService.studentActivityOccurredGlobal(qaContent)) { + QaMonitoringAction.logger.debug("USER_EXCEPTION_NO_TOOL_SESSIONS is set to false"); + generalMonitoringDTO.setUserExceptionNoToolSessions(new Boolean(false).toString()); + } else { + QaMonitoringAction.logger.debug("USER_EXCEPTION_NO_TOOL_SESSIONS is set to true"); + generalMonitoringDTO.setUserExceptionNoToolSessions(new Boolean(true).toString()); + } + + QaMonitoringAction.logger.debug("final generalMonitoringDTO: " + generalMonitoringDTO); + request.setAttribute(QaAppConstants.QA_GENERAL_MONITORING_DTO, generalMonitoringDTO); + + /* find out if there are any reflection entries, from here */ + boolean notebookEntriesExist = MonitoringUtil.notebookEntriesExist(qaService, qaContent); + QaMonitoringAction.logger.debug("notebookEntriesExist : " + notebookEntriesExist); + + if (notebookEntriesExist) { + request.setAttribute(QaAppConstants.NOTEBOOK_ENTRIES_EXIST, new Boolean(true).toString()); + + String userExceptionNoToolSessions = generalMonitoringDTO.getUserExceptionNoToolSessions(); + QaMonitoringAction.logger.debug("userExceptionNoToolSessions : " + userExceptionNoToolSessions); + + if (userExceptionNoToolSessions.equals("true")) { + QaMonitoringAction.logger.debug("there are no online student activity but there are reflections : "); + request.setAttribute(QaAppConstants.NO_SESSIONS_NOTEBOOK_ENTRIES_EXIST, new Boolean(true).toString()); } - else - { - logger.debug("entry blank, not adding"); - } - + } else { + request.setAttribute(QaAppConstants.NOTEBOOK_ENTRIES_EXIST, new Boolean(false).toString()); + } + /* ... till here */ - request.setAttribute(LIST_QUESTION_CONTENT_DTO,listQuestionContentDTO); - sessionMap.put(LIST_QUESTION_CONTENT_DTO_KEY, listQuestionContentDTO); - logger.debug("listQuestionContentDTO now: " + listQuestionContentDTO); - - - String richTextTitle = request.getParameter(TITLE); - String richTextInstructions = request.getParameter(INSTRUCTIONS); - - logger.debug("richTextTitle: " + richTextTitle); - logger.debug("richTextInstructions: " + richTextInstructions); - qaGeneralAuthoringDTO.setActivityTitle(richTextTitle); - qaAuthoringForm.setTitle(richTextTitle); - - qaGeneralAuthoringDTO.setActivityInstructions(richTextInstructions); - - sessionMap.put(ACTIVITY_TITLE_KEY, richTextTitle); - sessionMap.put(ACTIVITY_INSTRUCTIONS_KEY, richTextInstructions); - - qaGeneralAuthoringDTO.setEditActivityEditMode(new Boolean(true).toString()); - - request.getSession().setAttribute(httpSessionID, sessionMap); - sessionMap.put(LIST_QUESTION_CONTENT_DTO_KEY, listQuestionContentDTO); - - QaUtils.setFormProperties(request, qaService, - qaAuthoringForm, qaGeneralAuthoringDTO, strToolContentID, defaultContentIdStr, activeModule, sessionMap, httpSessionID); - - - qaGeneralAuthoringDTO.setToolContentID(strToolContentID); - qaGeneralAuthoringDTO.setHttpSessionID(httpSessionID); - qaGeneralAuthoringDTO.setActiveModule(activeModule); - qaGeneralAuthoringDTO.setDefaultContentIdStr(defaultContentIdStr); - - qaAuthoringForm.setToolContentID(strToolContentID); - qaAuthoringForm.setHttpSessionID(httpSessionID); - qaAuthoringForm.setActiveModule(activeModule); - qaAuthoringForm.setDefaultContentIdStr(defaultContentIdStr); - qaAuthoringForm.setCurrentTab("3"); - - - logger.debug("qaGeneralAuthoringDTO now: " + qaGeneralAuthoringDTO); - request.setAttribute(QA_GENERAL_AUTHORING_DTO, qaGeneralAuthoringDTO); - - logger.debug("httpSessionID: " + httpSessionID); - logger.debug("sessionMap: " + sessionMap); - - request.getSession().setAttribute(httpSessionID, sessionMap); - logger.debug("qaGeneralAuthoringDTO.getMapQuestionContent(); " + qaGeneralAuthoringDTO.getMapQuestionContent()); - - request.setAttribute(TOTAL_QUESTION_COUNT, new Integer(listQuestionContentDTO.size())); - - /*start monitoring code*/ - GeneralMonitoringDTO qaGeneralMonitoringDTO=new GeneralMonitoringDTO(); - qaGeneralMonitoringDTO.setDefineLaterInEditMode(new Boolean(false).toString()); + MonitoringUtil.buildQaStatsDTO(request, qaService, qaContent); + MonitoringUtil.generateGroupsSessionData(request, qaService, qaContent, false); - if (qaService.studentActivityOccurredGlobal(qaContent)) - { - logger.debug("USER_EXCEPTION_NO_TOOL_SESSIONS is set to false"); - qaGeneralMonitoringDTO.setUserExceptionNoToolSessions(new Boolean(false).toString()); - } - else - { - logger.debug("USER_EXCEPTION_NO_TOOL_SESSIONS is set to true"); - qaGeneralMonitoringDTO.setUserExceptionNoToolSessions(new Boolean(true).toString()); - } - qaGeneralMonitoringDTO.setDefineLaterInEditMode(new Boolean(true).toString()); + return mapping.findForward(QaAppConstants.LEARNER_NOTEBOOK); + } - qaGeneralMonitoringDTO.setOnlineInstructions(qaContent.getOnlineInstructions()); - qaGeneralMonitoringDTO.setOfflineInstructions(qaContent.getOfflineInstructions()); + public void prepareEditActivityScreenData(HttpServletRequest request, QaContent qaContent) { + QaMonitoringAction.logger.debug("starting prepareEditActivityScreenData: " + qaContent); + QaGeneralAuthoringDTO qaGeneralAuthoringDTO = new QaGeneralAuthoringDTO(); - List attachmentList = qaService.retrieveQaUploadedFiles(qaContent); - logger.debug("attachmentList: " + attachmentList); - qaGeneralMonitoringDTO.setAttachmentList(attachmentList); - logger.debug("final qaGeneralMonitoringDTO: " + qaGeneralMonitoringDTO ); + qaGeneralAuthoringDTO.setActivityTitle(qaContent.getTitle()); + qaGeneralAuthoringDTO.setActivityInstructions(qaContent.getInstructions()); - - logger.debug("final generalMonitoringDTO: " + qaGeneralMonitoringDTO ); - request.setAttribute(QA_GENERAL_MONITORING_DTO, qaGeneralMonitoringDTO); + QaMonitoringAction.logger.debug("final qaGeneralAuthoringDTO: " + qaGeneralAuthoringDTO); + request.setAttribute(QaAppConstants.QA_GENERAL_AUTHORING_DTO, qaGeneralAuthoringDTO); + } - prepareReflectionData(request, qaContent, qaService, null, false , "All"); - - /*find out if there are any reflection entries, from here*/ - boolean notebookEntriesExist=MonitoringUtil.notebookEntriesExist(qaService, qaContent); - logger.debug("notebookEntriesExist : " + notebookEntriesExist); - - if (notebookEntriesExist) - { - request.setAttribute(NOTEBOOK_ENTRIES_EXIST, new Boolean(true).toString()); - - String userExceptionNoToolSessions=(String)qaGeneralMonitoringDTO.getUserExceptionNoToolSessions(); - logger.debug("userExceptionNoToolSessions : " + userExceptionNoToolSessions); - - if (userExceptionNoToolSessions.equals("true")) - { - logger.debug("there are no online student activity but there are reflections : "); - request.setAttribute(NO_SESSIONS_NOTEBOOK_ENTRIES_EXIST, new Boolean(true).toString()); - } - } - else - { - request.setAttribute(NOTEBOOK_ENTRIES_EXIST, new Boolean(false).toString()); - } - /* ... till here*/ - - MonitoringUtil.buildQaStatsDTO(request,qaService, qaContent); - MonitoringUtil.generateGroupsSessionData(request, qaService, qaContent, false); - - return mapping.findForward(LOAD_MONITORING); + public ActionForward submitAllContent(ActionMapping mapping, ActionForm form, HttpServletRequest request, + HttpServletResponse response) throws IOException, ServletException { + QaMonitoringAction.logger.debug("dispatching proxy submitAllContent..."); + + /* start authoring code */ + QaAuthoringForm qaAuthoringForm = (QaMonitoringForm) form; + QaMonitoringAction.logger.debug("dispathcing submitAllContent :" + form); + + IQaService qaService = QaServiceProxy.getQaService(getServlet().getServletContext()); + QaMonitoringAction.logger.debug("qaService: " + qaService); + + String httpSessionID = request.getParameter("httpSessionID"); + QaMonitoringAction.logger.debug("httpSessionID: " + httpSessionID); + + SessionMap sessionMap = (SessionMap) request.getSession().getAttribute(httpSessionID); + QaMonitoringAction.logger.debug("sessionMap: " + sessionMap); + + String contentFolderID = WebUtil.readStrParam(request, AttributeNames.PARAM_CONTENT_FOLDER_ID); + QaMonitoringAction.logger.debug("contentFolderID: " + contentFolderID); + qaAuthoringForm.setContentFolderID(contentFolderID); + + String activeModule = request.getParameter(QaAppConstants.ACTIVE_MODULE); + QaMonitoringAction.logger.debug("activeModule: " + activeModule); + + String strToolContentID = request.getParameter(AttributeNames.PARAM_TOOL_CONTENT_ID); + QaMonitoringAction.logger.debug("strToolContentID: " + strToolContentID); + + String defaultContentIdStr = request.getParameter(QaAppConstants.DEFAULT_CONTENT_ID_STR); + QaMonitoringAction.logger.debug("defaultContentIdStr: " + defaultContentIdStr); + + List listQuestionContentDTO = (List) sessionMap.get(QaAppConstants.LIST_QUESTION_CONTENT_DTO_KEY); + QaMonitoringAction.logger.debug("listQuestionContentDTO: " + listQuestionContentDTO); + + Map mapQuestionContent = AuthoringUtil.extractMapQuestionContent(listQuestionContentDTO); + QaMonitoringAction.logger.debug("extracted mapQuestionContent: " + mapQuestionContent); + + Map mapFeedback = AuthoringUtil.extractMapFeedback(listQuestionContentDTO); + QaMonitoringAction.logger.debug("extracted mapFeedback: " + mapFeedback); + + ActionMessages errors = new ActionMessages(); + QaMonitoringAction.logger.debug("mapQuestionContent size: " + mapQuestionContent.size()); + + if (mapQuestionContent.size() == 0) { + ActionMessage error = new ActionMessage("questions.none.submitted"); + errors.add(ActionMessages.GLOBAL_MESSAGE, error); } + QaMonitoringAction.logger.debug("errors: " + errors); - - - public ActionForward addSingleQuestion(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) - throws IOException, ServletException - { - logger.debug("dispathcing proxy addSingleQuestion"); + AuthoringUtil authoringUtil = new AuthoringUtil(); - /*start authoring code*/ - QaAuthoringForm qaAuthoringForm = (QaMonitoringForm) form; - logger.debug("dispathcing addSingleQuestion"); - - IQaService qaService =QaServiceProxy.getQaService(getServlet().getServletContext()); - logger.debug("qaService: " + qaService); - - String httpSessionID=request.getParameter("httpSessionID"); - logger.debug("httpSessionID: " + httpSessionID); - - SessionMap sessionMap=(SessionMap)request.getSession().getAttribute(httpSessionID); - logger.debug("sessionMap: " + sessionMap); - - String contentFolderID = WebUtil.readStrParam(request, AttributeNames.PARAM_CONTENT_FOLDER_ID); - logger.debug("contentFolderID: " + contentFolderID); - qaAuthoringForm.setContentFolderID(contentFolderID); - - - String activeModule=request.getParameter(ACTIVE_MODULE); - logger.debug("activeModule: " + activeModule); - - String strToolContentID=request.getParameter(AttributeNames.PARAM_TOOL_CONTENT_ID); - logger.debug("strToolContentID: " + strToolContentID); - - String defaultContentIdStr=request.getParameter(DEFAULT_CONTENT_ID_STR); - logger.debug("defaultContentIdStr: " + defaultContentIdStr); - - QaContent qaContent=qaService.loadQa(new Long(strToolContentID).longValue()); - logger.debug("qaContent: " + qaContent); - - if (qaContent == null) - { - logger.debug("using defaultContentIdStr: " + defaultContentIdStr); - qaContent=qaService.loadQa(new Long(defaultContentIdStr).longValue()); - } - logger.debug("final qaContent: " + qaContent); - - QaGeneralAuthoringDTO qaGeneralAuthoringDTO= new QaGeneralAuthoringDTO(); - logger.debug("qaGeneralAuthoringDTO: " + qaGeneralAuthoringDTO); - qaGeneralAuthoringDTO.setContentFolderID(contentFolderID); - - qaGeneralAuthoringDTO.setSbmtSuccess(new Integer(0).toString()); - - AuthoringUtil authoringUtil= new AuthoringUtil(); - - List listQuestionContentDTO=(List)sessionMap.get(LIST_QUESTION_CONTENT_DTO_KEY); - logger.debug("listQuestionContentDTO: " + listQuestionContentDTO); - - String newQuestion=request.getParameter("newQuestion"); - logger.debug("newQuestion: " + newQuestion); - - String feedback=request.getParameter("feedback"); - logger.debug("feedback: " + feedback); - - - int listSize=listQuestionContentDTO.size(); - logger.debug("listSize: " + listSize); - - if ((newQuestion != null) && (newQuestion.length() > 0)) - { - boolean duplicates=AuthoringUtil.checkDuplicateQuestions(listQuestionContentDTO, newQuestion); - logger.debug("duplicates: " + duplicates); - - if (!duplicates) - { - QaQuestionContentDTO qaQuestionContentDTO=new QaQuestionContentDTO(); - qaQuestionContentDTO.setDisplayOrder(new Long(listSize+1).toString()); - qaQuestionContentDTO.setFeedback(feedback); - qaQuestionContentDTO.setQuestion(newQuestion); - - listQuestionContentDTO.add(qaQuestionContentDTO); - logger.debug("updated listQuestionContentDTO: " + listQuestionContentDTO); - } - else - { - logger.debug("entry duplicate, not adding"); - } + QaGeneralAuthoringDTO qaGeneralAuthoringDTO = new QaGeneralAuthoringDTO(); + qaGeneralAuthoringDTO.setContentFolderID(contentFolderID); + + String richTextTitle = request.getParameter(QaAppConstants.TITLE); + String richTextInstructions = request.getParameter(QaAppConstants.INSTRUCTIONS); + + QaMonitoringAction.logger.debug("richTextTitle: " + richTextTitle); + QaMonitoringAction.logger.debug("richTextInstructions: " + richTextInstructions); + + qaGeneralAuthoringDTO.setActivityTitle(richTextTitle); + qaAuthoringForm.setTitle(richTextTitle); + + qaGeneralAuthoringDTO.setActivityInstructions(richTextInstructions); + + sessionMap.put(QaAppConstants.ACTIVITY_TITLE_KEY, richTextTitle); + sessionMap.put(QaAppConstants.ACTIVITY_INSTRUCTIONS_KEY, richTextInstructions); + + qaGeneralAuthoringDTO.setMapQuestionContent(mapQuestionContent); + QaMonitoringAction.logger.debug("qaGeneralAuthoringDTO: " + qaGeneralAuthoringDTO); + + QaMonitoringAction.logger.debug("qaGeneralAuthoringDTO now: " + qaGeneralAuthoringDTO); + request.setAttribute(QaAppConstants.QA_GENERAL_AUTHORING_DTO, qaGeneralAuthoringDTO); + + QaMonitoringAction.logger.debug("there are no issues with input, continue and submit data"); + + QaContent qaContentTest = qaService.loadQa(new Long(strToolContentID).longValue()); + QaMonitoringAction.logger.debug("qaContentTest: " + qaContentTest); + + QaMonitoringAction.logger.debug("errors: " + errors); + if (!errors.isEmpty()) { + saveErrors(request, errors); + QaMonitoringAction.logger.debug("errors saved: " + errors); + } + + GeneralMonitoringDTO qaGeneralMonitoringDTO = new GeneralMonitoringDTO(); + + QaContent qaContent = qaContentTest; + if (errors.isEmpty()) { + QaMonitoringAction.logger.debug("errors is empty: " + errors); + /* + * to remove deleted entries in the questions table based on mapQuestionContent + */ + authoringUtil.removeRedundantQuestions(mapQuestionContent, qaService, qaAuthoringForm, request, + strToolContentID); + QaMonitoringAction.logger.debug("end of removing unused entries... "); + + qaContent = authoringUtil.saveOrUpdateQaContent(mapQuestionContent, mapFeedback, qaService, + qaAuthoringForm, request, qaContentTest, strToolContentID, null); + QaMonitoringAction.logger.debug("qaContent: " + qaContent); + + long defaultContentID = 0; + QaMonitoringAction.logger.debug("attempt retrieving tool with signatute : " + QaAppConstants.MY_SIGNATURE); + defaultContentID = qaService.getToolDefaultContentIdBySignature(QaAppConstants.MY_SIGNATURE); + QaMonitoringAction.logger.debug("retrieved tool default contentId: " + defaultContentID); + + if (qaContent != null) { + qaGeneralAuthoringDTO.setDefaultContentIdStr(new Long(defaultContentID).toString()); } - else - { - logger.debug("entry blank, not adding"); - } - - - request.setAttribute(LIST_QUESTION_CONTENT_DTO,listQuestionContentDTO); - sessionMap.put(LIST_QUESTION_CONTENT_DTO_KEY, listQuestionContentDTO); - - - String richTextTitle = request.getParameter(TITLE); - String richTextInstructions = request.getParameter(INSTRUCTIONS); - - logger.debug("richTextTitle: " + richTextTitle); - logger.debug("richTextInstructions: " + richTextInstructions); - qaGeneralAuthoringDTO.setActivityTitle(richTextTitle); - qaAuthoringForm.setTitle(richTextTitle); - - qaGeneralAuthoringDTO.setActivityInstructions(richTextInstructions); - - sessionMap.put(ACTIVITY_TITLE_KEY, richTextTitle); - sessionMap.put(ACTIVITY_INSTRUCTIONS_KEY, richTextInstructions); - - qaGeneralAuthoringDTO.setEditActivityEditMode(new Boolean(true).toString()); - request.getSession().setAttribute(httpSessionID, sessionMap); - - QaUtils.setFormProperties(request, qaService, - qaAuthoringForm, qaGeneralAuthoringDTO, strToolContentID, defaultContentIdStr, activeModule, sessionMap, httpSessionID); - - - qaGeneralAuthoringDTO.setToolContentID(strToolContentID); - qaGeneralAuthoringDTO.setHttpSessionID(httpSessionID); - qaGeneralAuthoringDTO.setActiveModule(activeModule); - qaGeneralAuthoringDTO.setDefaultContentIdStr(defaultContentIdStr); - - qaAuthoringForm.setToolContentID(strToolContentID); - qaAuthoringForm.setHttpSessionID(httpSessionID); - qaAuthoringForm.setActiveModule(activeModule); - qaAuthoringForm.setDefaultContentIdStr(defaultContentIdStr); - qaAuthoringForm.setCurrentTab("3"); - - logger.debug("qaGeneralAuthoringDTO now: " + qaGeneralAuthoringDTO); - request.setAttribute(QA_GENERAL_AUTHORING_DTO, qaGeneralAuthoringDTO); - - logger.debug("httpSessionID: " + httpSessionID); - logger.debug("sessionMap: " + sessionMap); - - request.getSession().setAttribute(httpSessionID, sessionMap); - - logger.debug("qaGeneralAuthoringDTO.getMapQuestionContent(); " + qaGeneralAuthoringDTO.getMapQuestionContent()); - - request.setAttribute(TOTAL_QUESTION_COUNT, new Integer(listQuestionContentDTO.size())); - - /*start monitoring code*/ - GeneralMonitoringDTO qaGeneralMonitoringDTO=new GeneralMonitoringDTO(); - qaGeneralMonitoringDTO.setDefineLaterInEditMode(new Boolean(false).toString()); + QaMonitoringAction.logger.debug("updated qaGeneralAuthoringDTO to: " + qaGeneralAuthoringDTO); - if (qaService.studentActivityOccurredGlobal(qaContent)) - { - logger.debug("USER_EXCEPTION_NO_TOOL_SESSIONS is set to false"); - qaGeneralMonitoringDTO.setUserExceptionNoToolSessions(new Boolean(false).toString()); - } - else - { - logger.debug("USER_EXCEPTION_NO_TOOL_SESSIONS is set to true"); - qaGeneralMonitoringDTO.setUserExceptionNoToolSessions(new Boolean(true).toString()); - } + authoringUtil.reOrganizeDisplayOrder(mapQuestionContent, qaService, qaAuthoringForm, qaContent); - qaGeneralMonitoringDTO.setOnlineInstructions(qaContent.getOnlineInstructions()); - qaGeneralMonitoringDTO.setOfflineInstructions(qaContent.getOfflineInstructions()); + QaMonitoringAction.logger.debug("strToolContentID: " + strToolContentID); + QaUtils.setDefineLater(request, false, strToolContentID, qaService); + QaMonitoringAction.logger.debug("define later set to false"); - - List attachmentList = qaService.retrieveQaUploadedFiles(qaContent); - logger.debug("attachmentList: " + attachmentList); - qaGeneralMonitoringDTO.setAttachmentList(attachmentList); - logger.debug("final qaGeneralMonitoringDTO: " + qaGeneralMonitoringDTO ); + QaUtils.setFormProperties(request, qaService, qaAuthoringForm, qaGeneralAuthoringDTO, strToolContentID, + defaultContentIdStr, activeModule, sessionMap, httpSessionID); - - qaGeneralMonitoringDTO.setDefineLaterInEditMode(new Boolean(true).toString()); - logger.debug("final generalMonitoringDTO: " + qaGeneralMonitoringDTO ); - request.setAttribute(QA_GENERAL_MONITORING_DTO, qaGeneralMonitoringDTO); + qaGeneralMonitoringDTO.setDefineLaterInEditMode(new Boolean(false).toString()); + } else { + QaMonitoringAction.logger.debug("errors is not empty: " + errors); - prepareReflectionData(request, qaContent, qaService, null, false, "All"); - - /*find out if there are any reflection entries, from here*/ - boolean notebookEntriesExist=MonitoringUtil.notebookEntriesExist(qaService, qaContent); - logger.debug("notebookEntriesExist : " + notebookEntriesExist); - - if (notebookEntriesExist) - { - request.setAttribute(NOTEBOOK_ENTRIES_EXIST, new Boolean(true).toString()); - - String userExceptionNoToolSessions=(String)qaGeneralMonitoringDTO.getUserExceptionNoToolSessions(); - logger.debug("userExceptionNoToolSessions : " + userExceptionNoToolSessions); - - if (userExceptionNoToolSessions.equals("true")) - { - logger.debug("there are no online student activity but there are reflections : "); - request.setAttribute(NO_SESSIONS_NOTEBOOK_ENTRIES_EXIST, new Boolean(true).toString()); - } + if (qaContent != null) { + long defaultContentID = 0; + QaMonitoringAction.logger.debug("attempt retrieving tool with signatute : " + + QaAppConstants.MY_SIGNATURE); + defaultContentID = qaService.getToolDefaultContentIdBySignature(QaAppConstants.MY_SIGNATURE); + QaMonitoringAction.logger.debug("retrieved tool default contentId: " + defaultContentID); + + if (qaContent != null) { + qaGeneralAuthoringDTO.setDefaultContentIdStr(new Long(defaultContentID).toString()); } - else - { - request.setAttribute(NOTEBOOK_ENTRIES_EXIST, new Boolean(false).toString()); - } - /* ... till here*/ - - MonitoringUtil.buildQaStatsDTO(request,qaService, qaContent); - MonitoringUtil.generateGroupsSessionData(request, qaService, qaContent, false); - - return mapping.findForward(LOAD_MONITORING); + + QaUtils.setFormProperties(request, qaService, qaAuthoringForm, qaGeneralAuthoringDTO, strToolContentID, + defaultContentIdStr, activeModule, sessionMap, httpSessionID); + + } + qaGeneralMonitoringDTO.setDefineLaterInEditMode(new Boolean(true).toString()); + } + + qaGeneralAuthoringDTO.setSbmtSuccess(new Integer(1).toString()); + + qaAuthoringForm.resetUserAction(); + qaGeneralAuthoringDTO.setMapQuestionContent(mapQuestionContent); + + QaMonitoringAction.logger.debug("before saving final qaGeneralAuthoringDTO: " + qaGeneralAuthoringDTO); + request.setAttribute(QaAppConstants.QA_GENERAL_AUTHORING_DTO, qaGeneralAuthoringDTO); + + request.setAttribute(QaAppConstants.LIST_QUESTION_CONTENT_DTO, listQuestionContentDTO); + sessionMap.put(QaAppConstants.LIST_QUESTION_CONTENT_DTO_KEY, listQuestionContentDTO); + request.getSession().setAttribute(httpSessionID, sessionMap); + + request.setAttribute(QaAppConstants.TOTAL_QUESTION_COUNT, new Integer(listQuestionContentDTO.size())); + + qaGeneralAuthoringDTO.setToolContentID(strToolContentID); + qaGeneralAuthoringDTO.setHttpSessionID(httpSessionID); + qaGeneralAuthoringDTO.setActiveModule(activeModule); + qaGeneralAuthoringDTO.setDefaultContentIdStr(defaultContentIdStr); + + qaAuthoringForm.setToolContentID(strToolContentID); + qaAuthoringForm.setHttpSessionID(httpSessionID); + qaAuthoringForm.setActiveModule(activeModule); + qaAuthoringForm.setDefaultContentIdStr(defaultContentIdStr); + qaAuthoringForm.setCurrentTab("3"); + + /* start monitoring code */ + + if (qaService.studentActivityOccurredGlobal(qaContent)) { + QaMonitoringAction.logger.debug("USER_EXCEPTION_NO_TOOL_SESSIONS is set to false"); + qaGeneralMonitoringDTO.setUserExceptionNoToolSessions(new Boolean(false).toString()); + } else { + QaMonitoringAction.logger.debug("USER_EXCEPTION_NO_TOOL_SESSIONS is set to true"); + qaGeneralMonitoringDTO.setUserExceptionNoToolSessions(new Boolean(true).toString()); + } + + qaGeneralMonitoringDTO.setOnlineInstructions(qaContent.getOnlineInstructions()); + qaGeneralMonitoringDTO.setOfflineInstructions(qaContent.getOfflineInstructions()); + + List attachmentList = qaService.retrieveQaUploadedFiles(qaContent); + QaMonitoringAction.logger.debug("attachmentList: " + attachmentList); + qaGeneralMonitoringDTO.setAttachmentList(attachmentList); + QaMonitoringAction.logger.debug("final qaGeneralMonitoringDTO: " + qaGeneralMonitoringDTO); + + QaMonitoringAction.logger.debug("final generalMonitoringDTO: " + qaGeneralMonitoringDTO); + request.setAttribute(QaAppConstants.QA_GENERAL_MONITORING_DTO, qaGeneralMonitoringDTO); + + prepareReflectionData(request, qaContent, qaService, null, false, "All"); + + /* find out if there are any reflection entries, from here */ + boolean notebookEntriesExist = MonitoringUtil.notebookEntriesExist(qaService, qaContent); + QaMonitoringAction.logger.debug("notebookEntriesExist : " + notebookEntriesExist); + + if (notebookEntriesExist) { + request.setAttribute(QaAppConstants.NOTEBOOK_ENTRIES_EXIST, new Boolean(true).toString()); + + String userExceptionNoToolSessions = qaGeneralMonitoringDTO.getUserExceptionNoToolSessions(); + QaMonitoringAction.logger.debug("userExceptionNoToolSessions : " + userExceptionNoToolSessions); + + if (userExceptionNoToolSessions.equals("true")) { + QaMonitoringAction.logger.debug("there are no online student activity but there are reflections : "); + request.setAttribute(QaAppConstants.NO_SESSIONS_NOTEBOOK_ENTRIES_EXIST, new Boolean(true).toString()); + } + } else { + request.setAttribute(QaAppConstants.NOTEBOOK_ENTRIES_EXIST, new Boolean(false).toString()); + } + /* ... till here */ + + MonitoringUtil.buildQaStatsDTO(request, qaService, qaContent); + MonitoringUtil.generateGroupsSessionData(request, qaService, qaContent, false); + + return mapping.findForward(QaAppConstants.LOAD_MONITORING); } - - - - public ActionForward newQuestionBox(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) - throws IOException, ServletException - { - logger.debug("dispathcing proxy newQuestionBox"); - /*start authoring code*/ - QaAuthoringForm qaAuthoringForm = (QaMonitoringForm) form; - logger.debug("dispathcing newQuestionBox"); - - IQaService qaService =QaServiceProxy.getQaService(getServlet().getServletContext()); - logger.debug("qaService: " + qaService); - - String httpSessionID=request.getParameter("httpSessionID"); - logger.debug("httpSessionID: " + httpSessionID); - - SessionMap sessionMap=(SessionMap)request.getSession().getAttribute(httpSessionID); - logger.debug("sessionMap: " + sessionMap); - - String contentFolderID = WebUtil.readStrParam(request, AttributeNames.PARAM_CONTENT_FOLDER_ID); - logger.debug("contentFolderID: " + contentFolderID); - qaAuthoringForm.setContentFolderID(contentFolderID); + public ActionForward saveSingleQuestion(ActionMapping mapping, ActionForm form, HttpServletRequest request, + HttpServletResponse response) throws IOException, ServletException { + QaMonitoringAction.logger.debug("dispathcing proxy saveSingleQuestion"); - String activeModule=request.getParameter(ACTIVE_MODULE); - logger.debug("activeModule: " + activeModule); + /* start authoring code */ + QaAuthoringForm qaAuthoringForm = (QaMonitoringForm) form; + QaMonitoringAction.logger.debug("dispathcing saveSingleQuestion"); - String strToolContentID=request.getParameter(AttributeNames.PARAM_TOOL_CONTENT_ID); - logger.debug("strToolContentID: " + strToolContentID); - - String defaultContentIdStr=request.getParameter(DEFAULT_CONTENT_ID_STR); - logger.debug("defaultContentIdStr: " + defaultContentIdStr); - - QaContent qaContent=qaService.loadQa(new Long(strToolContentID).longValue()); - logger.debug("qaContent: " + qaContent); - - if (qaContent == null) - { - logger.debug("using defaultContentIdStr: " + defaultContentIdStr); - qaContent=qaService.loadQa(new Long(defaultContentIdStr).longValue()); - } - logger.debug("final qaContent: " + qaContent); - - QaGeneralAuthoringDTO qaGeneralAuthoringDTO= new QaGeneralAuthoringDTO(); - logger.debug("qaGeneralAuthoringDTO: " + qaGeneralAuthoringDTO); - qaGeneralAuthoringDTO.setContentFolderID(contentFolderID); + IQaService qaService = QaServiceProxy.getQaService(getServlet().getServletContext()); + QaMonitoringAction.logger.debug("qaService: " + qaService); - String richTextTitle = request.getParameter(TITLE); - String richTextInstructions = request.getParameter(INSTRUCTIONS); - - logger.debug("richTextTitle: " + richTextTitle); - logger.debug("richTextInstructions: " + richTextInstructions); - qaGeneralAuthoringDTO.setActivityTitle(richTextTitle); - qaAuthoringForm.setTitle(richTextTitle); - - qaGeneralAuthoringDTO.setActivityInstructions(richTextInstructions); - - - QaUtils.setFormProperties(request, qaService, - qaAuthoringForm, qaGeneralAuthoringDTO, strToolContentID, defaultContentIdStr, activeModule, sessionMap, httpSessionID); - - List listQuestionContentDTO=(List)sessionMap.get(LIST_QUESTION_CONTENT_DTO_KEY); - logger.debug("listQuestionContentDTO: " + listQuestionContentDTO); + String httpSessionID = request.getParameter("httpSessionID"); + QaMonitoringAction.logger.debug("httpSessionID: " + httpSessionID); - request.setAttribute(TOTAL_QUESTION_COUNT, new Integer(listQuestionContentDTO.size())); + SessionMap sessionMap = (SessionMap) request.getSession().getAttribute(httpSessionID); + QaMonitoringAction.logger.debug("sessionMap: " + sessionMap); - /*start monitoring code*/ - GeneralMonitoringDTO qaGeneralMonitoringDTO=new GeneralMonitoringDTO(); - qaGeneralMonitoringDTO.setDefineLaterInEditMode(new Boolean(false).toString()); + String contentFolderID = WebUtil.readStrParam(request, AttributeNames.PARAM_CONTENT_FOLDER_ID); + QaMonitoringAction.logger.debug("contentFolderID: " + contentFolderID); + qaAuthoringForm.setContentFolderID(contentFolderID); - if (qaService.studentActivityOccurredGlobal(qaContent)) - { - logger.debug("USER_EXCEPTION_NO_TOOL_SESSIONS is set to false"); - qaGeneralMonitoringDTO.setUserExceptionNoToolSessions(new Boolean(false).toString()); - } - else - { - logger.debug("USER_EXCEPTION_NO_TOOL_SESSIONS is set to true"); - qaGeneralMonitoringDTO.setUserExceptionNoToolSessions(new Boolean(true).toString()); - } + String editQuestionBoxRequest = request.getParameter("editQuestionBoxRequest"); + QaMonitoringAction.logger.debug("editQuestionBoxRequest: " + editQuestionBoxRequest); - - qaGeneralMonitoringDTO.setOnlineInstructions(qaContent.getOnlineInstructions()); - qaGeneralMonitoringDTO.setOfflineInstructions(qaContent.getOfflineInstructions()); + String activeModule = request.getParameter(QaAppConstants.ACTIVE_MODULE); + QaMonitoringAction.logger.debug("activeModule: " + activeModule); - List attachmentList = qaService.retrieveQaUploadedFiles(qaContent); - logger.debug("attachmentList: " + attachmentList); - qaGeneralMonitoringDTO.setAttachmentList(attachmentList); - logger.debug("final qaGeneralMonitoringDTO: " + qaGeneralMonitoringDTO ); + String strToolContentID = request.getParameter(AttributeNames.PARAM_TOOL_CONTENT_ID); + QaMonitoringAction.logger.debug("strToolContentID: " + strToolContentID); - qaGeneralMonitoringDTO.setDefineLaterInEditMode(new Boolean(true).toString()); - logger.debug("final generalMonitoringDTO: " + qaGeneralMonitoringDTO ); - request.setAttribute(QA_GENERAL_MONITORING_DTO, qaGeneralMonitoringDTO); + String defaultContentIdStr = request.getParameter(QaAppConstants.DEFAULT_CONTENT_ID_STR); + QaMonitoringAction.logger.debug("defaultContentIdStr: " + defaultContentIdStr); - prepareReflectionData(request, qaContent, qaService, null, false, "All"); - - /*find out if there are any reflection entries, from here*/ - boolean notebookEntriesExist=MonitoringUtil.notebookEntriesExist(qaService, qaContent); - logger.debug("notebookEntriesExist : " + notebookEntriesExist); - - if (notebookEntriesExist) - { - request.setAttribute(NOTEBOOK_ENTRIES_EXIST, new Boolean(true).toString()); - - String userExceptionNoToolSessions=(String)qaGeneralMonitoringDTO.getUserExceptionNoToolSessions(); - logger.debug("userExceptionNoToolSessions : " + userExceptionNoToolSessions); - - if (userExceptionNoToolSessions.equals("true")) - { - logger.debug("there are no online student activity but there are reflections : "); - request.setAttribute(NO_SESSIONS_NOTEBOOK_ENTRIES_EXIST, new Boolean(true).toString()); + QaContent qaContent = qaService.loadQa(new Long(strToolContentID).longValue()); + QaMonitoringAction.logger.debug("qaContent: " + qaContent); + + if (qaContent == null) { + QaMonitoringAction.logger.debug("using defaultContentIdStr: " + defaultContentIdStr); + qaContent = qaService.loadQa(new Long(defaultContentIdStr).longValue()); + } + QaMonitoringAction.logger.debug("final qaContent: " + qaContent); + + QaGeneralAuthoringDTO qaGeneralAuthoringDTO = new QaGeneralAuthoringDTO(); + + QaMonitoringAction.logger.debug("qaGeneralAuthoringDTO: " + qaGeneralAuthoringDTO); + qaGeneralAuthoringDTO.setContentFolderID(contentFolderID); + + qaGeneralAuthoringDTO.setSbmtSuccess(new Integer(0).toString()); + + AuthoringUtil authoringUtil = new AuthoringUtil(); + + List listQuestionContentDTO = (List) sessionMap.get(QaAppConstants.LIST_QUESTION_CONTENT_DTO_KEY); + QaMonitoringAction.logger.debug("listQuestionContentDTO: " + listQuestionContentDTO); + + String newQuestion = request.getParameter("newQuestion"); + QaMonitoringAction.logger.debug("newQuestion: " + newQuestion); + + String feedback = request.getParameter("feedback"); + QaMonitoringAction.logger.debug("feedback: " + feedback); + + String editableQuestionIndex = request.getParameter("editableQuestionIndex"); + QaMonitoringAction.logger.debug("editableQuestionIndex: " + editableQuestionIndex); + + if (newQuestion != null && newQuestion.length() > 0) { + if (editQuestionBoxRequest != null && editQuestionBoxRequest.equals("false")) { + QaMonitoringAction.logger.debug("request for add and save"); + boolean duplicates = AuthoringUtil.checkDuplicateQuestions(listQuestionContentDTO, newQuestion); + QaMonitoringAction.logger.debug("duplicates: " + duplicates); + + if (!duplicates) { + QaQuestionContentDTO qaQuestionContentDTO = null; + Iterator listIterator = listQuestionContentDTO.iterator(); + while (listIterator.hasNext()) { + qaQuestionContentDTO = (QaQuestionContentDTO) listIterator.next(); + QaMonitoringAction.logger.debug("qaQuestionContentDTO:" + qaQuestionContentDTO); + QaMonitoringAction.logger.debug("qaQuestionContentDTO question:" + + qaQuestionContentDTO.getQuestion()); + + String question = qaQuestionContentDTO.getQuestion(); + String displayOrder = qaQuestionContentDTO.getDisplayOrder(); + QaMonitoringAction.logger.debug("displayOrder:" + displayOrder); + + if (displayOrder != null && !displayOrder.equals("")) { + if (displayOrder.equals(editableQuestionIndex)) { + break; + } + + } } + QaMonitoringAction.logger.debug("qaQuestionContentDTO found:" + qaQuestionContentDTO); + + qaQuestionContentDTO.setQuestion(newQuestion); + qaQuestionContentDTO.setFeedback(feedback); + qaQuestionContentDTO.setDisplayOrder(editableQuestionIndex); + + listQuestionContentDTO = AuthoringUtil.reorderUpdateListQuestionContentDTO(listQuestionContentDTO, + qaQuestionContentDTO, editableQuestionIndex); + QaMonitoringAction.logger.debug("post reorderUpdateListQuestionContentDTO listQuestionContentDTO: " + + listQuestionContentDTO); + } else { + QaMonitoringAction.logger.debug("duplicate question entry, not adding"); } - else - { - request.setAttribute(NOTEBOOK_ENTRIES_EXIST, new Boolean(false).toString()); + } else { + QaMonitoringAction.logger.debug("request for edit and save."); + QaQuestionContentDTO qaQuestionContentDTO = null; + Iterator listIterator = listQuestionContentDTO.iterator(); + while (listIterator.hasNext()) { + qaQuestionContentDTO = (QaQuestionContentDTO) listIterator.next(); + QaMonitoringAction.logger.debug("qaQuestionContentDTO:" + qaQuestionContentDTO); + QaMonitoringAction.logger.debug("qaQuestionContentDTO question:" + + qaQuestionContentDTO.getQuestion()); + + String question = qaQuestionContentDTO.getQuestion(); + String displayOrder = qaQuestionContentDTO.getDisplayOrder(); + QaMonitoringAction.logger.debug("displayOrder:" + displayOrder); + + if (displayOrder != null && !displayOrder.equals("")) { + if (displayOrder.equals(editableQuestionIndex)) { + break; + } + + } } - /* ... till here*/ - - MonitoringUtil.buildQaStatsDTO(request,qaService, qaContent); - MonitoringUtil.generateGroupsSessionData(request, qaService, qaContent, false); - - logger.debug("fwd ing to newQuestionBox: "); - return (mapping.findForward("newQuestionBox")); + QaMonitoringAction.logger.debug("qaQuestionContentDTO found:" + qaQuestionContentDTO); + + qaQuestionContentDTO.setQuestion(newQuestion); + qaQuestionContentDTO.setFeedback(feedback); + qaQuestionContentDTO.setDisplayOrder(editableQuestionIndex); + + listQuestionContentDTO = AuthoringUtil.reorderUpdateListQuestionContentDTO(listQuestionContentDTO, + qaQuestionContentDTO, editableQuestionIndex); + QaMonitoringAction.logger.debug("post reorderUpdateListQuestionContentDTO listQuestionContentDTO: " + + listQuestionContentDTO); + } + } else { + QaMonitoringAction.logger.debug("entry blank, not adding"); + } + + request.setAttribute(QaAppConstants.LIST_QUESTION_CONTENT_DTO, listQuestionContentDTO); + sessionMap.put(QaAppConstants.LIST_QUESTION_CONTENT_DTO_KEY, listQuestionContentDTO); + QaMonitoringAction.logger.debug("listQuestionContentDTO now: " + listQuestionContentDTO); + + String richTextTitle = request.getParameter(QaAppConstants.TITLE); + String richTextInstructions = request.getParameter(QaAppConstants.INSTRUCTIONS); + + QaMonitoringAction.logger.debug("richTextTitle: " + richTextTitle); + QaMonitoringAction.logger.debug("richTextInstructions: " + richTextInstructions); + qaGeneralAuthoringDTO.setActivityTitle(richTextTitle); + qaAuthoringForm.setTitle(richTextTitle); + + qaGeneralAuthoringDTO.setActivityInstructions(richTextInstructions); + + sessionMap.put(QaAppConstants.ACTIVITY_TITLE_KEY, richTextTitle); + sessionMap.put(QaAppConstants.ACTIVITY_INSTRUCTIONS_KEY, richTextInstructions); + + qaGeneralAuthoringDTO.setEditActivityEditMode(new Boolean(true).toString()); + + request.getSession().setAttribute(httpSessionID, sessionMap); + sessionMap.put(QaAppConstants.LIST_QUESTION_CONTENT_DTO_KEY, listQuestionContentDTO); + + QaUtils.setFormProperties(request, qaService, qaAuthoringForm, qaGeneralAuthoringDTO, strToolContentID, + defaultContentIdStr, activeModule, sessionMap, httpSessionID); + + qaGeneralAuthoringDTO.setToolContentID(strToolContentID); + qaGeneralAuthoringDTO.setHttpSessionID(httpSessionID); + qaGeneralAuthoringDTO.setActiveModule(activeModule); + qaGeneralAuthoringDTO.setDefaultContentIdStr(defaultContentIdStr); + + qaAuthoringForm.setToolContentID(strToolContentID); + qaAuthoringForm.setHttpSessionID(httpSessionID); + qaAuthoringForm.setActiveModule(activeModule); + qaAuthoringForm.setDefaultContentIdStr(defaultContentIdStr); + qaAuthoringForm.setCurrentTab("3"); + + QaMonitoringAction.logger.debug("qaGeneralAuthoringDTO now: " + qaGeneralAuthoringDTO); + request.setAttribute(QaAppConstants.QA_GENERAL_AUTHORING_DTO, qaGeneralAuthoringDTO); + + QaMonitoringAction.logger.debug("httpSessionID: " + httpSessionID); + QaMonitoringAction.logger.debug("sessionMap: " + sessionMap); + + request.getSession().setAttribute(httpSessionID, sessionMap); + QaMonitoringAction.logger.debug("qaGeneralAuthoringDTO.getMapQuestionContent(); " + + qaGeneralAuthoringDTO.getMapQuestionContent()); + + request.setAttribute(QaAppConstants.TOTAL_QUESTION_COUNT, new Integer(listQuestionContentDTO.size())); + + /* start monitoring code */ + GeneralMonitoringDTO qaGeneralMonitoringDTO = new GeneralMonitoringDTO(); + qaGeneralMonitoringDTO.setDefineLaterInEditMode(new Boolean(false).toString()); + + if (qaService.studentActivityOccurredGlobal(qaContent)) { + QaMonitoringAction.logger.debug("USER_EXCEPTION_NO_TOOL_SESSIONS is set to false"); + qaGeneralMonitoringDTO.setUserExceptionNoToolSessions(new Boolean(false).toString()); + } else { + QaMonitoringAction.logger.debug("USER_EXCEPTION_NO_TOOL_SESSIONS is set to true"); + qaGeneralMonitoringDTO.setUserExceptionNoToolSessions(new Boolean(true).toString()); + } + qaGeneralMonitoringDTO.setDefineLaterInEditMode(new Boolean(true).toString()); + + qaGeneralMonitoringDTO.setOnlineInstructions(qaContent.getOnlineInstructions()); + qaGeneralMonitoringDTO.setOfflineInstructions(qaContent.getOfflineInstructions()); + + List attachmentList = qaService.retrieveQaUploadedFiles(qaContent); + QaMonitoringAction.logger.debug("attachmentList: " + attachmentList); + qaGeneralMonitoringDTO.setAttachmentList(attachmentList); + QaMonitoringAction.logger.debug("final qaGeneralMonitoringDTO: " + qaGeneralMonitoringDTO); + + QaMonitoringAction.logger.debug("final generalMonitoringDTO: " + qaGeneralMonitoringDTO); + request.setAttribute(QaAppConstants.QA_GENERAL_MONITORING_DTO, qaGeneralMonitoringDTO); + + prepareReflectionData(request, qaContent, qaService, null, false, "All"); + + /* find out if there are any reflection entries, from here */ + boolean notebookEntriesExist = MonitoringUtil.notebookEntriesExist(qaService, qaContent); + QaMonitoringAction.logger.debug("notebookEntriesExist : " + notebookEntriesExist); + + if (notebookEntriesExist) { + request.setAttribute(QaAppConstants.NOTEBOOK_ENTRIES_EXIST, new Boolean(true).toString()); + + String userExceptionNoToolSessions = qaGeneralMonitoringDTO.getUserExceptionNoToolSessions(); + QaMonitoringAction.logger.debug("userExceptionNoToolSessions : " + userExceptionNoToolSessions); + + if (userExceptionNoToolSessions.equals("true")) { + QaMonitoringAction.logger.debug("there are no online student activity but there are reflections : "); + request.setAttribute(QaAppConstants.NO_SESSIONS_NOTEBOOK_ENTRIES_EXIST, new Boolean(true).toString()); + } + } else { + request.setAttribute(QaAppConstants.NOTEBOOK_ENTRIES_EXIST, new Boolean(false).toString()); + } + /* ... till here */ + + MonitoringUtil.buildQaStatsDTO(request, qaService, qaContent); + MonitoringUtil.generateGroupsSessionData(request, qaService, qaContent, false); + + return mapping.findForward(QaAppConstants.LOAD_MONITORING); } - - - - public ActionForward newEditableQuestionBox(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) - throws IOException, ServletException - { - logger.debug("dispathcing proxy newEditableQuestionBox"); - /*start authoring code*/ - QaAuthoringForm qaAuthoringForm = (QaMonitoringForm) form; - logger.debug("dispathcing newEditableQuestionBox"); - - IQaService qaService =QaServiceProxy.getQaService(getServlet().getServletContext()); - logger.debug("qaService: " + qaService); - - String httpSessionID=request.getParameter("httpSessionID"); - logger.debug("httpSessionID: " + httpSessionID); - - SessionMap sessionMap=(SessionMap)request.getSession().getAttribute(httpSessionID); - logger.debug("sessionMap: " + sessionMap); + public ActionForward addSingleQuestion(ActionMapping mapping, ActionForm form, HttpServletRequest request, + HttpServletResponse response) throws IOException, ServletException { + QaMonitoringAction.logger.debug("dispathcing proxy addSingleQuestion"); - - String questionIndex=request.getParameter("questionIndex"); - logger.debug("questionIndex: " + questionIndex); - - qaAuthoringForm.setEditableQuestionIndex(questionIndex); - - List listQuestionContentDTO=(List)sessionMap.get(LIST_QUESTION_CONTENT_DTO_KEY); - logger.debug("listQuestionContentDTO: " + listQuestionContentDTO); + /* start authoring code */ + QaAuthoringForm qaAuthoringForm = (QaMonitoringForm) form; + QaMonitoringAction.logger.debug("dispathcing addSingleQuestion"); - String editableQuestion=""; - String editableFeedback=""; - Iterator listIterator=listQuestionContentDTO.iterator(); - while (listIterator.hasNext()) - { - QaQuestionContentDTO qaQuestionContentDTO= (QaQuestionContentDTO)listIterator.next(); - logger.debug("qaQuestionContentDTO:" + qaQuestionContentDTO); - logger.debug("qaQuestionContentDTO question:" + qaQuestionContentDTO.getQuestion()); - String question=qaQuestionContentDTO.getQuestion(); - String displayOrder=qaQuestionContentDTO.getDisplayOrder(); - - if ((displayOrder != null) && (!displayOrder.equals(""))) - { - if (displayOrder.equals(questionIndex)) - { - editableFeedback=qaQuestionContentDTO.getFeedback(); - editableQuestion=qaQuestionContentDTO.getQuestion(); - logger.debug("editableFeedback found :" + editableFeedback); - break; - } - - } + IQaService qaService = QaServiceProxy.getQaService(getServlet().getServletContext()); + QaMonitoringAction.logger.debug("qaService: " + qaService); + + String httpSessionID = request.getParameter("httpSessionID"); + QaMonitoringAction.logger.debug("httpSessionID: " + httpSessionID); + + SessionMap sessionMap = (SessionMap) request.getSession().getAttribute(httpSessionID); + QaMonitoringAction.logger.debug("sessionMap: " + sessionMap); + + String contentFolderID = WebUtil.readStrParam(request, AttributeNames.PARAM_CONTENT_FOLDER_ID); + QaMonitoringAction.logger.debug("contentFolderID: " + contentFolderID); + qaAuthoringForm.setContentFolderID(contentFolderID); + + String activeModule = request.getParameter(QaAppConstants.ACTIVE_MODULE); + QaMonitoringAction.logger.debug("activeModule: " + activeModule); + + String strToolContentID = request.getParameter(AttributeNames.PARAM_TOOL_CONTENT_ID); + QaMonitoringAction.logger.debug("strToolContentID: " + strToolContentID); + + String defaultContentIdStr = request.getParameter(QaAppConstants.DEFAULT_CONTENT_ID_STR); + QaMonitoringAction.logger.debug("defaultContentIdStr: " + defaultContentIdStr); + + QaContent qaContent = qaService.loadQa(new Long(strToolContentID).longValue()); + QaMonitoringAction.logger.debug("qaContent: " + qaContent); + + if (qaContent == null) { + QaMonitoringAction.logger.debug("using defaultContentIdStr: " + defaultContentIdStr); + qaContent = qaService.loadQa(new Long(defaultContentIdStr).longValue()); + } + QaMonitoringAction.logger.debug("final qaContent: " + qaContent); + + QaGeneralAuthoringDTO qaGeneralAuthoringDTO = new QaGeneralAuthoringDTO(); + QaMonitoringAction.logger.debug("qaGeneralAuthoringDTO: " + qaGeneralAuthoringDTO); + qaGeneralAuthoringDTO.setContentFolderID(contentFolderID); + + qaGeneralAuthoringDTO.setSbmtSuccess(new Integer(0).toString()); + + AuthoringUtil authoringUtil = new AuthoringUtil(); + + List listQuestionContentDTO = (List) sessionMap.get(QaAppConstants.LIST_QUESTION_CONTENT_DTO_KEY); + QaMonitoringAction.logger.debug("listQuestionContentDTO: " + listQuestionContentDTO); + + String newQuestion = request.getParameter("newQuestion"); + QaMonitoringAction.logger.debug("newQuestion: " + newQuestion); + + String feedback = request.getParameter("feedback"); + QaMonitoringAction.logger.debug("feedback: " + feedback); + + int listSize = listQuestionContentDTO.size(); + QaMonitoringAction.logger.debug("listSize: " + listSize); + + if (newQuestion != null && newQuestion.length() > 0) { + boolean duplicates = AuthoringUtil.checkDuplicateQuestions(listQuestionContentDTO, newQuestion); + QaMonitoringAction.logger.debug("duplicates: " + duplicates); + + if (!duplicates) { + QaQuestionContentDTO qaQuestionContentDTO = new QaQuestionContentDTO(); + qaQuestionContentDTO.setDisplayOrder(new Long(listSize + 1).toString()); + qaQuestionContentDTO.setFeedback(feedback); + qaQuestionContentDTO.setQuestion(newQuestion); + + listQuestionContentDTO.add(qaQuestionContentDTO); + QaMonitoringAction.logger.debug("updated listQuestionContentDTO: " + listQuestionContentDTO); + } else { + QaMonitoringAction.logger.debug("entry duplicate, not adding"); } - logger.debug("editableFeedback found :" + editableFeedback); - logger.debug("editableQuestion found :" + editableQuestion); + } else { + QaMonitoringAction.logger.debug("entry blank, not adding"); + } - - String contentFolderID = WebUtil.readStrParam(request, AttributeNames.PARAM_CONTENT_FOLDER_ID); - logger.debug("contentFolderID: " + contentFolderID); - qaAuthoringForm.setContentFolderID(contentFolderID); + request.setAttribute(QaAppConstants.LIST_QUESTION_CONTENT_DTO, listQuestionContentDTO); + sessionMap.put(QaAppConstants.LIST_QUESTION_CONTENT_DTO_KEY, listQuestionContentDTO); + String richTextTitle = request.getParameter(QaAppConstants.TITLE); + String richTextInstructions = request.getParameter(QaAppConstants.INSTRUCTIONS); - String activeModule=request.getParameter(ACTIVE_MODULE); - logger.debug("activeModule: " + activeModule); + QaMonitoringAction.logger.debug("richTextTitle: " + richTextTitle); + QaMonitoringAction.logger.debug("richTextInstructions: " + richTextInstructions); + qaGeneralAuthoringDTO.setActivityTitle(richTextTitle); + qaAuthoringForm.setTitle(richTextTitle); - String strToolContentID=request.getParameter(AttributeNames.PARAM_TOOL_CONTENT_ID); - logger.debug("strToolContentID: " + strToolContentID); - - String defaultContentIdStr=request.getParameter(DEFAULT_CONTENT_ID_STR); - logger.debug("defaultContentIdStr: " + defaultContentIdStr); - - QaContent qaContent=qaService.loadQa(new Long(strToolContentID).longValue()); - logger.debug("qaContent: " + qaContent); - - if (qaContent == null) - { - logger.debug("using defaultContentIdStr: " + defaultContentIdStr); - qaContent=qaService.loadQa(new Long(defaultContentIdStr).longValue()); - } - logger.debug("final qaContent: " + qaContent); - - QaGeneralAuthoringDTO qaGeneralAuthoringDTO= new QaGeneralAuthoringDTO(); - logger.debug("qaGeneralAuthoringDTO: " + qaGeneralAuthoringDTO); - qaGeneralAuthoringDTO.setContentFolderID(contentFolderID); + qaGeneralAuthoringDTO.setActivityInstructions(richTextInstructions); - - String richTextTitle = request.getParameter(TITLE); - String richTextInstructions = request.getParameter(INSTRUCTIONS); - - logger.debug("richTextTitle: " + richTextTitle); - logger.debug("richTextInstructions: " + richTextInstructions); - qaGeneralAuthoringDTO.setActivityTitle(richTextTitle); - qaAuthoringForm.setTitle(richTextTitle); - - qaGeneralAuthoringDTO.setActivityInstructions(richTextInstructions); - - QaUtils.setFormProperties(request, qaService, - qaAuthoringForm, qaGeneralAuthoringDTO, strToolContentID, defaultContentIdStr, activeModule, sessionMap, httpSessionID); - - qaGeneralAuthoringDTO.setEditableQuestionText(editableQuestion); - qaGeneralAuthoringDTO.setEditableQuestionFeedback (editableFeedback); - qaAuthoringForm.setFeedback(editableFeedback); - - logger.debug("qaGeneralAuthoringDTO now: " + qaGeneralAuthoringDTO); - request.setAttribute(QA_GENERAL_AUTHORING_DTO, qaGeneralAuthoringDTO); - - request.setAttribute(TOTAL_QUESTION_COUNT, new Integer(listQuestionContentDTO.size())); - - /*start monitoring code*/ - GeneralMonitoringDTO qaGeneralMonitoringDTO=new GeneralMonitoringDTO(); - qaGeneralMonitoringDTO.setDefineLaterInEditMode(new Boolean(false).toString()); + sessionMap.put(QaAppConstants.ACTIVITY_TITLE_KEY, richTextTitle); + sessionMap.put(QaAppConstants.ACTIVITY_INSTRUCTIONS_KEY, richTextInstructions); - if (qaService.studentActivityOccurredGlobal(qaContent)) - { - logger.debug("USER_EXCEPTION_NO_TOOL_SESSIONS is set to false"); - qaGeneralMonitoringDTO.setUserExceptionNoToolSessions(new Boolean(false).toString()); - } - else - { - logger.debug("USER_EXCEPTION_NO_TOOL_SESSIONS is set to true"); - qaGeneralMonitoringDTO.setUserExceptionNoToolSessions(new Boolean(true).toString()); - } + qaGeneralAuthoringDTO.setEditActivityEditMode(new Boolean(true).toString()); + request.getSession().setAttribute(httpSessionID, sessionMap); - qaGeneralMonitoringDTO.setOnlineInstructions(qaContent.getOnlineInstructions()); - qaGeneralMonitoringDTO.setOfflineInstructions(qaContent.getOfflineInstructions()); - - List attachmentList = qaService.retrieveQaUploadedFiles(qaContent); - logger.debug("attachmentList: " + attachmentList); - qaGeneralMonitoringDTO.setAttachmentList(attachmentList); - logger.debug("final qaGeneralMonitoringDTO: " + qaGeneralMonitoringDTO ); + QaUtils.setFormProperties(request, qaService, qaAuthoringForm, qaGeneralAuthoringDTO, strToolContentID, + defaultContentIdStr, activeModule, sessionMap, httpSessionID); - - qaGeneralMonitoringDTO.setDefineLaterInEditMode(new Boolean(true).toString()); - logger.debug("final generalMonitoringDTO: " + qaGeneralMonitoringDTO ); - request.setAttribute(QA_GENERAL_MONITORING_DTO, qaGeneralMonitoringDTO); + qaGeneralAuthoringDTO.setToolContentID(strToolContentID); + qaGeneralAuthoringDTO.setHttpSessionID(httpSessionID); + qaGeneralAuthoringDTO.setActiveModule(activeModule); + qaGeneralAuthoringDTO.setDefaultContentIdStr(defaultContentIdStr); - prepareReflectionData(request, qaContent, qaService, null, false ,"All"); - - /*find out if there are any reflection entries, from here*/ - boolean notebookEntriesExist=MonitoringUtil.notebookEntriesExist(qaService, qaContent); - logger.debug("notebookEntriesExist : " + notebookEntriesExist); - - if (notebookEntriesExist) - { - request.setAttribute(NOTEBOOK_ENTRIES_EXIST, new Boolean(true).toString()); - - String userExceptionNoToolSessions=(String)qaGeneralMonitoringDTO.getUserExceptionNoToolSessions(); - logger.debug("userExceptionNoToolSessions : " + userExceptionNoToolSessions); - - if (userExceptionNoToolSessions.equals("true")) - { - logger.debug("there are no online student activity but there are reflections : "); - request.setAttribute(NO_SESSIONS_NOTEBOOK_ENTRIES_EXIST, new Boolean(true).toString()); - } + qaAuthoringForm.setToolContentID(strToolContentID); + qaAuthoringForm.setHttpSessionID(httpSessionID); + qaAuthoringForm.setActiveModule(activeModule); + qaAuthoringForm.setDefaultContentIdStr(defaultContentIdStr); + qaAuthoringForm.setCurrentTab("3"); - } - else - { - request.setAttribute(NOTEBOOK_ENTRIES_EXIST, new Boolean(false).toString()); - } - /* ... till here*/ - - MonitoringUtil.buildQaStatsDTO(request,qaService, qaContent); - MonitoringUtil.generateGroupsSessionData(request, qaService, qaContent, false); - - logger.debug("fwd ing to editQuestionBox: "); - return (mapping.findForward("editQuestionBox")); + QaMonitoringAction.logger.debug("qaGeneralAuthoringDTO now: " + qaGeneralAuthoringDTO); + request.setAttribute(QaAppConstants.QA_GENERAL_AUTHORING_DTO, qaGeneralAuthoringDTO); + + QaMonitoringAction.logger.debug("httpSessionID: " + httpSessionID); + QaMonitoringAction.logger.debug("sessionMap: " + sessionMap); + + request.getSession().setAttribute(httpSessionID, sessionMap); + + QaMonitoringAction.logger.debug("qaGeneralAuthoringDTO.getMapQuestionContent(); " + + qaGeneralAuthoringDTO.getMapQuestionContent()); + + request.setAttribute(QaAppConstants.TOTAL_QUESTION_COUNT, new Integer(listQuestionContentDTO.size())); + + /* start monitoring code */ + GeneralMonitoringDTO qaGeneralMonitoringDTO = new GeneralMonitoringDTO(); + qaGeneralMonitoringDTO.setDefineLaterInEditMode(new Boolean(false).toString()); + + if (qaService.studentActivityOccurredGlobal(qaContent)) { + QaMonitoringAction.logger.debug("USER_EXCEPTION_NO_TOOL_SESSIONS is set to false"); + qaGeneralMonitoringDTO.setUserExceptionNoToolSessions(new Boolean(false).toString()); + } else { + QaMonitoringAction.logger.debug("USER_EXCEPTION_NO_TOOL_SESSIONS is set to true"); + qaGeneralMonitoringDTO.setUserExceptionNoToolSessions(new Boolean(true).toString()); + } + + qaGeneralMonitoringDTO.setOnlineInstructions(qaContent.getOnlineInstructions()); + qaGeneralMonitoringDTO.setOfflineInstructions(qaContent.getOfflineInstructions()); + + List attachmentList = qaService.retrieveQaUploadedFiles(qaContent); + QaMonitoringAction.logger.debug("attachmentList: " + attachmentList); + qaGeneralMonitoringDTO.setAttachmentList(attachmentList); + QaMonitoringAction.logger.debug("final qaGeneralMonitoringDTO: " + qaGeneralMonitoringDTO); + + qaGeneralMonitoringDTO.setDefineLaterInEditMode(new Boolean(true).toString()); + QaMonitoringAction.logger.debug("final generalMonitoringDTO: " + qaGeneralMonitoringDTO); + request.setAttribute(QaAppConstants.QA_GENERAL_MONITORING_DTO, qaGeneralMonitoringDTO); + + prepareReflectionData(request, qaContent, qaService, null, false, "All"); + + /* find out if there are any reflection entries, from here */ + boolean notebookEntriesExist = MonitoringUtil.notebookEntriesExist(qaService, qaContent); + QaMonitoringAction.logger.debug("notebookEntriesExist : " + notebookEntriesExist); + + if (notebookEntriesExist) { + request.setAttribute(QaAppConstants.NOTEBOOK_ENTRIES_EXIST, new Boolean(true).toString()); + + String userExceptionNoToolSessions = qaGeneralMonitoringDTO.getUserExceptionNoToolSessions(); + QaMonitoringAction.logger.debug("userExceptionNoToolSessions : " + userExceptionNoToolSessions); + + if (userExceptionNoToolSessions.equals("true")) { + QaMonitoringAction.logger.debug("there are no online student activity but there are reflections : "); + request.setAttribute(QaAppConstants.NO_SESSIONS_NOTEBOOK_ENTRIES_EXIST, new Boolean(true).toString()); + } + } else { + request.setAttribute(QaAppConstants.NOTEBOOK_ENTRIES_EXIST, new Boolean(false).toString()); + } + /* ... till here */ + + MonitoringUtil.buildQaStatsDTO(request, qaService, qaContent); + MonitoringUtil.generateGroupsSessionData(request, qaService, qaContent, false); + + return mapping.findForward(QaAppConstants.LOAD_MONITORING); } - - - - - public ActionForward removeQuestion(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) - throws IOException, ServletException { - logger.debug("dispathcing proxy removeQuestion"); - /*start authoring code*/ - QaAuthoringForm qaAuthoringForm = (QaMonitoringForm) form; - logger.debug("dispathcing removeQuestion"); - - IQaService qaService =QaServiceProxy.getQaService(getServlet().getServletContext()); - logger.debug("qaService: " + qaService); - - String httpSessionID=request.getParameter("httpSessionID"); - logger.debug("httpSessionID: " + httpSessionID); - - SessionMap sessionMap=(SessionMap)request.getSession().getAttribute(httpSessionID); - logger.debug("sessionMap: " + sessionMap); - - String questionIndex=request.getParameter("questionIndex"); - logger.debug("questionIndex: " + questionIndex); - - - List listQuestionContentDTO=(List)sessionMap.get(LIST_QUESTION_CONTENT_DTO_KEY); - logger.debug("listQuestionContentDTO: " + listQuestionContentDTO); - - QaQuestionContentDTO qaQuestionContentDTO= null; - Iterator listIterator=listQuestionContentDTO.iterator(); - while (listIterator.hasNext()) - { - qaQuestionContentDTO= (QaQuestionContentDTO)listIterator.next(); - logger.debug("qaQuestionContentDTO:" + qaQuestionContentDTO); - logger.debug("qaQuestionContentDTO question:" + qaQuestionContentDTO.getQuestion()); - - String question=qaQuestionContentDTO.getQuestion(); - String displayOrder=qaQuestionContentDTO.getDisplayOrder(); - logger.debug("displayOrder:" + displayOrder); - - if ((displayOrder != null) && (!displayOrder.equals(""))) - { - if (displayOrder.equals(questionIndex)) - { - break; - } - - } + public ActionForward newQuestionBox(ActionMapping mapping, ActionForm form, HttpServletRequest request, + HttpServletResponse response) throws IOException, ServletException { + QaMonitoringAction.logger.debug("dispathcing proxy newQuestionBox"); + + /* start authoring code */ + QaAuthoringForm qaAuthoringForm = (QaMonitoringForm) form; + QaMonitoringAction.logger.debug("dispathcing newQuestionBox"); + + IQaService qaService = QaServiceProxy.getQaService(getServlet().getServletContext()); + QaMonitoringAction.logger.debug("qaService: " + qaService); + + String httpSessionID = request.getParameter("httpSessionID"); + QaMonitoringAction.logger.debug("httpSessionID: " + httpSessionID); + + SessionMap sessionMap = (SessionMap) request.getSession().getAttribute(httpSessionID); + QaMonitoringAction.logger.debug("sessionMap: " + sessionMap); + + String contentFolderID = WebUtil.readStrParam(request, AttributeNames.PARAM_CONTENT_FOLDER_ID); + QaMonitoringAction.logger.debug("contentFolderID: " + contentFolderID); + qaAuthoringForm.setContentFolderID(contentFolderID); + + String activeModule = request.getParameter(QaAppConstants.ACTIVE_MODULE); + QaMonitoringAction.logger.debug("activeModule: " + activeModule); + + String strToolContentID = request.getParameter(AttributeNames.PARAM_TOOL_CONTENT_ID); + QaMonitoringAction.logger.debug("strToolContentID: " + strToolContentID); + + String defaultContentIdStr = request.getParameter(QaAppConstants.DEFAULT_CONTENT_ID_STR); + QaMonitoringAction.logger.debug("defaultContentIdStr: " + defaultContentIdStr); + + QaContent qaContent = qaService.loadQa(new Long(strToolContentID).longValue()); + QaMonitoringAction.logger.debug("qaContent: " + qaContent); + + if (qaContent == null) { + QaMonitoringAction.logger.debug("using defaultContentIdStr: " + defaultContentIdStr); + qaContent = qaService.loadQa(new Long(defaultContentIdStr).longValue()); + } + QaMonitoringAction.logger.debug("final qaContent: " + qaContent); + + QaGeneralAuthoringDTO qaGeneralAuthoringDTO = new QaGeneralAuthoringDTO(); + QaMonitoringAction.logger.debug("qaGeneralAuthoringDTO: " + qaGeneralAuthoringDTO); + qaGeneralAuthoringDTO.setContentFolderID(contentFolderID); + + String richTextTitle = request.getParameter(QaAppConstants.TITLE); + String richTextInstructions = request.getParameter(QaAppConstants.INSTRUCTIONS); + + QaMonitoringAction.logger.debug("richTextTitle: " + richTextTitle); + QaMonitoringAction.logger.debug("richTextInstructions: " + richTextInstructions); + qaGeneralAuthoringDTO.setActivityTitle(richTextTitle); + qaAuthoringForm.setTitle(richTextTitle); + + qaGeneralAuthoringDTO.setActivityInstructions(richTextInstructions); + + QaUtils.setFormProperties(request, qaService, qaAuthoringForm, qaGeneralAuthoringDTO, strToolContentID, + defaultContentIdStr, activeModule, sessionMap, httpSessionID); + + List listQuestionContentDTO = (List) sessionMap.get(QaAppConstants.LIST_QUESTION_CONTENT_DTO_KEY); + QaMonitoringAction.logger.debug("listQuestionContentDTO: " + listQuestionContentDTO); + + request.setAttribute(QaAppConstants.TOTAL_QUESTION_COUNT, new Integer(listQuestionContentDTO.size())); + + /* start monitoring code */ + GeneralMonitoringDTO qaGeneralMonitoringDTO = new GeneralMonitoringDTO(); + qaGeneralMonitoringDTO.setDefineLaterInEditMode(new Boolean(false).toString()); + + if (qaService.studentActivityOccurredGlobal(qaContent)) { + QaMonitoringAction.logger.debug("USER_EXCEPTION_NO_TOOL_SESSIONS is set to false"); + qaGeneralMonitoringDTO.setUserExceptionNoToolSessions(new Boolean(false).toString()); + } else { + QaMonitoringAction.logger.debug("USER_EXCEPTION_NO_TOOL_SESSIONS is set to true"); + qaGeneralMonitoringDTO.setUserExceptionNoToolSessions(new Boolean(true).toString()); + } + + qaGeneralMonitoringDTO.setOnlineInstructions(qaContent.getOnlineInstructions()); + qaGeneralMonitoringDTO.setOfflineInstructions(qaContent.getOfflineInstructions()); + + List attachmentList = qaService.retrieveQaUploadedFiles(qaContent); + QaMonitoringAction.logger.debug("attachmentList: " + attachmentList); + qaGeneralMonitoringDTO.setAttachmentList(attachmentList); + QaMonitoringAction.logger.debug("final qaGeneralMonitoringDTO: " + qaGeneralMonitoringDTO); + + qaGeneralMonitoringDTO.setDefineLaterInEditMode(new Boolean(true).toString()); + QaMonitoringAction.logger.debug("final generalMonitoringDTO: " + qaGeneralMonitoringDTO); + request.setAttribute(QaAppConstants.QA_GENERAL_MONITORING_DTO, qaGeneralMonitoringDTO); + + prepareReflectionData(request, qaContent, qaService, null, false, "All"); + + /* find out if there are any reflection entries, from here */ + boolean notebookEntriesExist = MonitoringUtil.notebookEntriesExist(qaService, qaContent); + QaMonitoringAction.logger.debug("notebookEntriesExist : " + notebookEntriesExist); + + if (notebookEntriesExist) { + request.setAttribute(QaAppConstants.NOTEBOOK_ENTRIES_EXIST, new Boolean(true).toString()); + + String userExceptionNoToolSessions = qaGeneralMonitoringDTO.getUserExceptionNoToolSessions(); + QaMonitoringAction.logger.debug("userExceptionNoToolSessions : " + userExceptionNoToolSessions); + + if (userExceptionNoToolSessions.equals("true")) { + QaMonitoringAction.logger.debug("there are no online student activity but there are reflections : "); + request.setAttribute(QaAppConstants.NO_SESSIONS_NOTEBOOK_ENTRIES_EXIST, new Boolean(true).toString()); } - - logger.debug("qaQuestionContentDTO found:" + qaQuestionContentDTO); - qaQuestionContentDTO.setQuestion(""); - logger.debug("listQuestionContentDTO after remove:" + listQuestionContentDTO); - - - listQuestionContentDTO=AuthoringUtil.reorderListQuestionContentDTO(listQuestionContentDTO, questionIndex ); - logger.debug("listQuestionContentDTO reordered:" + listQuestionContentDTO); - - - sessionMap.put(LIST_QUESTION_CONTENT_DTO_KEY, listQuestionContentDTO); - - - String contentFolderID = WebUtil.readStrParam(request, AttributeNames.PARAM_CONTENT_FOLDER_ID); - logger.debug("contentFolderID: " + contentFolderID); - qaAuthoringForm.setContentFolderID(contentFolderID); - - - String activeModule=request.getParameter(ACTIVE_MODULE); - logger.debug("activeModule: " + activeModule); - - String richTextTitle = request.getParameter(TITLE); - logger.debug("richTextTitle: " + richTextTitle); - - String richTextInstructions = request.getParameter(INSTRUCTIONS); - logger.debug("richTextInstructions: " + richTextInstructions); - - - sessionMap.put(ACTIVITY_TITLE_KEY, richTextTitle); - sessionMap.put(ACTIVITY_INSTRUCTIONS_KEY, richTextInstructions); - - - String strToolContentID=request.getParameter(AttributeNames.PARAM_TOOL_CONTENT_ID); - logger.debug("strToolContentID: " + strToolContentID); - - String defaultContentIdStr=request.getParameter(DEFAULT_CONTENT_ID_STR); - logger.debug("defaultContentIdStr: " + defaultContentIdStr); - - QaContent qaContent=qaService.loadQa(new Long(strToolContentID).longValue()); - logger.debug("qaContent: " + qaContent); - - if (qaContent == null) - { - logger.debug("using defaultContentIdStr: " + defaultContentIdStr); - qaContent=qaService.loadQa(new Long(defaultContentIdStr).longValue()); - } - logger.debug("final qaContent: " + qaContent); - - QaGeneralAuthoringDTO qaGeneralAuthoringDTO= new QaGeneralAuthoringDTO(); - logger.debug("qaGeneralAuthoringDTO: " + qaGeneralAuthoringDTO); - qaGeneralAuthoringDTO.setContentFolderID(contentFolderID); - - qaGeneralAuthoringDTO.setActivityTitle(richTextTitle); - qaAuthoringForm.setTitle(richTextTitle); - - qaGeneralAuthoringDTO.setActivityInstructions(richTextInstructions); - - - AuthoringUtil authoringUtil= new AuthoringUtil(); - - qaGeneralAuthoringDTO.setEditActivityEditMode(new Boolean(true).toString()); - - request.getSession().setAttribute(httpSessionID, sessionMap); - - QaUtils.setFormProperties(request, qaService, - qaAuthoringForm, qaGeneralAuthoringDTO, strToolContentID, defaultContentIdStr, activeModule, sessionMap, httpSessionID); - - - qaGeneralAuthoringDTO.setToolContentID(strToolContentID); - qaGeneralAuthoringDTO.setHttpSessionID(httpSessionID); - qaGeneralAuthoringDTO.setActiveModule(activeModule); - qaGeneralAuthoringDTO.setDefaultContentIdStr(defaultContentIdStr); - qaAuthoringForm.setToolContentID(strToolContentID); - qaAuthoringForm.setHttpSessionID(httpSessionID); - qaAuthoringForm.setActiveModule(activeModule); - qaAuthoringForm.setDefaultContentIdStr(defaultContentIdStr); - qaAuthoringForm.setCurrentTab("3"); - - request.setAttribute(LIST_QUESTION_CONTENT_DTO,listQuestionContentDTO); - logger.debug("qaQuestionContentDTO now: " + qaQuestionContentDTO); - logger.debug("listQuestionContentDTO now: " + listQuestionContentDTO); - - - logger.debug("before saving final qaGeneralAuthoringDTO: " + qaGeneralAuthoringDTO); - request.setAttribute(QA_GENERAL_AUTHORING_DTO, qaGeneralAuthoringDTO); - - request.setAttribute(TOTAL_QUESTION_COUNT, new Integer(listQuestionContentDTO.size())); - - /*start monitoring code*/ - GeneralMonitoringDTO qaGeneralMonitoringDTO=new GeneralMonitoringDTO(); + } else { + request.setAttribute(QaAppConstants.NOTEBOOK_ENTRIES_EXIST, new Boolean(false).toString()); + } + /* ... till here */ - if (qaService.studentActivityOccurredGlobal(qaContent)) - { - logger.debug("USER_EXCEPTION_NO_TOOL_SESSIONS is set to false"); - qaGeneralMonitoringDTO.setUserExceptionNoToolSessions(new Boolean(false).toString()); - } - else - { - logger.debug("USER_EXCEPTION_NO_TOOL_SESSIONS is set to true"); - qaGeneralMonitoringDTO.setUserExceptionNoToolSessions(new Boolean(true).toString()); - } + MonitoringUtil.buildQaStatsDTO(request, qaService, qaContent); + MonitoringUtil.generateGroupsSessionData(request, qaService, qaContent, false); - qaGeneralMonitoringDTO.setOnlineInstructions(qaContent.getOnlineInstructions()); - qaGeneralMonitoringDTO.setOfflineInstructions(qaContent.getOfflineInstructions()); + QaMonitoringAction.logger.debug("fwd ing to newQuestionBox: "); + return mapping.findForward("newQuestionBox"); + } - List attachmentList = qaService.retrieveQaUploadedFiles(qaContent); - logger.debug("attachmentList: " + attachmentList); - qaGeneralMonitoringDTO.setAttachmentList(attachmentList); - logger.debug("final qaGeneralMonitoringDTO: " + qaGeneralMonitoringDTO ); + public ActionForward newEditableQuestionBox(ActionMapping mapping, ActionForm form, HttpServletRequest request, + HttpServletResponse response) throws IOException, ServletException { + QaMonitoringAction.logger.debug("dispathcing proxy newEditableQuestionBox"); - - qaGeneralMonitoringDTO.setDefineLaterInEditMode(new Boolean(true).toString()); - logger.debug("final generalMonitoringDTO: " + qaGeneralMonitoringDTO ); - request.setAttribute(QA_GENERAL_MONITORING_DTO, qaGeneralMonitoringDTO); + /* start authoring code */ + QaAuthoringForm qaAuthoringForm = (QaMonitoringForm) form; + QaMonitoringAction.logger.debug("dispathcing newEditableQuestionBox"); - prepareReflectionData(request, qaContent, qaService, null, false , "All"); + IQaService qaService = QaServiceProxy.getQaService(getServlet().getServletContext()); + QaMonitoringAction.logger.debug("qaService: " + qaService); - /*find out if there are any reflection entries, from here*/ - boolean notebookEntriesExist=MonitoringUtil.notebookEntriesExist(qaService, qaContent); - logger.debug("notebookEntriesExist : " + notebookEntriesExist); - - if (notebookEntriesExist) - { - request.setAttribute(NOTEBOOK_ENTRIES_EXIST, new Boolean(true).toString()); - - String userExceptionNoToolSessions=(String)qaGeneralMonitoringDTO.getUserExceptionNoToolSessions(); - logger.debug("userExceptionNoToolSessions : " + userExceptionNoToolSessions); - - if (userExceptionNoToolSessions.equals("true")) - { - logger.debug("there are no online student activity but there are reflections : "); - request.setAttribute(NO_SESSIONS_NOTEBOOK_ENTRIES_EXIST, new Boolean(true).toString()); - } + String httpSessionID = request.getParameter("httpSessionID"); + QaMonitoringAction.logger.debug("httpSessionID: " + httpSessionID); + SessionMap sessionMap = (SessionMap) request.getSession().getAttribute(httpSessionID); + QaMonitoringAction.logger.debug("sessionMap: " + sessionMap); + + String questionIndex = request.getParameter("questionIndex"); + QaMonitoringAction.logger.debug("questionIndex: " + questionIndex); + + qaAuthoringForm.setEditableQuestionIndex(questionIndex); + + List listQuestionContentDTO = (List) sessionMap.get(QaAppConstants.LIST_QUESTION_CONTENT_DTO_KEY); + QaMonitoringAction.logger.debug("listQuestionContentDTO: " + listQuestionContentDTO); + + String editableQuestion = ""; + String editableFeedback = ""; + Iterator listIterator = listQuestionContentDTO.iterator(); + while (listIterator.hasNext()) { + QaQuestionContentDTO qaQuestionContentDTO = (QaQuestionContentDTO) listIterator.next(); + QaMonitoringAction.logger.debug("qaQuestionContentDTO:" + qaQuestionContentDTO); + QaMonitoringAction.logger.debug("qaQuestionContentDTO question:" + qaQuestionContentDTO.getQuestion()); + String question = qaQuestionContentDTO.getQuestion(); + String displayOrder = qaQuestionContentDTO.getDisplayOrder(); + + if (displayOrder != null && !displayOrder.equals("")) { + if (displayOrder.equals(questionIndex)) { + editableFeedback = qaQuestionContentDTO.getFeedback(); + editableQuestion = qaQuestionContentDTO.getQuestion(); + QaMonitoringAction.logger.debug("editableFeedback found :" + editableFeedback); + break; } - else - { - request.setAttribute(NOTEBOOK_ENTRIES_EXIST, new Boolean(false).toString()); - } - /* ... till here*/ - - MonitoringUtil.buildQaStatsDTO(request,qaService, qaContent); - MonitoringUtil.generateGroupsSessionData(request, qaService, qaContent, false); - - - return mapping.findForward(LOAD_MONITORING); + + } + } + QaMonitoringAction.logger.debug("editableFeedback found :" + editableFeedback); + QaMonitoringAction.logger.debug("editableQuestion found :" + editableQuestion); + + String contentFolderID = WebUtil.readStrParam(request, AttributeNames.PARAM_CONTENT_FOLDER_ID); + QaMonitoringAction.logger.debug("contentFolderID: " + contentFolderID); + qaAuthoringForm.setContentFolderID(contentFolderID); + + String activeModule = request.getParameter(QaAppConstants.ACTIVE_MODULE); + QaMonitoringAction.logger.debug("activeModule: " + activeModule); + + String strToolContentID = request.getParameter(AttributeNames.PARAM_TOOL_CONTENT_ID); + QaMonitoringAction.logger.debug("strToolContentID: " + strToolContentID); + + String defaultContentIdStr = request.getParameter(QaAppConstants.DEFAULT_CONTENT_ID_STR); + QaMonitoringAction.logger.debug("defaultContentIdStr: " + defaultContentIdStr); + + QaContent qaContent = qaService.loadQa(new Long(strToolContentID).longValue()); + QaMonitoringAction.logger.debug("qaContent: " + qaContent); + + if (qaContent == null) { + QaMonitoringAction.logger.debug("using defaultContentIdStr: " + defaultContentIdStr); + qaContent = qaService.loadQa(new Long(defaultContentIdStr).longValue()); + } + QaMonitoringAction.logger.debug("final qaContent: " + qaContent); + + QaGeneralAuthoringDTO qaGeneralAuthoringDTO = new QaGeneralAuthoringDTO(); + QaMonitoringAction.logger.debug("qaGeneralAuthoringDTO: " + qaGeneralAuthoringDTO); + qaGeneralAuthoringDTO.setContentFolderID(contentFolderID); + + String richTextTitle = request.getParameter(QaAppConstants.TITLE); + String richTextInstructions = request.getParameter(QaAppConstants.INSTRUCTIONS); + + QaMonitoringAction.logger.debug("richTextTitle: " + richTextTitle); + QaMonitoringAction.logger.debug("richTextInstructions: " + richTextInstructions); + qaGeneralAuthoringDTO.setActivityTitle(richTextTitle); + qaAuthoringForm.setTitle(richTextTitle); + + qaGeneralAuthoringDTO.setActivityInstructions(richTextInstructions); + + QaUtils.setFormProperties(request, qaService, qaAuthoringForm, qaGeneralAuthoringDTO, strToolContentID, + defaultContentIdStr, activeModule, sessionMap, httpSessionID); + + qaGeneralAuthoringDTO.setEditableQuestionText(editableQuestion); + qaGeneralAuthoringDTO.setEditableQuestionFeedback(editableFeedback); + qaAuthoringForm.setFeedback(editableFeedback); + + QaMonitoringAction.logger.debug("qaGeneralAuthoringDTO now: " + qaGeneralAuthoringDTO); + request.setAttribute(QaAppConstants.QA_GENERAL_AUTHORING_DTO, qaGeneralAuthoringDTO); + + request.setAttribute(QaAppConstants.TOTAL_QUESTION_COUNT, new Integer(listQuestionContentDTO.size())); + + /* start monitoring code */ + GeneralMonitoringDTO qaGeneralMonitoringDTO = new GeneralMonitoringDTO(); + qaGeneralMonitoringDTO.setDefineLaterInEditMode(new Boolean(false).toString()); + + if (qaService.studentActivityOccurredGlobal(qaContent)) { + QaMonitoringAction.logger.debug("USER_EXCEPTION_NO_TOOL_SESSIONS is set to false"); + qaGeneralMonitoringDTO.setUserExceptionNoToolSessions(new Boolean(false).toString()); + } else { + QaMonitoringAction.logger.debug("USER_EXCEPTION_NO_TOOL_SESSIONS is set to true"); + qaGeneralMonitoringDTO.setUserExceptionNoToolSessions(new Boolean(true).toString()); + } + + qaGeneralMonitoringDTO.setOnlineInstructions(qaContent.getOnlineInstructions()); + qaGeneralMonitoringDTO.setOfflineInstructions(qaContent.getOfflineInstructions()); + + List attachmentList = qaService.retrieveQaUploadedFiles(qaContent); + QaMonitoringAction.logger.debug("attachmentList: " + attachmentList); + qaGeneralMonitoringDTO.setAttachmentList(attachmentList); + QaMonitoringAction.logger.debug("final qaGeneralMonitoringDTO: " + qaGeneralMonitoringDTO); + + qaGeneralMonitoringDTO.setDefineLaterInEditMode(new Boolean(true).toString()); + QaMonitoringAction.logger.debug("final generalMonitoringDTO: " + qaGeneralMonitoringDTO); + request.setAttribute(QaAppConstants.QA_GENERAL_MONITORING_DTO, qaGeneralMonitoringDTO); + + prepareReflectionData(request, qaContent, qaService, null, false, "All"); + + /* find out if there are any reflection entries, from here */ + boolean notebookEntriesExist = MonitoringUtil.notebookEntriesExist(qaService, qaContent); + QaMonitoringAction.logger.debug("notebookEntriesExist : " + notebookEntriesExist); + + if (notebookEntriesExist) { + request.setAttribute(QaAppConstants.NOTEBOOK_ENTRIES_EXIST, new Boolean(true).toString()); + + String userExceptionNoToolSessions = qaGeneralMonitoringDTO.getUserExceptionNoToolSessions(); + QaMonitoringAction.logger.debug("userExceptionNoToolSessions : " + userExceptionNoToolSessions); + + if (userExceptionNoToolSessions.equals("true")) { + QaMonitoringAction.logger.debug("there are no online student activity but there are reflections : "); + request.setAttribute(QaAppConstants.NO_SESSIONS_NOTEBOOK_ENTRIES_EXIST, new Boolean(true).toString()); + } + + } else { + request.setAttribute(QaAppConstants.NOTEBOOK_ENTRIES_EXIST, new Boolean(false).toString()); + } + /* ... till here */ + + MonitoringUtil.buildQaStatsDTO(request, qaService, qaContent); + MonitoringUtil.generateGroupsSessionData(request, qaService, qaContent, false); + + QaMonitoringAction.logger.debug("fwd ing to editQuestionBox: "); + return mapping.findForward("editQuestionBox"); } - - - - public ActionForward moveQuestionDown(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) - throws IOException, ServletException { - logger.debug("dispathcing proxy moveQuestionDown"); + public ActionForward removeQuestion(ActionMapping mapping, ActionForm form, HttpServletRequest request, + HttpServletResponse response) throws IOException, ServletException { + QaMonitoringAction.logger.debug("dispathcing proxy removeQuestion"); - /*start authoring code*/ - QaAuthoringForm qaAuthoringForm = (QaMonitoringForm) form; - logger.debug("dispathcing moveQuestionDown"); - - IQaService qaService =QaServiceProxy.getQaService(getServlet().getServletContext()); - logger.debug("qaService: " + qaService); - - String httpSessionID=request.getParameter("httpSessionID"); - logger.debug("httpSessionID: " + httpSessionID); - - SessionMap sessionMap=(SessionMap)request.getSession().getAttribute(httpSessionID); - logger.debug("sessionMap: " + sessionMap); - - String questionIndex=request.getParameter("questionIndex"); - logger.debug("questionIndex: " + questionIndex); - - - List listQuestionContentDTO=(List)sessionMap.get(LIST_QUESTION_CONTENT_DTO_KEY); - logger.debug("listQuestionContentDTO: " + listQuestionContentDTO); - - listQuestionContentDTO=AuthoringUtil.swapNodes(listQuestionContentDTO, questionIndex, "down"); - logger.debug("listQuestionContentDTO after swap: " + listQuestionContentDTO); - - listQuestionContentDTO=AuthoringUtil.reorderSimpleListQuestionContentDTO(listQuestionContentDTO); - logger.debug("listQuestionContentDTO after reordersimple: " + listQuestionContentDTO); + /* start authoring code */ + QaAuthoringForm qaAuthoringForm = (QaMonitoringForm) form; + QaMonitoringAction.logger.debug("dispathcing removeQuestion"); - - sessionMap.put(LIST_QUESTION_CONTENT_DTO_KEY, listQuestionContentDTO); - - - String contentFolderID = WebUtil.readStrParam(request, AttributeNames.PARAM_CONTENT_FOLDER_ID); - logger.debug("contentFolderID: " + contentFolderID); - qaAuthoringForm.setContentFolderID(contentFolderID); - - - String activeModule=request.getParameter(ACTIVE_MODULE); - logger.debug("activeModule: " + activeModule); - - String richTextTitle = request.getParameter(TITLE); - logger.debug("richTextTitle: " + richTextTitle); - - String richTextInstructions = request.getParameter(INSTRUCTIONS); - logger.debug("richTextInstructions: " + richTextInstructions); - - - sessionMap.put(ACTIVITY_TITLE_KEY, richTextTitle); - sessionMap.put(ACTIVITY_INSTRUCTIONS_KEY, richTextInstructions); - - - String strToolContentID=request.getParameter(AttributeNames.PARAM_TOOL_CONTENT_ID); - logger.debug("strToolContentID: " + strToolContentID); - - String defaultContentIdStr=request.getParameter(DEFAULT_CONTENT_ID_STR); - logger.debug("defaultContentIdStr: " + defaultContentIdStr); - - QaContent qaContent=qaService.loadQa(new Long(strToolContentID).longValue()); - logger.debug("qaContent: " + qaContent); - - if (qaContent == null) - { - logger.debug("using defaultContentIdStr: " + defaultContentIdStr); - qaContent=qaService.loadQa(new Long(defaultContentIdStr).longValue()); - } - logger.debug("final qaContent: " + qaContent); - - QaGeneralAuthoringDTO qaGeneralAuthoringDTO= new QaGeneralAuthoringDTO(); - logger.debug("qaGeneralAuthoringDTO: " + qaGeneralAuthoringDTO); - qaGeneralAuthoringDTO.setContentFolderID(contentFolderID); - - qaGeneralAuthoringDTO.setActivityTitle(richTextTitle); - qaAuthoringForm.setTitle(richTextTitle); - - qaGeneralAuthoringDTO.setActivityInstructions(richTextInstructions); - - AuthoringUtil authoringUtil= new AuthoringUtil(); - - qaGeneralAuthoringDTO.setEditActivityEditMode(new Boolean(true).toString()); - request.getSession().setAttribute(httpSessionID, sessionMap); - - QaUtils.setFormProperties(request, qaService, - qaAuthoringForm, qaGeneralAuthoringDTO, strToolContentID, defaultContentIdStr, activeModule, sessionMap, httpSessionID); - - - qaGeneralAuthoringDTO.setToolContentID(strToolContentID); - qaGeneralAuthoringDTO.setHttpSessionID(httpSessionID); - qaGeneralAuthoringDTO.setActiveModule(activeModule); - qaGeneralAuthoringDTO.setDefaultContentIdStr(defaultContentIdStr); - qaAuthoringForm.setToolContentID(strToolContentID); - qaAuthoringForm.setHttpSessionID(httpSessionID); - qaAuthoringForm.setActiveModule(activeModule); - qaAuthoringForm.setDefaultContentIdStr(defaultContentIdStr); - qaAuthoringForm.setCurrentTab("3"); - - request.setAttribute(LIST_QUESTION_CONTENT_DTO,listQuestionContentDTO); - logger.debug("listQuestionContentDTO now: " + listQuestionContentDTO); - - - logger.debug("before saving final qaGeneralAuthoringDTO: " + qaGeneralAuthoringDTO); - request.setAttribute(QA_GENERAL_AUTHORING_DTO, qaGeneralAuthoringDTO); - - request.setAttribute(TOTAL_QUESTION_COUNT, new Integer(listQuestionContentDTO.size())); - - /*start monitoring code*/ - GeneralMonitoringDTO qaGeneralMonitoringDTO=new GeneralMonitoringDTO(); + IQaService qaService = QaServiceProxy.getQaService(getServlet().getServletContext()); + QaMonitoringAction.logger.debug("qaService: " + qaService); - if (qaService.studentActivityOccurredGlobal(qaContent)) - { - logger.debug("USER_EXCEPTION_NO_TOOL_SESSIONS is set to false"); - qaGeneralMonitoringDTO.setUserExceptionNoToolSessions(new Boolean(false).toString()); - } - else - { - logger.debug("USER_EXCEPTION_NO_TOOL_SESSIONS is set to true"); - qaGeneralMonitoringDTO.setUserExceptionNoToolSessions(new Boolean(true).toString()); - } + String httpSessionID = request.getParameter("httpSessionID"); + QaMonitoringAction.logger.debug("httpSessionID: " + httpSessionID); - qaGeneralMonitoringDTO.setOnlineInstructions(qaContent.getOnlineInstructions()); - qaGeneralMonitoringDTO.setOfflineInstructions(qaContent.getOfflineInstructions()); + SessionMap sessionMap = (SessionMap) request.getSession().getAttribute(httpSessionID); + QaMonitoringAction.logger.debug("sessionMap: " + sessionMap); - List attachmentList = qaService.retrieveQaUploadedFiles(qaContent); - logger.debug("attachmentList: " + attachmentList); - qaGeneralMonitoringDTO.setAttachmentList(attachmentList); - logger.debug("final qaGeneralMonitoringDTO: " + qaGeneralMonitoringDTO ); + String questionIndex = request.getParameter("questionIndex"); + QaMonitoringAction.logger.debug("questionIndex: " + questionIndex); - - qaGeneralMonitoringDTO.setDefineLaterInEditMode(new Boolean(true).toString()); - logger.debug("final generalMonitoringDTO: " + qaGeneralMonitoringDTO ); - request.setAttribute(QA_GENERAL_MONITORING_DTO, qaGeneralMonitoringDTO); + List listQuestionContentDTO = (List) sessionMap.get(QaAppConstants.LIST_QUESTION_CONTENT_DTO_KEY); + QaMonitoringAction.logger.debug("listQuestionContentDTO: " + listQuestionContentDTO); - prepareReflectionData(request, qaContent, qaService, null, false , "All"); + QaQuestionContentDTO qaQuestionContentDTO = null; + Iterator listIterator = listQuestionContentDTO.iterator(); + while (listIterator.hasNext()) { + qaQuestionContentDTO = (QaQuestionContentDTO) listIterator.next(); + QaMonitoringAction.logger.debug("qaQuestionContentDTO:" + qaQuestionContentDTO); + QaMonitoringAction.logger.debug("qaQuestionContentDTO question:" + qaQuestionContentDTO.getQuestion()); - /*find out if there are any reflection entries, from here*/ - boolean notebookEntriesExist=MonitoringUtil.notebookEntriesExist(qaService, qaContent); - logger.debug("notebookEntriesExist : " + notebookEntriesExist); - - if (notebookEntriesExist) - { - request.setAttribute(NOTEBOOK_ENTRIES_EXIST, new Boolean(true).toString()); - - String userExceptionNoToolSessions=(String)qaGeneralMonitoringDTO.getUserExceptionNoToolSessions(); - logger.debug("userExceptionNoToolSessions : " + userExceptionNoToolSessions); - - if (userExceptionNoToolSessions.equals("true")) - { - logger.debug("there are no online student activity but there are reflections : "); - request.setAttribute(NO_SESSIONS_NOTEBOOK_ENTRIES_EXIST, new Boolean(true).toString()); - } + String question = qaQuestionContentDTO.getQuestion(); + String displayOrder = qaQuestionContentDTO.getDisplayOrder(); + QaMonitoringAction.logger.debug("displayOrder:" + displayOrder); + if (displayOrder != null && !displayOrder.equals("")) { + if (displayOrder.equals(questionIndex)) { + break; } - else - { - request.setAttribute(NOTEBOOK_ENTRIES_EXIST, new Boolean(false).toString()); - } - /* ... till here*/ - - MonitoringUtil.buildQaStatsDTO(request,qaService, qaContent); - MonitoringUtil.generateGroupsSessionData(request, qaService, qaContent, false); - - return mapping.findForward(LOAD_MONITORING); + } + } + + QaMonitoringAction.logger.debug("qaQuestionContentDTO found:" + qaQuestionContentDTO); + qaQuestionContentDTO.setQuestion(""); + QaMonitoringAction.logger.debug("listQuestionContentDTO after remove:" + listQuestionContentDTO); + + listQuestionContentDTO = AuthoringUtil.reorderListQuestionContentDTO(listQuestionContentDTO, questionIndex); + QaMonitoringAction.logger.debug("listQuestionContentDTO reordered:" + listQuestionContentDTO); + + sessionMap.put(QaAppConstants.LIST_QUESTION_CONTENT_DTO_KEY, listQuestionContentDTO); + + String contentFolderID = WebUtil.readStrParam(request, AttributeNames.PARAM_CONTENT_FOLDER_ID); + QaMonitoringAction.logger.debug("contentFolderID: " + contentFolderID); + qaAuthoringForm.setContentFolderID(contentFolderID); + + String activeModule = request.getParameter(QaAppConstants.ACTIVE_MODULE); + QaMonitoringAction.logger.debug("activeModule: " + activeModule); + + String richTextTitle = request.getParameter(QaAppConstants.TITLE); + QaMonitoringAction.logger.debug("richTextTitle: " + richTextTitle); + + String richTextInstructions = request.getParameter(QaAppConstants.INSTRUCTIONS); + QaMonitoringAction.logger.debug("richTextInstructions: " + richTextInstructions); + + sessionMap.put(QaAppConstants.ACTIVITY_TITLE_KEY, richTextTitle); + sessionMap.put(QaAppConstants.ACTIVITY_INSTRUCTIONS_KEY, richTextInstructions); + + String strToolContentID = request.getParameter(AttributeNames.PARAM_TOOL_CONTENT_ID); + QaMonitoringAction.logger.debug("strToolContentID: " + strToolContentID); + + String defaultContentIdStr = request.getParameter(QaAppConstants.DEFAULT_CONTENT_ID_STR); + QaMonitoringAction.logger.debug("defaultContentIdStr: " + defaultContentIdStr); + + QaContent qaContent = qaService.loadQa(new Long(strToolContentID).longValue()); + QaMonitoringAction.logger.debug("qaContent: " + qaContent); + + if (qaContent == null) { + QaMonitoringAction.logger.debug("using defaultContentIdStr: " + defaultContentIdStr); + qaContent = qaService.loadQa(new Long(defaultContentIdStr).longValue()); + } + QaMonitoringAction.logger.debug("final qaContent: " + qaContent); + + QaGeneralAuthoringDTO qaGeneralAuthoringDTO = new QaGeneralAuthoringDTO(); + QaMonitoringAction.logger.debug("qaGeneralAuthoringDTO: " + qaGeneralAuthoringDTO); + qaGeneralAuthoringDTO.setContentFolderID(contentFolderID); + + qaGeneralAuthoringDTO.setActivityTitle(richTextTitle); + qaAuthoringForm.setTitle(richTextTitle); + + qaGeneralAuthoringDTO.setActivityInstructions(richTextInstructions); + + AuthoringUtil authoringUtil = new AuthoringUtil(); + + qaGeneralAuthoringDTO.setEditActivityEditMode(new Boolean(true).toString()); + + request.getSession().setAttribute(httpSessionID, sessionMap); + + QaUtils.setFormProperties(request, qaService, qaAuthoringForm, qaGeneralAuthoringDTO, strToolContentID, + defaultContentIdStr, activeModule, sessionMap, httpSessionID); + + qaGeneralAuthoringDTO.setToolContentID(strToolContentID); + qaGeneralAuthoringDTO.setHttpSessionID(httpSessionID); + qaGeneralAuthoringDTO.setActiveModule(activeModule); + qaGeneralAuthoringDTO.setDefaultContentIdStr(defaultContentIdStr); + qaAuthoringForm.setToolContentID(strToolContentID); + qaAuthoringForm.setHttpSessionID(httpSessionID); + qaAuthoringForm.setActiveModule(activeModule); + qaAuthoringForm.setDefaultContentIdStr(defaultContentIdStr); + qaAuthoringForm.setCurrentTab("3"); + + request.setAttribute(QaAppConstants.LIST_QUESTION_CONTENT_DTO, listQuestionContentDTO); + QaMonitoringAction.logger.debug("qaQuestionContentDTO now: " + qaQuestionContentDTO); + QaMonitoringAction.logger.debug("listQuestionContentDTO now: " + listQuestionContentDTO); + + QaMonitoringAction.logger.debug("before saving final qaGeneralAuthoringDTO: " + qaGeneralAuthoringDTO); + request.setAttribute(QaAppConstants.QA_GENERAL_AUTHORING_DTO, qaGeneralAuthoringDTO); + + request.setAttribute(QaAppConstants.TOTAL_QUESTION_COUNT, new Integer(listQuestionContentDTO.size())); + + /* start monitoring code */ + GeneralMonitoringDTO qaGeneralMonitoringDTO = new GeneralMonitoringDTO(); + + if (qaService.studentActivityOccurredGlobal(qaContent)) { + QaMonitoringAction.logger.debug("USER_EXCEPTION_NO_TOOL_SESSIONS is set to false"); + qaGeneralMonitoringDTO.setUserExceptionNoToolSessions(new Boolean(false).toString()); + } else { + QaMonitoringAction.logger.debug("USER_EXCEPTION_NO_TOOL_SESSIONS is set to true"); + qaGeneralMonitoringDTO.setUserExceptionNoToolSessions(new Boolean(true).toString()); + } + + qaGeneralMonitoringDTO.setOnlineInstructions(qaContent.getOnlineInstructions()); + qaGeneralMonitoringDTO.setOfflineInstructions(qaContent.getOfflineInstructions()); + + List attachmentList = qaService.retrieveQaUploadedFiles(qaContent); + QaMonitoringAction.logger.debug("attachmentList: " + attachmentList); + qaGeneralMonitoringDTO.setAttachmentList(attachmentList); + QaMonitoringAction.logger.debug("final qaGeneralMonitoringDTO: " + qaGeneralMonitoringDTO); + + qaGeneralMonitoringDTO.setDefineLaterInEditMode(new Boolean(true).toString()); + QaMonitoringAction.logger.debug("final generalMonitoringDTO: " + qaGeneralMonitoringDTO); + request.setAttribute(QaAppConstants.QA_GENERAL_MONITORING_DTO, qaGeneralMonitoringDTO); + + prepareReflectionData(request, qaContent, qaService, null, false, "All"); + + /* find out if there are any reflection entries, from here */ + boolean notebookEntriesExist = MonitoringUtil.notebookEntriesExist(qaService, qaContent); + QaMonitoringAction.logger.debug("notebookEntriesExist : " + notebookEntriesExist); + + if (notebookEntriesExist) { + request.setAttribute(QaAppConstants.NOTEBOOK_ENTRIES_EXIST, new Boolean(true).toString()); + + String userExceptionNoToolSessions = qaGeneralMonitoringDTO.getUserExceptionNoToolSessions(); + QaMonitoringAction.logger.debug("userExceptionNoToolSessions : " + userExceptionNoToolSessions); + + if (userExceptionNoToolSessions.equals("true")) { + QaMonitoringAction.logger.debug("there are no online student activity but there are reflections : "); + request.setAttribute(QaAppConstants.NO_SESSIONS_NOTEBOOK_ENTRIES_EXIST, new Boolean(true).toString()); + } + + } else { + request.setAttribute(QaAppConstants.NOTEBOOK_ENTRIES_EXIST, new Boolean(false).toString()); + } + /* ... till here */ + + MonitoringUtil.buildQaStatsDTO(request, qaService, qaContent); + MonitoringUtil.generateGroupsSessionData(request, qaService, qaContent, false); + + return mapping.findForward(QaAppConstants.LOAD_MONITORING); } - - - - public ActionForward moveQuestionUp(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) - throws IOException, ServletException { - logger.debug("dispathcing proxy moveQuestionUp"); - /*start authoring code*/ - QaAuthoringForm qaAuthoringForm = (QaMonitoringForm) form; - logger.debug("dispathcing moveQuestionDown"); - - IQaService qaService =QaServiceProxy.getQaService(getServlet().getServletContext()); - logger.debug("qaService: " + qaService); - - String httpSessionID=request.getParameter("httpSessionID"); - logger.debug("httpSessionID: " + httpSessionID); - - SessionMap sessionMap=(SessionMap)request.getSession().getAttribute(httpSessionID); - logger.debug("sessionMap: " + sessionMap); - - String questionIndex=request.getParameter("questionIndex"); - logger.debug("questionIndex: " + questionIndex); - - - List listQuestionContentDTO=(List)sessionMap.get(LIST_QUESTION_CONTENT_DTO_KEY); - logger.debug("listQuestionContentDTO: " + listQuestionContentDTO); - - listQuestionContentDTO=AuthoringUtil.swapNodes(listQuestionContentDTO, questionIndex, "up"); - logger.debug("listQuestionContentDTO after swap: " + listQuestionContentDTO); - - listQuestionContentDTO=AuthoringUtil.reorderSimpleListQuestionContentDTO(listQuestionContentDTO); - logger.debug("listQuestionContentDTO after reordersimple: " + listQuestionContentDTO); - - sessionMap.put(LIST_QUESTION_CONTENT_DTO_KEY, listQuestionContentDTO); - - String contentFolderID = WebUtil.readStrParam(request, AttributeNames.PARAM_CONTENT_FOLDER_ID); - logger.debug("contentFolderID: " + contentFolderID); - qaAuthoringForm.setContentFolderID(contentFolderID); - - - String activeModule=request.getParameter(ACTIVE_MODULE); - logger.debug("activeModule: " + activeModule); - - String richTextTitle = request.getParameter(TITLE); - logger.debug("richTextTitle: " + richTextTitle); - - String richTextInstructions = request.getParameter(INSTRUCTIONS); - logger.debug("richTextInstructions: " + richTextInstructions); - - - sessionMap.put(ACTIVITY_TITLE_KEY, richTextTitle); - sessionMap.put(ACTIVITY_INSTRUCTIONS_KEY, richTextInstructions); - - - String strToolContentID=request.getParameter(AttributeNames.PARAM_TOOL_CONTENT_ID); - logger.debug("strToolContentID: " + strToolContentID); - - String defaultContentIdStr=request.getParameter(DEFAULT_CONTENT_ID_STR); - logger.debug("defaultContentIdStr: " + defaultContentIdStr); - - QaContent qaContent=qaService.loadQa(new Long(strToolContentID).longValue()); - logger.debug("qaContent: " + qaContent); - - if (qaContent == null) - { - logger.debug("using defaultContentIdStr: " + defaultContentIdStr); - qaContent=qaService.loadQa(new Long(defaultContentIdStr).longValue()); - } - logger.debug("final qaContent: " + qaContent); - - QaGeneralAuthoringDTO qaGeneralAuthoringDTO= new QaGeneralAuthoringDTO(); - logger.debug("qaGeneralAuthoringDTO: " + qaGeneralAuthoringDTO); - qaGeneralAuthoringDTO.setContentFolderID(contentFolderID); - - qaGeneralAuthoringDTO.setActivityTitle(richTextTitle); - qaAuthoringForm.setTitle(richTextTitle); - - qaGeneralAuthoringDTO.setActivityInstructions(richTextInstructions); - - AuthoringUtil authoringUtil= new AuthoringUtil(); - - qaGeneralAuthoringDTO.setEditActivityEditMode(new Boolean(true).toString()); - - request.getSession().setAttribute(httpSessionID, sessionMap); - - QaUtils.setFormProperties(request, qaService, - qaAuthoringForm, qaGeneralAuthoringDTO, strToolContentID, defaultContentIdStr, activeModule, sessionMap, httpSessionID); - - - qaGeneralAuthoringDTO.setToolContentID(strToolContentID); - qaGeneralAuthoringDTO.setHttpSessionID(httpSessionID); - qaGeneralAuthoringDTO.setActiveModule(activeModule); - qaGeneralAuthoringDTO.setDefaultContentIdStr(defaultContentIdStr); - qaAuthoringForm.setToolContentID(strToolContentID); - qaAuthoringForm.setHttpSessionID(httpSessionID); - qaAuthoringForm.setActiveModule(activeModule); - qaAuthoringForm.setDefaultContentIdStr(defaultContentIdStr); - qaAuthoringForm.setCurrentTab("3"); - - - request.setAttribute(LIST_QUESTION_CONTENT_DTO,listQuestionContentDTO); - logger.debug("listQuestionContentDTO now: " + listQuestionContentDTO); - - - logger.debug("before saving final qaGeneralAuthoringDTO: " + qaGeneralAuthoringDTO); - request.setAttribute(QA_GENERAL_AUTHORING_DTO, qaGeneralAuthoringDTO); - - request.setAttribute(TOTAL_QUESTION_COUNT, new Integer(listQuestionContentDTO.size())); - - /*start monitoring code*/ - GeneralMonitoringDTO qaGeneralMonitoringDTO=new GeneralMonitoringDTO(); + public ActionForward moveQuestionDown(ActionMapping mapping, ActionForm form, HttpServletRequest request, + HttpServletResponse response) throws IOException, ServletException { + QaMonitoringAction.logger.debug("dispathcing proxy moveQuestionDown"); - if (qaService.studentActivityOccurredGlobal(qaContent)) - { - logger.debug("USER_EXCEPTION_NO_TOOL_SESSIONS is set to false"); - qaGeneralMonitoringDTO.setUserExceptionNoToolSessions(new Boolean(false).toString()); - } - else - { - logger.debug("USER_EXCEPTION_NO_TOOL_SESSIONS is set to true"); - qaGeneralMonitoringDTO.setUserExceptionNoToolSessions(new Boolean(true).toString()); - } + /* start authoring code */ + QaAuthoringForm qaAuthoringForm = (QaMonitoringForm) form; + QaMonitoringAction.logger.debug("dispathcing moveQuestionDown"); - qaGeneralMonitoringDTO.setOnlineInstructions(qaContent.getOnlineInstructions()); - qaGeneralMonitoringDTO.setOfflineInstructions(qaContent.getOfflineInstructions()); + IQaService qaService = QaServiceProxy.getQaService(getServlet().getServletContext()); + QaMonitoringAction.logger.debug("qaService: " + qaService); - List attachmentList = qaService.retrieveQaUploadedFiles(qaContent); - logger.debug("attachmentList: " + attachmentList); - qaGeneralMonitoringDTO.setAttachmentList(attachmentList); - logger.debug("final qaGeneralMonitoringDTO: " + qaGeneralMonitoringDTO ); + String httpSessionID = request.getParameter("httpSessionID"); + QaMonitoringAction.logger.debug("httpSessionID: " + httpSessionID); - - qaGeneralMonitoringDTO.setDefineLaterInEditMode(new Boolean(true).toString()); - logger.debug("final generalMonitoringDTO: " + qaGeneralMonitoringDTO ); - request.setAttribute(QA_GENERAL_MONITORING_DTO, qaGeneralMonitoringDTO); + SessionMap sessionMap = (SessionMap) request.getSession().getAttribute(httpSessionID); + QaMonitoringAction.logger.debug("sessionMap: " + sessionMap); - prepareReflectionData(request, qaContent, qaService, null, false , "All"); - - /*find out if there are any reflection entries, from here*/ - boolean notebookEntriesExist=MonitoringUtil.notebookEntriesExist(qaService, qaContent); - logger.debug("notebookEntriesExist : " + notebookEntriesExist); - - if (notebookEntriesExist) - { - request.setAttribute(NOTEBOOK_ENTRIES_EXIST, new Boolean(true).toString()); - - String userExceptionNoToolSessions=(String)qaGeneralMonitoringDTO.getUserExceptionNoToolSessions(); - logger.debug("userExceptionNoToolSessions : " + userExceptionNoToolSessions); - - if (userExceptionNoToolSessions.equals("true")) - { - logger.debug("there are no online student activity but there are reflections : "); - request.setAttribute(NO_SESSIONS_NOTEBOOK_ENTRIES_EXIST, new Boolean(true).toString()); - } - } - else - { - request.setAttribute(NOTEBOOK_ENTRIES_EXIST, new Boolean(false).toString()); - } - /* ... till here*/ - - MonitoringUtil.buildQaStatsDTO(request,qaService, qaContent); - MonitoringUtil.generateGroupsSessionData(request, qaService, qaContent, false); - - return mapping.findForward(LOAD_MONITORING); + String questionIndex = request.getParameter("questionIndex"); + QaMonitoringAction.logger.debug("questionIndex: " + questionIndex); + + List listQuestionContentDTO = (List) sessionMap.get(QaAppConstants.LIST_QUESTION_CONTENT_DTO_KEY); + QaMonitoringAction.logger.debug("listQuestionContentDTO: " + listQuestionContentDTO); + + listQuestionContentDTO = AuthoringUtil.swapNodes(listQuestionContentDTO, questionIndex, "down", null); + QaMonitoringAction.logger.debug("listQuestionContentDTO after swap: " + listQuestionContentDTO); + + listQuestionContentDTO = AuthoringUtil.reorderSimpleListQuestionContentDTO(listQuestionContentDTO); + QaMonitoringAction.logger.debug("listQuestionContentDTO after reordersimple: " + listQuestionContentDTO); + + sessionMap.put(QaAppConstants.LIST_QUESTION_CONTENT_DTO_KEY, listQuestionContentDTO); + + String contentFolderID = WebUtil.readStrParam(request, AttributeNames.PARAM_CONTENT_FOLDER_ID); + QaMonitoringAction.logger.debug("contentFolderID: " + contentFolderID); + qaAuthoringForm.setContentFolderID(contentFolderID); + + String activeModule = request.getParameter(QaAppConstants.ACTIVE_MODULE); + QaMonitoringAction.logger.debug("activeModule: " + activeModule); + + String richTextTitle = request.getParameter(QaAppConstants.TITLE); + QaMonitoringAction.logger.debug("richTextTitle: " + richTextTitle); + + String richTextInstructions = request.getParameter(QaAppConstants.INSTRUCTIONS); + QaMonitoringAction.logger.debug("richTextInstructions: " + richTextInstructions); + + sessionMap.put(QaAppConstants.ACTIVITY_TITLE_KEY, richTextTitle); + sessionMap.put(QaAppConstants.ACTIVITY_INSTRUCTIONS_KEY, richTextInstructions); + + String strToolContentID = request.getParameter(AttributeNames.PARAM_TOOL_CONTENT_ID); + QaMonitoringAction.logger.debug("strToolContentID: " + strToolContentID); + + String defaultContentIdStr = request.getParameter(QaAppConstants.DEFAULT_CONTENT_ID_STR); + QaMonitoringAction.logger.debug("defaultContentIdStr: " + defaultContentIdStr); + + QaContent qaContent = qaService.loadQa(new Long(strToolContentID).longValue()); + QaMonitoringAction.logger.debug("qaContent: " + qaContent); + + if (qaContent == null) { + QaMonitoringAction.logger.debug("using defaultContentIdStr: " + defaultContentIdStr); + qaContent = qaService.loadQa(new Long(defaultContentIdStr).longValue()); + } + QaMonitoringAction.logger.debug("final qaContent: " + qaContent); + + QaGeneralAuthoringDTO qaGeneralAuthoringDTO = new QaGeneralAuthoringDTO(); + QaMonitoringAction.logger.debug("qaGeneralAuthoringDTO: " + qaGeneralAuthoringDTO); + qaGeneralAuthoringDTO.setContentFolderID(contentFolderID); + + qaGeneralAuthoringDTO.setActivityTitle(richTextTitle); + qaAuthoringForm.setTitle(richTextTitle); + + qaGeneralAuthoringDTO.setActivityInstructions(richTextInstructions); + + AuthoringUtil authoringUtil = new AuthoringUtil(); + + qaGeneralAuthoringDTO.setEditActivityEditMode(new Boolean(true).toString()); + request.getSession().setAttribute(httpSessionID, sessionMap); + + QaUtils.setFormProperties(request, qaService, qaAuthoringForm, qaGeneralAuthoringDTO, strToolContentID, + defaultContentIdStr, activeModule, sessionMap, httpSessionID); + + qaGeneralAuthoringDTO.setToolContentID(strToolContentID); + qaGeneralAuthoringDTO.setHttpSessionID(httpSessionID); + qaGeneralAuthoringDTO.setActiveModule(activeModule); + qaGeneralAuthoringDTO.setDefaultContentIdStr(defaultContentIdStr); + qaAuthoringForm.setToolContentID(strToolContentID); + qaAuthoringForm.setHttpSessionID(httpSessionID); + qaAuthoringForm.setActiveModule(activeModule); + qaAuthoringForm.setDefaultContentIdStr(defaultContentIdStr); + qaAuthoringForm.setCurrentTab("3"); + + request.setAttribute(QaAppConstants.LIST_QUESTION_CONTENT_DTO, listQuestionContentDTO); + QaMonitoringAction.logger.debug("listQuestionContentDTO now: " + listQuestionContentDTO); + + QaMonitoringAction.logger.debug("before saving final qaGeneralAuthoringDTO: " + qaGeneralAuthoringDTO); + request.setAttribute(QaAppConstants.QA_GENERAL_AUTHORING_DTO, qaGeneralAuthoringDTO); + + request.setAttribute(QaAppConstants.TOTAL_QUESTION_COUNT, new Integer(listQuestionContentDTO.size())); + + /* start monitoring code */ + GeneralMonitoringDTO qaGeneralMonitoringDTO = new GeneralMonitoringDTO(); + + if (qaService.studentActivityOccurredGlobal(qaContent)) { + QaMonitoringAction.logger.debug("USER_EXCEPTION_NO_TOOL_SESSIONS is set to false"); + qaGeneralMonitoringDTO.setUserExceptionNoToolSessions(new Boolean(false).toString()); + } else { + QaMonitoringAction.logger.debug("USER_EXCEPTION_NO_TOOL_SESSIONS is set to true"); + qaGeneralMonitoringDTO.setUserExceptionNoToolSessions(new Boolean(true).toString()); + } + + qaGeneralMonitoringDTO.setOnlineInstructions(qaContent.getOnlineInstructions()); + qaGeneralMonitoringDTO.setOfflineInstructions(qaContent.getOfflineInstructions()); + + List attachmentList = qaService.retrieveQaUploadedFiles(qaContent); + QaMonitoringAction.logger.debug("attachmentList: " + attachmentList); + qaGeneralMonitoringDTO.setAttachmentList(attachmentList); + QaMonitoringAction.logger.debug("final qaGeneralMonitoringDTO: " + qaGeneralMonitoringDTO); + + qaGeneralMonitoringDTO.setDefineLaterInEditMode(new Boolean(true).toString()); + QaMonitoringAction.logger.debug("final generalMonitoringDTO: " + qaGeneralMonitoringDTO); + request.setAttribute(QaAppConstants.QA_GENERAL_MONITORING_DTO, qaGeneralMonitoringDTO); + + prepareReflectionData(request, qaContent, qaService, null, false, "All"); + + /* find out if there are any reflection entries, from here */ + boolean notebookEntriesExist = MonitoringUtil.notebookEntriesExist(qaService, qaContent); + QaMonitoringAction.logger.debug("notebookEntriesExist : " + notebookEntriesExist); + + if (notebookEntriesExist) { + request.setAttribute(QaAppConstants.NOTEBOOK_ENTRIES_EXIST, new Boolean(true).toString()); + + String userExceptionNoToolSessions = qaGeneralMonitoringDTO.getUserExceptionNoToolSessions(); + QaMonitoringAction.logger.debug("userExceptionNoToolSessions : " + userExceptionNoToolSessions); + + if (userExceptionNoToolSessions.equals("true")) { + QaMonitoringAction.logger.debug("there are no online student activity but there are reflections : "); + request.setAttribute(QaAppConstants.NO_SESSIONS_NOTEBOOK_ENTRIES_EXIST, new Boolean(true).toString()); + } + + } else { + request.setAttribute(QaAppConstants.NOTEBOOK_ENTRIES_EXIST, new Boolean(false).toString()); + } + /* ... till here */ + + MonitoringUtil.buildQaStatsDTO(request, qaService, qaContent); + MonitoringUtil.generateGroupsSessionData(request, qaService, qaContent, false); + + return mapping.findForward(QaAppConstants.LOAD_MONITORING); + } - - - - public void prepareReflectionData(HttpServletRequest request, QaContent qaContent, - IQaService qaService, String userID, boolean exportMode, String currentSessionId) - { - logger.debug("starting prepareReflectionData: " + qaContent); - logger.debug("currentSessionId: " + currentSessionId); - logger.debug("userID: " + userID); - logger.debug("exportMode: " + exportMode); + public ActionForward moveQuestionUp(ActionMapping mapping, ActionForm form, HttpServletRequest request, + HttpServletResponse response) throws IOException, ServletException { + QaMonitoringAction.logger.debug("dispathcing proxy moveQuestionUp"); - List reflectionsContainerDTO= new LinkedList(); - /* - if (currentSessionId.equals("All")) - { - reflectionsContainerDTO=getReflectionList(qaContent, userID, qaService); + /* start authoring code */ + QaAuthoringForm qaAuthoringForm = (QaMonitoringForm) form; + QaMonitoringAction.logger.debug("dispathcing moveQuestionDown"); + + IQaService qaService = QaServiceProxy.getQaService(getServlet().getServletContext()); + QaMonitoringAction.logger.debug("qaService: " + qaService); + + String httpSessionID = request.getParameter("httpSessionID"); + QaMonitoringAction.logger.debug("httpSessionID: " + httpSessionID); + + SessionMap sessionMap = (SessionMap) request.getSession().getAttribute(httpSessionID); + QaMonitoringAction.logger.debug("sessionMap: " + sessionMap); + + String questionIndex = request.getParameter("questionIndex"); + QaMonitoringAction.logger.debug("questionIndex: " + questionIndex); + + List listQuestionContentDTO = (List) sessionMap.get(QaAppConstants.LIST_QUESTION_CONTENT_DTO_KEY); + QaMonitoringAction.logger.debug("listQuestionContentDTO: " + listQuestionContentDTO); + + listQuestionContentDTO = AuthoringUtil.swapNodes(listQuestionContentDTO, questionIndex, "up", null); + QaMonitoringAction.logger.debug("listQuestionContentDTO after swap: " + listQuestionContentDTO); + + listQuestionContentDTO = AuthoringUtil.reorderSimpleListQuestionContentDTO(listQuestionContentDTO); + QaMonitoringAction.logger.debug("listQuestionContentDTO after reordersimple: " + listQuestionContentDTO); + + sessionMap.put(QaAppConstants.LIST_QUESTION_CONTENT_DTO_KEY, listQuestionContentDTO); + + String contentFolderID = WebUtil.readStrParam(request, AttributeNames.PARAM_CONTENT_FOLDER_ID); + QaMonitoringAction.logger.debug("contentFolderID: " + contentFolderID); + qaAuthoringForm.setContentFolderID(contentFolderID); + + String activeModule = request.getParameter(QaAppConstants.ACTIVE_MODULE); + QaMonitoringAction.logger.debug("activeModule: " + activeModule); + + String richTextTitle = request.getParameter(QaAppConstants.TITLE); + QaMonitoringAction.logger.debug("richTextTitle: " + richTextTitle); + + String richTextInstructions = request.getParameter(QaAppConstants.INSTRUCTIONS); + QaMonitoringAction.logger.debug("richTextInstructions: " + richTextInstructions); + + sessionMap.put(QaAppConstants.ACTIVITY_TITLE_KEY, richTextTitle); + sessionMap.put(QaAppConstants.ACTIVITY_INSTRUCTIONS_KEY, richTextInstructions); + + String strToolContentID = request.getParameter(AttributeNames.PARAM_TOOL_CONTENT_ID); + QaMonitoringAction.logger.debug("strToolContentID: " + strToolContentID); + + String defaultContentIdStr = request.getParameter(QaAppConstants.DEFAULT_CONTENT_ID_STR); + QaMonitoringAction.logger.debug("defaultContentIdStr: " + defaultContentIdStr); + + QaContent qaContent = qaService.loadQa(new Long(strToolContentID).longValue()); + QaMonitoringAction.logger.debug("qaContent: " + qaContent); + + if (qaContent == null) { + QaMonitoringAction.logger.debug("using defaultContentIdStr: " + defaultContentIdStr); + qaContent = qaService.loadQa(new Long(defaultContentIdStr).longValue()); + } + QaMonitoringAction.logger.debug("final qaContent: " + qaContent); + + QaGeneralAuthoringDTO qaGeneralAuthoringDTO = new QaGeneralAuthoringDTO(); + QaMonitoringAction.logger.debug("qaGeneralAuthoringDTO: " + qaGeneralAuthoringDTO); + qaGeneralAuthoringDTO.setContentFolderID(contentFolderID); + + qaGeneralAuthoringDTO.setActivityTitle(richTextTitle); + qaAuthoringForm.setTitle(richTextTitle); + + qaGeneralAuthoringDTO.setActivityInstructions(richTextInstructions); + + AuthoringUtil authoringUtil = new AuthoringUtil(); + + qaGeneralAuthoringDTO.setEditActivityEditMode(new Boolean(true).toString()); + + request.getSession().setAttribute(httpSessionID, sessionMap); + + QaUtils.setFormProperties(request, qaService, qaAuthoringForm, qaGeneralAuthoringDTO, strToolContentID, + defaultContentIdStr, activeModule, sessionMap, httpSessionID); + + qaGeneralAuthoringDTO.setToolContentID(strToolContentID); + qaGeneralAuthoringDTO.setHttpSessionID(httpSessionID); + qaGeneralAuthoringDTO.setActiveModule(activeModule); + qaGeneralAuthoringDTO.setDefaultContentIdStr(defaultContentIdStr); + qaAuthoringForm.setToolContentID(strToolContentID); + qaAuthoringForm.setHttpSessionID(httpSessionID); + qaAuthoringForm.setActiveModule(activeModule); + qaAuthoringForm.setDefaultContentIdStr(defaultContentIdStr); + qaAuthoringForm.setCurrentTab("3"); + + request.setAttribute(QaAppConstants.LIST_QUESTION_CONTENT_DTO, listQuestionContentDTO); + QaMonitoringAction.logger.debug("listQuestionContentDTO now: " + listQuestionContentDTO); + + QaMonitoringAction.logger.debug("before saving final qaGeneralAuthoringDTO: " + qaGeneralAuthoringDTO); + request.setAttribute(QaAppConstants.QA_GENERAL_AUTHORING_DTO, qaGeneralAuthoringDTO); + + request.setAttribute(QaAppConstants.TOTAL_QUESTION_COUNT, new Integer(listQuestionContentDTO.size())); + + /* start monitoring code */ + GeneralMonitoringDTO qaGeneralMonitoringDTO = new GeneralMonitoringDTO(); + + if (qaService.studentActivityOccurredGlobal(qaContent)) { + QaMonitoringAction.logger.debug("USER_EXCEPTION_NO_TOOL_SESSIONS is set to false"); + qaGeneralMonitoringDTO.setUserExceptionNoToolSessions(new Boolean(false).toString()); + } else { + QaMonitoringAction.logger.debug("USER_EXCEPTION_NO_TOOL_SESSIONS is set to true"); + qaGeneralMonitoringDTO.setUserExceptionNoToolSessions(new Boolean(true).toString()); + } + + qaGeneralMonitoringDTO.setOnlineInstructions(qaContent.getOnlineInstructions()); + qaGeneralMonitoringDTO.setOfflineInstructions(qaContent.getOfflineInstructions()); + + List attachmentList = qaService.retrieveQaUploadedFiles(qaContent); + QaMonitoringAction.logger.debug("attachmentList: " + attachmentList); + qaGeneralMonitoringDTO.setAttachmentList(attachmentList); + QaMonitoringAction.logger.debug("final qaGeneralMonitoringDTO: " + qaGeneralMonitoringDTO); + + qaGeneralMonitoringDTO.setDefineLaterInEditMode(new Boolean(true).toString()); + QaMonitoringAction.logger.debug("final generalMonitoringDTO: " + qaGeneralMonitoringDTO); + request.setAttribute(QaAppConstants.QA_GENERAL_MONITORING_DTO, qaGeneralMonitoringDTO); + + prepareReflectionData(request, qaContent, qaService, null, false, "All"); + + /* find out if there are any reflection entries, from here */ + boolean notebookEntriesExist = MonitoringUtil.notebookEntriesExist(qaService, qaContent); + QaMonitoringAction.logger.debug("notebookEntriesExist : " + notebookEntriesExist); + + if (notebookEntriesExist) { + request.setAttribute(QaAppConstants.NOTEBOOK_ENTRIES_EXIST, new Boolean(true).toString()); + + String userExceptionNoToolSessions = qaGeneralMonitoringDTO.getUserExceptionNoToolSessions(); + QaMonitoringAction.logger.debug("userExceptionNoToolSessions : " + userExceptionNoToolSessions); + + if (userExceptionNoToolSessions.equals("true")) { + QaMonitoringAction.logger.debug("there are no online student activity but there are reflections : "); + request.setAttribute(QaAppConstants.NO_SESSIONS_NOTEBOOK_ENTRIES_EXIST, new Boolean(true).toString()); } - else - { - reflectionsContainerDTO=getReflectionListForSession(qaContent, userID, qaService, currentSessionId); - } - */ - - reflectionsContainerDTO=getReflectionList(qaContent, userID, qaService); - - logger.debug("reflectionsContainerDTO: " + reflectionsContainerDTO); - request.setAttribute(REFLECTIONS_CONTAINER_DTO, reflectionsContainerDTO); - - if (exportMode) - { - request.getSession().setAttribute(REFLECTIONS_CONTAINER_DTO, reflectionsContainerDTO); - } + } else { + request.setAttribute(QaAppConstants.NOTEBOOK_ENTRIES_EXIST, new Boolean(false).toString()); } - + /* ... till here */ + MonitoringUtil.buildQaStatsDTO(request, qaService, qaContent); + MonitoringUtil.generateGroupsSessionData(request, qaService, qaContent, false); + + return mapping.findForward(QaAppConstants.LOAD_MONITORING); + } + + public void prepareReflectionData(HttpServletRequest request, QaContent qaContent, IQaService qaService, + String userID, boolean exportMode, String currentSessionId) { + QaMonitoringAction.logger.debug("starting prepareReflectionData: " + qaContent); + QaMonitoringAction.logger.debug("currentSessionId: " + currentSessionId); + QaMonitoringAction.logger.debug("userID: " + userID); + QaMonitoringAction.logger.debug("exportMode: " + exportMode); + + List reflectionsContainerDTO = new LinkedList(); + /* + * if (currentSessionId.equals("All")) { reflectionsContainerDTO=getReflectionList(qaContent, userID, + * qaService); } else { reflectionsContainerDTO=getReflectionListForSession(qaContent, userID, qaService, + * currentSessionId); } + */ + + reflectionsContainerDTO = getReflectionList(qaContent, userID, qaService); + + QaMonitoringAction.logger.debug("reflectionsContainerDTO: " + reflectionsContainerDTO); + request.setAttribute(QaAppConstants.REFLECTIONS_CONTAINER_DTO, reflectionsContainerDTO); + + if (exportMode) { + request.getSession().setAttribute(QaAppConstants.REFLECTIONS_CONTAINER_DTO, reflectionsContainerDTO); + } + } + /** * returns reflection data for all sessions * * getReflectionList + * * @param qaContent * @param userID * @param qaService * @return */ - public List getReflectionList(QaContent qaContent, String userID, IQaService qaService) - { - logger.debug("getting reflections for all sessions"); - List reflectionsContainerDTO= new LinkedList(); - if (userID == null) - { - logger.debug("all users mode"); - for (Iterator sessionIter = qaContent.getQaSessions().iterator(); sessionIter.hasNext();) - { - QaSession qaSession = (QaSession) sessionIter.next(); - logger.debug("qaSession: " + qaSession); - logger.debug("qaSession sessionId: " + qaSession.getQaSessionId()); - - for (Iterator userIter = qaSession.getQaQueUsers().iterator(); userIter.hasNext();) - { - QaQueUsr user = (QaQueUsr) userIter.next(); - logger.debug("user: " + user); + public List getReflectionList(QaContent qaContent, String userID, IQaService qaService) { + QaMonitoringAction.logger.debug("getting reflections for all sessions"); + List reflectionsContainerDTO = new LinkedList(); + if (userID == null) { + QaMonitoringAction.logger.debug("all users mode"); + for (Iterator sessionIter = qaContent.getQaSessions().iterator(); sessionIter.hasNext();) { + QaSession qaSession = (QaSession) sessionIter.next(); + QaMonitoringAction.logger.debug("qaSession: " + qaSession); + QaMonitoringAction.logger.debug("qaSession sessionId: " + qaSession.getQaSessionId()); - NotebookEntry notebookEntry = qaService.getEntry(qaSession.getQaSessionId(), - CoreNotebookConstants.NOTEBOOK_TOOL, - MY_SIGNATURE, new Integer(user.getQueUsrId().toString())); - - logger.debug("notebookEntry: " + notebookEntry); - - if (notebookEntry != null) { - ReflectionDTO reflectionDTO = new ReflectionDTO(); - reflectionDTO.setUserId(user.getQueUsrId().toString()); - reflectionDTO.setSessionId(qaSession.getQaSessionId().toString()); - reflectionDTO.setUserName(user.getFullname()); - reflectionDTO.setReflectionUid (notebookEntry.getUid().toString()); - String notebookEntryPresentable=QaUtils.replaceNewLines(notebookEntry.getEntry()); - reflectionDTO.setEntry(notebookEntryPresentable); - reflectionsContainerDTO.add(reflectionDTO); - } - } - } - } - else - { - logger.debug("single user mode"); - for (Iterator sessionIter = qaContent.getQaSessions().iterator(); sessionIter.hasNext();) - { - QaSession qaSession = (QaSession) sessionIter.next(); - logger.debug("qaSession: " + qaSession); - for (Iterator userIter = qaSession.getQaQueUsers().iterator(); userIter.hasNext();) - { - QaQueUsr user = (QaQueUsr) userIter.next(); - logger.debug("user: " + user); - - if (user.getQueUsrId().toString().equals(userID)) - { - logger.debug("getting reflection for user with userID: " + userID); - NotebookEntry notebookEntry = qaService.getEntry(qaSession.getQaSessionId(), - CoreNotebookConstants.NOTEBOOK_TOOL, - MY_SIGNATURE, new Integer(user.getQueUsrId().toString())); - - logger.debug("notebookEntry: " + notebookEntry); - - if (notebookEntry != null) { - ReflectionDTO reflectionDTO = new ReflectionDTO(); - reflectionDTO.setUserId(user.getQueUsrId().toString()); - reflectionDTO.setSessionId(qaSession.getQaSessionId().toString()); - reflectionDTO.setUserName(user.getFullname()); - reflectionDTO.setReflectionUid (notebookEntry.getUid().toString()); - String notebookEntryPresentable=QaUtils.replaceNewLines(notebookEntry.getEntry()); - reflectionDTO.setEntry(notebookEntryPresentable); - reflectionsContainerDTO.add(reflectionDTO); - } - } - } - } - } - - return reflectionsContainerDTO; + for (Iterator userIter = qaSession.getQaQueUsers().iterator(); userIter.hasNext();) { + QaQueUsr user = (QaQueUsr) userIter.next(); + QaMonitoringAction.logger.debug("user: " + user); + + NotebookEntry notebookEntry = qaService.getEntry(qaSession.getQaSessionId(), + CoreNotebookConstants.NOTEBOOK_TOOL, QaAppConstants.MY_SIGNATURE, new Integer(user + .getQueUsrId().toString())); + + QaMonitoringAction.logger.debug("notebookEntry: " + notebookEntry); + + if (notebookEntry != null) { + ReflectionDTO reflectionDTO = new ReflectionDTO(); + reflectionDTO.setUserId(user.getQueUsrId().toString()); + reflectionDTO.setSessionId(qaSession.getQaSessionId().toString()); + reflectionDTO.setUserName(user.getFullname()); + reflectionDTO.setReflectionUid(notebookEntry.getUid().toString()); + String notebookEntryPresentable = QaUtils.replaceNewLines(notebookEntry.getEntry()); + reflectionDTO.setEntry(notebookEntryPresentable); + reflectionsContainerDTO.add(reflectionDTO); + } + } + } + } else { + QaMonitoringAction.logger.debug("single user mode"); + for (Iterator sessionIter = qaContent.getQaSessions().iterator(); sessionIter.hasNext();) { + QaSession qaSession = (QaSession) sessionIter.next(); + QaMonitoringAction.logger.debug("qaSession: " + qaSession); + for (Iterator userIter = qaSession.getQaQueUsers().iterator(); userIter.hasNext();) { + QaQueUsr user = (QaQueUsr) userIter.next(); + QaMonitoringAction.logger.debug("user: " + user); + + if (user.getQueUsrId().toString().equals(userID)) { + QaMonitoringAction.logger.debug("getting reflection for user with userID: " + userID); + NotebookEntry notebookEntry = qaService.getEntry(qaSession.getQaSessionId(), + CoreNotebookConstants.NOTEBOOK_TOOL, QaAppConstants.MY_SIGNATURE, new Integer(user + .getQueUsrId().toString())); + + QaMonitoringAction.logger.debug("notebookEntry: " + notebookEntry); + + if (notebookEntry != null) { + ReflectionDTO reflectionDTO = new ReflectionDTO(); + reflectionDTO.setUserId(user.getQueUsrId().toString()); + reflectionDTO.setSessionId(qaSession.getQaSessionId().toString()); + reflectionDTO.setUserName(user.getFullname()); + reflectionDTO.setReflectionUid(notebookEntry.getUid().toString()); + String notebookEntryPresentable = QaUtils.replaceNewLines(notebookEntry.getEntry()); + reflectionDTO.setEntry(notebookEntryPresentable); + reflectionsContainerDTO.add(reflectionDTO); + } + } + } + } + } + + return reflectionsContainerDTO; } - + /** * returns reflection data for a specific session * * getReflectionListForSession(QaContent qaContent, String userID, IQaService qaService, String currentSessionId) + * * @param qaContent * @param userID * @param qaService * @param currentSessionId * @return */ - public List getReflectionListForSession(QaContent qaContent, String userID, IQaService qaService, String currentSessionId) - { - logger.debug("getting reflections for a specific session"); - logger.debug("currentSessionId: " + currentSessionId); - - List reflectionsContainerDTO= new LinkedList(); - if (userID == null) - { - logger.debug("all users mode"); - for (Iterator sessionIter = qaContent.getQaSessions().iterator(); sessionIter.hasNext();) - { - QaSession qaSession = (QaSession) sessionIter.next(); - logger.debug("qaSession: " + qaSession); - logger.debug("qaSession sessionId: " + qaSession.getQaSessionId()); - - if (currentSessionId.equals(qaSession.getQaSessionId())) - { - - for (Iterator userIter = qaSession.getQaQueUsers().iterator(); userIter.hasNext();) - { - QaQueUsr user = (QaQueUsr) userIter.next(); - logger.debug("user: " + user); + public List getReflectionListForSession(QaContent qaContent, String userID, IQaService qaService, + String currentSessionId) { + QaMonitoringAction.logger.debug("getting reflections for a specific session"); + QaMonitoringAction.logger.debug("currentSessionId: " + currentSessionId); - NotebookEntry notebookEntry = qaService.getEntry(qaSession.getQaSessionId(), - CoreNotebookConstants.NOTEBOOK_TOOL, - MY_SIGNATURE, new Integer(user.getQueUsrId().toString())); - - logger.debug("notebookEntry: " + notebookEntry); - - if (notebookEntry != null) { - ReflectionDTO reflectionDTO = new ReflectionDTO(); - reflectionDTO.setUserId(user.getQueUsrId().toString()); - reflectionDTO.setSessionId(qaSession.getQaSessionId().toString()); - reflectionDTO.setUserName(user.getFullname()); - reflectionDTO.setReflectionUid (notebookEntry.getUid().toString()); - String notebookEntryPresentable=QaUtils.replaceNewLines(notebookEntry.getEntry()); - reflectionDTO.setEntry(notebookEntryPresentable); - reflectionsContainerDTO.add(reflectionDTO); - } - } - } - } - } - else - { - logger.debug("single user mode"); - for (Iterator sessionIter = qaContent.getQaSessions().iterator(); sessionIter.hasNext();) - { - QaSession qaSession = (QaSession) sessionIter.next(); - logger.debug("qaSession: " + qaSession); - - if (currentSessionId.equals(qaSession.getQaSessionId())) - { - for (Iterator userIter = qaSession.getQaQueUsers().iterator(); userIter.hasNext();) - { - QaQueUsr user = (QaQueUsr) userIter.next(); - logger.debug("user: " + user); - - if (user.getQueUsrId().toString().equals(userID)) - { - logger.debug("getting reflection for user with userID: " + userID); - NotebookEntry notebookEntry = qaService.getEntry(qaSession.getQaSessionId(), - CoreNotebookConstants.NOTEBOOK_TOOL, - MY_SIGNATURE, new Integer(user.getQueUsrId().toString())); - - logger.debug("notebookEntry: " + notebookEntry); - - if (notebookEntry != null) { - ReflectionDTO reflectionDTO = new ReflectionDTO(); - reflectionDTO.setUserId(user.getQueUsrId().toString()); - reflectionDTO.setSessionId(qaSession.getQaSessionId().toString()); - reflectionDTO.setUserName(user.getFullname()); - reflectionDTO.setReflectionUid (notebookEntry.getUid().toString()); - String notebookEntryPresentable=QaUtils.replaceNewLines(notebookEntry.getEntry()); - reflectionDTO.setEntry(notebookEntryPresentable); - reflectionsContainerDTO.add(reflectionDTO); - } - } - } - - } - } - } - - return reflectionsContainerDTO; + List reflectionsContainerDTO = new LinkedList(); + if (userID == null) { + QaMonitoringAction.logger.debug("all users mode"); + for (Iterator sessionIter = qaContent.getQaSessions().iterator(); sessionIter.hasNext();) { + QaSession qaSession = (QaSession) sessionIter.next(); + QaMonitoringAction.logger.debug("qaSession: " + qaSession); + QaMonitoringAction.logger.debug("qaSession sessionId: " + qaSession.getQaSessionId()); + + if (currentSessionId.equals(qaSession.getQaSessionId())) { + + for (Iterator userIter = qaSession.getQaQueUsers().iterator(); userIter.hasNext();) { + QaQueUsr user = (QaQueUsr) userIter.next(); + QaMonitoringAction.logger.debug("user: " + user); + + NotebookEntry notebookEntry = qaService.getEntry(qaSession.getQaSessionId(), + CoreNotebookConstants.NOTEBOOK_TOOL, QaAppConstants.MY_SIGNATURE, new Integer(user + .getQueUsrId().toString())); + + QaMonitoringAction.logger.debug("notebookEntry: " + notebookEntry); + + if (notebookEntry != null) { + ReflectionDTO reflectionDTO = new ReflectionDTO(); + reflectionDTO.setUserId(user.getQueUsrId().toString()); + reflectionDTO.setSessionId(qaSession.getQaSessionId().toString()); + reflectionDTO.setUserName(user.getFullname()); + reflectionDTO.setReflectionUid(notebookEntry.getUid().toString()); + String notebookEntryPresentable = QaUtils.replaceNewLines(notebookEntry.getEntry()); + reflectionDTO.setEntry(notebookEntryPresentable); + reflectionsContainerDTO.add(reflectionDTO); + } + } + } + } + } else { + QaMonitoringAction.logger.debug("single user mode"); + for (Iterator sessionIter = qaContent.getQaSessions().iterator(); sessionIter.hasNext();) { + QaSession qaSession = (QaSession) sessionIter.next(); + QaMonitoringAction.logger.debug("qaSession: " + qaSession); + + if (currentSessionId.equals(qaSession.getQaSessionId())) { + for (Iterator userIter = qaSession.getQaQueUsers().iterator(); userIter.hasNext();) { + QaQueUsr user = (QaQueUsr) userIter.next(); + QaMonitoringAction.logger.debug("user: " + user); + + if (user.getQueUsrId().toString().equals(userID)) { + QaMonitoringAction.logger.debug("getting reflection for user with userID: " + userID); + NotebookEntry notebookEntry = qaService.getEntry(qaSession.getQaSessionId(), + CoreNotebookConstants.NOTEBOOK_TOOL, QaAppConstants.MY_SIGNATURE, new Integer(user + .getQueUsrId().toString())); + + QaMonitoringAction.logger.debug("notebookEntry: " + notebookEntry); + + if (notebookEntry != null) { + ReflectionDTO reflectionDTO = new ReflectionDTO(); + reflectionDTO.setUserId(user.getQueUsrId().toString()); + reflectionDTO.setSessionId(qaSession.getQaSessionId().toString()); + reflectionDTO.setUserName(user.getFullname()); + reflectionDTO.setReflectionUid(notebookEntry.getUid().toString()); + String notebookEntryPresentable = QaUtils.replaceNewLines(notebookEntry.getEntry()); + reflectionDTO.setEntry(notebookEntryPresentable); + reflectionsContainerDTO.add(reflectionDTO); + } + } + } + + } + } + } + + return reflectionsContainerDTO; } - + } \ No newline at end of file Index: lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/QaStarterAction.java =================================================================== diff -u -r06fc623e39b864fa777669c1a52bd8d6ee19b23e -r0af4ed13b963a588f3499b080801863d57f8ad95 --- lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/QaStarterAction.java (.../QaStarterAction.java) (revision 06fc623e39b864fa777669c1a52bd8d6ee19b23e) +++ lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/QaStarterAction.java (.../QaStarterAction.java) (revision 0af4ed13b963a588f3499b080801863d57f8ad95) @@ -55,81 +55,83 @@ * The tool content id for this content is created as part of the installation process. * Whenever a tool is asked for some tool content that does not exist, it should supply the default tool content. * This will allow the system to render the normal screen, albeit with useless information, rather than crashing. -*/ + */ /** -* -* Authoring URL: -* -* The tool must supply an authoring module, which will be called to create new content or edit existing content. It will be called by an authoring URL using the following format: ????? -* The initial data displayed on the authoring screen for a new tool content id may be the default tool content. -* -* Authoring UI data consists of general Activity data fields and the Tool specific data fields. -* The authoring interface will have three tabs. The mandatory (and suggested) fields are given. Each tool will have its own fields which it will add on any of the three tabs, as appropriate to the tabs' function. -* -* Basic: Displays the basic set of fields that are needed for the tool, and it could be expected that a new LAMS user would use. Mandatory fields: Title, Instructions. -* Advanced: Displays the extra fields that would be used by experienced LAMS users. Optional fields: Lock On Finish, Make Responses Anonymous -* Instructions: Displays the "instructions" fields for teachers. Mandatory fields: Online instructions, Offline instructions, Document upload. -* The "Define Later" and "Run Offline" options are set on the Flash authoring part, and not on the tool's authoring screens. -* -* Preview The tool must be able to show the specified content as if it was running in a lesson. It will be the learner url with tool access mode set to ToolAccessMode.AUTHOR. -* Export The tool must be able to export its tool content for part of the overall learning design export. -* -* The format of the serialization for export is XML. Tool will define extra namespace inside the element to add a new data element (type). Inside the data element, it can further define more structures and types as it seems fit. -* The data elements must be "version" aware. The data elements must be "type" aware if they are to be shared between Tools. -* -* - - - - + * + * Authoring URL: + * + * The tool must supply an authoring module, which will be called to create new content or edit existing content. It will be called by an authoring URL using the following format: ????? + * The initial data displayed on the authoring screen for a new tool content id may be the default tool content. + * + * Authoring UI data consists of general Activity data fields and the Tool specific data fields. + * The authoring interface will have three tabs. The mandatory (and suggested) fields are given. Each tool will have its own fields which it will add on any of the three tabs, as appropriate to the tabs' function. + * + * Basic: Displays the basic set of fields that are needed for the tool, and it could be expected that a new LAMS user would use. Mandatory fields: Title, Instructions. + * Advanced: Displays the extra fields that would be used by experienced LAMS users. Optional fields: Lock On Finish, Make Responses Anonymous + * Instructions: Displays the "instructions" fields for teachers. Mandatory fields: Online instructions, Offline instructions, Document upload. + * The "Define Later" and "Run Offline" options are set on the Flash authoring part, and not on the tool's authoring screens. + * + * Preview The tool must be able to show the specified content as if it was running in a lesson. It will be the learner url with tool access mode set to ToolAccessMode.AUTHOR. + * Export The tool must be able to export its tool content for part of the overall learning design export. + * + * The format of the serialization for export is XML. Tool will define extra namespace inside the element to add a new data element (type). Inside the data element, it can further define more structures and types as it seems fit. + * The data elements must be "version" aware. The data elements must be "type" aware if they are to be shared between Tools. + * + * + + + + - - - + - - - + - + -* -*/ + + + * + */ + /* $$Id$$ */ package org.lamsfoundation.lams.tool.qa.web; + import java.io.IOException; import java.util.ArrayList; import java.util.Iterator; import java.util.LinkedList; import java.util.List; import java.util.Map; +import java.util.SortedSet; import java.util.TreeMap; +import java.util.TreeSet; import javax.servlet.ServletException; import javax.servlet.http.HttpServletRequest; @@ -146,508 +148,629 @@ 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.QaCondition; import org.lamsfoundation.lams.tool.qa.QaContent; import org.lamsfoundation.lams.tool.qa.QaGeneralAuthoringDTO; import org.lamsfoundation.lams.tool.qa.QaQueContent; import org.lamsfoundation.lams.tool.qa.QaQuestionContentDTO; 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.tool.qa.util.QaConditionComparator; import org.lamsfoundation.lams.util.WebUtil; import org.lamsfoundation.lams.web.util.AttributeNames; import org.lamsfoundation.lams.web.util.SessionMap; /** * * @author Ozgur Demirtas - * - * TODO To change the template for this generated type comment go to - * Window - Preferences - Java - Code Style - Code Templates * + * TODO To change the template for this generated type comment go to Window - + * Preferences - Java - Code Style - Code Templates + * * A Map data structure is used to present the UI. */ public class QaStarterAction extends Action implements QaAppConstants { - static Logger logger = Logger.getLogger(QaStarterAction.class.getName()); - - public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) - throws IOException, ServletException, QaApplicationException { - - QaUtils.cleanUpSessionAbsolute(request); - logger.debug("init authoring mode."); - QaAuthoringForm qaAuthoringForm = (QaAuthoringForm) form; - logger.debug("qaAuthoringForm: " + qaAuthoringForm); - - String contentFolderID = WebUtil.readStrParam(request, AttributeNames.PARAM_CONTENT_FOLDER_ID); - logger.debug("contentFolderID: " + contentFolderID); - qaAuthoringForm.setContentFolderID(contentFolderID); - - QaGeneralAuthoringDTO qaGeneralAuthoringDTO= new QaGeneralAuthoringDTO(); - qaGeneralAuthoringDTO.setContentFolderID(contentFolderID); - - Map mapQuestionContent= new TreeMap(new QaComparator()); - logger.debug("mapQuestionContent: " + mapQuestionContent); - - qaAuthoringForm.resetRadioBoxes(); - - IQaService qaService =null; - if ((getServlet() == null) || (getServlet().getServletContext() == null)) - { - logger.debug("obtaining qaService from the form"); - qaService=qaAuthoringForm.getQaService(); - } - else - { - logger.debug("obtaining qaService via proxy"); - qaService =QaServiceProxy.getQaService(getServlet().getServletContext()); - } - logger.debug("qaService: " + qaService); - - qaGeneralAuthoringDTO.setCurrentTab("1"); - logger.debug("setting currrent tab to 1:"); - - - qaGeneralAuthoringDTO.setMonitoringOriginatedDefineLater(new Boolean(false).toString()); - String servletPath=request.getServletPath(); - logger.debug("getServletPath: "+ servletPath); - String requestedModule=null; - if (servletPath.indexOf("authoringStarter") > 0) - { - logger.debug("request is for authoring module"); - qaGeneralAuthoringDTO.setActiveModule(AUTHORING); - qaGeneralAuthoringDTO.setDefineLaterInEditMode(new Boolean(true).toString()); - qaGeneralAuthoringDTO.setShowAuthoringTabs(new Boolean(true).toString()); - qaAuthoringForm.setActiveModule(AUTHORING); - requestedModule=AUTHORING; - } - else - { - logger.debug("request is for define later module either direcly from define later url or monitoring url"); - qaGeneralAuthoringDTO.setActiveModule(DEFINE_LATER); - qaGeneralAuthoringDTO.setDefineLaterInEditMode(new Boolean(true).toString()); - qaGeneralAuthoringDTO.setShowAuthoringTabs(new Boolean(false).toString()); - qaAuthoringForm.setActiveModule(DEFINE_LATER); - requestedModule=DEFINE_LATER; - - if (servletPath.indexOf("monitoring") > 0) - { - logger.debug("request is from monitoring url."); - qaGeneralAuthoringDTO.setMonitoringOriginatedDefineLater(new Boolean(true).toString()); - } - } - logger.debug("requestedModule: " + requestedModule); - qaGeneralAuthoringDTO.setRequestedModule(requestedModule); + static Logger logger = Logger.getLogger(QaStarterAction.class.getName()); - - /* in development this needs to be called only once. */ - /* QaUtils.configureContentRepository(request); */ - - String sourceMcStarter = (String) request.getAttribute(SOURCE_MC_STARTER); - logger.debug("sourceMcStarter: " + sourceMcStarter); - - boolean validateSignature=readSignature(request,mapping, qaService, qaGeneralAuthoringDTO, qaAuthoringForm); - logger.debug("validateSignature: " + validateSignature); - if (validateSignature == false) - { - logger.debug("error during validation"); - } - - /* mark the http session as an authoring activity */ - qaGeneralAuthoringDTO.setTargetMode(TARGET_MODE_AUTHORING); - - /* - * find out whether the request is coming from monitoring module for EditActivity tab or from authoring environment url - */ - logger.debug("no problems getting the default content, will render authoring screen"); - String strToolContentID=""; - /*the authoring url must be passed a tool content id*/ - strToolContentID=request.getParameter(AttributeNames.PARAM_TOOL_CONTENT_ID); - logger.debug("strToolContentID: " + strToolContentID); - qaGeneralAuthoringDTO.setToolContentID(strToolContentID); - - SessionMap sessionMap = new SessionMap(); - List sequentialCheckedCa= new LinkedList(); - sessionMap.put(ATTACHMENT_LIST_KEY, new ArrayList()); - sessionMap.put(DELETED_ATTACHMENT_LIST_KEY, new ArrayList()); - sessionMap.put(ACTIVITY_TITLE_KEY, ""); - sessionMap.put(ACTIVITY_INSTRUCTIONS_KEY, ""); - qaAuthoringForm.setHttpSessionID(sessionMap.getSessionID()); - qaGeneralAuthoringDTO.setHttpSessionID(sessionMap.getSessionID()); - - String defaultContentId=null; - //pay attention here: remove request.getSession().getAttribute(TOOL_CONTENT_ID); - if (strToolContentID == null) - { - /*it is possible that the original request for authoring module is coming from monitoring url which keeps the - TOOL_CONTENT_ID in the session*/ - logger.debug("strToolContentID is null, handle this"); - - Long toolContentID =(Long) request.getSession().getAttribute(TOOL_CONTENT_ID); - logger.debug("toolContentID: " + toolContentID); - if (toolContentID != null) - { - strToolContentID= toolContentID.toString(); - logger.debug("cached strToolContentID from the session: " + strToolContentID); - } - else - { - logger.debug("we should IDEALLY not arrive here. The TOOL_CONTENT_ID is NOT available from the url or the session."); - /*use default content instead of giving a warning*/ - defaultContentId=qaAuthoringForm.getDefaultContentIdStr(); - logger.debug("using MCQ defaultContentId: " + defaultContentId); - strToolContentID=defaultContentId; - } - } - logger.debug("final strToolContentID: " + strToolContentID); - - if ((strToolContentID == null) || (strToolContentID.equals(""))) - { - QaUtils.cleanUpSessionAbsolute(request); - logger.debug("forwarding to: " + ERROR_LIST); - return (mapping.findForward(ERROR_LIST)); - } + @Override + public ActionForward execute(ActionMapping mapping, ActionForm form, + HttpServletRequest request, HttpServletResponse response) + throws IOException, ServletException, QaApplicationException { - qaAuthoringForm.setToolContentID(strToolContentID); + QaUtils.cleanUpSessionAbsolute(request); + QaStarterAction.logger.debug("init authoring mode."); + QaAuthoringForm qaAuthoringForm = (QaAuthoringForm) form; + QaStarterAction.logger.debug("qaAuthoringForm: " + qaAuthoringForm); - /* - * 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. - */ - - String defaultContentIdStr=null; - QaContent qaContent=null; - if (!existsContent(new Long(strToolContentID).longValue(), qaService)) - { - logger.debug("getting default content"); - /*fetch default content*/ - defaultContentIdStr=qaAuthoringForm.getDefaultContentIdStr(); - logger.debug("defaultContentIdStr:" + defaultContentIdStr); - qaContent=retrieveContent(request, mapping, qaAuthoringForm, mapQuestionContent, - new Long(defaultContentIdStr).longValue(), true, qaService, qaGeneralAuthoringDTO, sessionMap); - - logger.debug("post retrive content :" + sessionMap); + String contentFolderID = WebUtil.readStrParam(request, + AttributeNames.PARAM_CONTENT_FOLDER_ID); + QaStarterAction.logger.debug("contentFolderID: " + contentFolderID); + qaAuthoringForm.setContentFolderID(contentFolderID); - } - else - { - logger.debug("getting existing content"); - /* it is possible that the content is in use by learners.*/ - qaContent=qaService.loadQa(new Long(strToolContentID).longValue()); - logger.debug("qaContent: " + qaContent); - if (qaService.studentActivityOccurredGlobal(qaContent)) - { - QaUtils.cleanUpSessionAbsolute(request); - logger.debug("student activity occurred on this content:" + qaContent); - persistError(request, "error.content.inUse"); - logger.debug("add error.content.inUse to ActionMessages."); - return (mapping.findForward(ERROR_LIST)); - } - qaContent=retrieveContent(request, mapping, qaAuthoringForm, mapQuestionContent, - new Long(strToolContentID).longValue(),false, qaService, qaGeneralAuthoringDTO, sessionMap); - - logger.debug("post retrive content :" + sessionMap); - } - - logger.debug("qaGeneralAuthoringDTO.getOnlineInstructions() :" + qaGeneralAuthoringDTO.getOnlineInstructions()); - logger.debug("qaGeneralAuthoringDTO.getOfflineInstructions():" + qaGeneralAuthoringDTO.getOfflineInstructions()); - - if ((qaGeneralAuthoringDTO.getOnlineInstructions() == null) || (qaGeneralAuthoringDTO.getOnlineInstructions().length() == 0)) - { - qaGeneralAuthoringDTO.setOnlineInstructions(DEFAULT_ONLINE_INST); - qaAuthoringForm.setOnlineInstructions(DEFAULT_ONLINE_INST); - sessionMap.put(ONLINE_INSTRUCTIONS_KEY, DEFAULT_ONLINE_INST); + QaGeneralAuthoringDTO qaGeneralAuthoringDTO = new QaGeneralAuthoringDTO(); + qaGeneralAuthoringDTO.setContentFolderID(contentFolderID); + + Map mapQuestionContent = new TreeMap(new QaComparator()); + QaStarterAction.logger.debug("mapQuestionContent: " + + mapQuestionContent); + + qaAuthoringForm.resetRadioBoxes(); + + IQaService qaService = null; + if (getServlet() == null || getServlet().getServletContext() == null) { + QaStarterAction.logger.debug("obtaining qaService from the form"); + qaService = qaAuthoringForm.getQaService(); + } else { + QaStarterAction.logger.debug("obtaining qaService via proxy"); + qaService = QaServiceProxy.getQaService(getServlet() + .getServletContext()); + } + QaStarterAction.logger.debug("qaService: " + qaService); + + qaGeneralAuthoringDTO.setCurrentTab("1"); + QaStarterAction.logger.debug("setting currrent tab to 1:"); + + qaGeneralAuthoringDTO.setMonitoringOriginatedDefineLater(new Boolean( + false).toString()); + String servletPath = request.getServletPath(); + QaStarterAction.logger.debug("getServletPath: " + servletPath); + String requestedModule = null; + if (servletPath.indexOf("authoringStarter") > 0) { + QaStarterAction.logger.debug("request is for authoring module"); + qaGeneralAuthoringDTO.setActiveModule(QaAppConstants.AUTHORING); + qaGeneralAuthoringDTO.setDefineLaterInEditMode(new Boolean(true) + .toString()); + qaGeneralAuthoringDTO.setShowAuthoringTabs(new Boolean(true) + .toString()); + qaAuthoringForm.setActiveModule(QaAppConstants.AUTHORING); + requestedModule = QaAppConstants.AUTHORING; + } else { + QaStarterAction.logger + .debug("request is for define later module either direcly from define later url or monitoring url"); + qaGeneralAuthoringDTO.setActiveModule(QaAppConstants.DEFINE_LATER); + qaGeneralAuthoringDTO.setDefineLaterInEditMode(new Boolean(true) + .toString()); + qaGeneralAuthoringDTO.setShowAuthoringTabs(new Boolean(false) + .toString()); + qaAuthoringForm.setActiveModule(QaAppConstants.DEFINE_LATER); + requestedModule = QaAppConstants.DEFINE_LATER; + + if (servletPath.indexOf("monitoring") > 0) { + QaStarterAction.logger + .debug("request is from monitoring url."); + qaGeneralAuthoringDTO + .setMonitoringOriginatedDefineLater(new Boolean(true) + .toString()); } - - if ((qaGeneralAuthoringDTO.getOfflineInstructions() == null) || (qaGeneralAuthoringDTO.getOfflineInstructions().length() == 0)) - { - qaGeneralAuthoringDTO.setOfflineInstructions(DEFAULT_OFFLINE_INST); - qaAuthoringForm.setOfflineInstructions(DEFAULT_OFFLINE_INST); - sessionMap.put(OFFLINE_INSTRUCTIONS_KEY, DEFAULT_OFFLINE_INST); - } + } + QaStarterAction.logger.debug("requestedModule: " + requestedModule); + qaGeneralAuthoringDTO.setRequestedModule(requestedModule); - - logger.debug("final qaGeneralAuthoringDTO: " + qaGeneralAuthoringDTO); - logger.debug("will return to jsp with: " + sourceMcStarter); - String destination=QaUtils.getDestination(sourceMcStarter, requestedModule); - logger.debug("destination: " + destination); - - Map mapQuestionContentLocal=qaGeneralAuthoringDTO.getMapQuestionContent(); - logger.debug("mapQuestionContentLocal: " + mapQuestionContentLocal); - - logger.debug("mapQuestionContent: " + mapQuestionContent); - sessionMap.put(MAP_QUESTION_CONTENT_KEY, mapQuestionContent); - - logger.debug("persisting sessionMap into session: " + sessionMap); - request.getSession().setAttribute(sessionMap.getSessionID(), sessionMap); - - logger.debug("before fwding to jsp, qaAuthoringForm : " + qaAuthoringForm); - logger.debug("final qaGeneralAuthoringDTO: " + qaGeneralAuthoringDTO); - request.setAttribute(QA_GENERAL_AUTHORING_DTO, qaGeneralAuthoringDTO); - - return (mapping.findForward(destination)); - } - - - - /** - * retrives the existing content information from the db and prepares the data for presentation purposes. - * ActionForward retrieveExistingContent(HttpServletRequest request, ActionMapping mapping, QaAuthoringForm qaAuthoringForm, Map mapQuestionContent, long toolContentID) - * - * @param request - * @param mapping - * @param qaAuthoringForm - * @param mapQuestionContent - * @param toolContentID - * @return ActionForward - */ - protected QaContent retrieveContent(HttpServletRequest request, ActionMapping mapping, QaAuthoringForm qaAuthoringForm, - Map mapQuestionContent, long toolContentID, boolean isDefaultContent, IQaService qaService, - QaGeneralAuthoringDTO qaGeneralAuthoringDTO, SessionMap sessionMap) - { - logger.debug("starting retrieveContent: " + qaService); - logger.debug("toolContentID: " + toolContentID); - logger.debug("isDefaultContent: " + isDefaultContent); + /* in development this needs to be called only once. */ + /* QaUtils.configureContentRepository(request); */ - logger.debug("getting content with id:" + toolContentID); - QaContent qaContent = qaService.retrieveQa(toolContentID); - logger.debug("QaContent: " + qaContent); - - QaUtils.populateAuthoringDTO(request, qaContent, qaGeneralAuthoringDTO); - - qaAuthoringForm.setUsernameVisible(qaContent.isUsernameVisible()?"1":"0"); - qaAuthoringForm.setShowOtherAnswers(qaContent.isShowOtherAnswers()?"1":"0"); - qaAuthoringForm.setSynchInMonitor(qaContent.isSynchInMonitor()?"1":"0"); - qaAuthoringForm.setQuestionsSequenced(qaContent.isQuestionsSequenced()?"1":"0"); - qaAuthoringForm.setLockWhenFinished(qaContent.isLockWhenFinished()?"1":"0"); - - qaGeneralAuthoringDTO.setReflect(qaContent.isReflect()?"1":"0"); - - logger.debug("QaContent isReflect: " + qaContent.isReflect()); - qaAuthoringForm.setReflect(qaContent.isReflect()?"1":"0"); - - qaAuthoringForm.setReflectionSubject(qaContent.getReflectionSubject()); - qaGeneralAuthoringDTO.setReflectionSubject(qaContent.getReflectionSubject()); - - List attachmentList = qaService.retrieveQaUploadedFiles(qaContent); - qaGeneralAuthoringDTO.setAttachmentList(attachmentList); - qaGeneralAuthoringDTO.setDeletedAttachmentList(new ArrayList()); + String sourceMcStarter = (String) request + .getAttribute(QaAppConstants.SOURCE_MC_STARTER); + QaStarterAction.logger.debug("sourceMcStarter: " + sourceMcStarter); - sessionMap.put(ATTACHMENT_LIST_KEY, attachmentList); - sessionMap.put(DELETED_ATTACHMENT_LIST_KEY, new ArrayList()); + boolean validateSignature = readSignature(request, mapping, qaService, + qaGeneralAuthoringDTO, qaAuthoringForm); + QaStarterAction.logger + .debug("validateSignature: " + validateSignature); + if (validateSignature == false) { + QaStarterAction.logger.debug("error during validation"); + } + /* mark the http session as an authoring activity */ + qaGeneralAuthoringDTO + .setTargetMode(QaAppConstants.TARGET_MODE_AUTHORING); - qaGeneralAuthoringDTO.setIsDefineLater(new Boolean(qaContent.isDefineLater()).toString()); - - qaGeneralAuthoringDTO.setActivityTitle(qaContent.getTitle()); - qaAuthoringForm.setTitle(qaContent.getTitle()); + /* + * find out whether the request is coming from monitoring module for + * EditActivity tab or from authoring environment url + */ + QaStarterAction.logger + .debug("no problems getting the default content, will render authoring screen"); + String strToolContentID = ""; + /* the authoring url must be passed a tool content id */ + strToolContentID = request + .getParameter(AttributeNames.PARAM_TOOL_CONTENT_ID); + QaStarterAction.logger.debug("strToolContentID: " + strToolContentID); + qaGeneralAuthoringDTO.setToolContentID(strToolContentID); - qaGeneralAuthoringDTO.setActivityInstructions( qaContent.getInstructions()); - qaAuthoringForm.setInstructions(qaContent.getInstructions()); - - sessionMap.put(ACTIVITY_TITLE_KEY, qaGeneralAuthoringDTO.getActivityTitle()); - sessionMap.put(ACTIVITY_INSTRUCTIONS_KEY, qaGeneralAuthoringDTO.getActivityInstructions()); + SessionMap sessionMap = new SessionMap(); + List sequentialCheckedCa = new LinkedList(); + sessionMap.put(QaAppConstants.ATTACHMENT_LIST_KEY, new ArrayList()); + sessionMap.put(QaAppConstants.DELETED_ATTACHMENT_LIST_KEY, + new ArrayList()); + sessionMap.put(QaAppConstants.ACTIVITY_TITLE_KEY, ""); + sessionMap.put(QaAppConstants.ACTIVITY_INSTRUCTIONS_KEY, ""); + qaAuthoringForm.setHttpSessionID(sessionMap.getSessionID()); + qaGeneralAuthoringDTO.setHttpSessionID(sessionMap.getSessionID()); - - List listQuestionContentDTO= new LinkedList(); - + String defaultContentId = null; + // pay attention here: remove + // request.getSession().getAttribute(TOOL_CONTENT_ID); + if (strToolContentID == null) { /* - * get the existing question content - */ - logger.debug("setting content data from the db"); - mapQuestionContent.clear(); - Iterator queIterator=qaContent.getQaQueContents().iterator(); - Long mapIndex=new Long(1); - logger.debug("mapQuestionContent: " + mapQuestionContent); - while (queIterator.hasNext()) - { - QaQuestionContentDTO qaQuestionContentDTO=new QaQuestionContentDTO(); - - QaQueContent qaQueContent=(QaQueContent) queIterator.next(); - if (qaQueContent != null) - { - logger.debug("question: " + qaQueContent.getQuestion()); - logger.debug("displayorder: " + new Integer(qaQueContent.getDisplayOrder()).toString()); - logger.debug("feedback: " + qaQueContent.getFeedback()); - - mapQuestionContent.put(mapIndex.toString(),qaQueContent.getQuestion()); - - qaQuestionContentDTO.setQuestion(qaQueContent.getQuestion()); - qaQuestionContentDTO.setDisplayOrder(new Integer(qaQueContent.getDisplayOrder()).toString()); - qaQuestionContentDTO.setFeedback(qaQueContent.getFeedback()); - listQuestionContentDTO.add(qaQuestionContentDTO); - /** - * make the first entry the default(first) one for jsp - */ - if (mapIndex.longValue() == 1) - qaGeneralAuthoringDTO.setDefaultQuestionContent(qaQueContent.getQuestion()); - mapIndex=new Long(mapIndex.longValue()+1); - } - } - logger.debug("Map initialized with existing contentid to: " + mapQuestionContent); - - request.setAttribute(TOTAL_QUESTION_COUNT, new Integer(mapQuestionContent.size())); - - - logger.debug("listQuestionContentDTO: " + listQuestionContentDTO); - request.setAttribute(LIST_QUESTION_CONTENT_DTO,listQuestionContentDTO); - sessionMap.put(LIST_QUESTION_CONTENT_DTO_KEY, listQuestionContentDTO); - - - if (isDefaultContent) - { - logger.debug("overwriting default question."); - qaGeneralAuthoringDTO.setDefaultQuestionContent("Sample Question 1?"); - - } - - logger.debug("mapQuestionContent is:" + mapQuestionContent); - qaGeneralAuthoringDTO.setMapQuestionContent(mapQuestionContent); + * it is possible that the original request for authoring module is + * coming from monitoring url which keeps the TOOL_CONTENT_ID in the + * session + */ + QaStarterAction.logger + .debug("strToolContentID is null, handle this"); - - logger.debug("qaContent.getOnlineInstructions():" + qaContent.getOnlineInstructions()); - logger.debug("qaContent.getOfflineInstructions():" + qaContent.getOfflineInstructions()); - qaGeneralAuthoringDTO.setOnlineInstructions(qaContent.getOnlineInstructions()); - qaGeneralAuthoringDTO.setOfflineInstructions(qaContent.getOfflineInstructions()); - - qaAuthoringForm.setOnlineInstructions(qaContent.getOnlineInstructions()); - qaAuthoringForm.setOfflineInstructions(qaContent.getOfflineInstructions()); - sessionMap.put(ONLINE_INSTRUCTIONS_KEY, qaContent.getOnlineInstructions()); - sessionMap.put(OFFLINE_INSTRUCTIONS_KEY, qaContent.getOfflineInstructions()); - - logger.debug("ACTIVITY_TITLE_KEY set to:" + sessionMap.get(ACTIVITY_TITLE_KEY )); - - qaAuthoringForm.resetUserAction(); - logger.debug("returning qaContent:" + qaContent); - return qaContent; + Long toolContentID = (Long) request.getSession().getAttribute( + QaAppConstants.TOOL_CONTENT_ID); + QaStarterAction.logger.debug("toolContentID: " + toolContentID); + if (toolContentID != null) { + strToolContentID = toolContentID.toString(); + QaStarterAction.logger + .debug("cached strToolContentID from the session: " + + strToolContentID); + } else { + QaStarterAction.logger + .debug("we should IDEALLY not arrive here. The TOOL_CONTENT_ID is NOT available from the url or the session."); + /* use default content instead of giving a warning */ + defaultContentId = qaAuthoringForm.getDefaultContentIdStr(); + QaStarterAction.logger.debug("using MCQ defaultContentId: " + + defaultContentId); + strToolContentID = defaultContentId; + } } + QaStarterAction.logger.debug("final strToolContentID: " + + strToolContentID); - - /** - * each tool has a signature. QA tool's signature is stored in MY_SIGNATURE. The default tool content id and - * other depending content ids are obtained in this method. - * if all the default content has been setup properly the method persists DEFAULT_CONTENT_ID in the session. + if (strToolContentID == null || strToolContentID.equals("")) { + QaUtils.cleanUpSessionAbsolute(request); + QaStarterAction.logger.debug("forwarding to: " + + QaAppConstants.ERROR_LIST); + return mapping.findForward(QaAppConstants.ERROR_LIST); + } + + qaAuthoringForm.setToolContentID(strToolContentID); + + /* + * 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. * - * readSignature(HttpServletRequest request, ActionMapping mapping) - * @param request - * @param mapping - * @return ActionForward + * 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. */ - public boolean readSignature(HttpServletRequest request, ActionMapping mapping, IQaService qaService, - QaGeneralAuthoringDTO qaGeneralAuthoringDTO, QaAuthoringForm qaAuthoringForm) - { - logger.debug("qaService: " + qaService); - /* - * retrieve the default content id based on tool signature + + String defaultContentIdStr = null; + QaContent qaContent = null; + if (!existsContent(new Long(strToolContentID).longValue(), qaService)) { + QaStarterAction.logger.debug("getting default content"); + /* fetch default content */ + defaultContentIdStr = qaAuthoringForm.getDefaultContentIdStr(); + QaStarterAction.logger.debug("defaultContentIdStr:" + + defaultContentIdStr); + qaContent = retrieveContent(request, mapping, qaAuthoringForm, + mapQuestionContent, new Long(defaultContentIdStr) + .longValue(), true, qaService, + qaGeneralAuthoringDTO, sessionMap); + + QaStarterAction.logger.debug("post retrive content :" + sessionMap); + + } else { + QaStarterAction.logger.debug("getting existing content"); + /* it is possible that the content is in use by learners. */ + qaContent = qaService + .loadQa(new Long(strToolContentID).longValue()); + QaStarterAction.logger.debug("qaContent: " + qaContent); + if (qaService.studentActivityOccurredGlobal(qaContent)) { + QaUtils.cleanUpSessionAbsolute(request); + QaStarterAction.logger + .debug("student activity occurred on this content:" + + qaContent); + persistError(request, "error.content.inUse"); + QaStarterAction.logger + .debug("add error.content.inUse to ActionMessages."); + return mapping.findForward(QaAppConstants.ERROR_LIST); + } + qaContent = retrieveContent(request, mapping, qaAuthoringForm, + mapQuestionContent, new Long(strToolContentID).longValue(), + false, qaService, qaGeneralAuthoringDTO, sessionMap); + + QaStarterAction.logger.debug("post retrive content :" + sessionMap); + } + + QaStarterAction.logger + .debug("qaGeneralAuthoringDTO.getOnlineInstructions() :" + + qaGeneralAuthoringDTO.getOnlineInstructions()); + QaStarterAction.logger + .debug("qaGeneralAuthoringDTO.getOfflineInstructions():" + + qaGeneralAuthoringDTO.getOfflineInstructions()); + + if (qaGeneralAuthoringDTO.getOnlineInstructions() == null + || qaGeneralAuthoringDTO.getOnlineInstructions().length() == 0) { + qaGeneralAuthoringDTO + .setOnlineInstructions(QaAppConstants.DEFAULT_ONLINE_INST); + qaAuthoringForm + .setOnlineInstructions(QaAppConstants.DEFAULT_ONLINE_INST); + sessionMap.put(QaAppConstants.ONLINE_INSTRUCTIONS_KEY, + QaAppConstants.DEFAULT_ONLINE_INST); + } + + if (qaGeneralAuthoringDTO.getOfflineInstructions() == null + || qaGeneralAuthoringDTO.getOfflineInstructions().length() == 0) { + qaGeneralAuthoringDTO + .setOfflineInstructions(QaAppConstants.DEFAULT_OFFLINE_INST); + qaAuthoringForm + .setOfflineInstructions(QaAppConstants.DEFAULT_OFFLINE_INST); + sessionMap.put(QaAppConstants.OFFLINE_INSTRUCTIONS_KEY, + QaAppConstants.DEFAULT_OFFLINE_INST); + } + + SortedSet conditionList = getTaskListConditionList(sessionMap); + conditionList.clear(); + conditionList.addAll(qaContent.getConditions()); + + sessionMap.put(QaAppConstants.ATTR_QA_AUTHORING_FORM, qaAuthoringForm); + + QaStarterAction.logger.debug("final qaGeneralAuthoringDTO: " + + qaGeneralAuthoringDTO); + QaStarterAction.logger.debug("will return to jsp with: " + + sourceMcStarter); + String destination = QaUtils.getDestination(sourceMcStarter, + requestedModule); + QaStarterAction.logger.debug("destination: " + destination); + + Map mapQuestionContentLocal = qaGeneralAuthoringDTO + .getMapQuestionContent(); + QaStarterAction.logger.debug("mapQuestionContentLocal: " + + mapQuestionContentLocal); + + QaStarterAction.logger.debug("mapQuestionContent: " + + mapQuestionContent); + sessionMap.put(QaAppConstants.MAP_QUESTION_CONTENT_KEY, + mapQuestionContent); + + QaStarterAction.logger.debug("persisting sessionMap into session: " + + sessionMap); + request.getSession() + .setAttribute(sessionMap.getSessionID(), sessionMap); + + QaStarterAction.logger.debug("before fwding to jsp, qaAuthoringForm : " + + qaAuthoringForm); + QaStarterAction.logger.debug("final qaGeneralAuthoringDTO: " + + qaGeneralAuthoringDTO); + request.setAttribute(QaAppConstants.QA_GENERAL_AUTHORING_DTO, + qaGeneralAuthoringDTO); + + return mapping.findForward(destination); + } + + /** + * retrives the existing content information from the db and prepares the + * data for presentation purposes. ActionForward + * retrieveExistingContent(HttpServletRequest request, ActionMapping + * mapping, QaAuthoringForm qaAuthoringForm, Map mapQuestionContent, long + * toolContentID) + * + * @param request + * @param mapping + * @param qaAuthoringForm + * @param mapQuestionContent + * @param toolContentID + * @return ActionForward + */ + protected QaContent retrieveContent(HttpServletRequest request, + ActionMapping mapping, QaAuthoringForm qaAuthoringForm, + Map mapQuestionContent, long toolContentID, + boolean isDefaultContent, IQaService qaService, + QaGeneralAuthoringDTO qaGeneralAuthoringDTO, SessionMap sessionMap) { + QaStarterAction.logger.debug("starting retrieveContent: " + qaService); + QaStarterAction.logger.debug("toolContentID: " + toolContentID); + QaStarterAction.logger.debug("isDefaultContent: " + isDefaultContent); + + QaStarterAction.logger + .debug("getting content with id:" + toolContentID); + QaContent qaContent = qaService.retrieveQa(toolContentID); + QaStarterAction.logger.debug("QaContent: " + qaContent); + + QaUtils.populateAuthoringDTO(request, qaContent, qaGeneralAuthoringDTO); + + qaAuthoringForm.setUsernameVisible(qaContent.isUsernameVisible() ? "1" + : "0"); + qaAuthoringForm + .setShowOtherAnswers(qaContent.isShowOtherAnswers() ? "1" : "0"); + qaAuthoringForm.setSynchInMonitor(qaContent.isSynchInMonitor() ? "1" + : "0"); + qaAuthoringForm + .setQuestionsSequenced(qaContent.isQuestionsSequenced() ? "1" + : "0"); + qaAuthoringForm + .setLockWhenFinished(qaContent.isLockWhenFinished() ? "1" : "0"); + + qaGeneralAuthoringDTO.setReflect(qaContent.isReflect() ? "1" : "0"); + + QaStarterAction.logger.debug("QaContent isReflect: " + + qaContent.isReflect()); + qaAuthoringForm.setReflect(qaContent.isReflect() ? "1" : "0"); + + qaAuthoringForm.setReflectionSubject(qaContent.getReflectionSubject()); + qaGeneralAuthoringDTO.setReflectionSubject(qaContent + .getReflectionSubject()); + + List attachmentList = qaService.retrieveQaUploadedFiles(qaContent); + qaGeneralAuthoringDTO.setAttachmentList(attachmentList); + qaGeneralAuthoringDTO.setDeletedAttachmentList(new ArrayList()); + + sessionMap.put(QaAppConstants.ATTACHMENT_LIST_KEY, attachmentList); + sessionMap.put(QaAppConstants.DELETED_ATTACHMENT_LIST_KEY, + new ArrayList()); + + qaGeneralAuthoringDTO.setIsDefineLater(new Boolean(qaContent + .isDefineLater()).toString()); + + qaGeneralAuthoringDTO.setActivityTitle(qaContent.getTitle()); + qaAuthoringForm.setTitle(qaContent.getTitle()); + + qaGeneralAuthoringDTO.setActivityInstructions(qaContent + .getInstructions()); + qaAuthoringForm.setInstructions(qaContent.getInstructions()); + + sessionMap.put(QaAppConstants.ACTIVITY_TITLE_KEY, qaGeneralAuthoringDTO + .getActivityTitle()); + sessionMap.put(QaAppConstants.ACTIVITY_INSTRUCTIONS_KEY, + qaGeneralAuthoringDTO.getActivityInstructions()); + + List listQuestionContentDTO = new LinkedList(); + + /* + * get the existing question content + */ + QaStarterAction.logger.debug("setting content data from the db"); + mapQuestionContent.clear(); + Iterator queIterator = qaContent.getQaQueContents().iterator(); + Long mapIndex = new Long(1); + QaStarterAction.logger.debug("mapQuestionContent: " + + mapQuestionContent); + while (queIterator.hasNext()) { + QaQuestionContentDTO qaQuestionContentDTO = new QaQuestionContentDTO(); + + QaQueContent qaQueContent = (QaQueContent) queIterator.next(); + if (qaQueContent != null) { + QaStarterAction.logger.debug("question: " + + qaQueContent.getQuestion()); + QaStarterAction.logger.debug("displayorder: " + + new Integer(qaQueContent.getDisplayOrder()) + .toString()); + QaStarterAction.logger.debug("feedback: " + + qaQueContent.getFeedback()); + + mapQuestionContent.put(mapIndex.toString(), qaQueContent + .getQuestion()); + + qaQuestionContentDTO.setQuestion(qaQueContent.getQuestion()); + qaQuestionContentDTO.setDisplayOrder(new Integer(qaQueContent + .getDisplayOrder()).toString()); + qaQuestionContentDTO.setFeedback(qaQueContent.getFeedback()); + listQuestionContentDTO.add(qaQuestionContentDTO); + /** + * make the first entry the default(first) one for jsp */ - long defaultContentID=0; - try - { - logger.debug("attempt retrieving tool with signatute : " + MY_SIGNATURE); - defaultContentID=qaService.getToolDefaultContentIdBySignature(MY_SIGNATURE); - logger.debug("retrieved tool default contentId: " + defaultContentID); - if (defaultContentID == 0) - { - logger.debug("default content id has not been setup"); - return false; - } + if (mapIndex.longValue() == 1) { + qaGeneralAuthoringDTO + .setDefaultQuestionContent(qaQueContent + .getQuestion()); } - catch(Exception e) - { - logger.debug("error getting the default content id: " + e.getMessage()); - persistError(request,"error.defaultContent.notSetup"); - return false; - } + mapIndex = new Long(mapIndex.longValue() + 1); + } + } + QaStarterAction.logger + .debug("Map initialized with existing contentid to: " + + mapQuestionContent); - - /* retrieve uid of the content based on default content id determined above */ - long contentUID=0; - try - { - logger.debug("retrieve uid of the content based on default content id determined above: " + defaultContentID); - QaContent qaContent=qaService.loadQa(defaultContentID); - if (qaContent == null) - { - logger.debug("Exception occured: No default content"); - persistError(request,"error.defaultContent.notSetup"); - return false; - } - logger.debug("using qaContent: " + qaContent); - logger.debug("using qaContent uid: " + qaContent.getUid()); - contentUID=qaContent.getUid().longValue(); - logger.debug("contentUID: " + contentUID); + request.setAttribute(QaAppConstants.TOTAL_QUESTION_COUNT, new Integer( + mapQuestionContent.size())); + + QaStarterAction.logger.debug("listQuestionContentDTO: " + + listQuestionContentDTO); + request.setAttribute(QaAppConstants.LIST_QUESTION_CONTENT_DTO, + listQuestionContentDTO); + sessionMap.put(QaAppConstants.LIST_QUESTION_CONTENT_DTO_KEY, + listQuestionContentDTO); + + SortedSet conditionSet = new TreeSet( + new QaConditionComparator()); + for (QaCondition condition : qaContent.getConditions()) { + conditionSet.add(condition); + for (QaQuestionContentDTO dto : (List) listQuestionContentDTO) { + if (dto.getDisplayOrder().equals( + String.valueOf(condition.getOrderId()))) { + condition.temporaryQuestionDTOSet.add(dto); } - catch(Exception e) - { - logger.debug("Exception occured: No default question content"); - persistError(request,"error.defaultContent.notSetup"); - return false; - } + } + } + sessionMap.put(QaAppConstants.ATTR_CONDITION_SET, conditionSet); - - logger.debug("QA tool has the default content id: " + defaultContentID); - qaGeneralAuthoringDTO.setDefaultContentIdStr(new Long(defaultContentID).toString()); - qaAuthoringForm.setDefaultContentIdStr(new Long(defaultContentID).toString()); - - return true; + if (isDefaultContent) { + QaStarterAction.logger.debug("overwriting default question."); + qaGeneralAuthoringDTO + .setDefaultQuestionContent("Sample Question 1?"); + } - - - - /** - * existsContent(long toolContentID) - * @param long toolContentID - * @return boolean - * determine whether a specific toolContentID exists in the db + + QaStarterAction.logger.debug("mapQuestionContent is:" + + mapQuestionContent); + qaGeneralAuthoringDTO.setMapQuestionContent(mapQuestionContent); + + QaStarterAction.logger.debug("qaContent.getOnlineInstructions():" + + qaContent.getOnlineInstructions()); + QaStarterAction.logger.debug("qaContent.getOfflineInstructions():" + + qaContent.getOfflineInstructions()); + qaGeneralAuthoringDTO.setOnlineInstructions(qaContent + .getOnlineInstructions()); + qaGeneralAuthoringDTO.setOfflineInstructions(qaContent + .getOfflineInstructions()); + + qaAuthoringForm + .setOnlineInstructions(qaContent.getOnlineInstructions()); + qaAuthoringForm.setOfflineInstructions(qaContent + .getOfflineInstructions()); + sessionMap.put(QaAppConstants.ONLINE_INSTRUCTIONS_KEY, qaContent + .getOnlineInstructions()); + sessionMap.put(QaAppConstants.OFFLINE_INSTRUCTIONS_KEY, qaContent + .getOfflineInstructions()); + + QaStarterAction.logger.debug("ACTIVITY_TITLE_KEY set to:" + + sessionMap.get(QaAppConstants.ACTIVITY_TITLE_KEY)); + + qaAuthoringForm.resetUserAction(); + QaStarterAction.logger.debug("returning qaContent:" + qaContent); + return qaContent; + } + + /** + * each tool has a signature. QA tool's signature is stored in MY_SIGNATURE. + * The default tool content id and other depending content ids are obtained + * in this method. if all the default content has been setup properly the + * method persists DEFAULT_CONTENT_ID in the session. + * + * readSignature(HttpServletRequest request, ActionMapping mapping) + * + * @param request + * @param mapping + * @return ActionForward + */ + public boolean readSignature(HttpServletRequest request, + ActionMapping mapping, IQaService qaService, + QaGeneralAuthoringDTO qaGeneralAuthoringDTO, + QaAuthoringForm qaAuthoringForm) { + QaStarterAction.logger.debug("qaService: " + qaService); + /* + * retrieve the default content id based on tool signature */ - protected boolean existsContent(long toolContentID, IQaService qaService) - { - QaContent qaContent=qaService.loadQa(toolContentID); - if (qaContent == null) - return false; - - return true; + long defaultContentID = 0; + try { + QaStarterAction.logger + .debug("attempt retrieving tool with signatute : " + + QaAppConstants.MY_SIGNATURE); + defaultContentID = qaService + .getToolDefaultContentIdBySignature(QaAppConstants.MY_SIGNATURE); + QaStarterAction.logger.debug("retrieved tool default contentId: " + + defaultContentID); + if (defaultContentID == 0) { + QaStarterAction.logger + .debug("default content id has not been setup"); + return false; + } + } catch (Exception e) { + QaStarterAction.logger + .debug("error getting the default content id: " + + e.getMessage()); + persistError(request, "error.defaultContent.notSetup"); + return false; } - - - /** - * bridges define later url request to authoring functionality - * - * executeDefineLater(ActionMapping mapping, ActionForm form, - HttpServletRequest request, HttpServletResponse response, IQaService qaService) - throws IOException, ServletException, QaApplicationException - * - * @param mapping - * @param form - * @param request - * @param response - * @param qaService - * @return - * @throws IOException - * @throws ServletException - * @throws QaApplicationException + + /* + * retrieve uid of the content based on default content id determined + * above */ - public ActionForward executeDefineLater(ActionMapping mapping, QaAuthoringForm qaAuthoringForm, - HttpServletRequest request, HttpServletResponse response, IQaService qaService) - throws IOException, ServletException, QaApplicationException { - logger.debug("calling execute..., qaService will be needed next."); - return execute(mapping, qaAuthoringForm, request, response); + long contentUID = 0; + try { + QaStarterAction.logger + .debug("retrieve uid of the content based on default content id determined above: " + + defaultContentID); + QaContent qaContent = qaService.loadQa(defaultContentID); + if (qaContent == null) { + QaStarterAction.logger + .debug("Exception occured: No default content"); + persistError(request, "error.defaultContent.notSetup"); + return false; + } + QaStarterAction.logger.debug("using qaContent: " + qaContent); + QaStarterAction.logger.debug("using qaContent uid: " + + qaContent.getUid()); + contentUID = qaContent.getUid().longValue(); + QaStarterAction.logger.debug("contentUID: " + contentUID); + } catch (Exception e) { + QaStarterAction.logger + .debug("Exception occured: No default question content"); + persistError(request, "error.defaultContent.notSetup"); + return false; } - - /** + QaStarterAction.logger.debug("QA tool has the default content id: " + + defaultContentID); + qaGeneralAuthoringDTO.setDefaultContentIdStr(new Long(defaultContentID) + .toString()); + qaAuthoringForm.setDefaultContentIdStr(new Long(defaultContentID) + .toString()); + + return true; + } + + /** + * existsContent(long toolContentID) + * + * @param long + * toolContentID + * @return boolean determine whether a specific toolContentID exists in the + * db + */ + protected boolean existsContent(long toolContentID, IQaService qaService) { + QaContent qaContent = qaService.loadQa(toolContentID); + if (qaContent == null) { + return false; + } + + return true; + } + + /** + * bridges define later url request to authoring functionality + * + * executeDefineLater(ActionMapping mapping, ActionForm form, + * HttpServletRequest request, HttpServletResponse response, IQaService + * qaService) throws IOException, ServletException, QaApplicationException + * + * @param mapping + * @param form + * @param request + * @param response + * @param qaService + * @return + * @throws IOException + * @throws ServletException + * @throws QaApplicationException + */ + public ActionForward executeDefineLater(ActionMapping mapping, + QaAuthoringForm qaAuthoringForm, HttpServletRequest request, + HttpServletResponse response, IQaService qaService) + throws IOException, ServletException, QaApplicationException { + QaStarterAction.logger + .debug("calling execute..., qaService will be needed next."); + return execute(mapping, qaAuthoringForm, 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("add " + message +" to ActionMessages:"); - saveErrors(request,errors); - } -} + public void persistError(HttpServletRequest request, String message) { + ActionMessages errors = new ActionMessages(); + errors.add(Globals.ERROR_KEY, new ActionMessage(message)); + QaStarterAction.logger.debug("add " + message + " to ActionMessages:"); + saveErrors(request, errors); + } + private SortedSet getTaskListConditionList( + SessionMap sessionMap) { + SortedSet list = (SortedSet) sessionMap + .get(QaAppConstants.ATTR_CONDITION_SET); + if (list == null) { + list = new TreeSet(new QaConditionComparator()); + sessionMap.put(QaAppConstants.ATTR_CONDITION_SET, list); + } + return list; + } +} Index: lams_tool_laqa/web/WEB-INF/lams.tld =================================================================== diff -u -rc5b655c3c11fa9d9b1d76e0ef602acf6363e45f9 -r0af4ed13b963a588f3499b080801863d57f8ad95 --- lams_tool_laqa/web/WEB-INF/lams.tld (.../lams.tld) (revision c5b655c3c11fa9d9b1d76e0ef602acf6363e45f9) +++ lams_tool_laqa/web/WEB-INF/lams.tld (.../lams.tld) (revision 0af4ed13b963a588f3499b080801863d57f8ad95) @@ -13,28 +13,36 @@ - Output the basic URL for the current webapp. e.g. http://server/lams/tool/nb11/ - Base URL for the current web app + Output the Server URL as defined in the lams.xml configuration file. + LAMS URL - WebAppURL - org.lamsfoundation.lams.web.tag.WebAppURLTag + LAMSURL + org.lamsfoundation.lams.web.tag.LAMSURLTag empty - Output a random number for the learner and passon flash movies to communicate directly. - generate unique ID + Converts text from \n or \r\n to <BR> before rendering + Converts text from \n or \r\n to <BR> before rendering - generateID - org.lamsfoundation.lams.web.tag.GenerateIDTag + out + org.lamsfoundation.lams.web.tag.MultiLinesOutputTag empty - Output a random number for the learner and passon flash movies to communicate directly. - id + Converts text from \n or \r\n to <BR> before rendering + value + true + + true + + + + Converts text from \n or \r\n to <BR> before rendering + escapeHtml false true @@ -44,6 +52,26 @@ + Render html tag with direction and language + Render html tag with direction and language + + + html + org.lamsfoundation.lams.web.tag.HtmlTag + JSP + + + Render html tag with direction and language + xhtml + false + + true + + + + + + Get the configuration value for the specified key Configuration value @@ -64,28 +92,17 @@ - Output the Server URL as defined in the lams.xml configuration file. - LAMS URL + Output a random number for the learner and passon flash movies to communicate directly. + generate unique ID - LAMSURL - org.lamsfoundation.lams.web.tag.LAMSURLTag + generateID + org.lamsfoundation.lams.web.tag.GenerateIDTag empty - - - - Render html tag with direction and language - Render html tag with direction and language - - - html - org.lamsfoundation.lams.web.tag.HtmlTag - JSP - - Render html tag with direction and language - xhtml + Output a random number for the learner and passon flash movies to communicate directly. + id false true @@ -95,26 +112,29 @@ - Converts text from \n or \r\n to <BR> before rendering - Converts text from \n or \r\n to <BR> before rendering + Output the basic URL for the current webapp. e.g. http://server/lams/tool/nb11/ + Base URL for the current web app - out - org.lamsfoundation.lams.web.tag.MultiLinesOutputTag + WebAppURL + org.lamsfoundation.lams.web.tag.WebAppURLTag empty - - Converts text from \n or \r\n to <BR> before rendering - value - true + + - true + Converts role name into form usable as message resources key + Converts role name into form usable as message resources key + + + role + org.lamsfoundation.lams.web.tag.RoleTag + empty - - Converts text from \n or \r\n to <BR> before rendering - escapeHtml - false + Converts role name into form usable as message resources key + role + true true @@ -167,17 +187,17 @@ - Converts role name into form usable as message resources key - Converts role name into form usable as message resources key + Output details from the shared session UserDTO object + user details - role - org.lamsfoundation.lams.web.tag.RoleTag + user + org.lamsfoundation.lams.web.tag.UserTag empty - Converts role name into form usable as message resources key - role + Output details from the shared session UserDTO object + property true true @@ -213,27 +233,7 @@ - - Output details from the shared session UserDTO object - user details - - - user - org.lamsfoundation.lams.web.tag.UserTag - empty - - - Output details from the shared session UserDTO object - property - true - - true - - - - - STRUTS-textarea org.lamsfoundation.lams.web.tag.MultiLinesTextareaTag @@ -289,11 +289,6 @@ true - index - false - true - - indexed false true @@ -466,6 +461,10 @@ ImgButtonWrapper /WEB-INF/tags/ImgButtonWrapper.tag + + + TextSearch + /WEB-INF/tags/TextSearch.tag textarea Index: lams_tool_laqa/web/WEB-INF/struts-config.xml =================================================================== diff -u -r47ed08dc3daff962ae3af84bef5d38bb531eeabb -r0af4ed13b963a588f3499b080801863d57f8ad95 --- lams_tool_laqa/web/WEB-INF/struts-config.xml (.../struts-config.xml) (revision 47ed08dc3daff962ae3af84bef5d38bb531eeabb) +++ lams_tool_laqa/web/WEB-INF/struts-config.xml (.../struts-config.xml) (revision 0af4ed13b963a588f3499b080801863d57f8ad95) @@ -16,6 +16,7 @@ + @@ -72,7 +73,7 @@ redirect="false" /> - + + + + + + + + + + + + + + + + + + + + + + + + + + +<%@ tag body-content="scriptless" %> +<%@ taglib uri="tags-core" prefix="c" %> +<%@ taglib uri="tags-fmt" prefix="fmt" %> +<%@ taglib uri="tags-html" prefix="html" %> +<%@ taglib uri="tags-lams" prefix="lams" %> + +<%-- Required attributes --%> +<%@ attribute name="sessionMapID" required="true" rtexprvalue="true" %> +<%@ attribute name="wrapInFormTag" required="true" rtexprvalue="true" %> + +<%-- Optional attributes --%> +<%@ attribute name="action" required="false" rtexprvalue="true" %> +<%@ attribute name="formID" required="false" rtexprvalue="true" %> +<%@ attribute name="headingLabelKey" required="false" rtexprvalue="true" %> +<%@ attribute name="allWordsLabelKey" required="false" rtexprvalue="true" %> +<%@ attribute name="phraseLabelKey" required="false" rtexprvalue="true" %> +<%@ attribute name="anyWordsLabelKey" required="false" rtexprvalue="true" %> +<%@ attribute name="excludedWordsLabelKey" required="false" rtexprvalue="true" %> +<%@ attribute name="saveButtonLabelKey" required="false" rtexprvalue="true" %> +<%@ attribute name="cancelButtonLabelKey" required="false" rtexprvalue="true" %> +<%@ attribute name="cancelAction" required="false" rtexprvalue="true" %> + +<%-- Default value for message key --%> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + +

+ + + + + + + + + + + + + + + + + +
+ + + +
+ + + +
+ + + +
+ + + +
+ + + + + + + + + + \ No newline at end of file Index: lams_tool_laqa/web/authoring/AuthoringTabsHolder.jsp =================================================================== diff -u -r18e5e690d2e1a7c3d918759f7a2827c8205feaac -r0af4ed13b963a588f3499b080801863d57f8ad95 --- lams_tool_laqa/web/authoring/AuthoringTabsHolder.jsp (.../AuthoringTabsHolder.jsp) (revision 18e5e690d2e1a7c3d918759f7a2827c8205feaac) +++ lams_tool_laqa/web/authoring/AuthoringTabsHolder.jsp (.../AuthoringTabsHolder.jsp) (revision 0af4ed13b963a588f3499b080801863d57f8ad95) @@ -33,6 +33,7 @@ tabs.add("label.basic"); tabs.add("label.advanced"); tabs.add("label.instructions"); + tabs.add("label.conditions"); pageContext.setAttribute("tabs", tabs); Set tabsBasic = new LinkedHashSet(); @@ -154,7 +155,10 @@ - + + + + +<%@ include file="/common/taglibs.jsp"%> + + + + <%@ include file="/common/header.jsp"%> + + + + + + <%@ include file="/common/messages.jsp"%> + + +

+ +

+ +
+ +
+ +
+ +
+ <%-- Text search form fields are being included --%> + +

+ + + + + +
+
+ +
+ + + + + + +
Index: lams_tool_laqa/web/authoring/conditionList.jsp =================================================================== diff -u --- lams_tool_laqa/web/authoring/conditionList.jsp (revision 0) +++ lams_tool_laqa/web/authoring/conditionList.jsp (revision 0af4ed13b963a588f3499b080801863d57f8ad95) @@ -0,0 +1,92 @@ +<%@ include file="/common/taglibs.jsp"%> + + + + + + + +
+

+ + +

+ + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + +
+ +
+ ${status.index + 1} + + ${condition.displayName} + + + " + onclick="upCondition(${status.index},'${sessionMapID}')"> + + "> + + + + + + "> + + + " + onclick="downCondition(${status.index},'${sessionMapID}')"> + + + " + onclick="editCondition(${status.index},'${sessionMapID}')" /> + + " + onclick="deleteCondition(${status.index},'${sessionMapID}')" /> +
+
+ +<%-- This script will works when a new resoruce Condition submit in order to refresh "TaskList List" panel. --%> + Index: lams_tool_laqa/web/authoring/conditions.jsp =================================================================== diff -u --- lams_tool_laqa/web/authoring/conditions.jsp (revision 0) +++ lams_tool_laqa/web/authoring/conditions.jsp (revision 0af4ed13b963a588f3499b080801863d57f8ad95) @@ -0,0 +1,110 @@ +<%@ include file="/common/taglibs.jsp"%> + + + + + +
+ + <%@ include file="/authoring/conditionList.jsp"%> +
+ +

+ ');" class="button-add-item"> + +

+ + +

+ +