Index: lams_tool_lamc/db/sql/create_lams_tool_mc.sql =================================================================== diff -u -r6f8e2be9415c06ea262122fd2182f6bd14bc7ba5 -r7e58118a02164b69f28068177656576f32aaeddd --- lams_tool_lamc/db/sql/create_lams_tool_mc.sql (.../create_lams_tool_mc.sql) (revision 6f8e2be9415c06ea262122fd2182f6bd14bc7ba5) +++ lams_tool_lamc/db/sql/create_lams_tool_mc.sql (.../create_lams_tool_mc.sql) (revision 7e58118a02164b69f28068177656576f32aaeddd) @@ -1,124 +1,121 @@ --- $Id$ - -CREATE TABLE tl_lamc11_content ( - uid BIGINT(20) NOT NULL AUTO_INCREMENT - , content_id BIGINT(20) NOT NULL - , title TEXT NOT NULL - , instructions TEXT NOT NULL - , creation_date DATETIME - , update_date DATETIME - , questions_sequenced TINYINT(1) NOT NULL DEFAULT 0 - , username_visible TINYINT(1) NOT NULL DEFAULT 0 - , created_by BIGINT(20) NOT NULL DEFAULT 0 - , monitoring_report_title TEXT NOT NULL - , report_title TEXT NOT NULL - , run_offline TINYINT(1) NOT NULL DEFAULT 0 - , define_later TINYINT(1) NOT NULL DEFAULT 0 - , synch_in_monitor TINYINT(1) NOT NULL DEFAULT 0 - , offline_instructions TEXT - , online_instructions TEXT - , end_learning_message TEXT NOT NULL - , content_in_use TINYINT(1) NOT NULL DEFAULT 0 - , retries TINYINT(1) NOT NULL DEFAULT 0 - , show_feedback TINYINT(1) NOT NULL DEFAULT 0 - , pass_mark INTEGER - , show_report TINYINT(1) NOT NULL DEFAULT 0 - , UNIQUE UQ_tl_lamc11_content_1 (content_id) - , PRIMARY KEY (uid) -)TYPE=InnoDB; - -CREATE TABLE tl_lamc11_que_content ( - uid BIGINT(20) NOT NULL AUTO_INCREMENT - , question VARCHAR(255) - , weight INT(5) NOT NULL DEFAULT 0 - , disabled TINYINT(1) NOT NULL DEFAULT 1 - , feedbackCorrect TEXT - , feedbackIncorrect TEXT - , display_order INT(5) - , mc_content_id BIGINT(20) NOT NULL - , PRIMARY KEY (uid) - , INDEX (mc_content_id) - , CONSTRAINT FK_tl_lamc11_que_content_1 FOREIGN KEY (mc_content_id) - REFERENCES tl_lamc11_content (uid) -)TYPE=InnoDB; - -CREATE TABLE tl_lamc11_options_content ( - uid BIGINT(20) NOT NULL AUTO_INCREMENT - , correct_option TINYINT(1) NOT NULL DEFAULT 0 - , mc_que_content_id BIGINT(20) NOT NULL - , mc_que_option_text VARCHAR(250) - , PRIMARY KEY (uid) - , INDEX (mc_que_content_id) - , CONSTRAINT FK_tl_lamc11_options_content_1 FOREIGN KEY (mc_que_content_id) - REFERENCES tl_lamc11_que_content (uid) -)TYPE=InnoDB; - -CREATE TABLE tl_lamc11_session ( - uid BIGINT(20) NOT NULL AUTO_INCREMENT - , mc_session_id BIGINT(20) NOT NULL - , session_start_date DATETIME - , session_end_date DATETIME - , session_name VARCHAR(100) - , session_status VARCHAR(100) - , mc_content_id BIGINT(20) NOT NULL - , UNIQUE UQ_tl_lamc11_session_1 (mc_session_id) - , PRIMARY KEY (uid) - , INDEX (mc_content_id) - , CONSTRAINT FK_tl_lamc_session_1 FOREIGN KEY (mc_content_id) - REFERENCES tl_lamc11_content (uid) -)TYPE=InnoDB; - -CREATE TABLE tl_lamc11_que_usr ( - uid BIGINT(20) NOT NULL AUTO_INCREMENT - , que_usr_id BIGINT(20) NOT NULL - , mc_session_id BIGINT(20) NOT NULL - , username VARCHAR(100) - , fullname VARCHAR(100) - , UNIQUE UQ_tl_lamc11_que_usr_1 (que_usr_id) - , PRIMARY KEY (uid) - , INDEX (mc_session_id) - , CONSTRAINT FK_tl_lamc_tool_usr_1 FOREIGN KEY (mc_session_id) - REFERENCES tl_lamc11_session (uid) -)TYPE=InnoDB; - -CREATE TABLE tl_lamc11_usr_attempt ( - uid BIGINT(20) NOT NULL AUTO_INCREMENT - , que_usr_id BIGINT(20) NOT NULL - , mc_que_content_id BIGINT(20) NOT NULL - , mc_que_option_id BIGINT(20) NOT NULL - , attempt_time DATETIME - , time_zone VARCHAR(255) - , isAttemptCorrect TINYINT(1) NOT NULL DEFAULT 0 - , mark VARCHAR(255) - , passed TINYINT(1) NOT NULL DEFAULT 0 - , attemptOrder INTEGER NOT NULL DEFAULT 1 - , PRIMARY KEY (uid) - , INDEX (que_usr_id) - , CONSTRAINT FK_tl_lamc11_usr_attempt_1 FOREIGN KEY (que_usr_id) - REFERENCES tl_lamc11_que_usr (uid) - , INDEX (mc_que_content_id) - , CONSTRAINT FK_tl_lamc11_usr_attempt_2 FOREIGN KEY (mc_que_content_id) - REFERENCES tl_lamc11_que_content (uid) - , INDEX (mc_que_option_id) - , CONSTRAINT FK_tl_lamc11_usr_attempt_3 FOREIGN KEY (mc_que_option_id) - REFERENCES tl_lamc11_options_content (uid) -)TYPE=InnoDB; - -CREATE TABLE tl_lamc11_uploadedfile ( - uid BIGINT(20) NOT NULL AUTO_INCREMENT - , uuid VARCHAR(255) NOT NULL - , mc_content_id BIGINT(20) NOT NULL - , isOnline_File TINYINT(1) NOT NULL - , filename VARCHAR(255) NOT NULL - , PRIMARY KEY (uid) - , INDEX (mc_content_id) - , CONSTRAINT FK_tl_lamc11_uploadedFile FOREIGN KEY (mc_content_id) - REFERENCES tl_lamc11_content (uid) -)TYPE=InnoDB; - -INSERT INTO tl_lamc11_content(uid, content_id , title , instructions , creation_date , questions_sequenced , username_visible , created_by , monitoring_report_title , report_title , run_offline , define_later, synch_in_monitor, offline_instructions, online_instructions, end_learning_message, content_in_use, retries, show_feedback, show_report) VALUES (1, ${default_content_id} ,'Mc Title','Mc Instructions', NOW(), 0, 0,1,'Monitoring Report','Report', 0, 0, 0,'offline instructions','online instructions','Finished Activity...', 0, 0, 0, 0); - -INSERT INTO tl_lamc11_que_content (uid,question, weight, disabled, display_order, mc_content_id) VALUES (1, 'a sample question', 0, 1, 1, 1); - -INSERT INTO tl_lamc11_options_content (uid, correct_option, mc_que_content_id, mc_que_option_text) VALUES (1, 0, 1,'sample answer 1'); - +CREATE TABLE tl_lamc11_content ( + uid BIGINT(20) NOT NULL AUTO_INCREMENT + , content_id BIGINT(20) NOT NULL + , title TEXT NOT NULL + , instructions TEXT NOT NULL + , creation_date DATETIME + , update_date DATETIME + , questions_sequenced TINYINT(1) NOT NULL DEFAULT 0 + , username_visible TINYINT(1) NOT NULL DEFAULT 0 + , created_by BIGINT(20) NOT NULL DEFAULT 0 + , monitoring_report_title TEXT NOT NULL + , report_title TEXT NOT NULL + , run_offline TINYINT(1) NOT NULL DEFAULT 0 + , define_later TINYINT(1) NOT NULL DEFAULT 0 + , synch_in_monitor TINYINT(1) NOT NULL DEFAULT 0 + , offline_instructions TEXT + , online_instructions TEXT + , end_learning_message TEXT NOT NULL + , content_in_use TINYINT(1) NOT NULL DEFAULT 0 + , retries TINYINT(1) NOT NULL DEFAULT 0 + , show_feedback TINYINT(1) NOT NULL DEFAULT 0 + , pass_mark INTEGER + , show_report TINYINT(1) NOT NULL DEFAULT 0 + , UNIQUE UQ_tl_lamc11_content_1 (content_id) + , PRIMARY KEY (uid) +)TYPE=InnoDB; + +CREATE TABLE tl_lamc11_que_content ( + uid BIGINT(20) NOT NULL AUTO_INCREMENT + , question VARCHAR(255) + , weight INT(5) NOT NULL DEFAULT 0 + , disabled TINYINT(1) NOT NULL DEFAULT 1 + , feedbackCorrect TEXT + , feedbackIncorrect TEXT + , display_order INT(5) + , mc_content_id BIGINT(20) NOT NULL + , PRIMARY KEY (uid) + , INDEX (mc_content_id) + , CONSTRAINT FK_tl_lamc11_que_content_1 FOREIGN KEY (mc_content_id) + REFERENCES tl_lamc11_content (uid) +)TYPE=InnoDB; + +CREATE TABLE tl_lamc11_options_content ( + uid BIGINT(20) NOT NULL AUTO_INCREMENT + , correct_option TINYINT(1) NOT NULL DEFAULT 0 + , mc_que_content_id BIGINT(20) NOT NULL + , mc_que_option_text VARCHAR(250) + , PRIMARY KEY (uid) + , INDEX (mc_que_content_id) + , CONSTRAINT FK_tl_lamc11_options_content_1 FOREIGN KEY (mc_que_content_id) + REFERENCES tl_lamc11_que_content (uid) +)TYPE=InnoDB; + +CREATE TABLE tl_lamc11_session ( + uid BIGINT(20) NOT NULL AUTO_INCREMENT + , mc_session_id BIGINT(20) NOT NULL + , session_start_date DATETIME + , session_end_date DATETIME + , session_name VARCHAR(100) + , session_status VARCHAR(100) + , mc_content_id BIGINT(20) NOT NULL + , UNIQUE UQ_tl_lamc11_session_1 (mc_session_id) + , PRIMARY KEY (uid) + , INDEX (mc_content_id) + , CONSTRAINT FK_tl_lamc_session_1 FOREIGN KEY (mc_content_id) + REFERENCES tl_lamc11_content (uid) +)TYPE=InnoDB; + +CREATE TABLE tl_lamc11_que_usr ( + uid BIGINT(20) NOT NULL AUTO_INCREMENT + , que_usr_id BIGINT(20) NOT NULL + , mc_session_id BIGINT(20) NOT NULL + , username VARCHAR(100) + , fullname VARCHAR(100) + , PRIMARY KEY (uid) + , INDEX (mc_session_id) + , CONSTRAINT FK_tl_lamc11_que_usr_1 FOREIGN KEY (mc_session_id) + REFERENCES tl_lamc11_session (uid) +)TYPE=InnoDB; + +CREATE TABLE tl_lamc11_usr_attempt ( + uid BIGINT(20) NOT NULL AUTO_INCREMENT + , que_usr_id BIGINT(20) NOT NULL + , mc_que_content_id BIGINT(20) NOT NULL + , mc_que_option_id BIGINT(20) NOT NULL + , attempt_time DATETIME + , time_zone VARCHAR(255) + , isAttemptCorrect TINYINT(1) NOT NULL DEFAULT 0 + , mark VARCHAR(255) + , passed TINYINT(1) NOT NULL DEFAULT 0 + , attemptOrder INTEGER NOT NULL DEFAULT 1 + , PRIMARY KEY (uid) + , INDEX (mc_que_content_id) + , CONSTRAINT FK_tl_lamc11_usr_attempt_2 FOREIGN KEY (mc_que_content_id) + REFERENCES tl_lamc11_que_content (uid) + , INDEX (mc_que_option_id) + , CONSTRAINT FK_tl_lamc11_usr_attempt_3 FOREIGN KEY (mc_que_option_id) + REFERENCES tl_lamc11_options_content (uid) + , INDEX (que_usr_id) + , CONSTRAINT FK_tl_lamc11_usr_attempt_4 FOREIGN KEY (que_usr_id) + REFERENCES tl_lamc11_que_usr (uid) +)TYPE=InnoDB; + +CREATE TABLE tl_lamc11_uploadedfile ( + uid BIGINT(20) NOT NULL AUTO_INCREMENT + , uuid VARCHAR(255) NOT NULL + , mc_content_id BIGINT(20) NOT NULL + , isOnline_File TINYINT(1) NOT NULL + , filename VARCHAR(255) NOT NULL + , PRIMARY KEY (uid) + , INDEX (mc_content_id) + , CONSTRAINT FK_tl_lamc11_uploadedFile FOREIGN KEY (mc_content_id) + REFERENCES tl_lamc11_content (uid) +)TYPE=InnoDB; + +INSERT INTO tl_lamc11_content(uid, content_id , title , instructions , creation_date , questions_sequenced , username_visible , created_by , monitoring_report_title , report_title , run_offline , define_later, synch_in_monitor, offline_instructions, online_instructions, end_learning_message, content_in_use, retries, show_feedback, show_report) VALUES (1, ${default_content_id} ,'Mc Title','Mc Instructions', NOW(), 0, 0,1,'Monitoring Report','Report', 0, 0, 0,'offline instructions','online instructions','Finished Activity...', 0, 0, 0, 0); + +INSERT INTO tl_lamc11_que_content (uid,question, weight, disabled, display_order, mc_content_id) VALUES (1, 'a sample question', 0, 1, 1, 1); + +INSERT INTO tl_lamc11_options_content (uid, correct_option, mc_que_content_id, mc_que_option_text) VALUES (1, 0, 1,'sample answer 1'); + Index: lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/ExportServlet.java =================================================================== diff -u -r3d2afa94019913eda4e30f231afcbe8f631ef5a2 -r7e58118a02164b69f28068177656576f32aaeddd --- lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/ExportServlet.java (.../ExportServlet.java) (revision 3d2afa94019913eda4e30f231afcbe8f631ef5a2) +++ lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/ExportServlet.java (.../ExportServlet.java) (revision 7e58118a02164b69f28068177656576f32aaeddd) @@ -49,8 +49,8 @@ public class ExportServlet extends AbstractExportPortfolioServlet implements McAppConstants{ static Logger logger = Logger.getLogger(ExportServlet.class.getName()); - private static final long serialVersionUID = -4119093489007108143L; - private final String FILENAME = "mc_main.html"; + private static final long serialVersionUID = -5119093489007108143L; + private final String FILENAME = "mcq_main.html"; public String doExport(HttpServletRequest request, HttpServletResponse response, String directoryName, Cookie[] cookies) @@ -113,16 +113,10 @@ logger.debug("calling learning mode toolSessionID:" + toolSessionID + " userID: " + userID ); McMonitoringAction mcMonitoringAction= new McMonitoringAction(); - logger.debug("start refreshSummaryData for learner mode."); - //mcMonitoringAction.refreshSummaryData(request, content, mcService, true, true, toolSessionID.toString(), userID.toString()); - /* - List listMonitoredAnswersContainerDTO=MonitoringUtil.buildGroupsQuestionData(request, content); + List listMonitoredAnswersContainerDTO=MonitoringUtil.buildSessionQuestionData(request, content, toolSessionID, userID); request.getSession().setAttribute(LIST_MONITORED_ANSWERS_CONTAINER_DTO, listMonitoredAnswersContainerDTO); logger.debug("LIST_MONITORED_ANSWERS_CONTAINER_DTO: " + request.getSession().getAttribute(LIST_MONITORED_ANSWERS_CONTAINER_DTO)); - */ - - - logger.debug("end refreshSummaryData for learner mode."); + logger.debug("ending learner mode: "); } Index: lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/LearningUtil.java =================================================================== diff -u -rc9531327d15636b54f293077ee1cd9f60195381b -r7e58118a02164b69f28068177656576f32aaeddd --- lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/LearningUtil.java (.../LearningUtil.java) (revision c9531327d15636b54f293077ee1cd9f60195381b) +++ lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/LearningUtil.java (.../LearningUtil.java) (revision 7e58118a02164b69f28068177656576f32aaeddd) @@ -609,14 +609,29 @@ return false; } + public static McQueUsr getUser(HttpServletRequest request) + { + IMcService mcService =McUtils.getToolService(request); + Long queUsrId=McUtils.getUserId(); + + Long toolSessionId=(Long)request.getSession().getAttribute(TOOL_SESSION_ID); + logger.debug("toolSessionId: " + toolSessionId); + + McSession mcSession=mcService.retrieveMcSession(toolSessionId); + logger.debug("retrieving mcSession: " + mcSession); + McQueUsr mcQueUsr=mcService.getMcUserBySession(queUsrId, mcSession.getUid()); + //McQueUsr mcQueUsr=mcService.retrieveMcQueUsr(queUsrId); + return mcQueUsr; + } + /** * creates the user in the db * createUser(HttpServletRequest request) * * @param request */ - public static void createUser(HttpServletRequest request) + public static McQueUsr createUser(HttpServletRequest request) { IMcService mcService =McUtils.getToolService(request); Long queUsrId=McUtils.getUserId(); @@ -632,38 +647,11 @@ new TreeSet()); mcService.createMcQueUsr(mcQueUsr); logger.debug("created mcQueUsr in the db: " + mcQueUsr); + return mcQueUsr; } /** - * checks if the user is in the db - * doesUserExists(HttpServletRequest request) - * - * @param request - */ - public static boolean doesUserExists(HttpServletRequest request) - { - IMcService mcService =McUtils.getToolService(request); - Long queUsrId=McUtils.getUserId(); - McQueUsr mcQueUsr=mcService.retrieveMcQueUsr(queUsrId); - - if (mcQueUsr != null) - return true; - - return false; - } - - - public static McQueUsr getUser(HttpServletRequest request) - { - IMcService mcService =McUtils.getToolService(request); - Long queUsrId=McUtils.getUserId(); - McQueUsr mcQueUsr=mcService.retrieveMcQueUsr(queUsrId); - return mcQueUsr; - } - - - /** * creates a user attempt in the db * createAttempt(HttpServletRequest request) * Fisheye: Tag 7e58118a02164b69f28068177656576f32aaeddd refers to a dead (removed) revision in file `lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/McExportAction.java'. Fisheye: No comparison available. Pass `N' to diff? Index: lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/McLearningAction.java =================================================================== diff -u -r1dff7467ea5dbd5ca46d957a89ce42b1eb8b64c1 -r7e58118a02164b69f28068177656576f32aaeddd --- lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/McLearningAction.java (.../McLearningAction.java) (revision 1dff7467ea5dbd5ca46d957a89ce42b1eb8b64c1) +++ lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/McLearningAction.java (.../McLearningAction.java) (revision 7e58118a02164b69f28068177656576f32aaeddd) @@ -48,6 +48,7 @@ import org.lamsfoundation.lams.tool.mc.pojos.McContent; import org.lamsfoundation.lams.tool.mc.pojos.McQueContent; import org.lamsfoundation.lams.tool.mc.pojos.McQueUsr; +import org.lamsfoundation.lams.tool.mc.pojos.McSession; import org.lamsfoundation.lams.tool.mc.pojos.McUsrAttempt; import org.lamsfoundation.lams.tool.mc.service.IMcService; import org.lamsfoundation.lams.web.action.LamsDispatchAction; @@ -426,17 +427,42 @@ mcLearningForm.setPassMarkApplicable(new Boolean(false).toString()); } - boolean isUserDefined=LearningUtil.doesUserExists(request); - logger.debug("isUserDefined"); + + Long toolSessionId=(Long)request.getSession().getAttribute(TOOL_SESSION_ID); + logger.debug("toolSessionId: " + toolSessionId); + + McSession mcSession=mcService.retrieveMcSession(toolSessionId); + logger.debug("retrieving mcSession: " + mcSession); + + Long toolSessionUid=mcSession.getUid(); + logger.debug("toolSessionUid: " + toolSessionUid); + + + boolean isUserDefined=false; + String userID=(String)request.getSession().getAttribute(USER_ID); + logger.debug("userID: " + userID); + McQueUsr existingMcQueUsr=mcService.getMcUserBySession(new Long(userID), mcSession.getUid()); + logger.debug("existingMcQueUsr: " + existingMcQueUsr); + + if (existingMcQueUsr != null) + isUserDefined=true; + + logger.debug("isUserDefined: " + isUserDefined); + + McQueUsr mcQueUsr=null; if (isUserDefined == false) { - LearningUtil.createUser(request); - logger.debug("created user in the db"); + mcQueUsr=LearningUtil.createUser(request); + logger.debug("created user in the db: " + mcQueUsr); } - McQueUsr mcQueUsr=LearningUtil.getUser(request); - logger.debug("mcQueUsr: " + mcQueUsr); + else + { + mcQueUsr=existingMcQueUsr; + logger.debug("assign"); + } + + logger.debug("final mcQueUsr: " + mcQueUsr); - String highestAttemptOrder=(String)request.getSession().getAttribute(LEARNER_LAST_ATTEMPT_ORDER); logger.debug("current highestAttemptOrder:" + highestAttemptOrder); @@ -538,7 +564,18 @@ request.getSession().setAttribute(CURRENT_QUESTION_INDEX, "1"); request.getSession().setAttribute(TOTAL_COUNT_REACHED, new Boolean(false).toString()); - McQueUsr mcQueUsr=LearningUtil.getUser(request); + Long toolSessionId=(Long)request.getSession().getAttribute(TOOL_SESSION_ID); + logger.debug("toolSessionId: " + toolSessionId); + + McSession mcSession=mcService.retrieveMcSession(toolSessionId); + logger.debug("retrieving mcSession: " + mcSession); + + String userID=(String)request.getSession().getAttribute(USER_ID); + logger.debug("userID: " + userID); + + McQueUsr mcQueUsr=mcService.getMcUserBySession(new Long(userID), mcSession.getUid()); + logger.debug("mcQueUsr: " + mcQueUsr); + Long queUsrId=mcQueUsr.getUid(); logger.debug("queUsrId: " + queUsrId); @@ -609,8 +646,15 @@ } else { - mcQueUsr=mcService.retrieveMcQueUsr(new Long(learnerProgressUserId)); - logger.debug("mcQueUsr: " + mcQueUsr); + //mcQueUsr=mcService.retrieveMcQueUsr(new Long(learnerProgressUserId)); + //logger.debug("mcQueUsr: " + mcQueUsr); + Long toolSessionId=(Long)request.getSession().getAttribute(TOOL_SESSION_ID); + logger.debug("toolSessionId: " + toolSessionId); + + McSession mcSession=mcService.retrieveMcSession(toolSessionId); + logger.debug("retrieving mcSession: " + mcSession); + + mcQueUsr=mcService.getMcUserBySession(new Long(learnerProgressUserId), mcSession.getUid()); queUsrId=mcQueUsr.getUid(); logger.debug("queUsrId: " + queUsrId); Index: lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/McLearningStarterAction.java =================================================================== diff -u -r1dff7467ea5dbd5ca46d957a89ce42b1eb8b64c1 -r7e58118a02164b69f28068177656576f32aaeddd --- lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/McLearningStarterAction.java (.../McLearningStarterAction.java) (revision 1dff7467ea5dbd5ca46d957a89ce42b1eb8b64c1) +++ lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/McLearningStarterAction.java (.../McLearningStarterAction.java) (revision 7e58118a02164b69f28068177656576f32aaeddd) @@ -357,8 +357,11 @@ McLearningAction mcLearningAction= new McLearningAction(); /* pay attention that this userId is the learner's userId passed by the request parameter. * It is differerent than USER_ID kept in the session of the current system user*/ - McQueUsr mcQueUsr=mcService.retrieveMcQueUsr(new Long(userId)); - logger.debug("mcQueUsr:" + mcQueUsr); + //McQueUsr mcQueUsr=mcService.retrieveMcQueUsr(new Long(userId)); + //logger.debug("mcQueUsr:" + mcQueUsr); + + McQueUsr mcQueUsr=mcService.getMcUserBySession(new Long(userId), mcSession.getUid()); + logger.debug("mcQueUsr: " + mcQueUsr); if (mcQueUsr == null) { McUtils.cleanUpSessionAbsolute(request); @@ -440,7 +443,8 @@ String userID=(String) request.getSession().getAttribute(USER_ID); logger.debug("userID:" + userID); - McQueUsr mcQueUsr=mcService.retrieveMcQueUsr(new Long(userID)); + //McQueUsr mcQueUsr=mcService.retrieveMcQueUsr(new Long(userID)); + McQueUsr mcQueUsr=mcService.getMcUserBySession(new Long(userID), mcSession.getUid()); logger.debug("mcQueUsr:" + mcQueUsr); if (mcQueUsr != null) Index: lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/MonitoringUtil.java =================================================================== diff -u -r3d2afa94019913eda4e30f231afcbe8f631ef5a2 -r7e58118a02164b69f28068177656576f32aaeddd --- lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/MonitoringUtil.java (.../MonitoringUtil.java) (revision 3d2afa94019913eda4e30f231afcbe8f631ef5a2) +++ lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/MonitoringUtil.java (.../MonitoringUtil.java) (revision 7e58118a02164b69f28068177656576f32aaeddd) @@ -132,7 +132,48 @@ logger.debug("final listMonitoredAnswersContainerDTO:..." + listMonitoredAnswersContainerDTO); return listMonitoredAnswersContainerDTO; } + + public static List buildSessionQuestionData(HttpServletRequest request, McContent mcContent, Long sessionId, Long userID) + { + logger.debug("doing buildSessionQuestionData with sessionId: " + sessionId); + logger.debug("doing buildSessionQuestionData with userID: " + userID); + logger.debug("will be building groups question data for content:..." + mcContent); + IMcService mcService =McUtils.getToolService(request); + List listQuestions=mcService.getAllQuestionEntries(mcContent.getUid()); + logger.debug("listQuestions:..." + listQuestions); + + List listMonitoredAnswersContainerDTO= new LinkedList(); + + Iterator itListQuestions = listQuestions.iterator(); + while (itListQuestions.hasNext()) + { + McQueContent mcQueContent =(McQueContent)itListQuestions.next(); + logger.debug("mcQueContent:..." + mcQueContent); + + if (mcQueContent != null) + { + McMonitoredAnswersDTO mcMonitoredAnswersDTO= new McMonitoredAnswersDTO(); + mcMonitoredAnswersDTO.setQuestionUid(mcQueContent.getUid().toString()); + mcMonitoredAnswersDTO.setQuestion(mcQueContent.getQuestion()); + + List listCandidateAnswers=mcService.findMcOptionNamesByQueId(mcQueContent.getUid()); + logger.debug("listCandidateAnswers:..." + listCandidateAnswers); + mcMonitoredAnswersDTO.setCandidateAnswers(listCandidateAnswers); + + Map questionAttemptData= buildSessionAttemptData(request, mcContent, mcQueContent, mcQueContent.getUid().toString(), sessionId, userID); + logger.debug("questionAttemptData:..." + questionAttemptData); + mcMonitoredAnswersDTO.setQuestionAttempts(questionAttemptData); + listMonitoredAnswersContainerDTO.add(mcMonitoredAnswersDTO); + + } + } + logger.debug("final listMonitoredAnswersContainerDTO:..." + listMonitoredAnswersContainerDTO); + return listMonitoredAnswersContainerDTO; + } + + + /** * helps populating user's attempt history * buildGroupsAttemptData(HttpServletRequest request, McContent mcContent, McQueContent mcQueContent) @@ -167,7 +208,7 @@ { List listMcUsers=mcService.getMcUserBySessionOnly(mcSession); logger.debug("listMcUsers for session id:" + mcSession.getMcSessionId() + " = " + listMcUsers); - Map sessionUsersAttempts=populateSessionUsersAttempts(request,mcSession.getMcSessionId(), listMcUsers, questionUid); + Map sessionUsersAttempts=populateSessionUsersAttempts(request,mcSession.getMcSessionId(), listMcUsers, questionUid, null); listMonitoredAttemptsContainerDTO.add(sessionUsersAttempts); } @@ -180,7 +221,34 @@ return mapMonitoredAttemptsContainerDTO; } + + public static Map buildSessionAttemptData(HttpServletRequest request, McContent mcContent, McQueContent mcQueContent, String questionUid, Long sessionId, Long userID) + { + logger.debug("doing buildSessionAttemptData with sessionId: " + sessionId); + logger.debug("doing buildSessionAttemptData with userID: " + userID); + logger.debug("will be building groups attempt data for mcQueContent:..." + mcQueContent + " questionUid:" + questionUid); + + IMcService mcService =McUtils.getToolService(request); + Map mapMonitoredAttemptsContainerDTO= new TreeMap(new McStringComparator()); + List listMonitoredAttemptsContainerDTO= new LinkedList(); + + McSession mcSession= mcService.findMcSessionById(sessionId); + logger.debug("mcSession: " + " = " + mcSession); + if (mcSession != null) + { + List listMcUsers=mcService.getMcUserBySessionOnly(mcSession); + logger.debug("listMcUsers for session id:" + mcSession.getMcSessionId() + " = " + listMcUsers); + Map sessionUsersAttempts=populateSessionUsersAttempts(request,mcSession.getMcSessionId(), listMcUsers, questionUid, userID); + + listMonitoredAttemptsContainerDTO.add(sessionUsersAttempts); + logger.debug("final listMonitoredAttemptsContainerDTO:..." + listMonitoredAttemptsContainerDTO); + mapMonitoredAttemptsContainerDTO=convertToMap(listMonitoredAttemptsContainerDTO); + logger.debug("final mapMonitoredAttemptsContainerDTO:..." + mapMonitoredAttemptsContainerDTO); + } + return mapMonitoredAttemptsContainerDTO; + } + /** * return total attempt count from all the users * getTotalAttemptCount(HttpServletRequest request) @@ -205,54 +273,105 @@ * @param listMcUsers * @return List */ - public static Map populateSessionUsersAttempts(HttpServletRequest request,Long sessionId, List listMcUsers, String questionUid) + public static Map populateSessionUsersAttempts(HttpServletRequest request,Long sessionId, List listMcUsers, String questionUid, Long userID) { logger.debug("will be populating users attempt history for session id: " + sessionId); + logger.debug("userID: " + userID); IMcService mcService =McUtils.getToolService(request); Map mapMonitoredUserContainerDTO= new TreeMap(new McStringComparator()); List listMonitoredUserContainerDTO= new LinkedList(); - Iterator itUsers=listMcUsers.iterator(); - while (itUsers.hasNext()) + if (userID == null) { - McQueUsr mcQueUsr=(McQueUsr)itUsers.next(); - logger.debug("mcQueUsr: " + mcQueUsr); - - if (mcQueUsr != null) - { - logger.debug("getting listUserAttempts for user id: " + mcQueUsr.getUid() + " and que content id: " + questionUid); - List listUserAttempts=mcService.getAttemptsForUserAndQuestionContent(mcQueUsr.getUid(), new Long(questionUid)); - logger.debug("listUserAttempts: " + listUserAttempts); + Iterator itUsers=listMcUsers.iterator(); + while (itUsers.hasNext()) + { + McQueUsr mcQueUsr=(McQueUsr)itUsers.next(); + logger.debug("mcQueUsr: " + mcQueUsr); + + if (mcQueUsr != null) + { + logger.debug("getting listUserAttempts for user id: " + mcQueUsr.getUid() + " and que content id: " + questionUid); + List listUserAttempts=mcService.getAttemptsForUserAndQuestionContent(mcQueUsr.getUid(), new Long(questionUid)); + logger.debug("listUserAttempts: " + listUserAttempts); - Iterator itAttempts=listUserAttempts.iterator(); - while (itAttempts.hasNext()) - { - McUsrAttempt mcUsrAttempt=(McUsrAttempt)itAttempts.next(); - logger.debug("mcUsrAttempt: " + mcUsrAttempt); - - if (mcUsrAttempt != null) - { - McMonitoredUserDTO mcMonitoredUserDTO = new McMonitoredUserDTO(); - mcMonitoredUserDTO.setAttemptTime(mcUsrAttempt.getAttemptTime().toString()); - mcMonitoredUserDTO.setIsCorrect(new Boolean(mcUsrAttempt.isAttemptCorrect()).toString()); - mcMonitoredUserDTO.setResponse(mcUsrAttempt.getMcOptionsContent().getMcQueOptionText().toString()); - mcMonitoredUserDTO.setTimeZone(mcUsrAttempt.getTimeZone()); - mcMonitoredUserDTO.setUid(mcUsrAttempt.getUid().toString()); - mcMonitoredUserDTO.setUserName(mcQueUsr.getUsername()); - mcMonitoredUserDTO.setQueUsrId(mcQueUsr.getUid().toString()); - mcMonitoredUserDTO.setSessionId(sessionId.toString()); - mcMonitoredUserDTO.setQuestionUid(questionUid); - listMonitoredUserContainerDTO.add(mcMonitoredUserDTO); - } - } - } + Iterator itAttempts=listUserAttempts.iterator(); + while (itAttempts.hasNext()) + { + McUsrAttempt mcUsrAttempt=(McUsrAttempt)itAttempts.next(); + logger.debug("mcUsrAttempt: " + mcUsrAttempt); + + if (mcUsrAttempt != null) + { + McMonitoredUserDTO mcMonitoredUserDTO = new McMonitoredUserDTO(); + mcMonitoredUserDTO.setAttemptTime(mcUsrAttempt.getAttemptTime().toString()); + mcMonitoredUserDTO.setIsCorrect(new Boolean(mcUsrAttempt.isAttemptCorrect()).toString()); + mcMonitoredUserDTO.setResponse(mcUsrAttempt.getMcOptionsContent().getMcQueOptionText().toString()); + mcMonitoredUserDTO.setTimeZone(mcUsrAttempt.getTimeZone()); + mcMonitoredUserDTO.setUid(mcUsrAttempt.getUid().toString()); + mcMonitoredUserDTO.setUserName(mcQueUsr.getFullname()); + mcMonitoredUserDTO.setQueUsrId(mcQueUsr.getUid().toString()); + mcMonitoredUserDTO.setSessionId(sessionId.toString()); + mcMonitoredUserDTO.setQuestionUid(questionUid); + listMonitoredUserContainerDTO.add(mcMonitoredUserDTO); + } + } + } + } + logger.debug("final listMonitoredUserContainerDTO: " + listMonitoredUserContainerDTO); + mapMonitoredUserContainerDTO=convertToMcMonitoredUserDTOMap(listMonitoredUserContainerDTO); + logger.debug("final mapMonitoredUserContainerDTO:..." + mapMonitoredUserContainerDTO); + return mapMonitoredUserContainerDTO; } - logger.debug("final listMonitoredUserContainerDTO: " + listMonitoredUserContainerDTO); - mapMonitoredUserContainerDTO=convertToMcMonitoredUserDTOMap(listMonitoredUserContainerDTO); - logger.debug("final mapMonitoredUserContainerDTO:..." + mapMonitoredUserContainerDTO); - return mapMonitoredUserContainerDTO; + else + { + logger.debug("request is for learner export portfolio: " + userID); + Iterator itUsers=listMcUsers.iterator(); + while (itUsers.hasNext()) + { + McQueUsr mcQueUsr=(McQueUsr)itUsers.next(); + logger.debug("mcQueUsr: " + mcQueUsr); + logger.debug("local mcQueUsr userID: " + mcQueUsr.getQueUsrId()); + logger.debug("mcQueUsr.getQueUsrId().toString versus userID.toString(): " + mcQueUsr.getQueUsrId().toString() + " versus " + userID.toString()); + if ((mcQueUsr != null) && (mcQueUsr.getQueUsrId().toString().equals(userID.toString()))) + { + logger.debug("the user in question is found: " + mcQueUsr.getQueUsrId()); + logger.debug("getting listUserAttempts for user id: " + mcQueUsr.getUid() + " and que content id: " + questionUid); + List listUserAttempts=mcService.getAttemptsForUserAndQuestionContent(mcQueUsr.getUid(), new Long(questionUid)); + logger.debug("listUserAttempts: " + listUserAttempts); + + Iterator itAttempts=listUserAttempts.iterator(); + while (itAttempts.hasNext()) + { + McUsrAttempt mcUsrAttempt=(McUsrAttempt)itAttempts.next(); + logger.debug("mcUsrAttempt: " + mcUsrAttempt); + + if (mcUsrAttempt != null) + { + McMonitoredUserDTO mcMonitoredUserDTO = new McMonitoredUserDTO(); + mcMonitoredUserDTO.setAttemptTime(mcUsrAttempt.getAttemptTime().toString()); + mcMonitoredUserDTO.setIsCorrect(new Boolean(mcUsrAttempt.isAttemptCorrect()).toString()); + mcMonitoredUserDTO.setResponse(mcUsrAttempt.getMcOptionsContent().getMcQueOptionText().toString()); + mcMonitoredUserDTO.setTimeZone(mcUsrAttempt.getTimeZone()); + mcMonitoredUserDTO.setUid(mcUsrAttempt.getUid().toString()); + mcMonitoredUserDTO.setUserName(mcQueUsr.getFullname()); + mcMonitoredUserDTO.setQueUsrId(mcQueUsr.getUid().toString()); + mcMonitoredUserDTO.setSessionId(sessionId.toString()); + mcMonitoredUserDTO.setQuestionUid(questionUid); + listMonitoredUserContainerDTO.add(mcMonitoredUserDTO); + } + } + } + } + logger.debug("final listMonitoredUserContainerDTO: " + listMonitoredUserContainerDTO); + mapMonitoredUserContainerDTO=convertToMcMonitoredUserDTOMap(listMonitoredUserContainerDTO); + logger.debug("final mapMonitoredUserContainerDTO:..." + mapMonitoredUserContainerDTO); + return mapMonitoredUserContainerDTO; + + } + } public static Map populateToolSessionsId(HttpServletRequest request, McContent mcContent, IMcService mcService) Index: lams_tool_lamc/web/export/ExportContent.jsp =================================================================== diff -u -r3d2afa94019913eda4e30f231afcbe8f631ef5a2 -r7e58118a02164b69f28068177656576f32aaeddd --- lams_tool_lamc/web/export/ExportContent.jsp (.../ExportContent.jsp) (revision 3d2afa94019913eda4e30f231afcbe8f631ef5a2) +++ lams_tool_lamc/web/export/ExportContent.jsp (.../ExportContent.jsp) (revision 7e58118a02164b69f28068177656576f32aaeddd) @@ -51,7 +51,7 @@