Search in sources :

Example 1 with PersistentAssessableCourseNode

use of org.olat.course.nodes.PersistentAssessableCourseNode in project OpenOLAT by OpenOLAT.

the class IQRunController method exposeUserTestDataToVC.

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("docs", 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);
            boolean resultsVisible = assessmentEntry.getUserVisibility() == null || assessmentEntry.getUserVisibility().booleanValue();
            myContent.contextPut("resultsVisible", resultsVisible);
            myContent.contextPut("score", AssessmentHelper.getRoundedScore(assessmentEntry.getScore()));
            myContent.contextPut("hasPassedValue", (assessmentEntry.getPassed() == null ? Boolean.FALSE : Boolean.TRUE));
            myContent.contextPut("passed", assessmentEntry.getPassed());
            if (resultsVisible) {
                if (acn.hasCommentConfigured()) {
                    StringBuilder comment = Formatter.stripTabsAndReturns(assessmentEntry.getComment());
                    myContent.contextPut("comment", StringHelper.xssScan(comment));
                    myContent.contextPut("in-comment", isPanelOpen(ureq, "comment", true));
                }
                if (acn.hasIndividualAsssessmentDocuments()) {
                    List<File> docs = acn.getIndividualAssessmentDocuments(userCourseEnv);
                    String mapperUri = registerCacheableMapper(ureq, null, new DocumentsMapper(docs));
                    myContent.contextPut("docsMapperUri", mapperUri);
                    myContent.contextPut("docs", docs);
                    myContent.contextPut("in-assessmentDocuments", isPanelOpen(ureq, "assessmentDocuments", true));
                }
            }
            myContent.contextPut("attempts", assessmentEntry.getAttempts() == null ? 0 : assessmentEntry.getAttempts());
        }
    }
    UserNodeAuditManager am = userCourseEnv.getCourseEnvironment().getAuditManager();
    myContent.contextPut("log", am.getUserNodeLog(courseNode, identity));
    exposeResults(ureq);
}
Also used : UserNodeAuditManager(org.olat.course.auditing.UserNodeAuditManager) PersistentAssessableCourseNode(org.olat.course.nodes.PersistentAssessableCourseNode) Identity(org.olat.core.id.Identity) DocumentsMapper(org.olat.course.nodes.ms.DocumentsMapper) AssessmentEntry(org.olat.modules.assessment.AssessmentEntry) File(java.io.File)

Example 2 with PersistentAssessableCourseNode

use of org.olat.course.nodes.PersistentAssessableCourseNode in project openolat by klemens.

the class IQRunController method exposeUserTestDataToVC.

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("docs", 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);
            boolean resultsVisible = assessmentEntry.getUserVisibility() == null || assessmentEntry.getUserVisibility().booleanValue();
            myContent.contextPut("resultsVisible", resultsVisible);
            myContent.contextPut("score", AssessmentHelper.getRoundedScore(assessmentEntry.getScore()));
            myContent.contextPut("hasPassedValue", (assessmentEntry.getPassed() == null ? Boolean.FALSE : Boolean.TRUE));
            myContent.contextPut("passed", assessmentEntry.getPassed());
            if (resultsVisible) {
                if (acn.hasCommentConfigured()) {
                    StringBuilder comment = Formatter.stripTabsAndReturns(assessmentEntry.getComment());
                    myContent.contextPut("comment", StringHelper.xssScan(comment));
                    myContent.contextPut("in-comment", isPanelOpen(ureq, "comment", true));
                }
                if (acn.hasIndividualAsssessmentDocuments()) {
                    List<File> docs = acn.getIndividualAssessmentDocuments(userCourseEnv);
                    String mapperUri = registerCacheableMapper(ureq, null, new DocumentsMapper(docs));
                    myContent.contextPut("docsMapperUri", mapperUri);
                    myContent.contextPut("docs", docs);
                    myContent.contextPut("in-assessmentDocuments", isPanelOpen(ureq, "assessmentDocuments", true));
                }
            }
            myContent.contextPut("attempts", assessmentEntry.getAttempts() == null ? 0 : assessmentEntry.getAttempts());
        }
    }
    UserNodeAuditManager am = userCourseEnv.getCourseEnvironment().getAuditManager();
    myContent.contextPut("log", am.getUserNodeLog(courseNode, identity));
    exposeResults(ureq);
}
Also used : UserNodeAuditManager(org.olat.course.auditing.UserNodeAuditManager) PersistentAssessableCourseNode(org.olat.course.nodes.PersistentAssessableCourseNode) Identity(org.olat.core.id.Identity) DocumentsMapper(org.olat.course.nodes.ms.DocumentsMapper) AssessmentEntry(org.olat.modules.assessment.AssessmentEntry) File(java.io.File)

Aggregations

File (java.io.File)2 Identity (org.olat.core.id.Identity)2 UserNodeAuditManager (org.olat.course.auditing.UserNodeAuditManager)2 PersistentAssessableCourseNode (org.olat.course.nodes.PersistentAssessableCourseNode)2 DocumentsMapper (org.olat.course.nodes.ms.DocumentsMapper)2 AssessmentEntry (org.olat.modules.assessment.AssessmentEntry)2