private void exposeUserTestDataToVC(final UserRequest ureq) { // config : show score info final 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 if (!(courseNode instanceof AssessableCourseNode)) { throw new AssertException( "exposeUserTestDataToVC can only be called for test nodes, not for selftest or questionnaire"); } final AssessableCourseNode acn = (AssessableCourseNode) courseNode; // assessment nodes are assesable final ScoreEvaluation scoreEval = acn.getUserScoreEvaluation(userCourseEnv); final Identity identity = userCourseEnv.getIdentityEnvironment().getIdentity(); myContent.contextPut("score", AssessmentHelper.getRoundedScore(scoreEval.getScore())); myContent.contextPut( "hasPassedValue", (scoreEval.getPassed() == null ? Boolean.FALSE : Boolean.TRUE)); myContent.contextPut("passed", scoreEval.getPassed()); myContent.contextPut("comment", acn.getUserUserComment(userCourseEnv)); myContent.contextPut("attempts", acn.getUserAttempts(userCourseEnv)); final UserNodeAuditManager am = userCourseEnv.getCourseEnvironment().getAuditManager(); myContent.contextPut("log", am.getUserNodeLog(courseNode, identity)); exposeResults(ureq); }
@Override protected void event(final UserRequest urequest, final Controller source, final Event event) { if (source == displayController) { if (event instanceof IQSubmittedEvent) { final IQSubmittedEvent se = (IQSubmittedEvent) event; final AssessmentManager am = userCourseEnv.getCourseEnvironment().getAssessmentManager(); // Save results in case of test if (type.equals(AssessmentInstance.QMD_ENTRY_TYPE_ASSESS)) { // update scoring overview for the user in the current course final Float score = new Float(se.getScore()); final Boolean passed = new Boolean(se.isPassed()); final ScoreEvaluation sceval = new ScoreEvaluation(score, passed, new Long(se.getAssessmentID())); final AssessableCourseNode acn = (AssessableCourseNode) courseNode; // assessment nodes are assesable final boolean incrementUserAttempts = true; acn.updateUserScoreEvaluation( sceval, userCourseEnv, urequest.getIdentity(), incrementUserAttempts); // userCourseEnv.getScoreAccounting().scoreInfoChanged(acn, sceval); exposeUserTestDataToVC(urequest); // Mark publisher for notifications final Long courseId = userCourseEnv.getCourseEnvironment().getCourseResourceableId(); notificationHandler.markPublisherNews(urequest.getIdentity(), courseId); if (!assessmentStopped) { assessmentStopped = true; final AssessmentEvent assessmentStoppedEvent = new AssessmentEvent(AssessmentEvent.TYPE.STOPPED, userSession); singleUserEventCenter.deregisterFor(this, assessmentInstanceOres); singleUserEventCenter.fireEventToListenersOf( assessmentStoppedEvent, assessmentEventOres); } } // Save results in case of questionnaire else if (type.equals(AssessmentInstance.QMD_ENTRY_TYPE_SURVEY)) { // save number of attempts // although this is not an assessable node we still use the assessment // manager since this one uses caching am.incrementNodeAttempts(courseNode, urequest.getIdentity(), userCourseEnv); exposeUserQuestionnaireDataToVC(); getWindowControl().pop(); } // Don't save results in case of self-test // but do safe attempts ! else if (type.equals(AssessmentInstance.QMD_ENTRY_TYPE_SELF)) { am.incrementNodeAttempts(courseNode, urequest.getIdentity(), userCourseEnv); } } else if (event.equals(Event.DONE_EVENT)) { getWindowControl().pop(); if (type.equals(AssessmentInstance.QMD_ENTRY_TYPE_ASSESS) && !assessmentStopped) { assessmentStopped = true; final AssessmentEvent assessmentStoppedEvent = new AssessmentEvent(AssessmentEvent.TYPE.STOPPED, userSession); singleUserEventCenter.deregisterFor(this, assessmentInstanceOres); singleUserEventCenter.fireEventToListenersOf(assessmentStoppedEvent, assessmentEventOres); } fireEvent(urequest, Event.DONE_EVENT); } } }