Search in sources :

Example 11 with ScoreEvaluation

use of org.olat.ims.qti21.model.xml.interactions.SimpleChoiceAssessmentItemBuilder.ScoreEvaluation in project OpenOLAT by OpenOLAT.

the class QTI21AssessmentRunController method initAssessment.

private void initAssessment(UserRequest ureq) {
    // config : show score info
    boolean enableScoreInfo = config.getBooleanSafe(IQEditController.CONFIG_KEY_ENABLESCOREINFO);
    mainVC.contextPut("enableScoreInfo", Boolean.valueOf(enableScoreInfo));
    // configuration data
    int maxAttempts = deliveryOptions.getMaxAttempts();
    if (maxAttempts > 0) {
        mainVC.contextPut("attemptsConfig", Integer.valueOf(maxAttempts));
    } else {
        mainVC.contextPut("attemptsConfig", Boolean.FALSE);
    }
    // configure date period
    mainVC.contextPut("blockDate", Boolean.valueOf(blockedBasedOnDate()));
    // time limit
    Long timeLimit = getAssessmentTestMaxTimeLimit();
    if (timeLimit != null) {
        mainVC.contextPut("timeLimit", Formatter.formatHourAndSeconds(timeLimit.longValue() * 1000l));
    }
    if (courseNode instanceof AssessableCourseNode) {
        AssessableCourseNode assessableCourseNode = (AssessableCourseNode) courseNode;
        if (assessableCourseNode.hasScoreConfigured() || userCourseEnv.isCoach()) {
            HighScoreRunController highScoreCtr = new HighScoreRunController(ureq, getWindowControl(), userCourseEnv, courseNode);
            if (highScoreCtr.isViewHighscore()) {
                Component highScoreComponent = highScoreCtr.getInitialComponent();
                mainVC.put("highScore", highScoreComponent);
            }
        }
    }
    // user data
    if (courseNode instanceof SelfAssessableCourseNode) {
        SelfAssessableCourseNode acn = (SelfAssessableCourseNode) courseNode;
        ScoreEvaluation scoreEval = acn.getUserScoreEvaluation(userCourseEnv);
        Integer attempts = acn.getUserAttempts(userCourseEnv);
        if (scoreEval != null) {
            mainVC.contextPut("resultsVisible", Boolean.TRUE);
            mainVC.contextPut("hasResults", Boolean.TRUE);
            mainVC.contextPut("score", AssessmentHelper.getRoundedScore(scoreEval.getScore()));
            mainVC.contextPut("hasPassedValue", (scoreEval.getPassed() == null ? Boolean.FALSE : Boolean.TRUE));
            mainVC.contextPut("passed", scoreEval.getPassed());
            // at least one attempt
            mainVC.contextPut("attempts", attempts);
            mainVC.contextPut("showChangeLog", Boolean.TRUE && enableScoreInfo);
            exposeResults(ureq, true);
        } else {
            exposeResults(ureq, false);
        }
    } else if (courseNode instanceof IQTESTCourseNode) {
        IQTESTCourseNode testCourseNode = (IQTESTCourseNode) courseNode;
        AssessmentEntry assessmentEntry = testCourseNode.getUserAssessmentEntry(userCourseEnv);
        if (assessmentEntry == null) {
            mainVC.contextPut("blockAfterSuccess", Boolean.FALSE);
            mainVC.contextPut("score", null);
            mainVC.contextPut("hasPassedValue", Boolean.FALSE);
            mainVC.contextPut("passed", Boolean.FALSE);
            mainVC.contextPut("comment", null);
            mainVC.contextPut("attempts", 0);
            mainVC.contextPut("showChangeLog", Boolean.FALSE);
        } else {
            Boolean passed = assessmentEntry.getPassed();
            // block if test passed (and config set to check it)
            Boolean blocked = Boolean.FALSE;
            boolean blockAfterSuccess = deliveryOptions.isBlockAfterSuccess();
            if (blockAfterSuccess && passed != null && passed.booleanValue()) {
                blocked = Boolean.TRUE;
            }
            mainVC.contextPut("blockAfterSuccess", blocked);
            boolean resultsVisible = assessmentEntry.getUserVisibility() == null || assessmentEntry.getUserVisibility().booleanValue();
            mainVC.contextPut("resultsVisible", resultsVisible);
            mainVC.contextPut("score", AssessmentHelper.getRoundedScore(assessmentEntry.getScore()));
            mainVC.contextPut("hasPassedValue", (passed == null ? Boolean.FALSE : Boolean.TRUE));
            mainVC.contextPut("passed", passed);
            if (resultsVisible) {
                if (testCourseNode.hasCommentConfigured()) {
                    StringBuilder comment = Formatter.stripTabsAndReturns(testCourseNode.getUserUserComment(userCourseEnv));
                    if (comment != null && comment.length() > 0) {
                        mainVC.contextPut("comment", StringHelper.xssScan(comment));
                        mainVC.contextPut("in-comment", isPanelOpen(ureq, "comment", true));
                    }
                }
                if (testCourseNode.hasIndividualAsssessmentDocuments()) {
                    List<File> docs = testCourseNode.getIndividualAssessmentDocuments(userCourseEnv);
                    String mapperUri = registerCacheableMapper(ureq, null, new DocumentsMapper(docs));
                    mainVC.contextPut("docsMapperUri", mapperUri);
                    mainVC.contextPut("docs", docs);
                    mainVC.contextPut("in-assessmentDocuments", isPanelOpen(ureq, "assessmentDocuments", true));
                }
            }
            Integer attempts = assessmentEntry.getAttempts();
            mainVC.contextPut("attempts", attempts == null ? new Integer(0) : attempts);
            boolean showChangelog = (!anonym && enableScoreInfo && resultsVisible && isResultVisible(config));
            mainVC.contextPut("showChangeLog", showChangelog);
            if (deliveryOptions.isDigitalSignature()) {
                AssessmentTestSession session = qtiService.getAssessmentTestSession(assessmentEntry.getAssessmentId());
                if (session != null) {
                    File signature = qtiService.getAssessmentResultSignature(session);
                    if (signature != null && signature.exists()) {
                        signatureDownloadLink = LinkFactory.createLink("digital.signature.download.link", mainVC, this);
                        signatureDownloadLink.setIconLeftCSS("o_icon o_icon-fw o_icon_download");
                        signatureDownloadLink.setTarget("_blank");
                        Date issueDate = qtiService.getAssessmentResultSignatureIssueDate(session);
                        if (issueDate != null) {
                            mainVC.contextPut("signatureIssueDate", Formatter.getInstance(getLocale()).formatDateAndTime(issueDate));
                        }
                    }
                }
            }
            exposeResults(ureq, resultsVisible);
        }
    }
}
Also used : AssessmentTestSession(org.olat.ims.qti21.AssessmentTestSession) ScoreEvaluation(org.olat.course.run.scoring.ScoreEvaluation) HighScoreRunController(org.olat.course.highscore.ui.HighScoreRunController) DocumentsMapper(org.olat.course.nodes.ms.DocumentsMapper) AssessmentEntry(org.olat.modules.assessment.AssessmentEntry) Date(java.util.Date) AssessableCourseNode(org.olat.course.nodes.AssessableCourseNode) SelfAssessableCourseNode(org.olat.course.nodes.SelfAssessableCourseNode) IQTESTCourseNode(org.olat.course.nodes.IQTESTCourseNode) List(java.util.List) Component(org.olat.core.gui.components.Component) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) File(java.io.File) SelfAssessableCourseNode(org.olat.course.nodes.SelfAssessableCourseNode)

Example 12 with ScoreEvaluation

use of org.olat.ims.qti21.model.xml.interactions.SimpleChoiceAssessmentItemBuilder.ScoreEvaluation in project OpenOLAT by OpenOLAT.

the class IQIdentityListCourseNodeController method doUpdateCourseNode.

private void doUpdateCourseNode(List<AssessmentTestSession> testSessionsToComplete, AssessmentTest assessmentTest, AssessmentEntryStatus status) {
    if (testSessionsToComplete == null || testSessionsToComplete.isEmpty())
        return;
    Double cutValue = QtiNodesExtractor.extractCutValue(assessmentTest);
    for (AssessmentTestSession testSession : testSessionsToComplete) {
        UserCourseEnvironment assessedUserCourseEnv = AssessmentHelper.createAndInitUserCourseEnvironment(testSession.getIdentity(), getCourseEnvironment());
        ScoreEvaluation scoreEval = ((IQTESTCourseNode) courseNode).getUserScoreEvaluation(assessedUserCourseEnv);
        BigDecimal finalScore = testSession.getFinalScore();
        Float score = finalScore == null ? null : finalScore.floatValue();
        Boolean passed = scoreEval.getPassed();
        if (testSession.getManualScore() != null && finalScore != null && cutValue != null) {
            boolean calculated = finalScore.compareTo(BigDecimal.valueOf(cutValue.doubleValue())) >= 0;
            passed = Boolean.valueOf(calculated);
        }
        AssessmentEntryStatus finalStatus = status == null ? scoreEval.getAssessmentStatus() : status;
        ScoreEvaluation manualScoreEval = new ScoreEvaluation(score, passed, finalStatus, scoreEval.getUserVisible(), scoreEval.getFullyAssessed(), scoreEval.getCurrentRunCompletion(), scoreEval.getCurrentRunStatus(), testSession.getKey());
        ((IQTESTCourseNode) courseNode).updateUserScoreEvaluation(manualScoreEval, assessedUserCourseEnv, getIdentity(), false, Role.coach);
    }
}
Also used : AssessmentTestSession(org.olat.ims.qti21.AssessmentTestSession) ScoreEvaluation(org.olat.course.run.scoring.ScoreEvaluation) IQTESTCourseNode(org.olat.course.nodes.IQTESTCourseNode) UserCourseEnvironment(org.olat.course.run.userview.UserCourseEnvironment) AssessmentEntryStatus(org.olat.modules.assessment.model.AssessmentEntryStatus) BigDecimal(java.math.BigDecimal)

Example 13 with ScoreEvaluation

use of org.olat.ims.qti21.model.xml.interactions.SimpleChoiceAssessmentItemBuilder.ScoreEvaluation in project OpenOLAT by OpenOLAT.

the class MatchAssessmentItemBuilder method extractScoreEvaluationMode.

private void extractScoreEvaluationMode() {
    boolean hasMapping = false;
    if (matchInteraction != null) {
        ResponseDeclaration responseDeclaration = assessmentItem.getResponseDeclaration(matchInteraction.getResponseIdentifier());
        if (responseDeclaration != null) {
            Mapping mapping = responseDeclaration.getMapping();
            hasMapping = (mapping != null && mapping.getMapEntries() != null && mapping.getMapEntries().size() > 0);
            if (hasMapping) {
                scoreMapping = new HashMap<>();
                for (MapEntry entry : mapping.getMapEntries()) {
                    SingleValue sValue = entry.getMapKey();
                    if (sValue instanceof DirectedPairValue) {
                        Identifier sourceIdentifier = ((DirectedPairValue) sValue).sourceValue();
                        Identifier destIdentifier = ((DirectedPairValue) sValue).destValue();
                        scoreMapping.put(new DirectedPairValue(sourceIdentifier, destIdentifier), entry.getMappedValue());
                    }
                }
            }
        }
    }
    scoreEvaluation = hasMapping ? ScoreEvaluation.perAnswer : ScoreEvaluation.allCorrectAnswers;
}
Also used : MapEntry(uk.ac.ed.ph.jqtiplus.node.item.response.declaration.MapEntry) SingleValue(uk.ac.ed.ph.jqtiplus.value.SingleValue) Identifier(uk.ac.ed.ph.jqtiplus.types.Identifier) ComplexReferenceIdentifier(uk.ac.ed.ph.jqtiplus.types.ComplexReferenceIdentifier) Mapping(uk.ac.ed.ph.jqtiplus.node.item.response.declaration.Mapping) DirectedPairValue(uk.ac.ed.ph.jqtiplus.value.DirectedPairValue) AssessmentItemFactory.appendAssociationMatchResponseDeclaration(org.olat.ims.qti21.model.xml.AssessmentItemFactory.appendAssociationMatchResponseDeclaration) AssessmentItemFactory.createMatchResponseDeclaration(org.olat.ims.qti21.model.xml.AssessmentItemFactory.createMatchResponseDeclaration) ResponseDeclaration(uk.ac.ed.ph.jqtiplus.node.item.response.declaration.ResponseDeclaration)

Example 14 with ScoreEvaluation

use of org.olat.ims.qti21.model.xml.interactions.SimpleChoiceAssessmentItemBuilder.ScoreEvaluation in project OpenOLAT by OpenOLAT.

the class MatchAssessmentItemBuilder method buildResponseAndOutcomeDeclarations.

@Override
protected void buildResponseAndOutcomeDeclarations() {
    // refresh correct response
    ResponseDeclaration responseDeclaration;
    if (assessmentItem.getResponseDeclaration(responseIdentifier) != null) {
        responseDeclaration = assessmentItem.getResponseDeclaration(responseIdentifier);
        appendAssociationMatchResponseDeclaration(responseDeclaration, associations);
    } else {
        responseDeclaration = createMatchResponseDeclaration(assessmentItem, responseIdentifier, associations);
        assessmentItem.getResponseDeclarations().add(responseDeclaration);
    }
    if (scoreEvaluation == ScoreEvaluation.perAnswer) {
        Map<DirectedPairValue, Double> pairMapping = new HashMap<>();
        if (scoreMapping != null && scoreMapping.size() > 0) {
            for (Map.Entry<DirectedPairValue, Double> entry : scoreMapping.entrySet()) {
                DirectedPairValue sdKey = entry.getKey();
                pairMapping.put(new DirectedPairValue(sdKey.sourceValue(), sdKey.destValue()), entry.getValue());
            }
        }
        AssessmentItemFactory.appendPairMapping(responseDeclaration, pairMapping);
    } else {
        // make sure there isn't any mapping
        responseDeclaration.setMapping(null);
    }
}
Also used : HashMap(java.util.HashMap) DirectedPairValue(uk.ac.ed.ph.jqtiplus.value.DirectedPairValue) AssessmentItemFactory.appendAssociationMatchResponseDeclaration(org.olat.ims.qti21.model.xml.AssessmentItemFactory.appendAssociationMatchResponseDeclaration) AssessmentItemFactory.createMatchResponseDeclaration(org.olat.ims.qti21.model.xml.AssessmentItemFactory.createMatchResponseDeclaration) ResponseDeclaration(uk.ac.ed.ph.jqtiplus.node.item.response.declaration.ResponseDeclaration) Map(java.util.Map) HashMap(java.util.HashMap)

Example 15 with ScoreEvaluation

use of org.olat.ims.qti21.model.xml.interactions.SimpleChoiceAssessmentItemBuilder.ScoreEvaluation in project OpenOLAT by OpenOLAT.

the class HottextAssessmentItemBuilder method buildResponseAndOutcomeDeclarations.

@Override
protected void buildResponseAndOutcomeDeclarations() {
    ResponseDeclaration responseDeclaration = AssessmentItemFactory.createHottextCorrectResponseDeclaration(assessmentItem, responseIdentifier, correctAnswers);
    if (scoreEvaluation == ScoreEvaluation.perAnswer) {
        AssessmentItemFactory.appendMapping(responseDeclaration, scoreMapping);
    }
    assessmentItem.getResponseDeclarations().add(responseDeclaration);
}
Also used : ResponseDeclaration(uk.ac.ed.ph.jqtiplus.node.item.response.declaration.ResponseDeclaration) AssessmentItemFactory.createHottextCorrectResponseDeclaration(org.olat.ims.qti21.model.xml.AssessmentItemFactory.createHottextCorrectResponseDeclaration)

Aggregations

ResponseDeclaration (uk.ac.ed.ph.jqtiplus.node.item.response.declaration.ResponseDeclaration)16 ScoreEvaluation (org.olat.course.run.scoring.ScoreEvaluation)6 AssessmentTestSession (org.olat.ims.qti21.AssessmentTestSession)6 HashMap (java.util.HashMap)4 Map (java.util.Map)4 IQTESTCourseNode (org.olat.course.nodes.IQTESTCourseNode)4 AssessmentItemFactory.appendAssociationMatchResponseDeclaration (org.olat.ims.qti21.model.xml.AssessmentItemFactory.appendAssociationMatchResponseDeclaration)4 AssessmentItemFactory.createHottextCorrectResponseDeclaration (org.olat.ims.qti21.model.xml.AssessmentItemFactory.createHottextCorrectResponseDeclaration)4 AssessmentItemFactory.createMatchResponseDeclaration (org.olat.ims.qti21.model.xml.AssessmentItemFactory.createMatchResponseDeclaration)4 AssessmentItemFactory.createNumericalEntryResponseDeclaration (org.olat.ims.qti21.model.xml.AssessmentItemFactory.createNumericalEntryResponseDeclaration)4 AssessmentItemFactory.createTextEntryResponseDeclaration (org.olat.ims.qti21.model.xml.AssessmentItemFactory.createTextEntryResponseDeclaration)4 MapEntry (uk.ac.ed.ph.jqtiplus.node.item.response.declaration.MapEntry)4 Mapping (uk.ac.ed.ph.jqtiplus.node.item.response.declaration.Mapping)4 ComplexReferenceIdentifier (uk.ac.ed.ph.jqtiplus.types.ComplexReferenceIdentifier)4 Identifier (uk.ac.ed.ph.jqtiplus.types.Identifier)4 DirectedPairValue (uk.ac.ed.ph.jqtiplus.value.DirectedPairValue)4 SingleValue (uk.ac.ed.ph.jqtiplus.value.SingleValue)4 File (java.io.File)2 BigDecimal (java.math.BigDecimal)2 Date (java.util.Date)2