Search in sources :

Example 36 with Control

use of org.olat.ims.qti.editor.beecom.objects.Control 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)

Aggregations

Control (org.olat.ims.qti.editor.beecom.objects.Control)36 ArrayList (java.util.ArrayList)22 Item (org.olat.ims.qti.editor.beecom.objects.Item)18 VFSItem (org.olat.core.util.vfs.VFSItem)12 ChoiceQuestion (org.olat.ims.qti.editor.beecom.objects.ChoiceQuestion)12 List (java.util.List)10 WindowControl (org.olat.core.gui.control.WindowControl)10 Mattext (org.olat.ims.qti.editor.beecom.objects.Mattext)10 QTIObject (org.olat.ims.qti.editor.beecom.objects.QTIObject)10 Question (org.olat.ims.qti.editor.beecom.objects.Question)10 Iterator (java.util.Iterator)8 Duration (org.olat.ims.qti.editor.beecom.objects.Duration)8 Element (org.dom4j.Element)6 Assessment (org.olat.ims.qti.editor.beecom.objects.Assessment)6 ChoiceResponse (org.olat.ims.qti.editor.beecom.objects.ChoiceResponse)6 EssayResponse (org.olat.ims.qti.editor.beecom.objects.EssayResponse)6 FIBResponse (org.olat.ims.qti.editor.beecom.objects.FIBResponse)6 Material (org.olat.ims.qti.editor.beecom.objects.Material)6 OutcomesProcessing (org.olat.ims.qti.editor.beecom.objects.OutcomesProcessing)6 Section (org.olat.ims.qti.editor.beecom.objects.Section)6