Search in sources :

Example 16 with ItemSessionControl

use of uk.ac.ed.ph.jqtiplus.node.test.ItemSessionControl in project openolat by klemens.

the class QTI12To21Converter method convert.

public AssessmentTest convert(VFSContainer originalContainer, QTIDocument doc, QTI21DeliveryOptions qti21Options) throws URISyntaxException {
    Assessment assessment = doc.getAssessment();
    AssessmentTest assessmentTest = new AssessmentTest();
    String assessmentTestIdentifier = IdentifierGenerator.newAssessmentTestFilename();
    File testFile = new File(unzippedDirRoot, assessmentTestIdentifier + ".xml");
    manifest.appendAssessmentTest(testFile.getName());
    assessmentTest.setIdentifier(assessmentTestIdentifier);
    assessmentTest.setTitle(assessment.getTitle());
    assessmentTest.setToolName(QTI21Constants.TOOLNAME);
    assessmentTest.setToolVersion(Settings.getVersion());
    convertDuration((Duration) assessment.getDuration(), assessmentTest);
    TestPart testPart = AssessmentTestFactory.createTestPart(assessmentTest);
    ItemSessionControl itemSessionControl = testPart.getItemSessionControl();
    Control tmpControl = QTIEditHelper.getControl(assessment);
    if (tmpControl.getSolution() == Control.CTRL_YES) {
        itemSessionControl.setShowSolution(Boolean.TRUE);
    }
    if (qti21Options != null) {
        qti21Options.setHideFeedbacks(false);
        if (assessment.isInheritControls() && tmpControl.getFeedback() != Control.CTRL_YES) {
            qti21Options.setHideFeedbacks(true);
        }
    }
    AssessmentTestBuilder assessmentTestBuilder = new AssessmentTestBuilder(assessmentTest);
    // root
    List<Section> sections = assessment.getSections();
    for (Section section : sections) {
        convert(section, testPart);
    }
    // this are lost in QTI 2.1
    // assessment.getSelection_ordering().getOrderType();
    // assessment.getSelection_ordering().getSelectionNumber();
    OutcomesProcessing outcomesProcessing = assessment.getOutcomes_processing();
    if (outcomesProcessing != null) {
        String cutValue = outcomesProcessing.getField(OutcomesProcessing.CUTVALUE);
        if (StringHelper.containsNonWhitespace(cutValue)) {
            try {
                assessmentTestBuilder.setCutValue(Double.valueOf(cutValue));
            } catch (NumberFormatException e) {
                log.error("Cannot parse cut value: " + cutValue, e);
            }
        }
    }
    assessmentTestBuilder.setMaxScore(atomicMaxScore.doubleValue());
    assessmentTest = assessmentTestBuilder.build();
    persistAssessmentObject(testFile, assessmentTest);
    manifest.write(new File(unzippedDirRoot, "imsmanifest.xml"));
    copyMaterial(originalContainer);
    return assessmentTest;
}
Also used : AssessmentTest(uk.ac.ed.ph.jqtiplus.node.test.AssessmentTest) ItemSessionControl(uk.ac.ed.ph.jqtiplus.node.test.ItemSessionControl) AssessmentTestBuilder(org.olat.ims.qti21.model.xml.AssessmentTestBuilder) ItemSessionControl(uk.ac.ed.ph.jqtiplus.node.test.ItemSessionControl) Control(org.olat.ims.qti.editor.beecom.objects.Control) Assessment(org.olat.ims.qti.editor.beecom.objects.Assessment) TestPart(uk.ac.ed.ph.jqtiplus.node.test.TestPart) OutcomesProcessing(org.olat.ims.qti.editor.beecom.objects.OutcomesProcessing) File(java.io.File) Section(org.olat.ims.qti.editor.beecom.objects.Section) AssessmentSection(uk.ac.ed.ph.jqtiplus.node.test.AssessmentSection)

Example 17 with ItemSessionControl

use of uk.ac.ed.ph.jqtiplus.node.test.ItemSessionControl in project openolat by klemens.

the class QTI12To21Converter method convertItemBasics.

private void convertItemBasics(Item item, AssessmentItemRef itemRef) {
    if (item.getMaxattempts() > 0) {
        ItemSessionControl itemSessionControl = itemRef.getItemSessionControl();
        if (itemSessionControl == null) {
            itemSessionControl = new ItemSessionControl(itemRef);
            itemRef.setItemSessionControl(itemSessionControl);
        }
        itemSessionControl.setMaxAttempts(item.getMaxattempts());
    }
    if (item.getDuration() != null && item.getDuration().isSet()) {
        TimeLimits timeLimits = itemRef.getTimeLimits();
        if (timeLimits == null) {
            timeLimits = new TimeLimits(itemRef);
            itemRef.setTimeLimits(timeLimits);
        }
        timeLimits.setMinimum(0.0d);
        double max = 0.0d;
        if (item.getDuration().getMin() > 0) {
            max += item.getDuration().getMin() * 60d;
        }
        if (item.getDuration().getSec() > 0) {
            max += item.getDuration().getSec();
        }
        timeLimits.setMaximum(max);
    }
}
Also used : ItemSessionControl(uk.ac.ed.ph.jqtiplus.node.test.ItemSessionControl) TimeLimits(uk.ac.ed.ph.jqtiplus.node.test.TimeLimits)

Example 18 with ItemSessionControl

use of uk.ac.ed.ph.jqtiplus.node.test.ItemSessionControl in project openolat by klemens.

the class ItemSessionControlController method formOK.

@Override
protected void formOK(UserRequest ureq) {
    // can be null
    ItemSessionControl itemSessionControl = part.getItemSessionControl();
    // need to be first!
    if (allowSkippingEl.isOneSelected()) {
        if (allowSkippingEl.isSelected(0)) {
            // yes
            checkNotNull(itemSessionControl).setAllowSkipping(Boolean.TRUE);
        } else if (allowSkippingEl.isSelected(1)) {
            // no
            checkNotNull(itemSessionControl).setAllowSkipping(Boolean.FALSE);
        } else if (itemSessionControl != null) {
            // inherit
            itemSessionControl.setAllowSkipping(null);
        }
    }
    if (allowCommentEl.isOneSelected()) {
        if (allowCommentEl.isSelected(0)) {
            checkNotNull(itemSessionControl).setAllowComment(Boolean.TRUE);
        } else if (allowCommentEl.isSelected(1)) {
            checkNotNull(itemSessionControl).setAllowComment(Boolean.FALSE);
        } else if (itemSessionControl != null) {
            itemSessionControl.setAllowComment(null);
        }
    }
    if (allowReviewEl.isOneSelected()) {
        if (allowReviewEl.isSelected(0)) {
            checkNotNull(itemSessionControl).setAllowReview(Boolean.TRUE);
        } else if (allowReviewEl.isSelected(1)) {
            checkNotNull(itemSessionControl).setAllowReview(Boolean.FALSE);
        } else if (itemSessionControl != null) {
            itemSessionControl.setAllowReview(null);
        }
    }
    if (showSolutionEl.isOneSelected()) {
        if (showSolutionEl.isSelected(0)) {
            checkNotNull(itemSessionControl).setShowSolution(Boolean.TRUE);
        } else if (showSolutionEl.isSelected(1)) {
            checkNotNull(itemSessionControl).setShowSolution(Boolean.FALSE);
        } else if (itemSessionControl != null) {
            itemSessionControl.setShowSolution(null);
        }
    }
    if (limitAttemptsEl.isSelected(0) && maxAttemptsEl != null && maxAttemptsEl.isVisible() && StringHelper.isLong(maxAttemptsEl.getValue())) {
        int maxAttempts = Integer.parseInt(maxAttemptsEl.getValue());
        checkNotNull(itemSessionControl).setMaxAttempts(new Integer(maxAttempts));
    } else if (limitAttemptsEl.isSelected(1)) {
        checkNotNull(itemSessionControl).setMaxAttempts(0);
    } else if (itemSessionControl != null) {
        itemSessionControl.setMaxAttempts(null);
    }
}
Also used : ItemSessionControl(uk.ac.ed.ph.jqtiplus.node.test.ItemSessionControl)

Aggregations

ItemSessionControl (uk.ac.ed.ph.jqtiplus.node.test.ItemSessionControl)18 TestPart (uk.ac.ed.ph.jqtiplus.node.test.TestPart)8 AssessmentSection (uk.ac.ed.ph.jqtiplus.node.test.AssessmentSection)6 File (java.io.File)4 RubricBlock (uk.ac.ed.ph.jqtiplus.node.content.variable.RubricBlock)4 AssessmentTest (uk.ac.ed.ph.jqtiplus.node.test.AssessmentTest)4 Ordering (uk.ac.ed.ph.jqtiplus.node.test.Ordering)4 FileOutputStream (java.io.FileOutputStream)2 URISyntaxException (java.net.URISyntaxException)2 Date (java.util.Date)2 Test (org.junit.Test)2 Assessment (org.olat.ims.qti.editor.beecom.objects.Assessment)2 Control (org.olat.ims.qti.editor.beecom.objects.Control)2 OutcomesProcessing (org.olat.ims.qti.editor.beecom.objects.OutcomesProcessing)2 Section (org.olat.ims.qti.editor.beecom.objects.Section)2 AssessmentTestBuilder (org.olat.ims.qti21.model.xml.AssessmentTestBuilder)2 ManifestBuilder (org.olat.ims.qti21.model.xml.ManifestBuilder)2 AssessmentItem (uk.ac.ed.ph.jqtiplus.node.item.AssessmentItem)2 Selection (uk.ac.ed.ph.jqtiplus.node.test.Selection)2 TimeLimits (uk.ac.ed.ph.jqtiplus.node.test.TimeLimits)2