Search in sources :

Example 6 with OutcomesProcessing

use of org.olat.ims.qti.editor.beecom.objects.OutcomesProcessing in project OpenOLAT by OpenOLAT.

the class AssessmentParser method parse.

/**
 * @see org.olat.ims.qti.editor.beecom.IParser#parse(org.dom4j.Element)
 */
public Object parse(Element element) {
    // assert element.getName().equalsIgnoreCase("assessment");
    Assessment assessment = new Assessment();
    // attributes
    Attribute attr = element.attribute("ident");
    if (attr != null)
        assessment.setIdent(attr.getValue());
    attr = element.attribute("title");
    if (attr != null)
        assessment.setTitle(attr.getValue());
    // elements
    // DURATION
    QTIObject duration = (QTIObject) parserManager.parse(element.element("duration"));
    assessment.setDuration(duration);
    // ASSESSMENTCONTROL
    List assessmentcontrolsXML = element.elements("assessmentcontrol");
    List assessmentcontrols = new ArrayList();
    for (Iterator i = assessmentcontrolsXML.iterator(); i.hasNext(); ) {
        assessmentcontrols.add(parserManager.parse((Element) i.next()));
        assessment.setInheritControls(true);
    }
    if (assessmentcontrols.size() == 0) {
        assessmentcontrols.add(new Control());
        assessment.setInheritControls(false);
    }
    assessment.setAssessmentcontrols(assessmentcontrols);
    // OUTCOMES PROCESSING
    OutcomesProcessing outcomesProcessing = (OutcomesProcessing) parserManager.parse(element.element("outcomes_processing"));
    if (outcomesProcessing != null)
        assessment.setOutcomes_processing(outcomesProcessing);
    // SELECTION ORDERING
    SelectionOrdering selectionOrdering = (SelectionOrdering) parserManager.parse(element.element("selection_ordering"));
    if (selectionOrdering != null) {
        assessment.setSelection_ordering(selectionOrdering);
    } else {
        assessment.setSelection_ordering(new SelectionOrdering());
    }
    // SECTIONS
    List sectionsXML = element.elements("section");
    List sections = new ArrayList();
    for (Iterator i = sectionsXML.iterator(); i.hasNext(); ) {
        sections.add(parserManager.parse((Element) i.next()));
    }
    assessment.setSections(sections);
    // ITEMS
    List itemsXML = element.elements("item");
    List items = new ArrayList();
    for (Iterator i = itemsXML.iterator(); i.hasNext(); ) {
        items.add(parserManager.parse((Element) i.next()));
    }
    assessment.setItems(items);
    // OBJECTIVES
    Element mattext = (Element) element.selectSingleNode("./objectives/material/mattext");
    if (mattext != null)
        assessment.setObjectives(mattext.getTextTrim());
    // METADATA
    Metadata metadata = (Metadata) parserManager.parse(element.element("qtimetadata"));
    if (metadata != null)
        assessment.setMetadata(metadata);
    return assessment;
}
Also used : Control(org.olat.ims.qti.editor.beecom.objects.Control) QTIObject(org.olat.ims.qti.editor.beecom.objects.QTIObject) SelectionOrdering(org.olat.ims.qti.editor.beecom.objects.SelectionOrdering) Attribute(org.dom4j.Attribute) Assessment(org.olat.ims.qti.editor.beecom.objects.Assessment) Element(org.dom4j.Element) ArrayList(java.util.ArrayList) Iterator(java.util.Iterator) OutcomesProcessing(org.olat.ims.qti.editor.beecom.objects.OutcomesProcessing) Metadata(org.olat.ims.qti.editor.beecom.objects.Metadata) List(java.util.List) ArrayList(java.util.ArrayList)

Example 7 with OutcomesProcessing

use of org.olat.ims.qti.editor.beecom.objects.OutcomesProcessing in project OpenOLAT by OpenOLAT.

the class QTIWordExport method renderAssessment.

public static void renderAssessment(Assessment assessment, OpenXMLDocument document, Translator translator) {
    String title = assessment.getTitle();
    document.appendTitle(title);
    OutcomesProcessing outcomesProcessing = assessment.getOutcomes_processing();
    if (outcomesProcessing != null) {
        String cutValue = outcomesProcessing.getField(OutcomesProcessing.CUTVALUE);
        String cutValueLabel = translator.translate("cut_value");
        document.appendText(cutValueLabel + ": " + cutValue, true);
    }
    String objectives = assessment.getObjectives();
    document.appendText(objectives, true);
}
Also used : OutcomesProcessing(org.olat.ims.qti.editor.beecom.objects.OutcomesProcessing)

Example 8 with OutcomesProcessing

use of org.olat.ims.qti.editor.beecom.objects.OutcomesProcessing in project OpenOLAT by OpenOLAT.

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 9 with OutcomesProcessing

use of org.olat.ims.qti.editor.beecom.objects.OutcomesProcessing in project openolat by klemens.

the class AssessmentParser method parse.

/**
 * @see org.olat.ims.qti.editor.beecom.IParser#parse(org.dom4j.Element)
 */
public Object parse(Element element) {
    // assert element.getName().equalsIgnoreCase("assessment");
    Assessment assessment = new Assessment();
    // attributes
    Attribute attr = element.attribute("ident");
    if (attr != null)
        assessment.setIdent(attr.getValue());
    attr = element.attribute("title");
    if (attr != null)
        assessment.setTitle(attr.getValue());
    // elements
    // DURATION
    QTIObject duration = (QTIObject) parserManager.parse(element.element("duration"));
    assessment.setDuration(duration);
    // ASSESSMENTCONTROL
    List assessmentcontrolsXML = element.elements("assessmentcontrol");
    List assessmentcontrols = new ArrayList();
    for (Iterator i = assessmentcontrolsXML.iterator(); i.hasNext(); ) {
        assessmentcontrols.add(parserManager.parse((Element) i.next()));
        assessment.setInheritControls(true);
    }
    if (assessmentcontrols.size() == 0) {
        assessmentcontrols.add(new Control());
        assessment.setInheritControls(false);
    }
    assessment.setAssessmentcontrols(assessmentcontrols);
    // OUTCOMES PROCESSING
    OutcomesProcessing outcomesProcessing = (OutcomesProcessing) parserManager.parse(element.element("outcomes_processing"));
    if (outcomesProcessing != null)
        assessment.setOutcomes_processing(outcomesProcessing);
    // SELECTION ORDERING
    SelectionOrdering selectionOrdering = (SelectionOrdering) parserManager.parse(element.element("selection_ordering"));
    if (selectionOrdering != null) {
        assessment.setSelection_ordering(selectionOrdering);
    } else {
        assessment.setSelection_ordering(new SelectionOrdering());
    }
    // SECTIONS
    List sectionsXML = element.elements("section");
    List sections = new ArrayList();
    for (Iterator i = sectionsXML.iterator(); i.hasNext(); ) {
        sections.add(parserManager.parse((Element) i.next()));
    }
    assessment.setSections(sections);
    // ITEMS
    List itemsXML = element.elements("item");
    List items = new ArrayList();
    for (Iterator i = itemsXML.iterator(); i.hasNext(); ) {
        items.add(parserManager.parse((Element) i.next()));
    }
    assessment.setItems(items);
    // OBJECTIVES
    Element mattext = (Element) element.selectSingleNode("./objectives/material/mattext");
    if (mattext != null)
        assessment.setObjectives(mattext.getTextTrim());
    // METADATA
    Metadata metadata = (Metadata) parserManager.parse(element.element("qtimetadata"));
    if (metadata != null)
        assessment.setMetadata(metadata);
    return assessment;
}
Also used : Control(org.olat.ims.qti.editor.beecom.objects.Control) QTIObject(org.olat.ims.qti.editor.beecom.objects.QTIObject) SelectionOrdering(org.olat.ims.qti.editor.beecom.objects.SelectionOrdering) Attribute(org.dom4j.Attribute) Assessment(org.olat.ims.qti.editor.beecom.objects.Assessment) Element(org.dom4j.Element) ArrayList(java.util.ArrayList) Iterator(java.util.Iterator) OutcomesProcessing(org.olat.ims.qti.editor.beecom.objects.OutcomesProcessing) Metadata(org.olat.ims.qti.editor.beecom.objects.Metadata) List(java.util.List) ArrayList(java.util.ArrayList)

Example 10 with OutcomesProcessing

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

OutcomesProcessing (org.olat.ims.qti.editor.beecom.objects.OutcomesProcessing)10 Control (org.olat.ims.qti.editor.beecom.objects.Control)6 Iterator (java.util.Iterator)4 List (java.util.List)4 Attribute (org.dom4j.Attribute)4 Element (org.dom4j.Element)4 Assessment (org.olat.ims.qti.editor.beecom.objects.Assessment)4 File (java.io.File)2 ArrayList (java.util.ArrayList)2 WindowControl (org.olat.core.gui.control.WindowControl)2 Duration (org.olat.ims.qti.editor.beecom.objects.Duration)2 Metadata (org.olat.ims.qti.editor.beecom.objects.Metadata)2 QTIObject (org.olat.ims.qti.editor.beecom.objects.QTIObject)2 Section (org.olat.ims.qti.editor.beecom.objects.Section)2 SelectionOrdering (org.olat.ims.qti.editor.beecom.objects.SelectionOrdering)2 AssessmentTestBuilder (org.olat.ims.qti21.model.xml.AssessmentTestBuilder)2 AssessmentSection (uk.ac.ed.ph.jqtiplus.node.test.AssessmentSection)2 AssessmentTest (uk.ac.ed.ph.jqtiplus.node.test.AssessmentTest)2 ItemSessionControl (uk.ac.ed.ph.jqtiplus.node.test.ItemSessionControl)2 TestPart (uk.ac.ed.ph.jqtiplus.node.test.TestPart)2