Search in sources :

Example 31 with Section

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

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 32 with Section

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

the class QTIQPoolServiceProvider method exportToEditorPackage.

public void exportToEditorPackage(QTIEditorPackageImpl editorPackage, List<QuestionItemShort> items, boolean newTest) {
    VFSContainer editorContainer = editorPackage.getBaseDir();
    List<Long> itemKeys = toKeys(items);
    List<QuestionItemFull> fullItems = questionItemDao.loadByIds(itemKeys);
    Section section = editorPackage.getQTIDocument().getAssessment().getSections().get(0);
    if (newTest) {
        // remove autogenerated question
        section.getItems().clear();
    }
    QTIExportProcessor processor = new QTIExportProcessor(qpoolFileStorage);
    for (QuestionItemFull fullItem : fullItems) {
        Element itemEl = processor.exportToQTIEditor(fullItem, editorContainer);
        Item item = (Item) new ParserManager().parse(itemEl);
        item.setIdent(QTIEditHelper.generateNewIdent(item.getIdent()));
        section.getItems().add(item);
    }
}
Also used : ParserManager(org.olat.ims.qti.editor.beecom.parser.ParserManager) Item(org.olat.ims.qti.editor.beecom.objects.Item) VFSItem(org.olat.core.util.vfs.VFSItem) QuestionItem(org.olat.modules.qpool.QuestionItem) QuestionItemFull(org.olat.modules.qpool.QuestionItemFull) VFSContainer(org.olat.core.util.vfs.VFSContainer) Element(org.dom4j.Element) Section(org.olat.ims.qti.editor.beecom.objects.Section)

Example 33 with Section

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

the class QTIStatisticResourceResult method getController.

public Controller getController(UserRequest ureq, WindowControl wControl, TooledStackedPanel stackPanel, TreeNode selectedNode, boolean printMode) {
    if (selectedNode instanceof StatisticResourceNode) {
        return createAssessmentController(ureq, wControl, stackPanel, printMode);
    } else if (selectedNode instanceof SectionNode) {
        return createAssessmentController(ureq, wControl, stackPanel, printMode);
    } else if (selectedNode instanceof ItemNode) {
        Section section = null;
        INode sectionNode = selectedNode.getParent();
        if (sectionNode instanceof SectionNode) {
            section = (Section) ((SectionNode) sectionNode).getUserObject();
        }
        Item item = (Item) ((ItemNode) selectedNode).getUserObject();
        return createItemController(ureq, wControl, section, item, printMode);
    }
    return null;
}
Also used : Item(org.olat.ims.qti.editor.beecom.objects.Item) ItemNode(org.olat.ims.qti.editor.tree.ItemNode) INode(org.olat.core.util.nodes.INode) StatisticResourceNode(org.olat.course.statistic.StatisticResourceNode) SectionNode(org.olat.ims.qti.editor.tree.SectionNode) Section(org.olat.ims.qti.editor.beecom.objects.Section)

Example 34 with Section

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

Section (org.olat.ims.qti.editor.beecom.objects.Section)34 Item (org.olat.ims.qti.editor.beecom.objects.Item)28 Assessment (org.olat.ims.qti.editor.beecom.objects.Assessment)18 ItemNode (org.olat.ims.qti.editor.tree.ItemNode)10 SectionNode (org.olat.ims.qti.editor.tree.SectionNode)10 VFSItem (org.olat.core.util.vfs.VFSItem)8 ArrayList (java.util.ArrayList)6 Iterator (java.util.Iterator)6 List (java.util.List)6 AssessmentNode (org.olat.ims.qti.editor.tree.AssessmentNode)6 Control (org.olat.ims.qti.editor.beecom.objects.Control)5 Element (org.dom4j.Element)4 Translator (org.olat.core.gui.translator.Translator)4 INode (org.olat.core.util.nodes.INode)4 VFSContainer (org.olat.core.util.vfs.VFSContainer)4 Response (org.olat.ims.qti.editor.beecom.objects.Response)4 GenericQtiNode (org.olat.ims.qti.editor.tree.GenericQtiNode)4 QTIDocument (org.olat.ims.qti.editor.beecom.objects.QTIDocument)3 QTIObject (org.olat.ims.qti.editor.beecom.objects.QTIObject)3 File (java.io.File)2