Fisheye: Tag 1.1.2.1 refers to a dead (removed) revision in file `lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/AnswerDTO.java'. Fisheye: No comparison available. Pass `N' to diff? Index: lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/McAppConstants.java =================================================================== RCS file: /usr/local/cvsroot/lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/McAppConstants.java,v diff -u -r1.112.2.6 -r1.112.2.7 --- lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/McAppConstants.java 15 Jun 2016 07:59:47 -0000 1.112.2.6 +++ lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/McAppConstants.java 13 Sep 2016 04:57:11 -0000 1.112.2.7 @@ -206,7 +206,7 @@ public static final String MAP_QUESTION_CONTENT_LEARNER = "mapQuestionContentLearner"; public static final String LEARNER_ANSWERS_DTO_LIST = "learnerAnswersDTOList"; public static final String MC_GENERAL_LEARNER_FLOW_DTO = "mcGeneralLearnerFlowDTO"; - public static final String LIST_SELECTED_QUESTION_CANDIDATEANSWERS_DTO = "listSelectedQuestionCandidateAnswersDto"; + public static final String ANSWER_DTOS = "answerDtos"; public static final String CURRENT_QUESTION_INDEX = "currentQuestionIndex"; public static final String TOTAL_QUESTION_COUNT = "totalQuestionCount"; public static final String HR_COLUMN_COUNT = "hrColumnCount"; @@ -219,7 +219,6 @@ public static final String NOTEBOOK = "notebook"; public static final String ENTRY_TEXT = "entryText"; - public static final String MC_LEARNER_STARTER_DTO = "mcLearnerStarterDTO"; public static final String IS_USERNAME_VISIBLE = "isUsernameVisible"; public static final String IS_CONTENT_IN_USE = "isContentInUse"; public static final String IS_MONITORED_CONTENT_IN_USE = "isMonitoredContentInUse"; @@ -263,9 +262,6 @@ public static final String SESSION_DTOS = "sessionDtos"; public static final String TIMEZONE = "timeZone"; - public static final String QUESTION_LISTING_MODE = "questionListingMode"; - public static final String QUESTION_LISTING_MODE_SEQUENTIAL = "questionListingModeSequential"; - public static final String QUESTION_LISTING_MODE_COMBINED = "questionListingModeCombined"; public static final String PREVIEW_ONLY = "previewOnly"; public static final String MODE = "mode"; Index: lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/McGeneralLearnerFlowDTO.java =================================================================== RCS file: /usr/local/cvsroot/lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/McGeneralLearnerFlowDTO.java,v diff -u -r1.20.2.2 -r1.20.2.3 --- lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/McGeneralLearnerFlowDTO.java 11 May 2016 07:36:13 -0000 1.20.2.2 +++ lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/McGeneralLearnerFlowDTO.java 13 Sep 2016 04:57:11 -0000 1.20.2.3 @@ -95,8 +95,6 @@ protected Integer questionIndex; - protected String questionListingMode; - protected Integer totalMarksPossible; protected Map mapFeedbackContent; @@ -119,21 +117,6 @@ } /** - * @return Returns the questionListingMode. - */ - public String getQuestionListingMode() { - return questionListingMode; - } - - /** - * @param questionListingMode - * The questionListingMode to set. - */ - public void setQuestionListingMode(String questionListingMode) { - this.questionListingMode = questionListingMode; - } - - /** * @return Returns the questionIndex. */ public Integer getQuestionIndex() { @@ -392,10 +375,10 @@ .append("passMarkApplicable: ", passMarkApplicable).append("userPassed: ", userPassed) .append("userOverPassMark: ", userOverPassMark).append("reportTitleLearner: ", reportTitleLearner) .append("activityInstructions: ", activityInstructions).append("activityTitle: ", activityTitle) - .append("questionListingMode: ", questionListingMode).append("learnerProgress: ", learnerProgress) - .append("displayAnswers: ", displayAnswers).append("reflection: ", reflection) - .append("reflectionSubject: ", reflectionSubject).append("notebookEntry: ", notebookEntry) - .append("notebookEntriesVisible: ", notebookEntriesVisible).toString(); + .append("learnerProgress: ", learnerProgress).append("displayAnswers: ", displayAnswers) + .append("reflection: ", reflection).append("reflectionSubject: ", reflectionSubject) + .append("notebookEntry: ", notebookEntry).append("notebookEntriesVisible: ", notebookEntriesVisible) + .toString(); } /** Fisheye: Tag 1.7.2.3 refers to a dead (removed) revision in file `lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/McLearnerAnswersDTO.java'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 1.5.2.3 refers to a dead (removed) revision in file `lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/McLearnerStarterDTO.java'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 1.7.2.3 refers to a dead (removed) revision in file `lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/McTempDataHolderDTO.java'. Fisheye: No comparison available. Pass `N' to diff? Index: lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/McUtils.java =================================================================== RCS file: /usr/local/cvsroot/lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/McUtils.java,v diff -u -r1.61.2.7 -r1.61.2.8 --- lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/McUtils.java 11 May 2016 07:36:13 -0000 1.61.2.7 +++ lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/McUtils.java 13 Sep 2016 04:57:11 -0000 1.61.2.8 @@ -158,9 +158,6 @@ request.getSession().removeAttribute(EDITACTIVITY_EDITMODE); request.getSession().removeAttribute(FORM_INDEX); request.getSession().removeAttribute(LIST_MONITORED_ANSWERS_CONTAINER_DTO); - request.getSession().removeAttribute(QUESTION_LISTING_MODE); - request.getSession().removeAttribute(QUESTION_LISTING_MODE_SEQUENTIAL); - request.getSession().removeAttribute(QUESTION_LISTING_MODE_COMBINED); request.getSession().removeAttribute(PREVIEW_ONLY); request.getSession().removeAttribute(TIMEZONE); request.getSession().removeAttribute(MODE); Index: lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/service/IMcService.java =================================================================== RCS file: /usr/local/cvsroot/lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/service/IMcService.java,v diff -u -r1.77.2.9 -r1.77.2.10 --- lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/service/IMcService.java 20 Jun 2016 16:20:34 -0000 1.77.2.9 +++ lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/service/IMcService.java 13 Sep 2016 04:57:11 -0000 1.77.2.10 @@ -32,7 +32,7 @@ import org.lamsfoundation.lams.tool.exception.DataMissingException; import org.lamsfoundation.lams.tool.exception.ToolException; import org.lamsfoundation.lams.tool.mc.McApplicationException; -import org.lamsfoundation.lams.tool.mc.McLearnerAnswersDTO; +import org.lamsfoundation.lams.tool.mc.AnswerDTO; import org.lamsfoundation.lams.tool.mc.McOptionDTO; import org.lamsfoundation.lams.tool.mc.McQuestionDTO; import org.lamsfoundation.lams.tool.mc.McSessionMarkDTO; @@ -85,7 +85,7 @@ McQueUsr getMcUserBySession(final Long queUsrId, final Long mcSessionUid) throws McApplicationException; - void saveUserAttempt(McQueUsr user, List selectedQuestionAndCandidateAnswersDTO); + void saveUserAttempt(McQueUsr user, List answerDtos); void updateMcUsrAttempt(McUsrAttempt mcUsrAttempt) throws McApplicationException; @@ -193,7 +193,7 @@ * user; pass null if there is no need to populate previous answers * @return */ - List buildLearnerAnswersDTOList(McContent mcContent, McQueUsr user); + List getAnswersFromDatabase(McContent mcContent, McQueUsr user); /** * Returns userMarksDtos grouped by sessions. Used *only* for export portfolio. Index: lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/service/McServicePOJO.java =================================================================== RCS file: /usr/local/cvsroot/lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/service/McServicePOJO.java,v diff -u -r1.128.2.17 -r1.128.2.18 --- lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/service/McServicePOJO.java 20 Jun 2016 16:20:33 -0000 1.128.2.17 +++ lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/service/McServicePOJO.java 13 Sep 2016 04:57:11 -0000 1.128.2.18 @@ -80,7 +80,7 @@ import org.lamsfoundation.lams.tool.exception.ToolException; import org.lamsfoundation.lams.tool.mc.McAppConstants; import org.lamsfoundation.lams.tool.mc.McApplicationException; -import org.lamsfoundation.lams.tool.mc.McLearnerAnswersDTO; +import org.lamsfoundation.lams.tool.mc.AnswerDTO; import org.lamsfoundation.lams.tool.mc.McOptionDTO; import org.lamsfoundation.lams.tool.mc.McQuestionDTO; import org.lamsfoundation.lams.tool.mc.McSessionMarkDTO; @@ -438,25 +438,25 @@ } @Override - public void saveUserAttempt(McQueUsr user, List selectedQuestionAndCandidateAnswersDTO) { + public void saveUserAttempt(McQueUsr user, List answerDtos) { Date attemptTime = new Date(System.currentTimeMillis()); - for (McLearnerAnswersDTO mcLearnerAnswersDTO : selectedQuestionAndCandidateAnswersDTO) { + for (AnswerDTO answerDto : answerDtos) { - Long questionUid = mcLearnerAnswersDTO.getQuestionUid(); + Long questionUid = answerDto.getQuestionUid(); McQueContent question = this.getQuestionByUid(questionUid); if (question == null) { throw new McApplicationException( - "Can't find question with specified question uid: " + mcLearnerAnswersDTO.getQuestionUid()); + "Can't find question with specified question uid: " + answerDto.getQuestionUid()); } - McOptsContent answerOption = mcLearnerAnswersDTO.getAnswerOption(); + McOptsContent answerOption = answerDto.getAnswerOption(); if (answerOption != null) { - Integer mark = mcLearnerAnswersDTO.getMark(); + Integer mark = answerDto.getMark(); boolean passed = user.isMarkPassed(mark); - boolean isAttemptCorrect = new Boolean(mcLearnerAnswersDTO.getAttemptCorrect()); + boolean isAttemptCorrect = answerDto.isAttemptCorrect(); McUsrAttempt userAttempt = this.getUserAttemptByQuestion(user.getUid(), questionUid); if (userAttempt != null) { @@ -480,7 +480,6 @@ // create new userAttempt userAttempt = new McUsrAttempt(attemptTime, question, user, answerOption, mark, passed, isAttemptCorrect); - } mcUsrAttemptDAO.saveMcUsrAttempt(userAttempt); @@ -500,12 +499,12 @@ } @Override - public List buildLearnerAnswersDTOList(McContent mcContent, McQueUsr user) { - List learnerAnswersDTOList = new LinkedList(); + public List getAnswersFromDatabase(McContent mcContent, McQueUsr user) { + List answerDtos = new LinkedList(); List questions = this.getQuestionsByContentUid(mcContent.getUid()); for (McQueContent question : questions) { - McLearnerAnswersDTO learnerAnswersDTO = new McLearnerAnswersDTO(); + AnswerDTO answerDto = new AnswerDTO(); Set optionSet = question.getMcOptionsContents(); List optionList = new LinkedList(optionSet); @@ -516,28 +515,28 @@ optionList = new LinkedList(shuffledList); } - learnerAnswersDTO.setQuestion(question.getQuestion()); - learnerAnswersDTO.setDisplayOrder(question.getDisplayOrder().toString()); - learnerAnswersDTO.setQuestionUid(question.getUid()); + answerDto.setQuestion(question.getQuestion()); + answerDto.setDisplayOrder(question.getDisplayOrder().toString()); + answerDto.setQuestionUid(question.getUid()); - learnerAnswersDTO.setMark(question.getMark()); - learnerAnswersDTO.setOptions(optionList); + answerDto.setMark(question.getMark()); + answerDto.setOptions(optionList); - learnerAnswersDTOList.add(learnerAnswersDTO); + answerDtos.add(answerDto); } // populate answers if (user != null) { - for (McLearnerAnswersDTO learnerAnswersDTO : learnerAnswersDTOList) { - Long questionUid = learnerAnswersDTO.getQuestionUid(); + for (AnswerDTO answerDto : answerDtos) { + Long questionUid = answerDto.getQuestionUid(); McUsrAttempt dbAttempt = this.getUserAttemptByQuestion(user.getUid(), questionUid); if (dbAttempt != null) { Long selectedOptionUid = dbAttempt.getMcOptionsContent().getUid(); // mark selected option as selected - for (McOptsContent option : learnerAnswersDTO.getOptions()) { + for (McOptsContent option : answerDto.getOptions()) { if (selectedOptionUid.equals(option.getUid())) { option.setSelected(true); } @@ -546,7 +545,7 @@ } } - return learnerAnswersDTOList; + return answerDtos; } @Override Index: lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/LearningUtil.java =================================================================== RCS file: /usr/local/cvsroot/lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/LearningUtil.java,v diff -u -r1.54.2.3 -r1.54.2.4 --- lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/LearningUtil.java 16 Aug 2016 08:37:37 -0000 1.54.2.3 +++ lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/LearningUtil.java 13 Sep 2016 04:57:11 -0000 1.54.2.4 @@ -30,7 +30,7 @@ import org.apache.log4j.Logger; import org.lamsfoundation.lams.tool.mc.McAppConstants; import org.lamsfoundation.lams.tool.mc.McGeneralLearnerFlowDTO; -import org.lamsfoundation.lams.tool.mc.McLearnerAnswersDTO; +import org.lamsfoundation.lams.tool.mc.AnswerDTO; import org.lamsfoundation.lams.tool.mc.pojos.McContent; /** @@ -63,11 +63,7 @@ mcLearningForm.setLearnerProgress(learnerProgress); String learnerProgressUserId = request.getParameter("learnerProgressUserId"); mcLearningForm.setLearnerProgressUserId(learnerProgressUserId); - } - - String questionListingMode = request.getParameter("questionListingMode"); - mcLearningForm.setQuestionListingMode(questionListingMode); } /** @@ -82,23 +78,17 @@ mcGeneralLearnerFlowDTO.setReportTitleLearner("Report"); mcGeneralLearnerFlowDTO.setLearnerProgress(new Boolean(false).toString()); - if (mcContent.isQuestionsSequenced()) { - mcGeneralLearnerFlowDTO.setQuestionListingMode(McAppConstants.QUESTION_LISTING_MODE_SEQUENTIAL); - } else { - mcGeneralLearnerFlowDTO.setQuestionListingMode(McAppConstants.QUESTION_LISTING_MODE_COMBINED); - } - mcGeneralLearnerFlowDTO.setTotalQuestionCount(new Integer(mcContent.getMcQueContents().size())); return mcGeneralLearnerFlowDTO; } /** * Should we show the marks for each question - we show the marks if any of the questions have a mark > 1. */ - public static Boolean isShowMarksOnQuestion(List listQuestionAndCandidateAnswersDTO) { + public static Boolean isShowMarksOnQuestion(List listQuestionAndCandidateAnswersDTO) { Iterator iter = listQuestionAndCandidateAnswersDTO.iterator(); while (iter.hasNext()) { - McLearnerAnswersDTO elem = (McLearnerAnswersDTO) iter.next(); + AnswerDTO elem = (AnswerDTO) iter.next(); if (elem.getMark().intValue() > 1) { return Boolean.TRUE; } Index: lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/McLearningAction.java =================================================================== RCS file: /usr/local/cvsroot/lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/McLearningAction.java,v diff -u -r1.82.2.5 -r1.82.2.6 --- lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/McLearningAction.java 16 Aug 2016 08:37:37 -0000 1.82.2.5 +++ lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/McLearningAction.java 13 Sep 2016 04:57:11 -0000 1.82.2.6 @@ -29,7 +29,6 @@ import java.util.Map; import java.util.Set; import java.util.TreeMap; -import java.util.regex.Pattern; import javax.servlet.ServletException; import javax.servlet.http.HttpServletRequest; @@ -40,19 +39,17 @@ import org.apache.struts.action.ActionForm; import org.apache.struts.action.ActionForward; import org.apache.struts.action.ActionMapping; -import org.apache.struts.action.ActionRedirect; import org.apache.tomcat.util.json.JSONException; import org.apache.tomcat.util.json.JSONObject; import org.lamsfoundation.lams.learning.web.util.LearningWebUtil; import org.lamsfoundation.lams.notebook.model.NotebookEntry; import org.lamsfoundation.lams.notebook.service.CoreNotebookConstants; import org.lamsfoundation.lams.tool.exception.DataMissingException; import org.lamsfoundation.lams.tool.exception.ToolException; +import org.lamsfoundation.lams.tool.mc.AnswerDTO; import org.lamsfoundation.lams.tool.mc.McAppConstants; import org.lamsfoundation.lams.tool.mc.McComparator; import org.lamsfoundation.lams.tool.mc.McGeneralLearnerFlowDTO; -import org.lamsfoundation.lams.tool.mc.McLearnerAnswersDTO; -import org.lamsfoundation.lams.tool.mc.McTempDataHolderDTO; import org.lamsfoundation.lams.tool.mc.McUtils; import org.lamsfoundation.lams.tool.mc.pojos.McContent; import org.lamsfoundation.lams.tool.mc.pojos.McOptsContent; @@ -68,10 +65,7 @@ import org.lamsfoundation.lams.web.session.SessionManager; import org.lamsfoundation.lams.web.util.AttributeNames; import org.lamsfoundation.lams.web.util.SessionMap; -import org.springframework.dao.DataIntegrityViolationException; -import com.mysql.jdbc.exceptions.MySQLIntegrityConstraintViolationException; - /** * @author Ozgur Demirtas */ @@ -177,23 +171,15 @@ LearningUtil.saveFormRequestData(request, mcLearningForm, false); // requested learner finished, the learner should be directed to next activity - String userID = ""; HttpSession ss = SessionManager.getSession(); + UserDTO userDto = (UserDTO) ss.getAttribute(AttributeNames.USER); - if (ss != null) { - UserDTO user = (UserDTO) ss.getAttribute(AttributeNames.USER); - if (user != null && user.getUserID() != null) { - userID = user.getUserID().toString(); - } - } - // attempting to leave/complete session with toolSessionId: - McUtils.cleanUpSessionAbsolute(request); String nextUrl = null; try { - nextUrl = mcService.leaveToolSession(new Long(toolSessionID), new Long(userID)); + nextUrl = mcService.leaveToolSession(new Long(toolSessionID), userDto.getUserID().longValue()); } catch (DataMissingException e) { McLearningAction.logger.error("failure getting nextUrl: " + e); return mapping.findForward(McAppConstants.LEARNING_STARTER); @@ -213,58 +199,49 @@ /** * */ - protected List buildSelectedQuestionAndCandidateAnswersDTO(List learnerInput, - McTempDataHolderDTO mcTempDataHolderDTO, McContent content) { + protected List buildAnswerDtos(List answers, McContent content) { - int learnerMark = 0; - int totalMarksPossible = 0; + List answerDtos = new LinkedList(); - List questionAndCandidateAnswersList = new LinkedList(); - for (McQueContent question : (Set) content.getMcQueContents()) { String questionUid = question.getUid().toString(); - int currentMark = question.getMark().intValue(); - totalMarksPossible += currentMark; + int questionMark = question.getMark().intValue(); - McLearnerAnswersDTO mcLearnerAnswersDTO = new McLearnerAnswersDTO(); - mcLearnerAnswersDTO.setQuestion(question.getQuestion()); - mcLearnerAnswersDTO.setDisplayOrder(question.getDisplayOrder().toString()); - mcLearnerAnswersDTO.setQuestionUid(question.getUid()); - mcLearnerAnswersDTO.setFeedback(question.getFeedback() != null ? question.getFeedback() : ""); + AnswerDTO answerDto = new AnswerDTO(); + answerDto.setQuestion(question.getQuestion()); + answerDto.setDisplayOrder(question.getDisplayOrder().toString()); + answerDto.setQuestionUid(question.getUid()); + answerDto.setFeedback(question.getFeedback() != null ? question.getFeedback() : ""); //search for according answer McOptsContent answerOption = null; - for (String input : learnerInput) { - int pos = input.indexOf("-"); - String inputQuestionUid = input.substring(0, pos); + for (String answer : answers) { + int hyphenPosition = answer.indexOf("-"); + String answeredQuestionUid = answer.substring(0, hyphenPosition); - if (questionUid.equals(inputQuestionUid)) { - String answerOptionUid = input.substring(pos + 1); - answerOption = question.getOptionsContentByUID(new Long(answerOptionUid)); - mcLearnerAnswersDTO.setAnswerOption(answerOption); + if (questionUid.equals(answeredQuestionUid)) { + String answeredOptionUid = answer.substring(hyphenPosition + 1); + answerOption = question.getOptionsContentByUID(new Long(answeredOptionUid)); + answerDto.setAnswerOption(answerOption); break; } } boolean isCorrect = (answerOption != null) && answerOption.isCorrectOption(); - mcLearnerAnswersDTO.setAttemptCorrect(new Boolean(isCorrect).toString()); + answerDto.setAttemptCorrect(isCorrect); if (isCorrect) { - mcLearnerAnswersDTO.setFeedbackCorrect(question.getFeedback()); - mcLearnerAnswersDTO.setMark(new Integer(currentMark)); - learnerMark += currentMark; + answerDto.setFeedbackCorrect(question.getFeedback()); + answerDto.setMark(questionMark); } else { - mcLearnerAnswersDTO.setFeedbackIncorrect(question.getFeedback()); - mcLearnerAnswersDTO.setMark(new Integer(0)); + answerDto.setFeedbackIncorrect(question.getFeedback()); + answerDto.setMark(0); } - questionAndCandidateAnswersList.add(mcLearnerAnswersDTO); + answerDtos.add(answerDto); } - mcTempDataHolderDTO.setLearnerMark(new Integer(learnerMark)); - mcTempDataHolderDTO.setTotalMarksPossible(new Integer(totalMarksPossible)); - - return questionAndCandidateAnswersList; + return answerDtos; } /** @@ -279,57 +256,48 @@ String httpSessionID = mcLearningForm.getHttpSessionID(); SessionMap sessionMap = (SessionMap) request.getSession().getAttribute(httpSessionID); + request.getSession().setAttribute(httpSessionID, sessionMap); + + String toolSessionID = request.getParameter(AttributeNames.PARAM_TOOL_SESSION_ID); + McSession session = mcService.getMcSessionById(new Long(toolSessionID)); + String toolContentId = session.getMcContent().getMcContentId().toString(); + McContent mcContent = mcService.getMcContent(new Long(toolContentId)); - String questionListingMode = mcLearningForm.getQuestionListingMode(); - - List learnerInput = McLearningAction.parseLearnerAnswers(mcLearningForm, request); - - if (questionListingMode.equals(McAppConstants.QUESTION_LISTING_MODE_SEQUENTIAL)) { - sessionMap.put(McAppConstants.QUESTION_AND_CANDIDATE_ANSWERS_KEY, learnerInput); + List answers = McLearningAction.parseLearnerAnswers(mcLearningForm, request, mcContent.isQuestionsSequenced()); + if (mcContent.isQuestionsSequenced()) { + sessionMap.put(McAppConstants.QUESTION_AND_CANDIDATE_ANSWERS_KEY, answers); } mcLearningForm.resetCa(mapping, request); - String toolSessionID = request.getParameter(AttributeNames.PARAM_TOOL_SESSION_ID); - McSession mcSession = mcService.getMcSessionById(new Long(toolSessionID)); - String toolContentId = mcSession.getMcContent().getMcContentId().toString(); - /* process the answers */ - McContent mcContent = mcService.getMcContent(new Long(toolContentId)); + McQueUsr user = getCurrentUser(toolSessionID); - McGeneralLearnerFlowDTO mcGeneralLearnerFlowDTO = LearningUtil.buildMcGeneralLearnerFlowDTO(mcContent); - - McTempDataHolderDTO mcTempDataHolderDTO = new McTempDataHolderDTO(); - List selectedQuestionAndCandidateAnswersDTO = buildSelectedQuestionAndCandidateAnswersDTO( - learnerInput, mcTempDataHolderDTO, mcContent); - request.setAttribute(McAppConstants.LIST_SELECTED_QUESTION_CANDIDATEANSWERS_DTO, - selectedQuestionAndCandidateAnswersDTO); - - mcGeneralLearnerFlowDTO.setQuestionListingMode(McAppConstants.QUESTION_LISTING_MODE_COMBINED); - - Integer learnerMark = mcTempDataHolderDTO.getLearnerMark(); - mcGeneralLearnerFlowDTO.setLearnerMark(learnerMark); - int totalQuestionCount = mcContent.getMcQueContents().size(); - mcGeneralLearnerFlowDTO.setTotalQuestionCount(new Integer(totalQuestionCount)); - mcGeneralLearnerFlowDTO.setTotalMarksPossible(mcTempDataHolderDTO.getTotalMarksPossible()); - - request.getSession().setAttribute(httpSessionID, sessionMap); - - HttpSession ss = SessionManager.getSession(); - UserDTO userDto = (UserDTO) ss.getAttribute(AttributeNames.USER); - String userID = userDto.getUserID().toString(); - McQueUsr user = mcService.getMcUserBySession(new Long(userID), mcSession.getUid()); - //prohibit users from submitting answers after response is finalized but Resubmit button is not pressed (e.g. using 2 browsers) if (user.isResponseFinalised()) { return viewAnswers(mapping, mcLearningForm, request, response); } + /* process the answers */ + List answerDtos = buildAnswerDtos(answers, mcContent); + mcService.saveUserAttempt(user, answerDtos); + request.setAttribute(McAppConstants.ANSWER_DTOS, answerDtos); + + //calculate total learner mark + int learnerMark = 0; + for (AnswerDTO answerDto : answerDtos) { + learnerMark += answerDto.getMark(); + } + + McGeneralLearnerFlowDTO mcGeneralLearnerFlowDTO = LearningUtil.buildMcGeneralLearnerFlowDTO(mcContent); + mcGeneralLearnerFlowDTO.setLearnerMark(learnerMark); + mcGeneralLearnerFlowDTO.setTotalQuestionCount(mcContent.getMcQueContents().size()); + mcGeneralLearnerFlowDTO.setTotalMarksPossible(mcContent.getTotalMarksPossible()); + // Have to work out in advance if passed so that we can store it against the attempts boolean passed = user.isMarkPassed(learnerMark); mcGeneralLearnerFlowDTO.setUserOverPassMark(new Boolean(passed).toString()); mcGeneralLearnerFlowDTO.setPassMarkApplicable(new Boolean(mcContent.getPassMark() != null).toString()); - McLearningAction.saveUserAttempt(user, selectedQuestionAndCandidateAnswersDTO); Integer numberOfAttempts = user.getNumberOfAttempts() + 1; user.setNumberOfAttempts(numberOfAttempts); @@ -341,7 +309,7 @@ mcGeneralLearnerFlowDTO.setShowMarks(new Boolean(mcContent.isShowMarks()).toString()); if (mcContent.isShowMarks()) { - Integer[] markStatistics = mcService.getMarkStatistics(mcSession); + Integer[] markStatistics = mcService.getMarkStatistics(session); mcGeneralLearnerFlowDTO.setTopMark(markStatistics[0]); mcGeneralLearnerFlowDTO.setLowestMark(markStatistics[1]); mcGeneralLearnerFlowDTO.setAverageMark(markStatistics[2]); @@ -382,10 +350,7 @@ String toolContentId = mcSession.getMcContent().getMcContentId().toString(); McContent mcContent = mcService.getMcContent(new Long(toolContentId)); - HttpSession ss = SessionManager.getSession(); - UserDTO userDto = (UserDTO) ss.getAttribute(AttributeNames.USER); - String userID = userDto.getUserID().toString(); - McQueUsr user = mcService.getMcUserBySession(new Long(userID), mcSession.getUid()); + McQueUsr user = getCurrentUser(toolSessionID); String httpSessionID = mcLearningForm.getHttpSessionID(); SessionMap sessionMap = (SessionMap) request.getSession() @@ -397,16 +362,14 @@ } //parse learner input - List learnerInput = McLearningAction.parseLearnerAnswers(mcLearningForm, request); - sessionMap.put(McAppConstants.QUESTION_AND_CANDIDATE_ANSWERS_KEY, learnerInput); + List answers = McLearningAction.parseLearnerAnswers(mcLearningForm, request, mcContent.isQuestionsSequenced()); + sessionMap.put(McAppConstants.QUESTION_AND_CANDIDATE_ANSWERS_KEY, answers); //save user attempt - List selectedQuestionAndCandidateAnswersDTO = buildSelectedQuestionAndCandidateAnswersDTO( - learnerInput, new McTempDataHolderDTO(), mcContent); - McLearningAction.saveUserAttempt(user, selectedQuestionAndCandidateAnswersDTO); - - McQueUsr mcQueUsr = getCurrentUser(toolSessionID); - List learnerAnswersDTOList = mcService.buildLearnerAnswersDTOList(mcContent, mcQueUsr); + List answerDtos = buildAnswerDtos(answers, mcContent); + mcService.saveUserAttempt(user, answerDtos); + + List learnerAnswersDTOList = mcService.getAnswersFromDatabase(mcContent, user); request.setAttribute(McAppConstants.LEARNER_ANSWERS_DTO_LIST, learnerAnswersDTOList); McGeneralLearnerFlowDTO mcGeneralLearnerFlowDTO = LearningUtil.buildMcGeneralLearnerFlowDTO(mcContent); @@ -419,14 +382,9 @@ } mcGeneralLearnerFlowDTO.setReflection(new Boolean(mcContent.isReflect()).toString()); - - // String reflectionSubject = McUtils.replaceNewLines(mcContent.getReflectionSubject()); mcGeneralLearnerFlowDTO.setReflectionSubject(mcContent.getReflectionSubject()); - mcGeneralLearnerFlowDTO.setRetries(new Boolean(mcContent.isRetries()).toString()); - mcGeneralLearnerFlowDTO.setTotalMarksPossible(mcContent.getTotalMarksPossible()); - mcGeneralLearnerFlowDTO.setQuestionIndex(new Integer(questionIndex)); request.setAttribute(McAppConstants.MC_GENERAL_LEARNER_FLOW_DTO, mcGeneralLearnerFlowDTO); @@ -562,9 +520,7 @@ } } mcGeneralLearnerFlowDTO.setAttemptMap(attemptMap); - mcGeneralLearnerFlowDTO.setReflection(new Boolean(mcContent.isReflect()).toString()); - // String reflectionSubject = McUtils.replaceNewLines(mcContent.getReflectionSubject()); mcGeneralLearnerFlowDTO.setReflectionSubject(mcContent.getReflectionSubject()); NotebookEntry notebookEntry = mcService.getEntry(new Long(toolSessionID), CoreNotebookConstants.NOTEBOOK_TOOL, @@ -623,17 +579,13 @@ List sequentialCheckedCa = new LinkedList(); sessionMap.put(McAppConstants.QUESTION_AND_CANDIDATE_ANSWERS_KEY, sequentialCheckedCa); - List learnerAnswersDTOList = mcService.buildLearnerAnswersDTOList(mcContent, mcQueUsr); + List learnerAnswersDTOList = mcService.getAnswersFromDatabase(mcContent, mcQueUsr); request.setAttribute(McAppConstants.LEARNER_ANSWERS_DTO_LIST, learnerAnswersDTOList); McGeneralLearnerFlowDTO mcGeneralLearnerFlowDTO = LearningUtil.buildMcGeneralLearnerFlowDTO(mcContent); mcGeneralLearnerFlowDTO.setQuestionIndex(new Integer(1)); - mcGeneralLearnerFlowDTO.setReflection(new Boolean(mcContent.isReflect()).toString()); - - //String reflectionSubject = McUtils.replaceNewLines(mcContent.getReflectionSubject()); mcGeneralLearnerFlowDTO.setReflectionSubject(mcContent.getReflectionSubject()); - mcGeneralLearnerFlowDTO.setRetries(new Boolean(mcContent.isRetries()).toString()); String passMarkApplicable = new Boolean(mcContent.isPassMarkApplicable()).toString(); @@ -786,73 +738,40 @@ McSession mcSession = mcService.getMcSessionById(new Long(toolSessionID)); McContent mcContent = mcSession.getMcContent(); - HttpSession ss = SessionManager.getSession(); - UserDTO userDto = (UserDTO) ss.getAttribute(AttributeNames.USER); - String userID = userDto.getUserID().toString(); - McQueUsr user = mcService.getMcUserBySession(new Long(userID), mcSession.getUid()); + Long userID = mcLearningForm.getUserID(); + McQueUsr user = mcService.getMcUserBySession(userID, mcSession.getUid()); //prohibit users from autosaving answers after response is finalized but Resubmit button is not pressed (e.g. using 2 browsers) if (user.isResponseFinalised()) { return null; } - List learnerInput = McLearningAction.parseLearnerAnswers(mcLearningForm, request); + List answers = McLearningAction.parseLearnerAnswers(mcLearningForm, request, mcContent.isQuestionsSequenced()); - List selectedQuestionAndCandidateAnswersDTO = buildSelectedQuestionAndCandidateAnswersDTO( - learnerInput, new McTempDataHolderDTO(), mcContent); - McLearningAction.saveUserAttempt(user, selectedQuestionAndCandidateAnswersDTO); + List answerDtos = buildAnswerDtos(answers, mcContent); + mcService.saveUserAttempt(user, answerDtos); return null; } - /** - * Makes a call to mcService.saveUserAttempt(). This method is designed purely for exception handling purposes. It - * needs to be performed inside Action class as otherwise Hibernate tries to flush the session which leads to - * another exception. - */ - private static void saveUserAttempt(McQueUsr user, - List selectedQuestionAndCandidateAnswersDTO) { - try { - mcService.saveUserAttempt(user, selectedQuestionAndCandidateAnswersDTO); - - } catch (DataIntegrityViolationException e) { - - // log DB exceptions occurred due to creating non-unique McUsrAttempt. And propagate all the other exceptions - if (e.getRootCause() instanceof MySQLIntegrityConstraintViolationException) { - String rootCauseMessage = e.getRootCause().getMessage(); - - Pattern pattern = Pattern.compile("Duplicate entry.*attempt_unique_index"); - if ((rootCauseMessage != null) && pattern.matcher(rootCauseMessage).find()) { - logger.error("Prevented creation of McUsrAttempt which was not unique for user and question: " - + rootCauseMessage); - return; - } - } - - throw e; - } - } - - private static List parseLearnerAnswers(McLearningForm mcLearningForm, HttpServletRequest request) { + private static List parseLearnerAnswers(McLearningForm mcLearningForm, HttpServletRequest request, boolean isQuestionsSequenced) { String httpSessionID = mcLearningForm.getHttpSessionID(); SessionMap sessionMap = (SessionMap) request.getSession().getAttribute(httpSessionID); - String questionListingMode = mcLearningForm.getQuestionListingMode(); + List answers = new LinkedList(); + if (isQuestionsSequenced) { - List learnerInput = new LinkedList(); - if (questionListingMode.equals(McAppConstants.QUESTION_LISTING_MODE_SEQUENTIAL)) { - - List previousLearnerInput = (List) sessionMap + List previousAnswers = (List) sessionMap .get(McAppConstants.QUESTION_AND_CANDIDATE_ANSWERS_KEY); - learnerInput.addAll(previousLearnerInput); + answers.addAll(previousAnswers); /* checkedCa refers to candidate answers */ String[] checkedCa = mcLearningForm.getCheckedCa(); if (checkedCa != null) { for (int i = 0; i < checkedCa.length; i++) { String currentCa = checkedCa[i]; - learnerInput.add(currentCa); + answers.add(currentCa); } } @@ -864,13 +783,13 @@ if (key.startsWith("checkedCa")) { String currentCheckedCa = request.getParameter(key); if (currentCheckedCa != null) { - learnerInput.add(currentCheckedCa); + answers.add(currentCheckedCa); } } } } - return learnerInput; + return answers; } private McQueUsr getCurrentUser(String toolSessionId) { Index: lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/McLearningForm.java =================================================================== RCS file: /usr/local/cvsroot/lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/McLearningForm.java,v diff -u -r1.31.2.3 -r1.31.2.4 --- lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/McLearningForm.java 16 Aug 2016 08:37:37 -0000 1.31.2.3 +++ lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/McLearningForm.java 13 Sep 2016 04:57:11 -0000 1.31.2.4 @@ -63,8 +63,6 @@ protected String learnerProgress; protected String learnerProgressUserId; - protected String questionListingMode; - protected String entryText; protected String questionIndex; @@ -366,21 +364,6 @@ } /** - * @return Returns the questionListingMode. - */ - public String getQuestionListingMode() { - return questionListingMode; - } - - /** - * @param questionListingMode - * The questionListingMode to set. - */ - public void setQuestionListingMode(String questionListingMode) { - this.questionListingMode = questionListingMode; - } - - /** * @return Returns the toolContentID. */ public String getToolContentID() { Index: lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/McLearningStarterAction.java =================================================================== RCS file: /usr/local/cvsroot/lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/McLearningStarterAction.java,v diff -u -r1.89.2.5 -r1.89.2.6 --- lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/McLearningStarterAction.java 16 Aug 2016 08:37:37 -0000 1.89.2.5 +++ lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/McLearningStarterAction.java 13 Sep 2016 04:57:11 -0000 1.89.2.6 @@ -46,11 +46,10 @@ import org.lamsfoundation.lams.notebook.model.NotebookEntry; import org.lamsfoundation.lams.notebook.service.CoreNotebookConstants; import org.lamsfoundation.lams.tool.ToolAccessMode; +import org.lamsfoundation.lams.tool.mc.AnswerDTO; import org.lamsfoundation.lams.tool.mc.McAppConstants; import org.lamsfoundation.lams.tool.mc.McApplicationException; import org.lamsfoundation.lams.tool.mc.McGeneralLearnerFlowDTO; -import org.lamsfoundation.lams.tool.mc.McLearnerAnswersDTO; -import org.lamsfoundation.lams.tool.mc.McLearnerStarterDTO; import org.lamsfoundation.lams.tool.mc.McUtils; import org.lamsfoundation.lams.tool.mc.pojos.McContent; import org.lamsfoundation.lams.tool.mc.pojos.McQueUsr; @@ -123,19 +122,6 @@ return (mapping.findForward(McAppConstants.ERROR_LIST)); } - /* - * The content we retrieved above must have been created before in Authoring time. And the passed tool session - * id already refers to it. - */ - McLearnerStarterDTO mcLearnerStarterDTO = new McLearnerStarterDTO(); - if (mcContent.isQuestionsSequenced()) { - mcLearnerStarterDTO.setQuestionListingMode(McAppConstants.QUESTION_LISTING_MODE_SEQUENTIAL); - mcLearningForm.setQuestionListingMode(McAppConstants.QUESTION_LISTING_MODE_SEQUENTIAL); - } else { - mcLearnerStarterDTO.setQuestionListingMode(McAppConstants.QUESTION_LISTING_MODE_COMBINED); - mcLearningForm.setQuestionListingMode(McAppConstants.QUESTION_LISTING_MODE_COMBINED); - } - String mode = request.getParameter(McAppConstants.MODE); McQueUsr user = null; if ((mode != null) && mode.equals(ToolAccessMode.TEACHER.toString())) { @@ -159,17 +145,14 @@ TimeZone learnerTimeZone = learnerDto.getTimeZone(); Date tzSubmissionDeadline = DateUtil.convertToTimeZoneFromDefault(learnerTimeZone, submissionDeadline); Date currentLearnerDate = DateUtil.convertToTimeZoneFromDefault(learnerTimeZone, new Date()); - mcLearnerStarterDTO.setSubmissionDeadline(submissionDeadline); + request.setAttribute("submissionDeadline", submissionDeadline); // calculate whether submission deadline has passed, and if so forward to "submissionDeadline" if (currentLearnerDate.after(tzSubmissionDeadline)) { - request.setAttribute(McAppConstants.MC_LEARNER_STARTER_DTO, mcLearnerStarterDTO); return mapping.findForward("submissionDeadline"); } } - mcLearnerStarterDTO.setActivityTitle(mcContent.getTitle()); - request.setAttribute(McAppConstants.MC_LEARNER_STARTER_DTO, mcLearnerStarterDTO); mcLearningForm.setToolContentID(mcContent.getMcContentId().toString()); McGeneralLearnerFlowDTO mcGeneralLearnerFlowDTO = LearningUtil.buildMcGeneralLearnerFlowDTO(mcContent); @@ -191,7 +174,7 @@ } request.setAttribute(McAppConstants.MC_GENERAL_LEARNER_FLOW_DTO, mcGeneralLearnerFlowDTO); - List learnerAnswersDTOList = mcService.buildLearnerAnswersDTOList(mcContent, user); + List learnerAnswersDTOList = mcService.getAnswersFromDatabase(mcContent, user); request.setAttribute(McAppConstants.LEARNER_ANSWERS_DTO_LIST, learnerAnswersDTOList); // should we show the marks for each question - we show the marks if any of the questions // have a mark > 1. @@ -250,7 +233,6 @@ return redirect; } - request.setAttribute(McAppConstants.MC_LEARNER_STARTER_DTO, mcLearnerStarterDTO); return (mapping.findForward(McAppConstants.LOAD_LEARNER)); } Index: lams_tool_lamc/web/learning/AnswersContent.jsp =================================================================== RCS file: /usr/local/cvsroot/lams_tool_lamc/web/learning/AnswersContent.jsp,v diff -u -r1.36.2.5 -r1.36.2.6 --- lams_tool_lamc/web/learning/AnswersContent.jsp 23 Feb 2016 14:46:50 -0000 1.36.2.5 +++ lams_tool_lamc/web/learning/AnswersContent.jsp 13 Sep 2016 04:57:11 -0000 1.36.2.6 @@ -72,7 +72,7 @@ function verifyAllQuestionsAnswered() { // in case oneQuestionPerPage option is ON user has to select 1 answer, and all answers otherwise - var isOneQuestionPerPage = ${mcGeneralLearnerFlowDTO.questionListingMode == 'questionListingModeSequential'}; + var isOneQuestionPerPage = ${sessionMap.content.questionsSequenced}; var answersRequiredNumber = (isOneQuestionPerPage) ? 1 : ${fn:length(requestScope.learnerAnswersDTOList)}; //check each question is answered @@ -125,11 +125,11 @@ - + - + @@ -153,7 +153,6 @@ - <%@ include file="/common/messages.jsp"%> @@ -166,7 +165,7 @@ - + Index: lams_tool_lamc/web/learning/IndividualLearnerResults.jsp =================================================================== RCS file: /usr/local/cvsroot/lams_tool_lamc/web/learning/Attic/IndividualLearnerResults.jsp,v diff -u -r1.57.2.4 -r1.57.2.5 --- lams_tool_lamc/web/learning/IndividualLearnerResults.jsp 2 Aug 2016 03:21:13 -0000 1.57.2.4 +++ lams_tool_lamc/web/learning/IndividualLearnerResults.jsp 13 Sep 2016 04:57:11 -0000 1.57.2.5 @@ -73,7 +73,7 @@ - +
@@ -96,14 +96,16 @@ - - - - - - + + + + + + + + @@ -154,7 +156,6 @@ -

Index: lams_tool_lamc/web/learning/ViewAnswers.jsp =================================================================== RCS file: /usr/local/cvsroot/lams_tool_lamc/web/learning/ViewAnswers.jsp,v diff -u -r1.69.2.4 -r1.69.2.5 --- lams_tool_lamc/web/learning/ViewAnswers.jsp 2 Aug 2016 03:21:13 -0000 1.69.2.4 +++ lams_tool_lamc/web/learning/ViewAnswers.jsp 13 Sep 2016 04:57:11 -0000 1.69.2.5 @@ -212,7 +212,6 @@ - - +