Search in sources :

Example 1 with Assessment

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

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

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

the class QTIEditHelper method getFeedbacks.

/**
 * @param object
 * @return
 */
private static List<Feedback> getFeedbacks(QTIObject object) {
    List<Feedback> feedbacks = null;
    if (Item.class.isAssignableFrom(object.getClass())) {
        Item item = (Item) object;
        feedbacks = item.getItemfeedbacks();
    } else if (Section.class.isAssignableFrom(object.getClass())) {
        Section section = (Section) object;
        feedbacks = section.getSectionfeedbacks();
    } else if (Assessment.class.isAssignableFrom(object.getClass())) {
        Assessment assessment = (Assessment) object;
        feedbacks = assessment.getAssessfeedbacks();
    }
    return feedbacks;
}
Also used : Item(org.olat.ims.qti.editor.beecom.objects.Item) VFSItem(org.olat.core.util.vfs.VFSItem) Feedback(org.olat.ims.qti.editor.beecom.objects.Feedback) Assessment(org.olat.ims.qti.editor.beecom.objects.Assessment) Section(org.olat.ims.qti.editor.beecom.objects.Section)

Example 3 with Assessment

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

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

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

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

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

the class OLATUpgrade_11_0_0 method checkEssay.

private boolean checkEssay(RepositoryEntry testEntry) {
    if (qtiEssayMap.containsKey(testEntry.getKey())) {
        return qtiEssayMap.get(testEntry.getKey()).booleanValue();
    }
    TestFileResource fr = new TestFileResource();
    fr.overrideResourceableId(testEntry.getOlatResource().getResourceableId());
    TransientIdentity pseudoIdentity = new TransientIdentity();
    pseudoIdentity.setName("transient");
    Translator translator = Util.createPackageTranslator(QTIModule.class, Locale.ENGLISH);
    try {
        QTIEditorPackage qtiPackage = new QTIEditorPackageImpl(pseudoIdentity, fr, null, translator);
        if (qtiPackage.getQTIDocument() != null && qtiPackage.getQTIDocument().getAssessment() != null) {
            Assessment ass = qtiPackage.getQTIDocument().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")) {
                        qtiEssayMap.put(testEntry.getKey(), Boolean.TRUE);
                        return true;
                    }
                }
            }
        }
    } catch (OLATRuntimeException e) {
        log.warn("QTI without content in repository entry: " + testEntry.getKey(), e);
    }
    qtiEssayMap.put(testEntry.getKey(), Boolean.FALSE);
    return false;
}
Also used : TransientIdentity(org.olat.admin.user.imp.TransientIdentity) Item(org.olat.ims.qti.editor.beecom.objects.Item) Translator(org.olat.core.gui.translator.Translator) OLATRuntimeException(org.olat.core.logging.OLATRuntimeException) QTIEditorPackageImpl(org.olat.ims.qti.editor.QTIEditorPackageImpl) Assessment(org.olat.ims.qti.editor.beecom.objects.Assessment) TestFileResource(org.olat.ims.qti.fileresource.TestFileResource) QTIEditorPackage(org.olat.ims.qti.editor.QTIEditorPackage) 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