private void exposeUserTestDataToVC(UserRequest ureq) { // config : show score info Object enableScoreInfoObject = modConfig.get(IQEditController.CONFIG_KEY_ENABLESCOREINFO); if (enableScoreInfoObject != null) { myContent.contextPut("enableScoreInfo", enableScoreInfoObject); } else { myContent.contextPut("enableScoreInfo", Boolean.TRUE); } // configuration data myContent.contextPut("attemptsConfig", modConfig.get(IQEditController.CONFIG_KEY_ATTEMPTS)); // user data Identity identity = userCourseEnv.getIdentityEnvironment().getIdentity(); if (courseNode instanceof PersistentAssessableCourseNode) { PersistentAssessableCourseNode acn = (PersistentAssessableCourseNode) courseNode; AssessmentEntry assessmentEntry = acn.getUserAssessmentEntry(userCourseEnv); if (assessmentEntry == null) { myContent.contextPut("blockAfterSuccess", Boolean.FALSE); myContent.contextPut("score", null); myContent.contextPut("hasPassedValue", Boolean.FALSE); myContent.contextPut("passed", Boolean.FALSE); myContent.contextPut("comment", null); myContent.contextPut("attempts", 0); } else { // block if test passed (and config set to check it) Boolean blockAfterSuccess = modConfig.getBooleanEntry(IQEditController.CONFIG_KEY_BLOCK_AFTER_SUCCESS); Boolean blocked = Boolean.FALSE; if (blockAfterSuccess != null && blockAfterSuccess.booleanValue()) { Boolean passed = assessmentEntry.getPassed(); if (passed != null && passed.booleanValue()) { blocked = Boolean.TRUE; } } myContent.contextPut("blockAfterSuccess", blocked); myContent.contextPut("score", AssessmentHelper.getRoundedScore(assessmentEntry.getScore())); myContent.contextPut( "hasPassedValue", (assessmentEntry.getPassed() == null ? Boolean.FALSE : Boolean.TRUE)); myContent.contextPut("passed", assessmentEntry.getPassed()); StringBuilder comment = Formatter.stripTabsAndReturns(assessmentEntry.getComment()); myContent.contextPut("comment", StringHelper.xssScan(comment)); myContent.contextPut("attempts", assessmentEntry.getAttempts()); } } UserNodeAuditManager am = userCourseEnv.getCourseEnvironment().getAuditManager(); myContent.contextPut("log", am.getUserNodeLog(courseNode, identity)); exposeResults(ureq); }
/** @return True if all results are the same */ private ModelInfos loadModel() { // load participants, load datas ICourse course = CourseFactory.loadCourse(courseEnv.getCourseResourceableId()); List<Identity> identities = businessGroupService.getMembers(assessedGroup, GroupRoles.participant.name()); Map<Identity, AssessmentEntry> identityToEntryMap = new HashMap<>(); List<AssessmentEntry> entries = course .getCourseEnvironment() .getAssessmentManager() .getAssessmentEntries(assessedGroup, gtaNode); for (AssessmentEntry entry : entries) { identityToEntryMap.put(entry.getIdentity(), entry); } int count = 0; boolean same = true; StringBuilder duplicateWarning = new StringBuilder(); Float scoreRef = null; Boolean passedRef = null; String commentRef = null; List<AssessmentRow> rows = new ArrayList<>(identities.size()); for (Identity identity : identities) { AssessmentEntry entry = identityToEntryMap.get(identity); ScoreEvaluation scoreEval = null; if (withScore || withPassed) { scoreEval = gtaNode.getUserScoreEvaluation(entry); if (scoreEval == null) { scoreEval = ScoreEvaluation.EMPTY_EVALUATION; } } String comment = null; if (withComment && entry != null) { comment = entry.getComment(); } boolean duplicate = duplicateMemberKeys.contains(identity.getKey()); if (duplicate) { if (duplicateWarning.length() > 0) duplicateWarning.append(", "); duplicateWarning.append(StringHelper.escapeHtml(userManager.getUserDisplayName(identity))); } AssessmentRow row = new AssessmentRow(identity, duplicate); rows.add(row); if (withScore) { Float score = scoreEval.getScore(); String pointVal = AssessmentHelper.getRoundedScore(score); TextElement pointEl = uifactory.addTextElement("point" + count, null, 5, pointVal, flc); pointEl.setDisplaySize(5); row.setScoreEl(pointEl); if (count == 0) { scoreRef = score; } else if (!same(scoreRef, score)) { same = false; } } if (withPassed && cutValue == null) { Boolean passed = scoreEval.getPassed(); MultipleSelectionElement passedEl = uifactory.addCheckboxesHorizontal("check" + count, null, flc, onKeys, onValues); if (passed != null && passed.booleanValue()) { passedEl.select(onKeys[0], passed.booleanValue()); } row.setPassedEl(passedEl); if (count == 0) { passedRef = passed; } else if (!same(passedRef, passed)) { same = false; } } if (withComment) { FormLink commentLink = uifactory.addFormLink( "comment-" + CodeHelper.getRAMUniqueID(), "comment", "comment", null, flc, Link.LINK); if (StringHelper.containsNonWhitespace(comment)) { commentLink.setIconLeftCSS("o_icon o_icon_comments"); } else { commentLink.setIconLeftCSS("o_icon o_icon_comments_none"); } commentLink.setUserObject(row); row.setComment(comment); row.setCommentEditLink(commentLink); if (count == 0) { commentRef = comment; } else if (!same(commentRef, comment)) { same = false; } } count++; } model.setObjects(rows); table.reset(); return new ModelInfos(same, scoreRef, passedRef, commentRef, duplicateWarning.toString()); }