Search in sources :

Example 1 with TestResult

use of uk.ac.ed.ph.jqtiplus.node.result.TestResult in project OpenOLAT by OpenOLAT.

the class AssessmentResultController method initForm.

@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
    if (formLayout instanceof FormLayoutContainer) {
        FormLayoutContainer layoutCont = (FormLayoutContainer) formLayout;
        layoutCont.contextPut("options", options);
        if (assessedIdentity != null) {
            layoutCont.contextPut("userDisplayName", userMgr.getUserDisplayName(assessedIdentity.getKey()));
        } else {
            layoutCont.contextPut("userDisplayName", Boolean.FALSE);
        }
        if (testSessionState == null || assessmentResult == null) {
            // An author has deleted the test session before the user end it.
            // It can happen with time limited tests.
            Results results = new Results(false, "o_qtiassessment_icon", false);
            layoutCont.contextPut("testResults", results);
            layoutCont.contextPut("itemResults", new ArrayList<>());
            layoutCont.contextPut("testSessionNotFound", Boolean.TRUE);
        } else {
            layoutCont.contextPut("title", Boolean.valueOf(withTitle));
            layoutCont.contextPut("print", Boolean.valueOf(withPrint));
            layoutCont.contextPut("printCommand", Boolean.FALSE);
            layoutCont.contextPut("toggleSolution", Boolean.valueOf(toggleSolution));
            if (withPrint) {
                layoutCont.contextPut("winid", "w" + layoutCont.getFormItemComponent().getDispatchID());
                layoutCont.getFormItemComponent().addListener(this);
            }
            if (assessedIdentityInfosCtrl != null) {
                layoutCont.put("assessedIdentityInfos", assessedIdentityInfosCtrl.getInitialComponent());
            } else if (anonym) {
                layoutCont.contextPut("anonym", Boolean.TRUE);
            }
            Results testResults = new Results(false, "o_qtiassessment_icon", options.isMetadata());
            testResults.setSessionState(testSessionState);
            layoutCont.contextPut("testResults", testResults);
            TestResult testResult = assessmentResult.getTestResult();
            if (testResult != null) {
                extractOutcomeVariable(testResult.getItemVariables(), testResults);
                if (candidateSession.getManualScore() != null) {
                    testResults.addScore(candidateSession.getManualScore());
                    testResults.setManualScore(candidateSession.getManualScore());
                }
                AssessmentTest assessmentTest = resolvedAssessmentTest.getRootNodeLookup().extractIfSuccessful();
                Double cutValue = QtiNodesExtractor.extractCutValue(assessmentTest);
                if (cutValue != null) {
                    testResults.setCutValue(cutValue);
                }
            }
            if (signatureMapperUri != null) {
                String signatureUrl = signatureMapperUri + "/assessmentResultSignature.xml";
                layoutCont.contextPut("signatureUrl", signatureUrl);
            }
            // reset max score and aggregate
            testResults.setMaxScore(null);
            initFormSections(layoutCont, testResults);
        }
    }
}
Also used : ResolvedAssessmentTest(uk.ac.ed.ph.jqtiplus.resolution.ResolvedAssessmentTest) AssessmentTest(uk.ac.ed.ph.jqtiplus.node.test.AssessmentTest) FormLayoutContainer(org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer) TestResult(uk.ac.ed.ph.jqtiplus.node.result.TestResult)

Example 2 with TestResult

use of uk.ac.ed.ph.jqtiplus.node.result.TestResult in project openolat by klemens.

the class AssessmentResultController method initForm.

@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
    if (formLayout instanceof FormLayoutContainer) {
        FormLayoutContainer layoutCont = (FormLayoutContainer) formLayout;
        layoutCont.contextPut("options", options);
        if (assessedIdentity != null) {
            layoutCont.contextPut("userDisplayName", userMgr.getUserDisplayName(assessedIdentity.getKey()));
        } else {
            layoutCont.contextPut("userDisplayName", Boolean.FALSE);
        }
        if (testSessionState == null || assessmentResult == null) {
            // An author has deleted the test session before the user end it.
            // It can happen with time limited tests.
            Results results = new Results(false, "o_qtiassessment_icon", false);
            layoutCont.contextPut("testResults", results);
            layoutCont.contextPut("itemResults", new ArrayList<>());
            layoutCont.contextPut("testSessionNotFound", Boolean.TRUE);
        } else {
            layoutCont.contextPut("title", Boolean.valueOf(withTitle));
            layoutCont.contextPut("print", Boolean.valueOf(withPrint));
            layoutCont.contextPut("printCommand", Boolean.FALSE);
            layoutCont.contextPut("toggleSolution", Boolean.valueOf(toggleSolution));
            if (withPrint) {
                layoutCont.contextPut("winid", "w" + layoutCont.getFormItemComponent().getDispatchID());
                layoutCont.getFormItemComponent().addListener(this);
            }
            if (assessedIdentityInfosCtrl != null) {
                layoutCont.put("assessedIdentityInfos", assessedIdentityInfosCtrl.getInitialComponent());
            } else if (anonym) {
                layoutCont.contextPut("anonym", Boolean.TRUE);
            }
            Results testResults = new Results(false, "o_qtiassessment_icon", options.isMetadata());
            testResults.setSessionState(testSessionState);
            layoutCont.contextPut("testResults", testResults);
            TestResult testResult = assessmentResult.getTestResult();
            if (testResult != null) {
                extractOutcomeVariable(testResult.getItemVariables(), testResults);
                if (candidateSession.getManualScore() != null) {
                    testResults.addScore(candidateSession.getManualScore());
                    testResults.setManualScore(candidateSession.getManualScore());
                }
                AssessmentTest assessmentTest = resolvedAssessmentTest.getRootNodeLookup().extractIfSuccessful();
                Double cutValue = QtiNodesExtractor.extractCutValue(assessmentTest);
                if (cutValue != null) {
                    testResults.setCutValue(cutValue);
                }
            }
            if (signatureMapperUri != null) {
                String signatureUrl = signatureMapperUri + "/assessmentResultSignature.xml";
                layoutCont.contextPut("signatureUrl", signatureUrl);
            }
            // reset max score and aggregate
            testResults.setMaxScore(null);
            initFormSections(layoutCont, testResults);
        }
    }
}
Also used : ResolvedAssessmentTest(uk.ac.ed.ph.jqtiplus.resolution.ResolvedAssessmentTest) AssessmentTest(uk.ac.ed.ph.jqtiplus.node.test.AssessmentTest) FormLayoutContainer(org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer) TestResult(uk.ac.ed.ph.jqtiplus.node.result.TestResult)

Aggregations

FormLayoutContainer (org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer)2 TestResult (uk.ac.ed.ph.jqtiplus.node.result.TestResult)2 AssessmentTest (uk.ac.ed.ph.jqtiplus.node.test.AssessmentTest)2 ResolvedAssessmentTest (uk.ac.ed.ph.jqtiplus.resolution.ResolvedAssessmentTest)2