Index: lams_tool_lamc/conf/language/ApplicationResources.properties =================================================================== diff -u -r9393c098e5dfd603e2d37347cd1e531a25aa424a -r8a81c117f2bb66e5e4c7e5be0f2ca4bb8a1db7de --- lams_tool_lamc/conf/language/ApplicationResources.properties (.../ApplicationResources.properties) (revision 9393c098e5dfd603e2d37347cd1e531a25aa424a) +++ lams_tool_lamc/conf/language/ApplicationResources.properties (.../ApplicationResources.properties) (revision 8a81c117f2bb66e5e4c7e5be0f2ca4bb8a1db7de) @@ -245,6 +245,7 @@ label.yourAnswers =Your answers: label.learner= Learner label.yourMark =Your Mark: +label.feedback =Question Feedback: label.authoring.title.col =Title: label.authoring.instructions.col =Instructions: Index: lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/McAppConstants.java =================================================================== diff -u -r54049b70be0d86d212cf2cee1e27bca3b97ea59f -r8a81c117f2bb66e5e4c7e5be0f2ca4bb8a1db7de --- lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/McAppConstants.java (.../McAppConstants.java) (revision 54049b70be0d86d212cf2cee1e27bca3b97ea59f) +++ lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/McAppConstants.java (.../McAppConstants.java) (revision 8a81c117f2bb66e5e4c7e5be0f2ca4bb8a1db7de) @@ -147,6 +147,7 @@ public static final String INSTRUCTIONS ="instructions"; public static final String CREATION_DATE ="creationDate"; public static final String DEFINE_LATER ="defineLater"; + public static final String RUN_OFFLINE ="runOffline"; public static final String RETRIES ="retries"; public static final String PASSMARK ="passMark"; public static final String VIEW_ANSWERS ="viewAnswers"; Index: lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/McGeneralLearnerFlowDTO.java =================================================================== diff -u -r54049b70be0d86d212cf2cee1e27bca3b97ea59f -r8a81c117f2bb66e5e4c7e5be0f2ca4bb8a1db7de --- lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/McGeneralLearnerFlowDTO.java (.../McGeneralLearnerFlowDTO.java) (revision 54049b70be0d86d212cf2cee1e27bca3b97ea59f) +++ lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/McGeneralLearnerFlowDTO.java (.../McGeneralLearnerFlowDTO.java) (revision 8a81c117f2bb66e5e4c7e5be0f2ca4bb8a1db7de) @@ -56,9 +56,80 @@ protected String activityTitle; + protected String learnerBestMark; + + protected String currentQuestionIndex; + + protected String countSessionComplete; + + protected String topMark; + + protected String lowestMark; + protected String averageMark; + /** + * @return Returns the averageMark. + */ + public String getAverageMark() { + return averageMark; + } + /** + * @param averageMark The averageMark to set. + */ + public void setAverageMark(String averageMark) { + this.averageMark = averageMark; + } + /** + * @return Returns the countSessionComplete. + */ + public String getCountSessionComplete() { + return countSessionComplete; + } + /** + * @param countSessionComplete The countSessionComplete to set. + */ + public void setCountSessionComplete(String countSessionComplete) { + this.countSessionComplete = countSessionComplete; + } + /** + * @return Returns the lowestMark. + */ + public String getLowestMark() { + return lowestMark; + } + /** + * @param lowestMark The lowestMark to set. + */ + public void setLowestMark(String lowestMark) { + this.lowestMark = lowestMark; + } + /** + * @return Returns the topMark. + */ + public String getTopMark() { + return topMark; + } + /** + * @param topMark The topMark to set. + */ + public void setTopMark(String topMark) { + this.topMark = topMark; + } + /** + * @return Returns the learnerBestMark. + */ + public String getLearnerBestMark() { + return learnerBestMark; + } + /** + * @param learnerBestMark The learnerBestMark to set. + */ + public void setLearnerBestMark(String learnerBestMark) { + this.learnerBestMark = learnerBestMark; + } + /** * @return Returns the activityInstructions. */ public String getActivityInstructions() { @@ -220,4 +291,16 @@ public void setUserPassed(String userPassed) { this.userPassed = userPassed; } + /** + * @return Returns the currentQuestionIndex. + */ + public String getCurrentQuestionIndex() { + return currentQuestionIndex; + } + /** + * @param currentQuestionIndex The currentQuestionIndex to set. + */ + public void setCurrentQuestionIndex(String currentQuestionIndex) { + this.currentQuestionIndex = currentQuestionIndex; + } } Index: lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/McTempDataHolderDTO.java =================================================================== diff -u --- lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/McTempDataHolderDTO.java (revision 0) +++ lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/McTempDataHolderDTO.java (revision 8a81c117f2bb66e5e4c7e5be0f2ca4bb8a1db7de) @@ -0,0 +1,82 @@ +/*************************************************************************** + * Copyright (C) 2005 LAMS Foundation (http://lamsfoundation.org) + * ============================================================= + * License Information: http://lamsfoundation.org/licensing/lams/2.0/ + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 + * USA + * + * http://www.gnu.org/licenses/gpl.txt + * ***********************************************************************/ +/* $$Id$$ */ +package org.lamsfoundation.lams.tool.mc; + +import org.apache.commons.lang.builder.ToStringBuilder; + + + +/** + *
DTO that holds temporary data + *
+ * + * @author Ozgur Demirtas + */ +public class McTempDataHolderDTO implements Comparable +{ + protected String learnerMark; + protected String totalUserWeight; + + + public int compareTo(Object o) + { + McTempDataHolderDTO mcTempDataHolderDTO = (McTempDataHolderDTO) o; + + if (mcTempDataHolderDTO == null) + return 1; + else + return 0; + } + + public String toString() { + return new ToStringBuilder(this) + .append("learnerMark: ", learnerMark) + .append("totalUserWeight : ", totalUserWeight) + .toString(); + } + + /** + * @return Returns the learnerMark. + */ + public String getLearnerMark() { + return learnerMark; + } + /** + * @param learnerMark The learnerMark to set. + */ + public void setLearnerMark(String learnerMark) { + this.learnerMark = learnerMark; + } + /** + * @return Returns the totalUserWeight. + */ + public String getTotalUserWeight() { + return totalUserWeight; + } + /** + * @param totalUserWeight The totalUserWeight to set. + */ + public void setTotalUserWeight(String totalUserWeight) { + this.totalUserWeight = totalUserWeight; + } +} Index: lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/LearningUtil.java =================================================================== diff -u -r54049b70be0d86d212cf2cee1e27bca3b97ea59f -r8a81c117f2bb66e5e4c7e5be0f2ca4bb8a1db7de --- lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/LearningUtil.java (.../LearningUtil.java) (revision 54049b70be0d86d212cf2cee1e27bca3b97ea59f) +++ lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/LearningUtil.java (.../LearningUtil.java) (revision 8a81c117f2bb66e5e4c7e5be0f2ca4bb8a1db7de) @@ -64,77 +64,15 @@ * @param form * @param questionIndex */ - public static void selectOptionsCheckBox(HttpServletRequest request,McLearningForm mcLearningForm, String questionIndex) - { - logger.debug("requested optionCheckBoxSelected..."); - logger.debug("questionIndex: " + mcLearningForm.getQuestionIndex()); - logger.debug("optionIndex: " + mcLearningForm.getOptionIndex()); - logger.debug("optionValue: " + mcLearningForm.getOptionValue()); - logger.debug("checked: " + mcLearningForm.getChecked()); - - Map mapGeneralCheckedOptionsContent=(Map) request.getSession().getAttribute(MAP_GENERAL_CHECKED_OPTIONS_CONTENT); - logger.debug("mapGeneralCheckedOptionsContent: " + mapGeneralCheckedOptionsContent); - - if (mapGeneralCheckedOptionsContent.size() == 0) - { - logger.debug("mapGeneralCheckedOptionsContent size is 0"); - Map mapLeanerCheckedOptionsContent= new TreeMap(new McComparator()); - - if (mcLearningForm.getChecked().equals("true")) - mapLeanerCheckedOptionsContent.put(mcLearningForm.getOptionIndex(), mcLearningForm.getOptionValue()); - else - mapLeanerCheckedOptionsContent.remove(mcLearningForm.getOptionIndex()); - - mapGeneralCheckedOptionsContent.put(mcLearningForm.getQuestionIndex(),mapLeanerCheckedOptionsContent); - request.getSession().setAttribute(MAP_GENERAL_CHECKED_OPTIONS_CONTENT, mapGeneralCheckedOptionsContent); - } - else - { - Map mapCurrentOptions=(Map) mapGeneralCheckedOptionsContent.get(questionIndex); - - logger.debug("mapCurrentOptions: " + mapCurrentOptions); - if (mapCurrentOptions != null) - { - if (mcLearningForm.getChecked().equals("true")) - mapCurrentOptions.put(mcLearningForm.getOptionIndex(), mcLearningForm.getOptionValue()); - else - mapCurrentOptions.remove(mcLearningForm.getOptionIndex()); - - logger.debug("updated mapCurrentOptions: " + mapCurrentOptions); - - mapGeneralCheckedOptionsContent.put(mcLearningForm.getQuestionIndex(),mapCurrentOptions); - request.getSession().setAttribute(MAP_GENERAL_CHECKED_OPTIONS_CONTENT, mapGeneralCheckedOptionsContent); - } - else - { - logger.debug("no options for this questions has been selected yet"); - Map mapLeanerCheckedOptionsContent= new TreeMap(new McComparator()); - - if (mcLearningForm.getChecked().equals("true")) - mapLeanerCheckedOptionsContent.put(mcLearningForm.getOptionIndex(), mcLearningForm.getOptionValue()); - else - mapLeanerCheckedOptionsContent.remove(mcLearningForm.getOptionIndex()); - - mapGeneralCheckedOptionsContent.put(mcLearningForm.getQuestionIndex(),mapLeanerCheckedOptionsContent); - request.getSession().setAttribute(MAP_GENERAL_CHECKED_OPTIONS_CONTENT, mapGeneralCheckedOptionsContent); - } - } - - mapGeneralCheckedOptionsContent=(Map) request.getSession().getAttribute(MAP_GENERAL_CHECKED_OPTIONS_CONTENT); - logger.debug("final mapGeneralCheckedOptionsContent: " + mapGeneralCheckedOptionsContent); - } - /** * continueOptions(HttpServletRequest request) * * @param request * @return boolean */ - public static boolean continueOptions(HttpServletRequest request) + public static boolean continueOptions(HttpServletRequest request, IMcService mcService) { - IMcService mcService =McUtils.getToolService(request); - logger.debug("continue options requested."); String currentQuestionIndex=(String)request.getSession().getAttribute(CURRENT_QUESTION_INDEX); logger.debug("currentQuestionIndex:" + currentQuestionIndex); @@ -184,57 +122,12 @@ } - /** - * readParameters(HttpServletRequest request, McLearningForm mcLearningForm) - * - * @param request - * @param mcLearningForm - */ - public static void readParameters(HttpServletRequest request, McLearningForm mcLearningForm) - { - String optionCheckBoxSelected=request.getParameter("optionCheckBoxSelected"); - logger.debug("parameter optionCheckBoxSelected: " + optionCheckBoxSelected); - - if ((optionCheckBoxSelected != null) && optionCheckBoxSelected.equals("1")) - { - logger.debug("parameter optionCheckBoxSelected is selected " + optionCheckBoxSelected); - mcLearningForm.setOptionCheckBoxSelected("1"); - } - - String questionIndex=request.getParameter("questionIndex"); - logger.debug("parameter questionIndex: " + questionIndex); - if ((questionIndex != null)) - { - logger.debug("parameter questionIndex is selected " + questionIndex); - mcLearningForm.setQuestionIndex(questionIndex); - } - - String optionIndex=request.getParameter("optionIndex"); - logger.debug("parameter optionIndex: " + optionIndex); - if (optionIndex != null) - { - logger.debug("parameter optionIndex is selected " + optionIndex); - mcLearningForm.setOptionIndex(optionIndex); - } - - String optionValue=request.getParameter("optionValue"); - logger.debug("parameter optionValue: " + optionValue); - if (optionValue != null) - { - mcLearningForm.setOptionValue(optionValue); - } - - String checked=request.getParameter("checked"); - logger.debug("parameter checked: " + checked); - if (checked != null) - { - logger.debug("parameter checked is selected " + checked); - mcLearningForm.setChecked(checked); - } - } + /** + * redundant method: + * * assess(HttpServletRequest request, Map mapGeneralCheckedOptionsContent) * * @param request @@ -375,9 +268,8 @@ * @param queUsrId * @return */ - public static int getHighestMark(HttpServletRequest request, Long queUsrId) + public static int getHighestMark(HttpServletRequest request, Long queUsrId, IMcService mcService) { - IMcService mcService =McUtils.getToolService(request); List listMarks=mcService.getHighestMark(queUsrId); Iterator itMarks=listMarks.iterator(); @@ -399,9 +291,8 @@ * @param request * @return */ - public static int getTopMark(HttpServletRequest request) + public static int getTopMark(HttpServletRequest request, IMcService mcService) { - IMcService mcService =McUtils.getToolService(request); List listMarks=mcService.getMarks(); Iterator itMarks=listMarks.iterator(); @@ -424,9 +315,8 @@ * @param request * @return */ - public static int getLowestMark(HttpServletRequest request) + public static int getLowestMark(HttpServletRequest request, IMcService mcService) { - IMcService mcService =McUtils.getToolService(request); List listMarks=mcService.getMarks(); Iterator itMarks=listMarks.iterator(); @@ -453,9 +343,8 @@ * @param request * @return */ - public static int getAverageMark(HttpServletRequest request) + public static int getAverageMark(HttpServletRequest request, IMcService mcService) { - IMcService mcService =McUtils.getToolService(request); List listMarks=mcService.getMarks(); Iterator itMarks=listMarks.iterator(); @@ -644,9 +533,8 @@ return false; } - public static McQueUsr getUser(HttpServletRequest request) + public static McQueUsr getUser(HttpServletRequest request, IMcService mcService) { - IMcService mcService =McUtils.getToolService(request); Long queUsrId=McUtils.getUserId(); Long toolSessionId=(Long)request.getSession().getAttribute(TOOL_SESSION_ID); @@ -685,13 +573,40 @@ return mcQueUsr; } - - /** - * creates a user attempt in the db - * createAttempt(HttpServletRequest request) - * - * @param request - */ + public static void createLearnerAttempt(HttpServletRequest request, McQueUsr mcQueUsr, List selectedQuestionAndCandidateAnswersDTO, + int mark, boolean passed, int highestAttemptOrder, Map mapLeanerAssessmentResults, IMcService mcService) + { + logger.debug("starting createLearnerAttempt: "); + Date attempTime=McUtils.getGMTDateTime(); + String timeZone= McUtils.getCurrentTimeZone(); + logger.debug("timeZone: " + timeZone); + + + Iterator itSelectedMap = selectedQuestionAndCandidateAnswersDTO.iterator(); + while (itSelectedMap.hasNext()) + { + McLearnerAnswersDTO mcLearnerAnswersDTO=(McLearnerAnswersDTO)itSelectedMap.next(); + logger.debug("mcLearnerAnswersDTO: " + mcLearnerAnswersDTO); + String questionUid=mcLearnerAnswersDTO.getQuestionUid(); + logger.debug("questionUid: " + questionUid); + + McQueContent mcQueContent=mcService.findMcQuestionContentByUid(new Long(questionUid)); + logger.debug("mcQueContent: " + mcQueContent); + + Map candidateAnswers=mcLearnerAnswersDTO.getCandidateAnswers(); + logger.debug("candidateAnswers: " + candidateAnswers); + + String isAttemptCorrect=mcLearnerAnswersDTO.getAttemptCorrect(); + logger.debug("isAttemptCorrect: " + isAttemptCorrect); + + logger.debug("requesting createIndividualOptions"); + createIndividualOptions(request, candidateAnswers, mcQueContent, mcQueUsr, attempTime, timeZone, mark, passed, + new Integer(highestAttemptOrder), isAttemptCorrect,mcService); + } + + } + + /* public static void createAttempt(HttpServletRequest request, McQueUsr mcQueUsr, Map mapGeneralCheckedOptionsContent, int mark, boolean passed, int highestAttemptOrder, Map mapLeanerAssessmentResults) { IMcService mcService =McUtils.getToolService(request); @@ -725,24 +640,26 @@ } } } + */ - - public static void createIndividualOptions(HttpServletRequest request, Map mapCheckedOptions, McQueContent mcQueContent, McQueUsr mcQueUsr, Date attempTime, String timeZone, int mark, boolean passed, Integer highestAttemptOrder, String isAttemptCorrect) + public static void createIndividualOptions(HttpServletRequest request, Map candidateAnswers, McQueContent mcQueContent, + McQueUsr mcQueUsr, Date attempTime, String timeZone, int mark, boolean passed, Integer highestAttemptOrder, String isAttemptCorrect, + IMcService mcService) { - IMcService mcService =McUtils.getToolService(request); + logger.debug("starting createIndividualOptions"); Integer IntegerMark= new Integer(mark); logger.debug("createIndividualOptions-> isAttemptCorrect: " + isAttemptCorrect); logger.debug("mcQueContent: " + mcQueContent); - logger.debug("mapCheckedOptions: " + mapCheckedOptions); + logger.debug("candidateAnswers: " + candidateAnswers); logger.debug("highestAttemptOrder used : " + highestAttemptOrder); if (mcQueContent != null) { - if (mapCheckedOptions != null) + if (candidateAnswers != null) { - Iterator itCheckedMap = mapCheckedOptions.entrySet().iterator(); + Iterator itCheckedMap = candidateAnswers.entrySet().iterator(); while (itCheckedMap.hasNext()) { Map.Entry checkedPairs = (Map.Entry)itCheckedMap.next(); @@ -767,29 +684,32 @@ * @param toolContentId * @return Map */ - public static Map buildWeightsMap(HttpServletRequest request, Long toolContentId) + public static Map buildWeightsMap(HttpServletRequest request, Long toolContentId, IMcService mcService) { - IMcService mcService =McUtils.getToolService(request); + logger.debug("starting buildWeightsMap : " + toolContentId); Map mapWeights= new TreeMap(new McComparator()); McContent mcContent=mcService.retrieveMc(toolContentId); + logger.debug("mcContent : " + mcContent); List questionsContent=mcService.refreshQuestionContent(mcContent.getUid()); + logger.debug("questionsContent : " + questionsContent); Iterator listIterator=questionsContent.iterator(); Long mapIndex=new Long(1); while (listIterator.hasNext()) { McQueContent mcQueContent=(McQueContent)listIterator.next(); + logger.debug("mcQueContent : " + mcQueContent); mapWeights.put(mapIndex.toString(),mcQueContent.getWeight().toString()); mapIndex=new Long(mapIndex.longValue()+1); } + logger.debug("mapWeights : " + mapWeights); return mapWeights; } - public static Map buildQuestionContentMap(HttpServletRequest request, McContent mcContent) + public static Map buildQuestionContentMap(HttpServletRequest request, McContent mcContent, IMcService mcService) { - IMcService mcService =McUtils.getToolService(request); Map mapQuestionsContent= new TreeMap(new McComparator()); Iterator contentIterator=mcContent.getMcQueContents().iterator(); @@ -935,16 +855,18 @@ logger.debug("passMark: " + passMark); logger.debug("original mapQuestionWeights: " + mapQuestionWeights); + boolean mapExcluded=false; int minimumQuestionCount=0; int totalHighestWeights=0; while (totalHighestWeights <= passMark.intValue()) { logger.debug("totalHighestWeights versus passMark: " + totalHighestWeights + " versus" + passMark); - int highestWeight=getHighestWeight(mapQuestionWeights); + int highestWeight=getHighestWeight(mapQuestionWeights, mapExcluded); logger.debug("highestWeight: " + highestWeight); totalHighestWeights=totalHighestWeights + highestWeight; logger.debug("totalHighestWeights: " + totalHighestWeights); mapQuestionWeights=rebuildWeightsMapExcludeHighestWeight(mapQuestionWeights, highestWeight); + mapExcluded=true; logger.debug("mapQuestionWeights: " + mapQuestionWeights); ++minimumQuestionCount; if (mapQuestionWeights.size() == 0) @@ -958,17 +880,18 @@ } - public static int getHighestWeight(Map mapQuestionWeights) + public static int getHighestWeight(Map mapQuestionWeights, boolean mapExcluded) { + logger.debug("mapExcluded: " + mapExcluded); - if (mapQuestionWeights.size() == 1) + if ((mapQuestionWeights.size() == 1) && (!mapExcluded)) { logger.debug("using map with 1 question only"); /*the only alternative is 100*/ return 100; } - logger.debug("using map with > 1 questions"); + logger.debug("continue excluding map"); Iterator itMap = mapQuestionWeights.entrySet().iterator(); int highestWeight=0; while (itMap.hasNext()) Index: lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/McLearningAction.java =================================================================== diff -u -r54049b70be0d86d212cf2cee1e27bca3b97ea59f -r8a81c117f2bb66e5e4c7e5be0f2ca4bb8a1db7de --- lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/McLearningAction.java (.../McLearningAction.java) (revision 54049b70be0d86d212cf2cee1e27bca3b97ea59f) +++ lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/McLearningAction.java (.../McLearningAction.java) (revision 8a81c117f2bb66e5e4c7e5be0f2ca4bb8a1db7de) @@ -51,6 +51,7 @@ import org.lamsfoundation.lams.tool.mc.McGeneralLearnerFlowDTO; import org.lamsfoundation.lams.tool.mc.McLearnerAnswersDTO; import org.lamsfoundation.lams.tool.mc.McStringComparator; +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; @@ -271,12 +272,6 @@ setContentInUse(request, toolContentId, mcService); return getNextOptions(mapping, form, request, response); } - else if (mcLearningForm.getOptionCheckBoxSelected() != null) - { - setContentInUse(request, toolContentId, mcService); - mcLearningForm.resetCommands(); - LearningUtil.selectOptionsCheckBox(request,mcLearningForm, mcLearningForm.getQuestionIndex()); - } else if (mcLearningForm.getRedoQuestions() != null) { setContentInUse(request, toolContentId, mcService); @@ -432,8 +427,7 @@ - protected List buildSelectedQuestionAndCandidateAnswersDTO(List learnerInput, Integer learnerMark, - Integer totalUserWeight, IMcService mcService) + protected List buildSelectedQuestionAndCandidateAnswersDTO(List learnerInput, McTempDataHolderDTO mcTempDataHolderDTO, IMcService mcService) { logger.debug("mcService: " + mcService); logger.debug("learnerInput: " + learnerInput); @@ -529,9 +523,10 @@ logger.debug("final questionAndCandidateAnswersList: " + questionAndCandidateAnswersList); logger.debug("final mark: " + mark); logger.debug("final userWeight: " + userWeight); - learnerMark= new Integer(mark); - totalUserWeight= new Integer(userWeight); + mcTempDataHolderDTO.setLearnerMark(new Integer(mark).toString()); + mcTempDataHolderDTO.setTotalUserWeight(new Integer(userWeight).toString()); + return questionAndCandidateAnswersList; } @@ -576,23 +571,37 @@ String toolContentId=mcLearningForm.getToolContentId(); logger.debug("toolContentId: " + toolContentId); - Integer learnerMark= new Integer(0); - Integer totalUserWeight= new Integer(0); + + //Integer learnerMark= new Integer(0); + //Integer totalUserWeight= new Integer(0); + McTempDataHolderDTO mcTempDataHolderDTO= new McTempDataHolderDTO(); - List selectedQuestionAndCandidateAnswersDTO=buildSelectedQuestionAndCandidateAnswersDTO(learnerInput,learnerMark, - totalUserWeight, mcService); + List selectedQuestionAndCandidateAnswersDTO=buildSelectedQuestionAndCandidateAnswersDTO(learnerInput,mcTempDataHolderDTO + , mcService); logger.debug("selectedQuestionAndCandidateAnswersDTO: " + selectedQuestionAndCandidateAnswersDTO); request.setAttribute(LIST_SELECTED_QUESTION_CANDIDATEANSWERS_DTO, selectedQuestionAndCandidateAnswersDTO); logger.debug("LIST_SELECTED_QUESTION_CANDIDATEANSWERS_DTO: " + request.getAttribute(LIST_SELECTED_QUESTION_CANDIDATEANSWERS_DTO)); - logger.debug("learnerMark becomes: " + learnerMark); - logger.debug("totalUserWeight becomes: " + totalUserWeight); - + logger.debug("mcTempDataHolderDTO becomes: " + mcTempDataHolderDTO); + String learnerMark=mcTempDataHolderDTO.getLearnerMark(); + logger.debug("learnerMark: " + learnerMark); + + String totalUserWeight=mcTempDataHolderDTO.getTotalUserWeight(); + logger.debug("totalUserWeight: " + totalUserWeight); + + + /* process the answers */ McContent mcContent=mcService.retrieveMc(new Long(toolContentId)); logger.debug("mcContent: " + mcContent); - McGeneralLearnerFlowDTO mcGeneralLearnerFlowDTO=LearningUtil.buildMcGeneralLearnerFlowDTO(mcContent); + McGeneralLearnerFlowDTO mcGeneralLearnerFlowDTO=LearningUtil.buildMcGeneralLearnerFlowDTO(mcContent); + logger.debug("constructed a new mcGeneralLearnerFlowDTO"); + + int totalQuestionCount=mcContent.getMcQueContents().size(); + logger.debug("totalQuestionCount: " + totalQuestionCount); + mcGeneralLearnerFlowDTO.setTotalQuestionCount(new Integer(totalQuestionCount).toString()); + mcGeneralLearnerFlowDTO.setLearnerMark(learnerMark.toString()); Integer passMark=mcContent.getPassMark(); @@ -605,7 +614,8 @@ { mcGeneralLearnerFlowDTO.setPassMarkApplicable(new Boolean(true).toString()); - if (totalUserWeight.intValue() < passMark.intValue()) + logger.debug("totalUserWeight versus passMark: " + totalUserWeight + " versus " + passMark); + if (new Integer(totalUserWeight).intValue() < passMark.intValue()) { logger.debug("USER FAILED"); logger.debug("totalUserWeight is less than passmark: " + totalUserWeight + " < " + passMark.intValue()); @@ -703,20 +713,15 @@ logger.debug("new highestAttemptOrder: " + highestAttemptOrder); - /* - logger.debug("passed: " + passed); - LearningUtil.createAttempt(request, mcQueUsr, mapGeneralCheckedOptionsContent, learnerMark.intValue(), passed, new Integer(highestAttemptOrder).intValue(), mapLearnerAssessmentResults); + LearningUtil.createLearnerAttempt(request, mcQueUsr, selectedQuestionAndCandidateAnswersDTO, new Integer(learnerMark).intValue(), passed, new Integer(highestAttemptOrder).intValue(), null, mcService); logger.debug("created user attempt in the db"); - - logger.debug("before getLearnerMarkAtLeast: passMark" + passMark); - logger.debug("before getLearnerMarkAtLeast: mapQuestionWeights" + mapQuestionWeights); + + Map mapQuestionWeights=LearningUtil.buildWeightsMap(request, mcContent.getMcContentId(), mcService); + logger.debug("mapQuestionWeights:" + mapQuestionWeights); int learnerMarkAtLeast=LearningUtil.getLearnerMarkAtLeast(passMark,mapQuestionWeights); logger.debug("learnerMarkAtLeast:" + learnerMarkAtLeast); - request.getSession().setAttribute(LEARNER_MARK_ATLEAST, new Integer(learnerMarkAtLeast).toString()); - mcGeneralLearnerFlowDTO.setLearnerMarkAtLeast (new Integer(learnerMarkAtLeast).toString()); - */ - + mcGeneralLearnerFlowDTO.setLearnerMarkAtLeast (new Integer(learnerMarkAtLeast).toString()); logger.debug("user over passmark:" + mcLearningForm.getUserOverPassMark()); logger.debug("is passmark applicable:" + mcLearningForm.getPassMarkApplicable()); @@ -798,15 +803,24 @@ McUtils.cleanUpUserExceptions(request); logger.debug("dispatching redoQuestions..."); McLearningForm mcLearningForm = (McLearningForm) form; - IMcService mcService = McServiceProxy.getMcService(getServlet().getServletContext()); + IMcService mcService = McServiceProxy.getMcService(getServlet().getServletContext()); + + String toolContentId=mcLearningForm.getToolContentId(); + logger.debug("toolContentId: " + toolContentId); + + McContent mcContent=mcService.retrieveMc(new Long(toolContentId)); + logger.debug("mcContent: " + mcContent); + + + McGeneralLearnerFlowDTO mcGeneralLearnerFlowDTO=LearningUtil.buildMcGeneralLearnerFlowDTO(mcContent); request.getSession().setAttribute(CURRENT_QUESTION_INDEX, "1"); request.getSession().setAttribute(TOTAL_COUNT_REACHED, new Boolean(false).toString()); - Long toolSessionId=(Long)request.getSession().getAttribute(TOOL_SESSION_ID); - logger.debug("toolSessionId: " + toolSessionId); + String toolSessionId=mcLearningForm.getToolSessionId(); + logger.debug("toolSessionId: " + toolSessionId); - McSession mcSession=mcService.retrieveMcSession(toolSessionId); + McSession mcSession=mcService.retrieveMcSession(new Long(toolSessionId)); logger.debug("retrieving mcSession: " + mcSession); String userID = ""; @@ -830,10 +844,13 @@ Long queUsrId=mcQueUsr.getUid(); logger.debug("queUsrId: " + queUsrId); - int learnerBestMark=LearningUtil.getHighestMark(request, queUsrId); + int learnerBestMark=LearningUtil.getHighestMark(request, queUsrId, mcService); logger.debug("learnerBestMark: " + learnerBestMark); - request.getSession().setAttribute(LEARNER_BEST_MARK,new Integer(learnerBestMark).toString()); + mcGeneralLearnerFlowDTO.setLearnerBestMark(new Integer(learnerBestMark).toString()); + request.setAttribute(MC_GENERAL_LEARNER_FLOW_DTO, mcGeneralLearnerFlowDTO); + logger.debug("MC_GENERAL_LEARNER_FLOW_DTO: " + request.getAttribute(MC_GENERAL_LEARNER_FLOW_DTO)); + mcLearningForm.resetCommands(); return (mapping.findForward(REDO_QUESTIONS)); } @@ -889,7 +906,7 @@ Long queUsrId=null; if (learnerProgressOn == false) { - mcQueUsr=LearningUtil.getUser(request); + mcQueUsr=LearningUtil.getUser(request, mcService); logger.debug("mcQueUsr: " + mcQueUsr); queUsrId=mcQueUsr.getUid(); @@ -1046,22 +1063,38 @@ logger.debug("dispatching viewSummary..."); McLearningForm mcLearningForm = (McLearningForm) form; IMcService mcService = McServiceProxy.getMcService(getServlet().getServletContext()); + + String toolContentId=mcLearningForm.getToolContentId(); + logger.debug("toolContentId: " + toolContentId); + + McContent mcContent=mcService.retrieveMc(new Long(toolContentId)); + logger.debug("mcContent: " + mcContent); + + McGeneralLearnerFlowDTO mcGeneralLearnerFlowDTO=LearningUtil.buildMcGeneralLearnerFlowDTO(mcContent); int countSessionComplete=mcService.countSessionComplete(); - int topMark=LearningUtil.getTopMark(request); - int lowestMark=LearningUtil.getLowestMark(request); - int averageMark=LearningUtil.getAverageMark(request); + int topMark=LearningUtil.getTopMark(request, mcService); + int lowestMark=LearningUtil.getLowestMark(request, mcService); + int averageMark=LearningUtil.getAverageMark(request, mcService); logger.debug("countSessionComplete: " + countSessionComplete); logger.debug("topMark: " + topMark); logger.debug("lowestMark: " + lowestMark); logger.debug("averageMark: " + averageMark); - request.getSession().setAttribute(COUNT_SESSION_COMPLETE, new Integer(countSessionComplete).toString()); - request.getSession().setAttribute(TOP_MARK, new Integer(topMark).toString()); - request.getSession().setAttribute(LOWEST_MARK, new Integer(lowestMark).toString()); - request.getSession().setAttribute(AVERAGE_MARK, new Integer(averageMark).toString()); + //request.getSession().setAttribute(COUNT_SESSION_COMPLETE, new Integer(countSessionComplete).toString()); + //request.getSession().setAttribute(TOP_MARK, new Integer(topMark).toString()); + //request.getSession().setAttribute(LOWEST_MARK, new Integer(lowestMark).toString()); + //request.getSession().setAttribute(AVERAGE_MARK, new Integer(averageMark).toString()); + mcGeneralLearnerFlowDTO.setCountSessionComplete(new Integer(countSessionComplete).toString()); + mcGeneralLearnerFlowDTO.setTopMark(new Integer(topMark).toString()); + mcGeneralLearnerFlowDTO.setLowestMark(new Integer(lowestMark).toString()); + mcGeneralLearnerFlowDTO.setAverageMark(new Integer(averageMark).toString()); + + request.setAttribute(MC_GENERAL_LEARNER_FLOW_DTO, mcGeneralLearnerFlowDTO); + logger.debug("MC_GENERAL_LEARNER_FLOW_DTO: " + request.getAttribute(MC_GENERAL_LEARNER_FLOW_DTO)); + mcLearningForm.resetCommands(); return (mapping.findForward(RESULTS_SUMMARY)); } @@ -1099,13 +1132,32 @@ { McUtils.cleanUpUserExceptions(request); logger.debug("requested redoQuestions..."); + IMcService mcService = McServiceProxy.getMcService(getServlet().getServletContext()); + /* reset the checked options MAP */ Map mapGeneralCheckedOptionsContent= new TreeMap(new McComparator()); - request.getSession().setAttribute(MAP_GENERAL_CHECKED_OPTIONS_CONTENT, mapGeneralCheckedOptionsContent); + //request.getSession().setAttribute(MAP_GENERAL_CHECKED_OPTIONS_CONTENT, mapGeneralCheckedOptionsContent); + + String toolContentId=mcLearningForm.getToolContentId(); + logger.debug("toolContentId: " + toolContentId); + + McContent mcContent=mcService.retrieveMc(new Long(toolContentId)); + logger.debug("mcContent: " + mcContent); + + + List listQuestionAndCandidateAnswersDTO=LearningUtil.buildQuestionAndCandidateAnswersDTO(request, mcContent, mcService); + logger.debug("listQuestionAndCandidateAnswersDTO: " + listQuestionAndCandidateAnswersDTO); + request.setAttribute(LIST_QUESTION_CANDIDATEANSWERS_DTO, listQuestionAndCandidateAnswersDTO); + logger.debug("LIST_QUESTION_CANDIDATEANSWERS_DTO: " + request.getAttribute(LIST_QUESTION_CANDIDATEANSWERS_DTO)); + + McGeneralLearnerFlowDTO mcGeneralLearnerFlowDTO=LearningUtil.buildMcGeneralLearnerFlowDTO(mcContent); + request.setAttribute(MC_GENERAL_LEARNER_FLOW_DTO, mcGeneralLearnerFlowDTO); + logger.debug("MC_GENERAL_LEARNER_FLOW_DTO: " + request.getAttribute(MC_GENERAL_LEARNER_FLOW_DTO)); + mcLearningForm.resetCommands(); - String previewOnly=(String)request.getSession().getAttribute(PREVIEW_ONLY); - logger.debug("previewOnly: " + previewOnly); + //String previewOnly=(String)request.getSession().getAttribute(PREVIEW_ONLY); + //logger.debug("previewOnly: " + previewOnly); logger.debug("fwding to LOAD_LEARNER: " + LOAD_LEARNER); return (mapping.findForward(LOAD_LEARNER)); Index: lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/McLearningForm.java =================================================================== diff -u -r54049b70be0d86d212cf2cee1e27bca3b97ea59f -r8a81c117f2bb66e5e4c7e5be0f2ca4bb8a1db7de --- lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/McLearningForm.java (.../McLearningForm.java) (revision 54049b70be0d86d212cf2cee1e27bca3b97ea59f) +++ lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/McLearningForm.java (.../McLearningForm.java) (revision 8a81c117f2bb66e5e4c7e5be0f2ca4bb8a1db7de) @@ -31,13 +31,8 @@ * ActionForm for the Learning environment */ public class McLearningForm extends ActionForm implements McAppConstants { - protected String optionCheckBoxSelected; - protected String questionIndex; - protected String optionIndex; - protected String optionValue; - protected String checked; - - protected String continueOptions; + + protected String continueOptions; protected String nextOptions; protected String continueOptionsCombined; protected String redoQuestions; @@ -76,11 +71,6 @@ public void resetParameters() { - this.setOptionCheckBoxSelected(null); - this.setQuestionIndex(null); - this.setOptionIndex(null); - this.setChecked(null); - this.setOptionValue(null); } @@ -96,54 +86,7 @@ public void setContinueOptions(String continueOptions) { this.continueOptions = continueOptions; } - /** - * @return Returns the checked. - */ - public String getChecked() { - return checked; - } - /** - * @param checked The checked to set. - */ - public void setChecked(String checked) { - this.checked = checked; - } - /** - * @return Returns the optionCheckBoxSelected. - */ - public String getOptionCheckBoxSelected() { - return optionCheckBoxSelected; - } - /** - * @param optionCheckBoxSelected The optionCheckBoxSelected to set. - */ - public void setOptionCheckBoxSelected(String optionCheckBoxSelected) { - this.optionCheckBoxSelected = optionCheckBoxSelected; - } - /** - * @return Returns the optionIndex. - */ - public String getOptionIndex() { - return optionIndex; - } - /** - * @param optionIndex The optionIndex to set. - */ - public void setOptionIndex(String optionIndex) { - this.optionIndex = optionIndex; - } - /** - * @return Returns the questionIndex. - */ - public String getQuestionIndex() { - return questionIndex; - } - /** - * @param questionIndex The questionIndex to set. - */ - public void setQuestionIndex(String questionIndex) { - this.questionIndex = questionIndex; - } + /** * @return Returns the viewSummary. @@ -182,18 +125,6 @@ this.redoQuestions = redoQuestions; } /** - * @return Returns the optionValue. - */ - public String getOptionValue() { - return optionValue; - } - /** - * @param optionValue The optionValue to set. - */ - public void setOptionValue(String optionValue) { - this.optionValue = optionValue; - } - /** * @return Returns the viewAnswers. */ public String getViewAnswers() { Index: lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/McLearningStarterAction.java =================================================================== diff -u -r54049b70be0d86d212cf2cee1e27bca3b97ea59f -r8a81c117f2bb66e5e4c7e5be0f2ca4bb8a1db7de --- lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/McLearningStarterAction.java (.../McLearningStarterAction.java) (revision 54049b70be0d86d212cf2cee1e27bca3b97ea59f) +++ lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/McLearningStarterAction.java (.../McLearningStarterAction.java) (revision 8a81c117f2bb66e5e4c7e5be0f2ca4bb8a1db7de) @@ -339,9 +339,8 @@ { McUtils.cleanUpSessionAbsolute(request); logger.debug("warning to learner: the activity is offline."); - //request.getSession().setAttribute(USER_EXCEPTION_CONTENT_RUNOFFLINE, new Boolean(true).toString()); - persistError(request,"label.learning.runOffline"); - return (mapping.findForward(ERROR_LIST)); + logger.debug("fwding to :" + RUN_OFFLINE); + return (mapping.findForward(RUN_OFFLINE)); } /* find out if the content is being modified at the moment. */ @@ -350,6 +349,7 @@ if (isDefineLater == true) { McUtils.cleanUpSessionAbsolute(request); + logger.debug("fwding to :" + DEFINE_LATER); return (mapping.findForward(DEFINE_LATER)); } @@ -408,7 +408,7 @@ logger.debug("highestAttemptOrder: " + highestAttemptOrder); //request.getSession().setAttribute(LEARNER_LAST_ATTEMPT_ORDER,new Integer(highestAttemptOrder).toString()); - int learnerBestMark=LearningUtil.getHighestMark(request, queUsrId); + int learnerBestMark=LearningUtil.getHighestMark(request, queUsrId, mcService); logger.debug("learnerBestMark: " + learnerBestMark); //request.getSession().setAttribute(LEARNER_BEST_MARK,new Integer(learnerBestMark).toString()); } Index: lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/McMonitoringStarterAction.java =================================================================== diff -u -rf5f65dc49c173cb6bef72ba8281762814c12b315 -r8a81c117f2bb66e5e4c7e5be0f2ca4bb8a1db7de --- lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/McMonitoringStarterAction.java (.../McMonitoringStarterAction.java) (revision f5f65dc49c173cb6bef72ba8281762814c12b315) +++ lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/McMonitoringStarterAction.java (.../McMonitoringStarterAction.java) (revision 8a81c117f2bb66e5e4c7e5be0f2ca4bb8a1db7de) @@ -392,13 +392,13 @@ int countMaxAttempt=1; logger.debug("countMaxAttempt: " + countMaxAttempt); - int topMark=LearningUtil.getTopMark(request); + int topMark=LearningUtil.getTopMark(request, mcService); logger.debug("topMark: " + topMark); - int lowestMark=LearningUtil.getLowestMark(request); + int lowestMark=LearningUtil.getLowestMark(request, mcService); logger.debug("lowestMark: " + lowestMark); - int averageMark=LearningUtil.getAverageMark(request); + int averageMark=LearningUtil.getAverageMark(request, mcService); logger.debug("averageMark: " + averageMark); request.getSession().setAttribute(COUNT_ALL_USERS, new Integer(countAllUsers).toString()); Index: lams_tool_lamc/web/WEB-INF/struts-config.xml =================================================================== diff -u -r9393c098e5dfd603e2d37347cd1e531a25aa424a -r8a81c117f2bb66e5e4c7e5be0f2ca4bb8a1db7de --- lams_tool_lamc/web/WEB-INF/struts-config.xml (.../struts-config.xml) (revision 9393c098e5dfd603e2d37347cd1e531a25aa424a) +++ lams_tool_lamc/web/WEB-INF/struts-config.xml (.../struts-config.xml) (revision 8a81c117f2bb66e5e4c7e5be0f2ca4bb8a1db7de) @@ -256,6 +256,12 @@ />