Search in sources :

Example 31 with AssessmentTest

use of uk.ac.ed.ph.jqtiplus.node.test.AssessmentTest in project OpenOLAT by OpenOLAT.

the class QTI21EditLayoutForm method getMaxTimeLimit.

/**
 * @return The time limit of the assessment test in seconds or -1 if not configured
 */
private long getMaxTimeLimit() {
    FileResourceManager frm = FileResourceManager.getInstance();
    File unzippedDirRoot = frm.unzipFileResource(testEntry.getOlatResource());
    ResolvedAssessmentTest resolvedAssessmentTest = qtiService.loadAndResolveAssessmentTest(unzippedDirRoot, false, false);
    AssessmentTest assessmentTest = resolvedAssessmentTest.getRootNodeLookup().extractIfSuccessful();
    long timeLimit = -1;
    if (assessmentTest != null && assessmentTest.getTimeLimits() != null && assessmentTest.getTimeLimits().getMaximum() != null) {
        timeLimit = assessmentTest.getTimeLimits().getMaximum().longValue();
    }
    return timeLimit;
}
Also used : ResolvedAssessmentTest(uk.ac.ed.ph.jqtiplus.resolution.ResolvedAssessmentTest) AssessmentTest(uk.ac.ed.ph.jqtiplus.node.test.AssessmentTest) FileResourceManager(org.olat.fileresource.FileResourceManager) ResolvedAssessmentTest(uk.ac.ed.ph.jqtiplus.resolution.ResolvedAssessmentTest) File(java.io.File)

Example 32 with AssessmentTest

use of uk.ac.ed.ph.jqtiplus.node.test.AssessmentTest in project OpenOLAT by OpenOLAT.

the class AssessmentTestHelper method needManualCorrection.

public static boolean needManualCorrection(ResolvedAssessmentTest resolvedAssessmentTest) {
    AssessmentTest test = resolvedAssessmentTest.getRootNodeLookup().extractIfSuccessful();
    boolean needManualCorrection = false;
    List<TestPart> parts = test.getChildAbstractParts();
    for (TestPart part : parts) {
        List<AssessmentSection> sections = part.getAssessmentSections();
        for (AssessmentSection section : sections) {
            if (needManualCorrection(section, resolvedAssessmentTest)) {
                needManualCorrection = true;
                break;
            }
        }
    }
    return needManualCorrection;
}
Also used : ResolvedAssessmentTest(uk.ac.ed.ph.jqtiplus.resolution.ResolvedAssessmentTest) AssessmentTest(uk.ac.ed.ph.jqtiplus.node.test.AssessmentTest) AssessmentSection(uk.ac.ed.ph.jqtiplus.node.test.AssessmentSection) TestPart(uk.ac.ed.ph.jqtiplus.node.test.TestPart)

Example 33 with AssessmentTest

use of uk.ac.ed.ph.jqtiplus.node.test.AssessmentTest in project OpenOLAT by OpenOLAT.

the class QTI21EditForm method update.

protected void update(RepositoryEntry testEntry) {
    Double minValue = null;
    Double maxValue = null;
    Double cutValue = null;
    FileResourceManager frm = FileResourceManager.getInstance();
    File unzippedDirRoot = frm.unzipFileResource(testEntry.getOlatResource());
    ResolvedAssessmentTest resolvedAssessmentTest = qtiService.loadAndResolveAssessmentTest(unzippedDirRoot, false, false);
    AssessmentTest assessmentTest = resolvedAssessmentTest.getRootNodeLookup().extractIfSuccessful();
    if (assessmentTest != null) {
        AssessmentTestBuilder testBuilder = new AssessmentTestBuilder(assessmentTest);
        maxValue = testBuilder.getMaxScore();
        cutValue = testBuilder.getCutValue();
        if (maxValue != null && "OpenOLAT".equals(assessmentTest.getToolName())) {
            minValue = 0d;
        }
    }
    // Put values to module configuration
    minScoreEl.setValue(minValue == null ? "" : AssessmentHelper.getRoundedScore(minValue));
    minScoreEl.setVisible(minValue != null);
    maxScoreEl.setValue(maxValue == null ? "" : AssessmentHelper.getRoundedScore(maxValue));
    maxScoreEl.setVisible(maxValue != null);
    cutValueEl.setValue(cutValue == null ? "" : AssessmentHelper.getRoundedScore(cutValue));
    cutValueEl.setVisible(cutValue != null);
    update();
}
Also used : ResolvedAssessmentTest(uk.ac.ed.ph.jqtiplus.resolution.ResolvedAssessmentTest) AssessmentTest(uk.ac.ed.ph.jqtiplus.node.test.AssessmentTest) AssessmentTestBuilder(org.olat.ims.qti21.model.xml.AssessmentTestBuilder) FileResourceManager(org.olat.fileresource.FileResourceManager) ResolvedAssessmentTest(uk.ac.ed.ph.jqtiplus.resolution.ResolvedAssessmentTest) File(java.io.File)

Example 34 with AssessmentTest

use of uk.ac.ed.ph.jqtiplus.node.test.AssessmentTest in project OpenOLAT by OpenOLAT.

the class AssessmentTestDisplayController method getAssessmentTestMaxTimeLimit.

/**
 * @return The maximum time limit in seconds.
 */
private Long getAssessmentTestMaxTimeLimit() {
    int extra = extraTime == null ? 0 : extraTime.intValue();
    long leadingTime = getLeadingTimeEndTestOption();
    if (overrideOptions != null && overrideOptions.getAssessmentTestMaxTimeLimit() != null) {
        long timeLimits = overrideOptions.getAssessmentTestMaxTimeLimit().longValue();
        return timeLimits > 0 ? Math.min(leadingTime, timeLimits) + extra : null;
    }
    AssessmentTest assessmentTest = resolvedAssessmentTest.getRootNodeLookup().extractIfSuccessful();
    if (assessmentTest.getTimeLimits() != null && assessmentTest.getTimeLimits().getMaximum() != null) {
        long timeLimits = assessmentTest.getTimeLimits().getMaximum().longValue();
        return Math.min(leadingTime, timeLimits) + extra;
    }
    return null;
}
Also used : AssessmentTest(uk.ac.ed.ph.jqtiplus.node.test.AssessmentTest) ResolvedAssessmentTest(uk.ac.ed.ph.jqtiplus.resolution.ResolvedAssessmentTest)

Example 35 with AssessmentTest

use of uk.ac.ed.ph.jqtiplus.node.test.AssessmentTest 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)

Aggregations

AssessmentTest (uk.ac.ed.ph.jqtiplus.node.test.AssessmentTest)60 ResolvedAssessmentTest (uk.ac.ed.ph.jqtiplus.resolution.ResolvedAssessmentTest)48 File (java.io.File)34 AssessmentSection (uk.ac.ed.ph.jqtiplus.node.test.AssessmentSection)22 TestPart (uk.ac.ed.ph.jqtiplus.node.test.TestPart)20 FileResourceManager (org.olat.fileresource.FileResourceManager)12 AssessmentItemRef (uk.ac.ed.ph.jqtiplus.node.test.AssessmentItemRef)12 ResolvedAssessmentItem (uk.ac.ed.ph.jqtiplus.resolution.ResolvedAssessmentItem)12 IOException (java.io.IOException)10 URISyntaxException (java.net.URISyntaxException)10 GenericTreeNode (org.olat.core.gui.components.tree.GenericTreeNode)10 AssessmentItem (uk.ac.ed.ph.jqtiplus.node.item.AssessmentItem)10 ArrayList (java.util.ArrayList)8 TreeNode (org.olat.core.gui.components.tree.TreeNode)8 ManifestBuilder (org.olat.ims.qti21.model.xml.ManifestBuilder)8 FileOutputStream (java.io.FileOutputStream)6 ManifestMetadataBuilder (org.olat.ims.qti21.model.xml.ManifestMetadataBuilder)6 QtiSerializer (uk.ac.ed.ph.jqtiplus.serialization.QtiSerializer)6 AssessmentTestBuilder (org.olat.ims.qti21.model.xml.AssessmentTestBuilder)5 CompleteAssessmentTestSessionEvent (org.olat.modules.assessment.ui.event.CompleteAssessmentTestSessionEvent)5