Index: lams_build/lib/lams/lams.jar =================================================================== diff -u -r5eca912646ea4d81e3cf72fa0fe8b0567aea3c3b -rb6b28d32fe5b2923cbb30a6c9b889c02e1ba29cf Binary files differ Index: lams_tool_assessment/src/java/org/lamsfoundation/lams/tool/assessment/dao/hibernate/AssessmentResultDAOHibernate.java =================================================================== diff -u -rfbaf103704f81cec6090f430a55f12349113eb47 -rb6b28d32fe5b2923cbb30a6c9b889c02e1ba29cf --- lams_tool_assessment/src/java/org/lamsfoundation/lams/tool/assessment/dao/hibernate/AssessmentResultDAOHibernate.java (.../AssessmentResultDAOHibernate.java) (revision fbaf103704f81cec6090f430a55f12349113eb47) +++ lams_tool_assessment/src/java/org/lamsfoundation/lams/tool/assessment/dao/hibernate/AssessmentResultDAOHibernate.java (.../AssessmentResultDAOHibernate.java) (revision b6b28d32fe5b2923cbb30a6c9b889c02e1ba29cf) @@ -227,15 +227,15 @@ @Override public List getLastFinishedAssessmentResultsBySession(Long sessionId) { - final String FIND_LAST_FINISHED_RESULTS_BY_SESSION_ID = "SELECT r, u FROM " + AssessmentResult.class.getName() + final String FIND_LAST_FINISHED_RESULTS_BY_SESSION_ID = "SELECT r, u.portraitUuid FROM " + AssessmentResult.class.getName() + " AS r, " + User.class.getName() + " as u WHERE r.sessionId=? AND (r.finishDate != null) AND r.latest=1 AND u.userId=r.user.userId"; return (List) doFind(FIND_LAST_FINISHED_RESULTS_BY_SESSION_ID, new Object[] { sessionId }); } @Override public List getLeadersLastFinishedAssessmentResults(Long contentId) { - final String FIND_LAST_FINISHED_RESULTS_BY_SESSION_ID = "SELECT r, u FROM " + AssessmentResult.class.getName() + final String FIND_LAST_FINISHED_RESULTS_BY_SESSION_ID = "SELECT r, u.portraitUuid FROM " + AssessmentResult.class.getName() + " AS r, " + User.class.getName() + " as u WHERE r.user=r.user.session.groupLeader AND r.assessment.contentId=? AND (r.finishDate != null) AND r.latest=1 AND u.userId=r.user.userId"; return (List) doFind(FIND_LAST_FINISHED_RESULTS_BY_SESSION_ID, new Object[] { contentId }); Index: lams_tool_lamc/conf/language/lams/ApplicationResources_en_AU.properties =================================================================== diff -u -r556d465d0c2dba467f2acef7d29c0f8261ecf84b -rb6b28d32fe5b2923cbb30a6c9b889c02e1ba29cf --- lams_tool_lamc/conf/language/lams/ApplicationResources_en_AU.properties (.../ApplicationResources_en_AU.properties) (revision 556d465d0c2dba467f2acef7d29c0f8261ecf84b) +++ lams_tool_lamc/conf/language/lams/ApplicationResources_en_AU.properties (.../ApplicationResources_en_AU.properties) (revision b6b28d32fe5b2923cbb30a6c9b889c02e1ba29cf) @@ -215,5 +215,8 @@ label.ok =OK message.monitoring.edit.activity.warning =Warning: if you edit and modify a question or change an answer that a learner has already answered, then the mark attained for the modified question will be deleted as it is assumed that the question has changed. If the option for retries is available, then the learner can submit an answer for this question again. +label.enable.confidence.levels =Enable confidence levels +label.what.is.your.confidence.level =How confident you are answering this question? +label.confidence =Confidence #======= End labels: Exported 208 labels for en AU ===== Index: lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/dao/IMcUsrAttemptDAO.java =================================================================== diff -u -r68a00ed36298398bdd7646b440a122d373bd75a1 -rb6b28d32fe5b2923cbb30a6c9b889c02e1ba29cf --- lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/dao/IMcUsrAttemptDAO.java (.../IMcUsrAttemptDAO.java) (revision 68a00ed36298398bdd7646b440a122d373bd75a1) +++ lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/dao/IMcUsrAttemptDAO.java (.../IMcUsrAttemptDAO.java) (revision b6b28d32fe5b2923cbb30a6c9b889c02e1ba29cf) @@ -79,6 +79,22 @@ * @return */ List getFinalizedUserAttempts(Long queUserUid); + + /** + * 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(). + * + * @param contentId + * @return + */ + List getLeadersFinalizedAttemptsByContentId(final Long contentId); /** * Get the highest attempt order for a user for a particular question Index: lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/dao/hibernate/McUsrAttemptDAO.java =================================================================== diff -u -r68a00ed36298398bdd7646b440a122d373bd75a1 -rb6b28d32fe5b2923cbb30a6c9b889c02e1ba29cf --- lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/dao/hibernate/McUsrAttemptDAO.java (.../McUsrAttemptDAO.java) (revision 68a00ed36298398bdd7646b440a122d373bd75a1) +++ lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/dao/hibernate/McUsrAttemptDAO.java (.../McUsrAttemptDAO.java) (revision b6b28d32fe5b2923cbb30a6c9b889c02e1ba29cf) @@ -30,6 +30,7 @@ import org.lamsfoundation.lams.tool.mc.dto.ToolOutputDTO; import org.lamsfoundation.lams.tool.mc.pojos.McQueUsr; import org.lamsfoundation.lams.tool.mc.pojos.McUsrAttempt; +import org.lamsfoundation.lams.usermanagement.User; import org.springframework.stereotype.Repository; /** @@ -80,8 +81,29 @@ return getSessionFactory().getCurrentSession().createQuery(LOAD_ALL_QUESTION_ATTEMPTS) .setLong("queUsrUid", userUid.longValue()).list(); } + + @Override + public List getFinalizedAttemptsBySessionId(final Long sessionId) { + final String LOAD_QUESTION_ATTEMPTS_BY_SESSION_ID = "SELECT attempt, u.portraitUuid FROM " + McUsrAttempt.class.getName() + + " AS attempt, " + User.class.getName() + " as u WHERE attempt.mcQueUsr.mcSession.mcSessionId=:sessionId" + + " AND attempt.mcQueUsr.responseFinalised = true AND u.userId=attempt.mcQueUsr.queUsrId"; + return getSessionFactory().getCurrentSession().createQuery(LOAD_QUESTION_ATTEMPTS_BY_SESSION_ID) + .setLong("sessionId", sessionId).list(); + } + @Override + public List getLeadersFinalizedAttemptsByContentId(final Long contentId) { + final String LOAD_QUESTION_ATTEMPTS_BY_SESSION_ID = "SELECT attempt, u.portraitUuid FROM " + McUsrAttempt.class.getName() + + " AS attempt, " + User.class.getName() + " as u WHERE attempt.mcQueUsr=attempt.mcQueUsr.mcSession.groupLeader " + + " AND attempt.mcQueContent.mcContent.mcContentId=:contentId " + + " AND attempt.mcQueUsr.responseFinalised = true AND u.userId=attempt.mcQueUsr.queUsrId"; + + return getSessionFactory().getCurrentSession().createQuery(LOAD_QUESTION_ATTEMPTS_BY_SESSION_ID) + .setLong("contentId", contentId).list(); + } + + @Override public int getUserTotalMark(final Long userUid) { List list = getSessionFactory().getCurrentSession().createQuery(FIND_USER_TOTAL_MARK) .setLong("userUid", userUid.longValue()).list(); Index: lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/service/IMcService.java =================================================================== diff -u -r68a00ed36298398bdd7646b440a122d373bd75a1 -rb6b28d32fe5b2923cbb30a6c9b889c02e1ba29cf --- lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/service/IMcService.java (.../IMcService.java) (revision 68a00ed36298398bdd7646b440a122d373bd75a1) +++ lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/service/IMcService.java (.../IMcService.java) (revision b6b28d32fe5b2923cbb30a6c9b889c02e1ba29cf) @@ -72,17 +72,14 @@ */ void copyAnswersFromLeader(McQueUsr user, McQueUsr leader); - void createMc(McContent mcContent) throws McApplicationException; + void createMc(McContent mcContent); - McContent getMcContent(Long toolContentId) throws McApplicationException; + McContent getMcContent(Long toolContentId); void setDefineLater(String strToolContentID, boolean value); - void updateQuestion(McQueContent mcQueContent) throws McApplicationException; + McQueContent getQuestionByDisplayOrder(final Long displayOrder, final Long mcContentUid); - McQueContent getQuestionByDisplayOrder(final Long displayOrder, final Long mcContentUid) - throws McApplicationException; - McQueUsr createMcUser(Long toolSessionId) throws McApplicationException; McQueUsr getMcUserBySession(final Long queUsrId, final Long mcSessionUid) throws McApplicationException; @@ -95,7 +92,7 @@ void removeMcQueContent(McQueContent mcQueContent) throws McApplicationException; - void saveOrUpdateMcQueContent(McQueContent mcQueContent) throws McApplicationException; + void saveOrUpdateMcQueContent(McQueContent mcQueContent); /** * persists the questions @@ -106,7 +103,7 @@ List refreshQuestionContent(final Long mcContentId) throws McApplicationException; - List getAllQuestionsSorted(final long mcContentId) throws McApplicationException; + List getAllQuestionsSorted(final long mcContentId); McQueContent getQuestionByUid(Long uid); @@ -119,7 +116,7 @@ String getLocalizedMessage(String key); - List getQuestionsByContentUid(final Long mcContentId) throws McApplicationException; + List getQuestionsByContentUid(final Long mcContentId); McSession getMcSessionById(Long mcSessionId) throws McApplicationException; @@ -129,13 +126,13 @@ List getOptionDtos(Long mcQueContentId) throws McApplicationException; - List getFinalizedUserAttempts(final McQueUsr user) throws McApplicationException; + List getFinalizedUserAttempts(final McQueUsr user); List findOptionsByQuestionUid(Long mcQueContentId) throws McApplicationException; void updateMcOptionsContent(McOptsContent mcOptsContent) throws McApplicationException; - McUsrAttempt getUserAttemptByQuestion(Long queUsrUid, Long mcQueContentId) throws McApplicationException; + McUsrAttempt getUserAttemptByQuestion(Long queUsrUid, Long mcQueContentId); List getLearnerMarksByContentId(Long toolContentId); Index: lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/service/McService.java =================================================================== diff -u -rfbaf103704f81cec6090f430a55f12349113eb47 -rb6b28d32fe5b2923cbb30a6c9b889c02e1ba29cf --- lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/service/McService.java (.../McService.java) (revision fbaf103704f81cec6090f430a55f12349113eb47) +++ lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/service/McService.java (.../McService.java) (revision b6b28d32fe5b2923cbb30a6c9b889c02e1ba29cf) @@ -104,6 +104,7 @@ import org.lamsfoundation.lams.usermanagement.dto.UserDTO; import org.lamsfoundation.lams.usermanagement.service.IUserManagementService; import org.lamsfoundation.lams.util.ExcelUtil; +import org.lamsfoundation.lams.util.HashUtil; import org.lamsfoundation.lams.util.JsonUtil; import org.lamsfoundation.lams.util.MessageService; import org.lamsfoundation.lams.util.NumberUtil; @@ -198,12 +199,13 @@ if (userAttempt == null) { userAttempt = new McUsrAttempt(leaderAttempt.getAttemptTime(), question, user, leaderAttempt.getMcOptionsContent(), leaderAttempt.getMark(), leaderAttempt.isPassed(), - leaderAttempt.isAttemptCorrect()); + leaderAttempt.isAttemptCorrect(), leaderAttempt.getConfidenceLevel()); mcUsrAttemptDAO.saveMcUsrAttempt(userAttempt); - // if it's been changed by the leader + // if it's been changed by the leader } else if (leaderAttempt.getAttemptTime().compareTo(userAttempt.getAttemptTime()) != 0) { userAttempt.setMcOptionsContent(leaderAttempt.getMcOptionsContent()); + userAttempt.setConfidenceLevel(leaderAttempt.getConfidenceLevel()); userAttempt.setAttemptTime(leaderAttempt.getAttemptTime()); this.updateMcUsrAttempt(userAttempt); } @@ -216,21 +218,12 @@ @Override public void createMc(McContent mcContent) throws McApplicationException { - try { - mcContentDAO.saveMcContent(mcContent); - } catch (DataAccessException e) { - throw new McApplicationException("Exception occured when lams is creating mc content: " + e.getMessage(), - e); - } + mcContentDAO.saveMcContent(mcContent); } @Override public McContent getMcContent(Long toolContentId) throws McApplicationException { - try { - return mcContentDAO.findMcContentById(toolContentId); - } catch (DataAccessException e) { - throw new McApplicationException("Exception occured when lams is loading mc content: " + e.getMessage(), e); - } + return mcContentDAO.findMcContentById(toolContentId); } @Override @@ -244,48 +237,25 @@ } @Override - public void updateQuestion(McQueContent mcQueContent) throws McApplicationException { - try { - mcQueContentDAO.updateMcQueContent(mcQueContent); - } catch (DataAccessException e) { - throw new McApplicationException( - "Exception occured when lams is updating mc que content: " + e.getMessage(), e); - } - + public McQueContent getQuestionByDisplayOrder(final Long displayOrder, final Long mcContentUid) { + return mcQueContentDAO.getQuestionContentByDisplayOrder(displayOrder, mcContentUid); } @Override - public McQueContent getQuestionByDisplayOrder(final Long displayOrder, final Long mcContentUid) - throws McApplicationException { - try { - return mcQueContentDAO.getQuestionContentByDisplayOrder(displayOrder, mcContentUid); - } catch (DataAccessException e) { - throw new McApplicationException( - "Exception occured when lams is getting mc que content by display order: " + e.getMessage(), e); - } + public List getAllQuestionsSorted(final long mcContentId) { + return mcQueContentDAO.getAllQuestionEntriesSorted(mcContentId); } @Override - public List getAllQuestionsSorted(final long mcContentId) throws McApplicationException { - try { - return mcQueContentDAO.getAllQuestionEntriesSorted(mcContentId); - } catch (DataAccessException e) { - throw new McApplicationException( - "Exception occured when lams is getting all question entries: " + e.getMessage(), e); - } + public void saveOrUpdateMcQueContent(McQueContent mcQueContent) { + //update questions' hash + String newHash = mcQueContent.getQuestion() == null ? null : HashUtil.sha1(mcQueContent.getQuestion()); + mcQueContent.setQuestionHash(newHash); + + mcQueContentDAO.saveOrUpdateMcQueContent(mcQueContent); } @Override - public void saveOrUpdateMcQueContent(McQueContent mcQueContent) throws McApplicationException { - try { - mcQueContentDAO.saveOrUpdateMcQueContent(mcQueContent); - } catch (DataAccessException e) { - throw new McApplicationException( - "Exception occured when lams is updating mc que content: " + e.getMessage(), e); - } - } - - @Override public McContent createQuestions(List questionDTOs, McContent content) { int displayOrder = 0; @@ -309,8 +279,8 @@ // in case question doesn't exist if (question == null) { - question = new McQueContent(currentQuestionText, new Integer(displayOrder), new Integer(currentMark), - currentFeedback, content, null, null); + question = new McQueContent(currentQuestionText, null, new Integer(displayOrder), + new Integer(currentMark), currentFeedback, content, null, null); // adding a new question to content content.getMcQueContents().add(question); @@ -356,7 +326,7 @@ question.setMcOptionsContents(newOptions); // updating the existing question content - updateQuestion(question); + saveOrUpdateMcQueContent(question); } return content; @@ -461,6 +431,7 @@ Integer mark = answerDto.getMark(); boolean passed = user.isMarkPassed(mark); boolean isAttemptCorrect = answerDto.isAttemptCorrect(); + int confidenceLevel = answerDto.getConfidenceLevel(); McUsrAttempt userAttempt = this.getUserAttemptByQuestion(user.getUid(), questionUid); if (userAttempt != null) { @@ -478,12 +449,13 @@ userAttempt.setMark(mark); userAttempt.setPassed(passed); userAttempt.setAttemptCorrect(isAttemptCorrect); + userAttempt.setConfidenceLevel(confidenceLevel); } } else { // create new userAttempt userAttempt = new McUsrAttempt(attemptTime, question, user, answerOption, mark, passed, - isAttemptCorrect); + isAttemptCorrect, confidenceLevel); } mcUsrAttemptDAO.saveMcUsrAttempt(userAttempt); @@ -537,9 +509,10 @@ McUsrAttempt dbAttempt = this.getUserAttemptByQuestion(user.getUid(), questionUid); if (dbAttempt != null) { - Long selectedOptionUid = dbAttempt.getMcOptionsContent().getUid(); + answerDto.setConfidenceLevel(dbAttempt.getConfidenceLevel()); // mark selected option as selected + Long selectedOptionUid = dbAttempt.getMcOptionsContent().getUid(); for (McOptsContent option : answerDto.getOptions()) { if (selectedOptionUid.equals(option.getUid())) { option.setSelected(true); @@ -655,26 +628,12 @@ @Override public List getFinalizedUserAttempts(final McQueUsr user) throws McApplicationException { - try { - return mcUsrAttemptDAO.getFinalizedUserAttempts(user.getUid()); - } catch (DataAccessException e) { - throw new McApplicationException( - "Exception occured when lams is getting the learner's attempts by user id and que content id and attempt order: " - + e.getMessage(), - e); - } + return mcUsrAttemptDAO.getFinalizedUserAttempts(user.getUid()); } @Override public McUsrAttempt getUserAttemptByQuestion(Long queUsrUid, Long mcQueContentId) throws McApplicationException { - try { - return mcUsrAttemptDAO.getUserAttemptByQuestion(queUsrUid, mcQueContentId); - } catch (DataAccessException e) { - throw new McApplicationException( - "Exception occured when lams is getting the learner's attempts by user id and que content id and attempt order: " - + e.getMessage(), - e); - } + return mcUsrAttemptDAO.getUserAttemptByQuestion(queUsrUid, mcQueContentId); } @Override @@ -684,12 +643,7 @@ @Override public List getQuestionsByContentUid(final Long contentUid) throws McApplicationException { - try { - return mcQueContentDAO.getQuestionsByContentUid(contentUid.longValue()); - } catch (DataAccessException e) { - throw new McApplicationException( - "Exception occured when lams is getting by uid mc question content: " + e.getMessage(), e); - } + return mcQueContentDAO.getQuestionsByContentUid(contentUid.longValue()); } @Override @@ -1566,10 +1520,42 @@ public List getToolOutputs(String name, Long toolContentId) { return mcOutputFactory.getToolOutputs(name, this, toolContentId); } - + @Override public List getConfidenceLevels(Long toolSessionId) { - return null; + List confidenceLevelDtos = new ArrayList(); + if (toolSessionId == null) { + return confidenceLevelDtos; + } + + McContent content = getMcSessionById(toolSessionId).getMcContent(); + + //in case McContent is leader aware return all leaders confidences, otherwise - confidences from the users from the same group as requestor + List userAttemptsAndPortraits = content.isUseSelectLeaderToolOuput() + ? mcUsrAttemptDAO.getLeadersFinalizedAttemptsByContentId(content.getMcContentId()) + : mcUsrAttemptDAO.getFinalizedAttemptsBySessionId(toolSessionId); + + for (Object[] userAttemptAndPortraitIter : userAttemptsAndPortraits) { + McUsrAttempt userAttempt = (McUsrAttempt) userAttemptAndPortraitIter[0]; + Long portraitUuid = userAttemptAndPortraitIter[1] == null ? null + : ((Number) userAttemptAndPortraitIter[1]).longValue(); + Long userId = userAttempt.getQueUsrId(); + + //fill in question's and user answer's hashes + McQueContent question = userAttempt.getMcQueContent(); + String answer = userAttempt.getMcOptionsContent().getMcQueOptionText(); + + ConfidenceLevelDTO confidenceLevelDto = new ConfidenceLevelDTO(); + confidenceLevelDto.setUserId(userId.intValue()); + confidenceLevelDto.setPortraitUuid(portraitUuid); + confidenceLevelDto.setLevel(userAttempt.getConfidenceLevel()); + confidenceLevelDto.setQuestion(question.getQuestion()); + confidenceLevelDto.setAnswer(answer); + + confidenceLevelDtos.add(confidenceLevelDto); + } + + return confidenceLevelDtos; } @Override @@ -1941,6 +1927,7 @@ mcq.setShowMarks(JsonUtil.opt(toolContentJSON, "showMarks", Boolean.FALSE)); mcq.setPrefixAnswersWithLetters(JsonUtil.opt(toolContentJSON, "prefixAnswersWithLetters", Boolean.TRUE)); mcq.setPassMark(JsonUtil.opt(toolContentJSON, "passMark", 0)); + mcq.setEnableConfidenceLevels(JsonUtil.opt(toolContentJSON, "enableConfidenceLevels", Boolean.FALSE)); // submissionDeadline is set in monitoring createMc(mcq); @@ -1949,8 +1936,9 @@ JSONArray questions = toolContentJSON.getJSONArray(RestTags.QUESTIONS); for (int i = 0; i < questions.length(); i++) { JSONObject questionData = (JSONObject) questions.get(i); - McQueContent question = new McQueContent(questionData.getString(RestTags.QUESTION_TEXT), - questionData.getInt(RestTags.DISPLAY_ORDER), 1, "", mcq, null, new HashSet()); + String questionText = questionData.getString(RestTags.QUESTION_TEXT); + McQueContent question = new McQueContent(questionText, null, questionData.getInt(RestTags.DISPLAY_ORDER), 1, + "", mcq, null, new HashSet()); JSONArray optionsData = questionData.getJSONArray(RestTags.ANSWERS); for (int j = 0; j < optionsData.length(); j++) { Index: lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/action/McMonitoringAction.java =================================================================== diff -u -r68a00ed36298398bdd7646b440a122d373bd75a1 -rb6b28d32fe5b2923cbb30a6c9b889c02e1ba29cf --- lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/action/McMonitoringAction.java (.../McMonitoringAction.java) (revision 68a00ed36298398bdd7646b440a122d373bd75a1) +++ lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/action/McMonitoringAction.java (.../McMonitoringAction.java) (revision b6b28d32fe5b2923cbb30a6c9b889c02e1ba29cf) @@ -260,6 +260,7 @@ } } + request.setAttribute(McAppConstants.ATTR_CONTENT, user.getMcSession().getMcContent()); request.setAttribute(McAppConstants.USER_ATTEMPTS, userAttempts); request.setAttribute(McAppConstants.TOOL_SESSION_ID, user.getMcSession().getMcSessionId()); return (userAttempts == null || userAttempts.isEmpty()) ? null