Index: lams_tool_laqa/conf/hibernate/mappings/org/lamsfoundation/lams/tool/qa/QaContent.hbm.xml =================================================================== RCS file: /usr/local/cvsroot/lams_tool_laqa/conf/hibernate/mappings/org/lamsfoundation/lams/tool/qa/QaContent.hbm.xml,v diff -u -r1.6 -r1.7 --- lams_tool_laqa/conf/hibernate/mappings/org/lamsfoundation/lams/tool/qa/QaContent.hbm.xml 23 Sep 2006 15:11:03 -0000 1.6 +++ lams_tool_laqa/conf/hibernate/mappings/org/lamsfoundation/lams/tool/qa/QaContent.hbm.xml 11 Nov 2006 14:58:36 -0000 1.7 @@ -129,7 +129,18 @@ length="1" /> + + + + + - + @@ -269,6 +269,19 @@ + + + + + + + + + + + + + Index: lams_tool_laqa/db/sql/create_lams_tool_qa.sql =================================================================== RCS file: /usr/local/cvsroot/lams_tool_laqa/db/sql/create_lams_tool_qa.sql,v diff -u -r1.43 -r1.44 --- lams_tool_laqa/db/sql/create_lams_tool_qa.sql 1 Nov 2006 22:39:17 -0000 1.43 +++ lams_tool_laqa/db/sql/create_lams_tool_qa.sql 11 Nov 2006 14:58:38 -0000 1.44 @@ -20,6 +20,7 @@ -- -- $Id$ + CREATE TABLE tl_laqa11_content ( uid BIGINT(20) NOT NULL AUTO_INCREMENT , qa_content_id BIGINT(20) NOT NULL @@ -38,6 +39,7 @@ , online_instructions TEXT , content_inUse TINYINT(1) DEFAULT 0 , reflectionSubject TEXT + , lockWhenFinished TINYINT(1) NOT NULL DEFAULT 1 , PRIMARY KEY (uid) )TYPE=InnoDB; @@ -112,12 +114,7 @@ )TYPE=InnoDB; -- data for content table -INSERT INTO tl_laqa11_content (qa_content_id, title, instructions, creation_date) VALUES (${default_content_id}, 'Q&A', 'Instructions', NOW()); +INSERT INTO tl_laqa11_content (qa_content_id, title, instructions, creation_date, lockWhenFinished) VALUES (${default_content_id}, 'Q&A', 'Instructions', NOW() , 1); -- data for content questions table INSERT INTO tl_laqa11_que_content (question, display_order, qa_content_id) VALUES ('Sample Question 1?',1,1); - - - - - Index: lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/dao/IQaUsrRespDAO.java =================================================================== RCS file: /usr/local/cvsroot/lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/dao/IQaUsrRespDAO.java,v diff -u -r1.11 -r1.12 --- lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/dao/IQaUsrRespDAO.java 20 Sep 2006 15:15:44 -0000 1.11 +++ lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/dao/IQaUsrRespDAO.java 11 Nov 2006 14:58:39 -0000 1.12 @@ -50,6 +50,8 @@ public QaUsrResp retrieveQaUsrResp(long responseId); public List getAttemptsForUserAndQuestionContent(final Long queUsrId, final Long qaQueContentId); + + public void removeAttemptsForUserAndQuestionContent(final Long queUsrId, final Long qaQueContentId); } Index: lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/dao/hibernate/QaUsrRespDAO.java =================================================================== RCS file: /usr/local/cvsroot/lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/dao/hibernate/QaUsrRespDAO.java,v diff -u -r1.14 -r1.15 --- lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/dao/hibernate/QaUsrRespDAO.java 20 Sep 2006 15:15:44 -0000 1.14 +++ lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/dao/hibernate/QaUsrRespDAO.java 11 Nov 2006 14:58:38 -0000 1.15 @@ -23,6 +23,7 @@ /* $$Id$$ */ package org.lamsfoundation.lams.tool.qa.dao.hibernate; +import java.util.Iterator; import java.util.List; import org.hibernate.FlushMode; @@ -112,6 +113,29 @@ return list; } + + public void removeAttemptsForUserAndQuestionContent(final Long queUsrId, final Long qaQueContentId) + { + HibernateTemplate templ = this.getHibernateTemplate(); + List list = getSession().createQuery(LOAD_ATTEMPT_FOR_USER_AND_QUESTION_CONTENT) + .setLong("queUsrId", queUsrId.longValue()) + .setLong("qaQueContentId", qaQueContentId.longValue()) + .list(); + + + if(list != null && list.size() > 0){ + Iterator listIterator=list.iterator(); + while (listIterator.hasNext()) + { + QaUsrResp qaUsrResp=(QaUsrResp)listIterator.next(); + this.getSession().setFlushMode(FlushMode.AUTO); + templ.delete(qaUsrResp); + templ.flush(); + } + } + } + + public void removeUserResponseByQaQueId(Long qaQueId) { if ( qaQueId != null ) { Index: lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/service/IQaService.java =================================================================== RCS file: /usr/local/cvsroot/lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/service/IQaService.java,v diff -u -r1.43 -r1.44 --- lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/service/IQaService.java 20 Sep 2006 15:15:44 -0000 1.43 +++ lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/service/IQaService.java 11 Nov 2006 14:58:36 -0000 1.44 @@ -153,6 +153,8 @@ 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; Index: lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/service/QaServicePOJO.java =================================================================== RCS file: /usr/local/cvsroot/lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/service/QaServicePOJO.java,v diff -u -r1.71 -r1.72 --- lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/service/QaServicePOJO.java 18 Oct 2006 02:16:49 -0000 1.71 +++ lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/service/QaServicePOJO.java 11 Nov 2006 14:58:37 -0000 1.72 @@ -448,6 +448,22 @@ } } + + 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 updateUserResponse(QaUsrResp resp) throws QaApplicationException { try @@ -2086,8 +2102,6 @@ */ public void import102ToolContent(Long toolContentId, UserDTO user, Hashtable importValues) { - - Date now = new Date(); QaContent toolContentObj = new QaContent(); toolContentObj.setContentLocked(Boolean.FALSE.booleanValue() ); @@ -2097,7 +2111,7 @@ toolContentObj.setInstructions(null); toolContentObj.setOfflineInstructions(null); toolContentObj.setOnlineInstructions(null); - toolContentObj.setReflect(Boolean.FALSE); + toolContentObj.setReflect(Boolean.FALSE.booleanValue()); toolContentObj.setReflectionSubject(null); toolContentObj.setRunOffline(Boolean.FALSE.booleanValue()); toolContentObj.setTitle((String)importValues.get(ToolContentImport102Manager.CONTENT_TITLE)); @@ -2108,6 +2122,7 @@ toolContentObj.setReportTitle(null); toolContentObj.setMonitoringReportTitle(null); toolContentObj.setSynchInMonitor(false); // doesn't appear to be used in LAMS 2.0 + toolContentObj.setLockWhenFinished(Boolean.TRUE.booleanValue()); // doesn't appear to be used in LAMS 2.0 Boolean bool; try { @@ -2148,7 +2163,7 @@ +" as the tool content does not exist."); } - qaContent.setReflect(Boolean.TRUE); + qaContent.setReflect(Boolean.TRUE.booleanValue()); qaContent.setReflectionSubject(description); } Index: lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/AuthoringUtil.java =================================================================== RCS file: /usr/local/cvsroot/lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/AuthoringUtil.java,v diff -u -r1.42 -r1.43 --- lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/AuthoringUtil.java 13 Oct 2006 12:23:20 -0000 1.42 +++ lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/AuthoringUtil.java 11 Nov 2006 14:58:34 -0000 1.43 @@ -438,10 +438,6 @@ { UserDTO toolUser = (UserDTO) SessionManager.getSession().getAttribute(AttributeNames.USER); - boolean isQuestionsSequenced=false; - boolean isSynchInMonitor=false; - boolean isUsernameVisible=false; - String richTextTitle = request.getParameter(TITLE); String richTextInstructions = request.getParameter(INSTRUCTIONS); @@ -450,10 +446,17 @@ String synchInMonitor=request.getParameter(SYNC_IN_MONITOR); logger.debug("synchInMonitor: " + synchInMonitor); + String usernameVisible=request.getParameter(USERNAME_VISIBLE); logger.debug("usernameVisible: " + usernameVisible); + 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); @@ -467,7 +470,7 @@ boolean setCommonContent=true; - if ((questionsSequenced == null) || (synchInMonitor == null) || + if ((questionsSequenced == null) || (synchInMonitor == null) || (lockWhenFinished == null) || (usernameVisible == null) || (reflect == null)) { setCommonContent=false; @@ -476,6 +479,7 @@ boolean questionsSequencedBoolean=false; boolean synchInMonitorBoolean=false; + boolean lockWhenFinishedBoolean=false; boolean usernameVisibleBoolean=false; boolean reflectBoolean=false; @@ -485,6 +489,9 @@ if ((synchInMonitor != null) && (synchInMonitor.equalsIgnoreCase("1"))) synchInMonitorBoolean=true; + if ((lockWhenFinished != null) && (lockWhenFinished.equalsIgnoreCase("1"))) + lockWhenFinishedBoolean=true; + if ((usernameVisible != null) && (usernameVisible.equalsIgnoreCase("1"))) usernameVisibleBoolean=true; @@ -494,6 +501,7 @@ logger.debug("questionsSequencedBoolean: " + questionsSequencedBoolean); logger.debug("synchInMonitorBoolean: " + synchInMonitorBoolean); + logger.debug("lockWhenFinishedBoolean: " + lockWhenFinishedBoolean); logger.debug("usernameVisibleBoolean: " + usernameVisibleBoolean); logger.debug("reflectBoolean: " + reflectBoolean); @@ -544,12 +552,11 @@ if (activeModule.equals(AUTHORING)) { logger.debug("setting other content values..."); - qaContent.setQuestionsSequenced(isQuestionsSequenced); - qaContent.setSynchInMonitor(isSynchInMonitor); qaContent.setOnlineInstructions(richTextOnlineInstructions); qaContent.setOfflineInstructions(richTextOfflineInstructions); qaContent.setUsernameVisible(usernameVisibleBoolean); qaContent.setQuestionsSequenced(questionsSequencedBoolean); + qaContent.setLockWhenFinished(lockWhenFinishedBoolean); qaContent.setSynchInMonitor(synchInMonitorBoolean); qaContent.setReflect(reflectBoolean); qaContent.setReflectionSubject(reflectionSubject); Index: lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/LearningUtil.java =================================================================== RCS file: /usr/local/cvsroot/lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/LearningUtil.java,v diff -u -r1.37 -r1.38 --- lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/LearningUtil.java 12 Oct 2006 13:21:17 -0000 1.37 +++ lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/LearningUtil.java 11 Nov 2006 14:58:36 -0000 1.38 @@ -205,9 +205,31 @@ boolean isResponseFinalized=qaQueUsr.isResponseFinalized(); logger.debug("isResponseFinalized: " + isResponseFinalized); - if (!isResponseFinalized) + boolean lockWhenFinished=qaContent.isLockWhenFinished(); + logger.debug("lockWhenFinished: " + lockWhenFinished); + + boolean enableAttemptEntry=false; + boolean userAttemptExist=false; + + if (!isResponseFinalized) + { + logger.debug("type 1 attempt entry"); + enableAttemptEntry=true; + } + + if (isResponseFinalized && (!lockWhenFinished)) + { + logger.debug("type 2 attempt entry"); + logger.debug("second visit and lockWhenFinished is false, enable attempt entry"); + userAttemptExist=true; + enableAttemptEntry=true; + } + logger.debug("final enableAttemptEntry: " + enableAttemptEntry); + logger.debug("final userAttemptExist: " + userAttemptExist); + + if (enableAttemptEntry) { - logger.debug("isResponseFinalized is false, so creating the responses: "); + logger.debug("enableAttemptEntry is true, so creating the responses: "); while (contentIterator.hasNext()) { QaQueContent qaQueContent=(QaQueContent)contentIterator.next(); @@ -216,7 +238,9 @@ logger.debug("qaQueContent uid:" + qaQueContent.getUid()); String question=qaQueContent.getQuestion(); + logger.debug("question:" + question); String displayOrder=new Long(qaQueContent.getDisplayOrder()).toString(); + logger.debug("displayOrder:" + displayOrder); String answer=(String)mapAnswers.get(displayOrder); logger.debug("iterationg question-answers: displayOrder: " + displayOrder + @@ -227,12 +251,12 @@ List attempts=qaService.getAttemptsForUserAndQuestionContent(qaQueUsr.getUid(), qaQueContent.getUid()); logger.debug("attempts:" + attempts); - if ((attempts != null) && (attempts.size() > 0)) + + if (userAttemptExist) { - logger.debug("this user already responsed to q/a in this session:"); - } - else - { + logger.debug("since userAttemptExist is true remove them:"); + qaService.removeAttemptsForUserAndQuestionContent(qaQueUsr.getUid(), qaQueContent.getUid()); + logger.debug("creating response."); QaUsrResp qaUsrResp= new QaUsrResp(answer,false, new Date(System.currentTimeMillis()), @@ -247,7 +271,34 @@ qaService.createQaUsrResp(qaUsrResp); logger.debug("created qaUsrResp in the db"); } + + logger.debug("recreated user attempts since the content is not locked when finished"); } + else + { + logger.debug("first time attempt entry or content is locked"); + if ((attempts != null) && (attempts.size() > 0)) + { + logger.debug("this user already responsed to q/a in this session:"); + } + else + { + logger.debug("creating response."); + QaUsrResp qaUsrResp= new QaUsrResp(answer,false, + new Date(System.currentTimeMillis()), + timezoneId, + qaQueContent, + qaQueUsr, + true); + + logger.debug("iterationg qaUsrResp: " + qaUsrResp); + if (qaUsrResp != null) + { + qaService.createQaUsrResp(qaUsrResp); + logger.debug("created qaUsrResp in the db"); + } + } + } } } Index: lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/QaAuthoringForm.java =================================================================== RCS file: /usr/local/cvsroot/lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/Attic/QaAuthoringForm.java,v diff -u -r1.22 -r1.23 --- lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/QaAuthoringForm.java 20 Sep 2006 15:15:41 -0000 1.22 +++ lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/QaAuthoringForm.java 11 Nov 2006 14:58:35 -0000 1.23 @@ -75,6 +75,7 @@ protected String endLearningMessage; protected String usernameVisible; protected String questionsSequenced; + protected String lockWhenFinished; protected String reflect; protected String reflectionSubject; @@ -142,6 +143,7 @@ this.reportTitle=null; this.monitoringReportTitle=null; this.questionsSequenced=null; + this.lockWhenFinished=null; this.reflect=null; @@ -159,6 +161,7 @@ this.synchInMonitor =OPTION_OFF; this.usernameVisible =OPTION_OFF; this.questionsSequenced =OPTION_OFF; + this.lockWhenFinished =OPTION_OFF; this.reflect =OPTION_OFF; } @@ -179,6 +182,7 @@ .append("usernameVisible: ", usernameVisible) .append("synchInMonitor: ", synchInMonitor) .append("questionsSequenced: ", questionsSequenced) + .append("lockWhenFinished: ", lockWhenFinished) .append("reflect: ", reflect) .append("defineLaterInEditMode: ", defineLaterInEditMode) .toString(); @@ -744,4 +748,16 @@ public void setEditQuestionBoxRequest(String editQuestionBoxRequest) { this.editQuestionBoxRequest = editQuestionBoxRequest; } + /** + * @return Returns the lockWhenFinished. + */ + public String getLockWhenFinished() { + return lockWhenFinished; + } + /** + * @param lockWhenFinished The lockWhenFinished to set. + */ + public void setLockWhenFinished(String lockWhenFinished) { + this.lockWhenFinished = lockWhenFinished; + } } Index: lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/QaLearningAction.java =================================================================== RCS file: /usr/local/cvsroot/lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/QaLearningAction.java,v diff -u -r1.27 -r1.28 --- lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/QaLearningAction.java 19 Oct 2006 23:38:54 -0000 1.27 +++ lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/QaLearningAction.java 11 Nov 2006 14:58:35 -0000 1.28 @@ -100,6 +100,7 @@ import java.util.Date; import java.util.HashMap; import java.util.Iterator; +import java.util.List; import java.util.Map; import java.util.TreeMap; import java.util.TreeSet; @@ -122,6 +123,7 @@ import org.lamsfoundation.lams.tool.qa.QaQueContent; import org.lamsfoundation.lams.tool.qa.QaQueUsr; import org.lamsfoundation.lams.tool.qa.QaSession; +import org.lamsfoundation.lams.tool.qa.QaUsrResp; import org.lamsfoundation.lams.tool.qa.QaUtils; import org.lamsfoundation.lams.tool.qa.service.IQaService; import org.lamsfoundation.lams.tool.qa.service.QaServiceProxy; @@ -273,7 +275,24 @@ return (mapping.findForward(INDIVIDUAL_LEARNER_RESULTS)); } - + + /** + * enables retaking the activity + * + * ActionForward redoQuestions(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 redoQuestions(ActionMapping mapping, ActionForm form, HttpServletRequest request, @@ -310,7 +329,6 @@ generalLearnerFlowDTO.setCurrentQuestionIndex(new Integer(1)); qaLearningForm.setCurrentQuestionIndex(new Integer(1).toString()); - //SessionMap sessionMap = new SessionMap(); String httpSessionID=qaLearningForm.getHttpSessionID(); logger.debug("httpSessionID: " + httpSessionID); @@ -370,25 +388,83 @@ logger.debug("QUESTION_LISTING_MODE: " + generalLearnerFlowDTO.getQuestionListingMode()); + + HttpSession ss = SessionManager.getSession(); + /* get back login user DTO */ + UserDTO toolUser = (UserDTO) ss.getAttribute(AttributeNames.USER); + logger.debug("retrieving toolUser: " + toolUser); + logger.debug("retrieving toolUser userId: " + toolUser.getUserID()); + logger.debug("retrieving toolUser username: " + toolUser.getLogin()); + + String userName=toolUser.getLogin(); + String fullName= toolUser.getFirstName() + " " + toolUser.getLastName(); + logger.debug("retrieving toolUser fullname: " + fullName); + + Long userId=new Long(toolUser.getUserID().longValue()); + logger.debug("userId: " + userId); + + QaQueUsr qaQueUsr=qaService.getQaUserBySession(userId, qaSession.getUid()); + logger.debug("qaQueUsr: " + qaQueUsr); + + Long qaQueUsrUid=null; + boolean isResponseFinalized=false; + if (qaQueUsr != null) + { + qaQueUsrUid=qaQueUsr.getUid(); + logger.debug("qaQueUsrUid: " + qaQueUsrUid); + + isResponseFinalized=qaQueUsr.isResponseFinalized (); + logger.debug("isResponseFinalized: " + isResponseFinalized); + } + + + Map mapAnswersFromDb= new TreeMap(new QaComparator()); /* * fetch question content from content */ Iterator contentIterator=qaContent.getQaQueContents().iterator(); + + int questionCount=0; while (contentIterator.hasNext()) { QaQueContent qaQueContent=(QaQueContent)contentIterator.next(); if (qaQueContent != null) { + Long questionUid=qaQueContent.getUid(); + logger.debug("questionUid: " + questionUid); + int displayOrder=qaQueContent.getDisplayOrder(); if (displayOrder != 0) { - /* - * add the question to the questions Map in the displayOrder - */ + ++questionCount; + logger.debug("questionCount: " + questionCount); + mapQuestions.put(new Integer(displayOrder).toString(),qaQueContent.getQuestion()); + + if (qaQueUsr != null) + { + List listUserAttempts=qaService.getAttemptsForUserAndQuestionContent(qaQueUsrUid, questionUid); + logger.debug("listUserAttempts: " + listUserAttempts); + + logger.debug("listUserAttempts size: " + listUserAttempts.size()); + + if (listUserAttempts.size() > 1) + { + logger.debug("Warning: There should not be more than 1 attempts for the question."); + } + + Iterator itAttempts=listUserAttempts.iterator(); + while (itAttempts.hasNext()) + { + QaUsrResp qaUsrResp=(QaUsrResp)itAttempts.next(); + logger.debug("qaUsrResp: " + qaUsrResp); + mapAnswersFromDb.put(new Integer(questionCount).toString() , qaUsrResp.getAnswer()); + } + } } } } + logger.debug("mapAnswersFromDb: " + mapAnswersFromDb); mapAnswers=(Map)sessionMap.get(MAP_ALL_RESULTS_KEY); @@ -402,14 +478,50 @@ generalLearnerFlowDTO.setMapQuestionContentLearner(mapQuestions); generalLearnerFlowDTO.setMapQuestions(mapQuestions); logger.debug("mapQuestions has : " + mapQuestions.size() + " entries."); + if (mapAnswers != null) { String currentAnswer=(String)mapAnswers.get("1"); logger.debug("first entry as the current answer : " + currentAnswer); generalLearnerFlowDTO.setCurrentAnswer(currentAnswer); } + else + { + logger.debug("since mapAnswers is null recreate it"); + mapAnswers= new TreeMap(new QaComparator()); + Iterator itMapQuestions = mapQuestions.entrySet().iterator(); + + while (itMapQuestions.hasNext()) + { + Map.Entry pairs = (Map.Entry)itMapQuestions.next(); + mapAnswers.put(pairs.getKey(), ""); + + } + logger.debug("mapAnswers : " + mapAnswers); + generalLearnerFlowDTO.setMapAnswers(mapAnswers); + logger.debug("mapQuestions: " + mapQuestions); + } + + if (isResponseFinalized) + { + logger.debug("isResponseFinalized is true"); + logger.debug("mapAnswersFromDb: " + mapAnswersFromDb); + if (mapAnswersFromDb.size() > 0) + { + logger.debug("since isResponseFinalized, use mapAnswersFromDb"); + generalLearnerFlowDTO.setMapAnswers(mapAnswersFromDb); + } + } + + + logger.debug("final mapAnswers : " + mapAnswers); + sessionMap.put(MAP_ALL_RESULTS_KEY, mapAnswers); + request.getSession().setAttribute(sessionMap.getSessionID(), sessionMap); + + request.setAttribute(GENERAL_LEARNER_FLOW_DTO, generalLearnerFlowDTO); + generalLearnerFlowDTO.setTotalQuestionCount(new Integer(mapQuestions.size())); qaLearningForm.setTotalQuestionCount(new Integer(mapQuestions.size()).toString()); generalLearnerFlowDTO.setRemainingQuestionCount(new Integer(mapQuestions.size()).toString()); @@ -482,6 +594,10 @@ String httpSessionID=qaLearningForm.getHttpSessionID(); logger.debug("httpSessionID: " + httpSessionID); + qaLearningForm.setHttpSessionID(httpSessionID); + generalLearnerFlowDTO.setHttpSessionID(httpSessionID); + + SessionMap sessionMap = (SessionMap) request.getSession().getAttribute(httpSessionID); logger.debug("sessionMap: " + sessionMap); @@ -509,19 +625,126 @@ generalLearnerFlowDTO.setRequestLearningReportProgress(new Boolean(false).toString()); generalLearnerFlowDTO.setReflection(new Boolean(qaContent.isReflect()).toString()); - generalLearnerFlowDTO.setNotebookEntriesVisible(new Boolean(false).toString()); - request.setAttribute(GENERAL_LEARNER_FLOW_DTO, generalLearnerFlowDTO); - logger.debug("final generalLearnerFlowDTO: " + generalLearnerFlowDTO); - logger.debug("fwd'ing to: " + INDIVIDUAL_LEARNER_REPORT); + qaLearningForm.resetAll(); + boolean lockWhenFinished=qaContent.isLockWhenFinished(); + logger.debug("lockWhenFinished: " + lockWhenFinished); + generalLearnerFlowDTO.setLockWhenFinished(new Boolean(lockWhenFinished).toString()); + + request.setAttribute(GENERAL_LEARNER_FLOW_DTO, generalLearnerFlowDTO); + logger.debug("final generalLearnerFlowDTO: " + generalLearnerFlowDTO); + + logger.debug("fwd'ing to INDIVIDUAL_LEARNER_REPORT: " + INDIVIDUAL_LEARNER_REPORT); + return (mapping.findForward(INDIVIDUAL_LEARNER_REPORT)); + } + + + /** + * ActionForward refreshAllResults(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 refreshAllResults(ActionMapping mapping, + ActionForm form, + HttpServletRequest request, + HttpServletResponse response) throws IOException, + ServletException + { + logger.debug("dispatching refreshAllResults..."); + QaLearningForm qaLearningForm = (QaLearningForm) form; + + LearningUtil.saveFormRequestData(request, qaLearningForm); + + IQaService qaService = QaServiceProxy.getQaService(getServlet().getServletContext()); + logger.debug("qaService: " + qaService); + + String toolSessionID=request.getParameter(AttributeNames.PARAM_TOOL_SESSION_ID); + logger.debug("toolSessionID: " + toolSessionID); + qaLearningForm.setToolSessionID(toolSessionID); + + String userID=request.getParameter("userID"); + logger.debug("userID: " + userID); + + + QaSession qaSession=qaService.retrieveQaSessionOrNullById(new Long(toolSessionID).longValue()); + logger.debug("retrieving qaSession: " + qaSession); + + String toolContentID=qaSession.getQaContent().getQaContentId().toString(); + logger.debug("toolContentID: " + toolContentID); + + QaContent qaContent=qaSession.getQaContent(); + logger.debug("using qaContent: " + qaContent); + + GeneralLearnerFlowDTO generalLearnerFlowDTO= LearningUtil.buildGeneralLearnerFlowDTO(qaContent); + logger.debug("generalLearnerFlowDTO: " + generalLearnerFlowDTO); + + String isUserNamesVisibleBoolean=generalLearnerFlowDTO.getUserNameVisible(); + boolean isUserNamesVisible=new Boolean(isUserNamesVisibleBoolean).booleanValue(); + logger.debug("isUserNamesVisible: " + isUserNamesVisible); + + String httpSessionID=qaLearningForm.getHttpSessionID(); + logger.debug("httpSessionID: " + httpSessionID); + + qaLearningForm.setHttpSessionID(httpSessionID); + generalLearnerFlowDTO.setHttpSessionID(httpSessionID); + + + SessionMap sessionMap = (SessionMap) request.getSession().getAttribute(httpSessionID); + logger.debug("sessionMap: " + sessionMap); + + Map mapAnswers=(Map)sessionMap.get(MAP_ALL_RESULTS_KEY); + logger.debug("mapAnswers retrieved: " + mapAnswers); + + /*recreate the users and responses*/ + LearningUtil learningUtil= new LearningUtil(); + + qaLearningForm.resetUserActions(); + qaLearningForm.setSubmitAnswersContent(null); + + learningUtil.setContentInUse(new Long(toolContentID).longValue(), qaService); + logger.debug("content has been set in use"); + + logger.debug("start generating learning report..."); + logger.debug("toolContentID: " + toolContentID); + + + QaMonitoringAction qaMonitoringAction= new QaMonitoringAction(); + qaMonitoringAction.refreshSummaryData(request, qaContent, qaService, isUserNamesVisible, true, toolSessionID, null, + generalLearnerFlowDTO, false , toolSessionID); + + generalLearnerFlowDTO.setRequestLearningReport(new Boolean(true).toString()); + generalLearnerFlowDTO.setRequestLearningReportProgress(new Boolean(false).toString()); + + generalLearnerFlowDTO.setReflection(new Boolean(qaContent.isReflect()).toString()); + //generalLearnerFlowDTO.setNotebookEntriesVisible(new Boolean(false).toString()); + qaLearningForm.resetAll(); - logger.debug("remove map holding MAP_ALL_RESULTS_KEY, httpSessionID: " + httpSessionID); + + boolean lockWhenFinished=qaContent.isLockWhenFinished(); + logger.debug("lockWhenFinished: " + lockWhenFinished); + generalLearnerFlowDTO.setLockWhenFinished(new Boolean(lockWhenFinished).toString()); + + request.setAttribute(GENERAL_LEARNER_FLOW_DTO, generalLearnerFlowDTO); + logger.debug("final generalLearnerFlowDTO: " + generalLearnerFlowDTO); + + logger.debug("fwd'ing to INDIVIDUAL_LEARNER_REPORT: " + INDIVIDUAL_LEARNER_REPORT); return (mapping.findForward(INDIVIDUAL_LEARNER_REPORT)); } + /** * moves to the next question and modifies the map * ActionForward getNextQuestion(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) @@ -550,6 +773,12 @@ String toolSessionID=request.getParameter(AttributeNames.PARAM_TOOL_SESSION_ID); logger.debug("toolSessionID: " + toolSessionID); qaLearningForm.setToolSessionID(toolSessionID); + + String httpSessionID=qaLearningForm.getHttpSessionID(); + logger.debug("httpSessionID: " + httpSessionID); + + qaLearningForm.setHttpSessionID(httpSessionID); + QaSession qaSession=qaService.retrieveQaSessionOrNullById(new Long(toolSessionID).longValue()); logger.debug("retrieving qaSession: " + qaSession); @@ -696,6 +925,11 @@ IQaService qaService = QaServiceProxy.getQaService(getServlet().getServletContext()); logger.debug("qaService: " + qaService); + String httpSessionID=qaLearningForm.getHttpSessionID(); + logger.debug("httpSessionID: " + httpSessionID); + + qaLearningForm.setHttpSessionID(httpSessionID); + String toolSessionID=request.getParameter(AttributeNames.PARAM_TOOL_SESSION_ID); logger.debug("toolSessionID: " + toolSessionID); qaLearningForm.setToolSessionID(toolSessionID); @@ -819,8 +1053,10 @@ String httpSessionID=qaLearningForm.getHttpSessionID(); logger.debug("removing map with httpSessionID: " + httpSessionID); - request.getSession().removeAttribute(httpSessionID); + //request.getSession().removeAttribute(httpSessionID); + qaLearningForm.setHttpSessionID(httpSessionID); + qaLearningForm.resetAll(); String nextActivityUrl = qaService.leaveToolSession(new Long(toolSessionID), new Long(user.getUserID().longValue())); @@ -830,6 +1066,19 @@ } + /** + * ActionForward submitReflection(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) + throws IOException, ServletException, ToolException + * + * @param mapping + * @param form + * @param request + * @param response + * @return + * @throws IOException + * @throws ServletException + * @throws ToolException + */ public ActionForward submitReflection(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException, ToolException { @@ -841,6 +1090,11 @@ IQaService qaService = QaServiceProxy.getQaService(getServlet().getServletContext()); logger.debug("qaService: " + qaService); + String httpSessionID=qaLearningForm.getHttpSessionID(); + logger.debug("httpSessionID: " + httpSessionID); + + qaLearningForm.setHttpSessionID(httpSessionID); + String toolSessionID=request.getParameter(AttributeNames.PARAM_TOOL_SESSION_ID); logger.debug("toolSessionID: " + toolSessionID); qaLearningForm.setToolSessionID(toolSessionID); @@ -905,6 +1159,20 @@ return endLearning(mapping, form, request, response); } + + /** + * ActionForward forwardtoReflection(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) + throws IOException, ServletException, ToolException + * + * @param mapping + * @param form + * @param request + * @param response + * @return + * @throws IOException + * @throws ServletException + * @throws ToolException + */ public ActionForward forwardtoReflection(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException, ToolException { @@ -913,6 +1181,11 @@ IQaService qaService = QaServiceProxy.getQaService(getServlet().getServletContext()); logger.debug("qaService: " + qaService); + String httpSessionID=qaLearningForm.getHttpSessionID(); + logger.debug("httpSessionID: " + httpSessionID); + + qaLearningForm.setHttpSessionID(httpSessionID); + String toolSessionID=request.getParameter(AttributeNames.PARAM_TOOL_SESSION_ID); logger.debug("toolSessionID: " + toolSessionID); Index: lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/QaLearningStarterAction.java =================================================================== RCS file: /usr/local/cvsroot/lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/QaLearningStarterAction.java,v diff -u -r1.63 -r1.64 --- lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/QaLearningStarterAction.java 10 Oct 2006 16:16:51 -0000 1.63 +++ lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/QaLearningStarterAction.java 11 Nov 2006 14:58:35 -0000 1.64 @@ -205,11 +205,23 @@ generalLearnerFlowDTO.setCurrentQuestionIndex(new Integer(1)); generalLearnerFlowDTO.setCurrentAnswer(""); + + logger.debug("reading httpSessionID"); - SessionMap sessionMap = new SessionMap(); - Map mapSequentialAnswers= new HashMap(); - sessionMap.put(MAP_SEQUENTIAL_ANSWERS_KEY, mapSequentialAnswers); - request.getSession().setAttribute(sessionMap.getSessionID(), sessionMap); + String httpSessionID=qaLearningForm.getHttpSessionID(); + logger.debug("httpSessionID: " + httpSessionID); + + SessionMap sessionMap = (SessionMap) request.getSession().getAttribute(httpSessionID); + logger.debug("sessionMap: " + sessionMap); + + if (sessionMap == null) + { + sessionMap = new SessionMap(); + Map mapSequentialAnswers= new HashMap(); + sessionMap.put(MAP_SEQUENTIAL_ANSWERS_KEY, mapSequentialAnswers); + request.getSession().setAttribute(sessionMap.getSessionID(), sessionMap); + } + qaLearningForm.setHttpSessionID(sessionMap.getSessionID()); generalLearnerFlowDTO.setHttpSessionID(sessionMap.getSessionID()); @@ -243,7 +255,6 @@ { QaUtils.cleanUpSessionAbsolute(request); logger.debug("error: The tool expects mcSession."); - //persistError(request,"error.toolSession.notAvailable"); return (mapping.findForward(ERROR_LIST_LEARNER)); } @@ -270,7 +281,6 @@ { QaUtils.cleanUpSessionAbsolute(request); logger.debug("error: The tool expects qaContent."); - //persistError(request,"error.toolContent.notAvailable"); return (mapping.findForward(ERROR_LIST_LEARNER)); } @@ -392,7 +402,6 @@ String userFeedback= feedBackType + generalLearnerFlowDTO.getTotalQuestionCount() + QUESTIONS; - //request.getSession().setAttribute(USER_FEEDBACK, userFeedback); generalLearnerFlowDTO.setUserFeedback(userFeedback); logger.debug("remaining question count: " + generalLearnerFlowDTO.getTotalQuestionCount().toString()); @@ -440,7 +449,8 @@ logger.debug("presenting teacher's report"); logger.debug("fwd'ing to for learner progress" + INDIVIDUAL_LEARNER_REPORT); - return (mapping.findForward(INDIVIDUAL_LEARNER_REPORT)); } + return (mapping.findForward(INDIVIDUAL_LEARNER_REPORT)); + } /* by now, we know that the mode is learner*/ /* find out if the content is set to run offline or online. If it is set to run offline , the learners are informed about that. */ @@ -469,59 +479,81 @@ logger.debug("currentToolSessionID: " + currentToolSessionID); logger.debug("current session uid: " + qaSession.getUid()); + boolean lockWhenFinished=qaContent.isLockWhenFinished(); + logger.debug("lockWhenFinished: " + lockWhenFinished); + + String sessionStatus=qaSession.getSession_status(); + logger.debug("sessionStatus: " + sessionStatus); + + if (userID != null) { QaQueUsr qaQueUsr=qaService.getQaUserBySession(new Long(userID), qaSession.getUid()); logger.debug("QaQueUsr:" + qaQueUsr); if ((qaQueUsr != null) && (qaQueUsr.isResponseFinalized())) { - logger.debug("is current user's response finalised: " + qaQueUsr.isResponseFinalized()); + logger.debug("is current user's response finalised: " + qaQueUsr.isResponseFinalized()); QaSession checkSession=qaQueUsr.getQaSession(); logger.debug("checkSession:" + checkSession); if (checkSession != null) { Long checkQaSessionId=checkSession.getQaSessionId(); logger.debug("checkQaSessionId:" + checkQaSessionId); + if (checkQaSessionId.toString().equals(currentToolSessionID.toString())) { - logger.debug("the learner is in the same session and has already responsed to this content, just generate a read-only report."); - + + logger.debug("the learner is in the same session and has already responsed to this content"); + logger.debug("lockWhenFinished: " + lockWhenFinished); + + boolean isLearnerFinished=qaQueUsr.isLearnerFinished(); + logger.debug("isLearnerFinished: " + isLearnerFinished); + + generalLearnerFlowDTO.setLockWhenFinished(new Boolean(lockWhenFinished).toString()); + logger.debug("isUserNamesVisible: " + qaContent.isUsernameVisible()); Boolean isUserNamesVisibleBoolean=new Boolean(qaContent.isUsernameVisible()); boolean isUserNamesVisible=isUserNamesVisibleBoolean.booleanValue(); - QaMonitoringAction qaMonitoringAction= new QaMonitoringAction(); /*the report should have all the users' entries OR * the report should have only the current session's entries*/ generalLearnerFlowDTO.setRequestLearningReport(new Boolean(true).toString()); - logger.debug("using generalLearnerFlowDTO: " + generalLearnerFlowDTO); qaMonitoringAction.refreshSummaryData(request, qaContent, qaService, isUserNamesVisible, true, currentToolSessionID.toString(), null, generalLearnerFlowDTO, false, toolSessionID); logger.debug("final generalLearnerFlowDTO: " + generalLearnerFlowDTO); - - - boolean isLearnerFinished=qaQueUsr.isLearnerFinished(); - logger.debug("isLearnerFinished: " + isLearnerFinished); + logger.debug("current sessionMap: " + sessionMap); + + mapAnswers=(Map)sessionMap.get(MAP_ALL_RESULTS_KEY); + logger.debug("mapAnswers: " + mapAnswers); + + if (isLearnerFinished) { - logger.debug("since the session is completed present a screen which can not be edited"); - generalLearnerFlowDTO.setRequestLearningReportViewOnly(new Boolean(true).toString()); + logger.debug("isLearnerFinished is true"); + generalLearnerFlowDTO.setRequestLearningReportViewOnly(new Boolean(true).toString()); + + request.setAttribute(GENERAL_LEARNER_FLOW_DTO, generalLearnerFlowDTO); + logger.debug("before fwd, GENERAL_LEARNER_FLOW_DTO: " + request.getAttribute(GENERAL_LEARNER_FLOW_DTO)); + + logger.debug("fwd'ing to." + REVISITED_LEARNER_REP); + return (mapping.findForward(REVISITED_LEARNER_REP)); } else { + logger.debug("NOT true both isLearnerFinished and lockWhenFinished"); generalLearnerFlowDTO.setRequestLearningReportViewOnly(new Boolean(false).toString()); + + request.setAttribute(GENERAL_LEARNER_FLOW_DTO, generalLearnerFlowDTO); + logger.debug("before fwd, GENERAL_LEARNER_FLOW_DTO: " + request.getAttribute(GENERAL_LEARNER_FLOW_DTO)); } - request.setAttribute(GENERAL_LEARNER_FLOW_DTO, generalLearnerFlowDTO); - logger.debug("before fwd, GENERAL_LEARNER_FLOW_DTO: " + request.getAttribute(GENERAL_LEARNER_FLOW_DTO)); - logger.debug("fwd'ing to." + INDIVIDUAL_LEARNER_REPORT); return (mapping.findForward(INDIVIDUAL_LEARNER_REPORT)); Index: lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/QaStarterAction.java =================================================================== RCS file: /usr/local/cvsroot/lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/QaStarterAction.java,v diff -u -r1.59 -r1.60 --- lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/QaStarterAction.java 23 Sep 2006 15:11:02 -0000 1.59 +++ lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/QaStarterAction.java 11 Nov 2006 14:58:36 -0000 1.60 @@ -328,7 +328,8 @@ qaContent=retrieveContent(request, mapping, qaAuthoringForm, mapQuestionContent, new Long(defaultContentIdStr).longValue(), true, qaService, qaGeneralAuthoringDTO, sessionMap); - logger.debug("post retrive content :" + sessionMap); + logger.debug("post retrive content :" + sessionMap); + qaAuthoringForm.setLockWhenFinished("1"); } else { @@ -419,6 +420,8 @@ qaAuthoringForm.setUsernameVisible(qaContent.isUsernameVisible()?"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()); Index: lams_tool_laqa/web/WEB-INF/struts-config.xml =================================================================== RCS file: /usr/local/cvsroot/lams_tool_laqa/web/WEB-INF/struts-config.xml,v diff -u -r1.42 -r1.43 --- lams_tool_laqa/web/WEB-INF/struts-config.xml 23 Sep 2006 15:11:02 -0000 1.42 +++ lams_tool_laqa/web/WEB-INF/struts-config.xml 11 Nov 2006 14:58:39 -0000 1.43 @@ -174,6 +174,14 @@ path="/learningIndex.jsp" redirect="false" /> + + + + + +

+

+ + + +

@@ -57,3 +65,4 @@ + Index: lams_tool_laqa/web/authoring/BasicContent.jsp =================================================================== RCS file: /usr/local/cvsroot/lams_tool_laqa/web/authoring/BasicContent.jsp,v diff -u -r1.32 -r1.33 --- lams_tool_laqa/web/authoring/BasicContent.jsp 3 Nov 2006 04:56:53 -0000 1.32 +++ lams_tool_laqa/web/authoring/BasicContent.jsp 11 Nov 2006 14:58:39 -0000 1.33 @@ -107,7 +107,7 @@ ');" + href="javascript:showMessage('');" class="button-add-item"> Index: lams_tool_laqa/web/authoring/InstructionsContent.jsp =================================================================== RCS file: /usr/local/cvsroot/lams_tool_laqa/web/authoring/Attic/InstructionsContent.jsp,v diff -u -r1.19 -r1.20 --- lams_tool_laqa/web/authoring/InstructionsContent.jsp 19 Oct 2006 07:21:44 -0000 1.19 +++ lams_tool_laqa/web/authoring/InstructionsContent.jsp 11 Nov 2006 14:58:39 -0000 1.20 @@ -1,4 +1,3 @@ - <%-- Copyright (C) 2005 LAMS Foundation (http://lamsfoundation.org) License Information: http://lamsfoundation.org/licensing/lams/2.0/ @@ -55,7 +54,7 @@   Index: lams_tool_laqa/web/monitoring/itemlist.jsp =================================================================== RCS file: /usr/local/cvsroot/lams_tool_laqa/web/monitoring/Attic/itemlist.jsp,v diff -u -r1.2 -r1.3 --- lams_tool_laqa/web/monitoring/itemlist.jsp 17 Oct 2006 20:32:56 -0000 1.2 +++ lams_tool_laqa/web/monitoring/itemlist.jsp 11 Nov 2006 14:58:34 -0000 1.3 @@ -77,7 +77,7 @@
- ');"> + ');"> images/edit.gif" border="0">