Search in sources :

Example 11 with Assessment

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

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

the class QTIWordExport method exportTest.

private void exportTest(String header, OutputStream out, boolean withResponses) {
    ZipOutputStream zout = null;
    try {
        OpenXMLDocument document = new OpenXMLDocument();
        document.setMediaContainer(mediaContainer);
        document.setDocumentHeader(header);
        Translator translator = Util.createPackageTranslator(QTIWordExport.class, locale, Util.createPackageTranslator(QTIEditorMainController.class, locale));
        Assessment assessment = rootNode.getAssessment();
        renderAssessment(assessment, document, translator);
        for (Section section : assessment.getSections()) {
            renderSection(section, document);
            List<Item> items = section.getItems();
            for (Iterator<Item> itemIt = items.iterator(); itemIt.hasNext(); ) {
                Item item = itemIt.next();
                if (item.isAlient()) {
                    renderAlienItem(item, document, translator);
                } else {
                    renderItem(item, document, withResponses, translator);
                }
                if (itemIt.hasNext()) {
                    document.appendPageBreak();
                }
            }
        }
        zout = new ZipOutputStream(out);
        zout.setLevel(9);
        OpenXMLDocumentWriter writer = new OpenXMLDocumentWriter();
        writer.createDocument(zout, document);
    } catch (Exception e) {
        log.error("", e);
    } finally {
        if (zout != null) {
            try {
                zout.finish();
            } catch (IOException e) {
                log.error("", e);
            }
        }
    }
}
Also used : Item(org.olat.ims.qti.editor.beecom.objects.Item) OpenXMLDocumentWriter(org.olat.core.util.openxml.OpenXMLDocumentWriter) Translator(org.olat.core.gui.translator.Translator) QTIEditorMainController(org.olat.ims.qti.editor.QTIEditorMainController) ZipOutputStream(java.util.zip.ZipOutputStream) Assessment(org.olat.ims.qti.editor.beecom.objects.Assessment) OpenXMLDocument(org.olat.core.util.openxml.OpenXMLDocument) IOException(java.io.IOException) Section(org.olat.ims.qti.editor.beecom.objects.Section) IOException(java.io.IOException)

Example 13 with Assessment

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

the class QTIEditorTreeModel method init.

/**
 * takes the assessment object tree and converts it to a QTIEditorTreeModel
 */
private void init() {
    Assessment ass = qtiPackage.getQTIDocument().getAssessment();
    GenericQtiNode rootNode = new AssessmentNode(ass, qtiPackage);
    this.setRootNode(rootNode);
    // Sections with their Items
    List<Section> sections = ass.getSections();
    for (int i = 0; i < sections.size(); i++) {
        // get section data
        Section elem = sections.get(i);
        GenericQtiNode sectionNode = new SectionNode(elem, qtiPackage);
        List<Item> items = elem.getItems();
        for (int j = 0; j < items.size(); j++) {
            // get item data
            Item elem2 = items.get(j);
            GenericQtiNode itemNode = new ItemNode(elem2, qtiPackage);
            // add item to its parent section
            sectionNode.addChild(itemNode);
        }
        // add section with its items to the rootNode
        rootNode.addChild(sectionNode);
    }
}
Also used : Item(org.olat.ims.qti.editor.beecom.objects.Item) Assessment(org.olat.ims.qti.editor.beecom.objects.Assessment) Section(org.olat.ims.qti.editor.beecom.objects.Section)

Example 14 with Assessment

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

the class QTI12ResultDetailsController method checkEssay.

private boolean checkEssay() {
    QTIDocument doc = TestFileResource.getQTIDocument(repositoryEntry.getOlatResource());
    if (doc != null && doc.getAssessment() != null) {
        Assessment ass = doc.getAssessment();
        // Sections with their Items
        List<Section> sections = ass.getSections();
        for (Section section : sections) {
            List<Item> items = section.getItems();
            for (Item item : items) {
                String ident = item.getIdent();
                if (ident != null && ident.startsWith("QTIEDIT:ESSAY")) {
                    return true;
                }
            }
        }
    }
    return false;
}
Also used : QTIDocument(org.olat.ims.qti.editor.beecom.objects.QTIDocument) Item(org.olat.ims.qti.editor.beecom.objects.Item) Assessment(org.olat.ims.qti.editor.beecom.objects.Assessment) Section(org.olat.ims.qti.editor.beecom.objects.Section)

Example 15 with Assessment

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

Aggregations

Assessment (org.olat.ims.qti.editor.beecom.objects.Assessment)22 Section (org.olat.ims.qti.editor.beecom.objects.Section)18 Item (org.olat.ims.qti.editor.beecom.objects.Item)16 Control (org.olat.ims.qti.editor.beecom.objects.Control)6 ArrayList (java.util.ArrayList)4 Iterator (java.util.Iterator)4 List (java.util.List)4 Translator (org.olat.core.gui.translator.Translator)4 VFSItem (org.olat.core.util.vfs.VFSItem)4 Metadata (org.olat.ims.qti.editor.beecom.objects.Metadata)4 OutcomesProcessing (org.olat.ims.qti.editor.beecom.objects.OutcomesProcessing)4 QTIDocument (org.olat.ims.qti.editor.beecom.objects.QTIDocument)4 QTIObject (org.olat.ims.qti.editor.beecom.objects.QTIObject)4 File (java.io.File)2 IOException (java.io.IOException)2 ZipOutputStream (java.util.zip.ZipOutputStream)2 Attribute (org.dom4j.Attribute)2 Element (org.dom4j.Element)2 TransientIdentity (org.olat.admin.user.imp.TransientIdentity)2 OLATRuntimeException (org.olat.core.logging.OLATRuntimeException)2