Index: lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/dao/IMcUsrAttemptDAO.java =================================================================== diff -u -r394f403c289f0fd7808c228840bead5c4e7d5d32 -re7cbd533f52ac2a431c09e7272b1f31769258022 --- lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/dao/IMcUsrAttemptDAO.java (.../IMcUsrAttemptDAO.java) (revision 394f403c289f0fd7808c228840bead5c4e7d5d32) +++ lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/dao/IMcUsrAttemptDAO.java (.../IMcUsrAttemptDAO.java) (revision e7cbd533f52ac2a431c09e7272b1f31769258022) @@ -79,18 +79,20 @@ * @return */ List getFinalizedUserAttempts(Long queUserUid); - + /** - * Returns attempts and portraitUiids left by all users in the specified session. It's used only by ToolSessionManager.getConfidenceLevels(). - * + * Returns attempts and portraitUiids left by all users in the specified session. It's used only by + * ToolSessionManager.getConfidenceLevels(). + * * @param sessionId * @return */ List getFinalizedAttemptsBySessionId(final Long sessionId); - + /** - * Returns attempts and portraitUiids left by all leaders in the specified activity. It's used only by ToolSessionManager.getConfidenceLevels(). - * + * Returns attempts and portraitUiids left by all leaders in the specified activity. It's used only by + * ToolSessionManager.getConfidenceLevels(). + * * @param contentId * @return */ @@ -105,15 +107,15 @@ * Get the highest attempt order for a all users in a session for a particular questionDescription */ List getUserAttemptsByQuestionSession(final Long sessionUid, final Long mcQueContentId); - + /** * Count how many attempts done to this option * * @param optionUid * @return */ - int getAttemptsCountPerOption(Long optionUid); - + int getAttemptsCountPerOption(Long optionUid, Long mcQueContentId); + /** * Checks whether anyone has attempted this assessment. */ @@ -128,10 +130,10 @@ int getUserTotalMark(final Long userUid); McUsrAttempt getUserAttemptByUid(Long uid); - + /** * Returns all existing total marks for users belonging to tool content. - * + * * @param toolContentId * @return */ Index: lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/dao/hibernate/McUsrAttemptDAO.java =================================================================== diff -u -r67db3e1b2ada0d59ff98c807a54282783797c5e6 -re7cbd533f52ac2a431c09e7272b1f31769258022 --- lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/dao/hibernate/McUsrAttemptDAO.java (.../McUsrAttemptDAO.java) (revision 67db3e1b2ada0d59ff98c807a54282783797c5e6) +++ lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/dao/hibernate/McUsrAttemptDAO.java (.../McUsrAttemptDAO.java) (revision e7cbd533f52ac2a431c09e7272b1f31769258022) @@ -61,7 +61,7 @@ + " AND attempt.mcQueUsr.responseFinalised = true order by attempt.qbToolQuestion.uid, attempt.qbOption.uid"; private static final String FIND_ATTEMPTS_COUNT_BY_OPTION = "select count(*) from " + McUsrAttempt.class.getName() - + " as attempt where attempt.qbOption.uid=? AND attempt.mcQueUsr.responseFinalised = true"; + + " as attempt where attempt.qbOption.uid=? AND attempt.qbToolQuestion.uid = ? AND attempt.mcQueUsr.responseFinalised = true"; private static final String FIND_USER_TOTAL_MARK = "select COALESCE(SUM(attempt.mark),0) from " + McUsrAttempt.class.getName() @@ -162,8 +162,8 @@ } @Override - public int getAttemptsCountPerOption(Long optionUid) { - List list = doFind(FIND_ATTEMPTS_COUNT_BY_OPTION, new Object[] { optionUid }); + public int getAttemptsCountPerOption(Long optionUid, Long mcQueContentId) { + List list = doFind(FIND_ATTEMPTS_COUNT_BY_OPTION, new Object[] { optionUid, mcQueContentId }); if (list == null || list.size() == 0) { return 0; } @@ -179,15 +179,15 @@ q.setParameter("mcContentUid", mcContentUid); return q.uniqueResult(); } - + @Override public List getLearnerMarksByContentId(Long toolContentId) { final String FIND_MARKS_FOR_CONTENT_ID = "SELECT user.queUsrId, user.lastAttemptTotalMark FROM " + McQueUsr.class.getName() + " user WHERE user.mcSession.mcContent.mcContentId = ? AND user.responseFinalised = true"; - List list = (List) doFind(FIND_MARKS_FOR_CONTENT_ID, new Object[] { toolContentId }); + List list = doFind(FIND_MARKS_FOR_CONTENT_ID, new Object[] { toolContentId }); List toolOutputDtos = new ArrayList<>(); if (list != null && list.size() > 0) { Index: lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/service/IMcService.java =================================================================== diff -u -r394f403c289f0fd7808c228840bead5c4e7d5d32 -re7cbd533f52ac2a431c09e7272b1f31769258022 --- lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/service/IMcService.java (.../IMcService.java) (revision 394f403c289f0fd7808c228840bead5c4e7d5d32) +++ lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/service/IMcService.java (.../IMcService.java) (revision e7cbd533f52ac2a431c09e7272b1f31769258022) @@ -95,7 +95,7 @@ * @param optionUid * @return */ - int getAttemptsCountPerOption(Long optionUid); + int getAttemptsCountPerOption(Long optionUid, Long mcQueContentUid); /** * Checks whether anyone has attempted this assessment. @@ -183,7 +183,8 @@ /** * Get the definitions for possible output for an activity, based on the toolContentId. These may be definitions * that are always available for the tool (e.g. number of marks for Multiple Choice) or a custom definition created - * for a particular activity such as the answer to the third questionDescription contains the word Koala and hence the need for + * for a particular activity such as the answer to the third questionDescription contains the word Koala and hence + * the need for * the toolContentId * * @return SortedMap of ToolOutputDefinitions with the key being the name of each definition Index: lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/service/McService.java =================================================================== diff -u -r5129d828c41c0731ee7889271cffde6421e2146c -re7cbd533f52ac2a431c09e7272b1f31769258022 --- lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/service/McService.java (.../McService.java) (revision 5129d828c41c0731ee7889271cffde6421e2146c) +++ lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/service/McService.java (.../McService.java) (revision e7cbd533f52ac2a431c09e7272b1f31769258022) @@ -533,8 +533,8 @@ } @Override - public int getAttemptsCountPerOption(Long optionUid) { - return mcUsrAttemptDAO.getAttemptsCountPerOption(optionUid); + public int getAttemptsCountPerOption(Long optionUid, Long mcQueContentUid) { + return mcUsrAttemptDAO.getAttemptsCountPerOption(optionUid, mcQueContentUid); } @Override @@ -1048,7 +1048,7 @@ int totalPercentage = 0; for (QbOption option : question.getQbQuestion().getQbOptions()) { - int optionAttemptCount = mcUsrAttemptDAO.getAttemptsCountPerOption(option.getUid()); + int optionAttemptCount = getAttemptsCountPerOption(option.getUid(), question.getUid()); cell = row.createCell(count++); int percentage = (optionAttemptCount * 100) / totalNumberOfUsers; cell.setCellValue(percentage + "%"); Index: lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/controller/TblMonitoringController.java =================================================================== diff -u -r9ca39edffd0c57ba7deeb38316f5a0f7b0d8fe44 -re7cbd533f52ac2a431c09e7272b1f31769258022 --- lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/controller/TblMonitoringController.java (.../TblMonitoringController.java) (revision 9ca39edffd0c57ba7deeb38316f5a0f7b0d8fe44) +++ lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/controller/TblMonitoringController.java (.../TblMonitoringController.java) (revision e7cbd533f52ac2a431c09e7272b1f31769258022) @@ -80,7 +80,7 @@ // build candidate dtos List optionDtos = new LinkedList<>(); for (QbOption option : question.getQbQuestion().getQbOptions()) { - int optionAttemptCount = mcService.getAttemptsCountPerOption(option.getUid()); + int optionAttemptCount = mcService.getAttemptsCountPerOption(option.getUid(), question.getUid()); float percentage = (float) (optionAttemptCount * 100) / totalNumberOfUsers;