Search in sources :

Example 16 with Assessment

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

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 17 with Assessment

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

the class QTIEditHelper method createAssessment.

/**
 * Creates an empty assessment
 * @param title
 * @param type
 * @return Assessment
 */
public static Assessment createAssessment(String title, String type) {
    Assessment assessment = new Assessment();
    assessment.setIdent(CodeHelper.getGlobalForeverUniqueID());
    assessment.setTitle(title);
    Metadata meta = new Metadata();
    meta.setField(AssessmentInstance.QMD_LABEL_TYPE, type);
    assessment.setMetadata(meta);
    return assessment;
}
Also used : Assessment(org.olat.ims.qti.editor.beecom.objects.Assessment) Metadata(org.olat.ims.qti.editor.beecom.objects.Metadata)

Example 18 with Assessment

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

the class QTIEditHelper method getControl.

/**
 * Get controls.
 * @param object
 * @return Controls.
 */
public static Control getControl(QTIObject object) {
    Control control = null;
    List controls = null;
    if (Item.class.isAssignableFrom(object.getClass())) {
        Item item = (Item) object;
        controls = item.getItemcontrols();
    } else if (Section.class.isAssignableFrom(object.getClass())) {
        Section section = (Section) object;
        controls = section.getSectioncontrols();
    } else if (Assessment.class.isAssignableFrom(object.getClass())) {
        Assessment assessment = (Assessment) object;
        controls = assessment.getAssessmentcontrols();
    }
    for (Iterator i = controls.iterator(); i.hasNext(); ) {
        Control tmp = (Control) i.next();
        if (tmp.getView() != null) {
            if (tmp.getView().equalsIgnoreCase("all")) {
                control = tmp;
                break;
            }
        } else {
            control = tmp;
        }
    }
    return control;
}
Also used : Item(org.olat.ims.qti.editor.beecom.objects.Item) VFSItem(org.olat.core.util.vfs.VFSItem) Control(org.olat.ims.qti.editor.beecom.objects.Control) Assessment(org.olat.ims.qti.editor.beecom.objects.Assessment) Iterator(java.util.Iterator) ArrayList(java.util.ArrayList) List(java.util.List) Section(org.olat.ims.qti.editor.beecom.objects.Section)

Example 19 with Assessment

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

the class QTIEditorMainController method doExportQItem.

private void doExportQItem() {
    GenericQtiNode selectedNode = menuTreeModel.getQtiNode(menuTree.getSelectedNodeId());
    if (selectedNode instanceof ItemNode) {
        ItemNode itemNode = (ItemNode) selectedNode;
        QTIObject qtiObject = itemNode.getUnderlyingQTIObject();
        if (qtiObject instanceof Item) {
            ItemAndMetadata item = new ItemAndMetadata((Item) qtiObject);
            VFSContainer editorContainer = qtiPackage.getBaseDir();
            qtiQpoolServiceProvider.importBeecomItem(getIdentity(), item, editorContainer, getLocale());
            showInfo("export.qpool.successful", "1");
        }
    } else if (selectedNode instanceof SectionNode) {
        SectionNode sectionNode = (SectionNode) selectedNode;
        QTIObject qtiObject = sectionNode.getUnderlyingQTIObject();
        if (qtiObject instanceof Section) {
            int count = doExportSection((Section) qtiObject);
            showInfo("export.qpool.successful", Integer.toString(count));
        }
    } else if (selectedNode instanceof AssessmentNode) {
        AssessmentNode assessmentNode = (AssessmentNode) selectedNode;
        QTIObject qtiObject = assessmentNode.getUnderlyingQTIObject();
        if (qtiObject instanceof Assessment) {
            int count = doExportAssessment((Assessment) qtiObject);
            showInfo("export.qpool.successful", Integer.toString(count));
        }
    }
}
Also used : Item(org.olat.ims.qti.editor.beecom.objects.Item) ItemNode(org.olat.ims.qti.editor.tree.ItemNode) QTIObject(org.olat.ims.qti.editor.beecom.objects.QTIObject) AssessmentNode(org.olat.ims.qti.editor.tree.AssessmentNode) GenericQtiNode(org.olat.ims.qti.editor.tree.GenericQtiNode) VFSContainer(org.olat.core.util.vfs.VFSContainer) Assessment(org.olat.ims.qti.editor.beecom.objects.Assessment) ItemAndMetadata(org.olat.ims.qti.questionimport.ItemAndMetadata) SectionNode(org.olat.ims.qti.editor.tree.SectionNode) Section(org.olat.ims.qti.editor.beecom.objects.Section)

Example 20 with Assessment

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

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