Search in sources :

Example 6 with Section

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

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

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

the class QTIEditHelper method getMediaReferences.

/**
 * Retrieves all referenced media by thisItem if filterOut is false,
 * or all referenced media by other items if filterOut is true.
 * <p>
 * Iterates over all sections, items, etc. </br>
 * -> if filterOut is true gets all references except those for thisItem.
 * -> if filterOut is false gets all references for thisItem.
 *
 * @param qtiDocument
 * @param thisItem
 * @param filterOut
 * @return Returns empty set if no reference found.
 */
private static Set<String> getMediaReferences(QTIDocument qtiDocument, Item thisItem, boolean filterOut) {
    HashSet<String> returnSet = new HashSet<String>();
    // sections
    List sectionList = qtiDocument.getAssessment().getSections();
    Iterator sectionIterator = sectionList.iterator();
    while (sectionIterator.hasNext()) {
        // section
        Section section = (Section) sectionIterator.next();
        List itemList = section.getItems();
        Iterator listIterator = itemList.iterator();
        while (listIterator.hasNext()) {
            // item
            Item item = (Item) listIterator.next();
            if ((filterOut && thisItem.getIdent().equals(item.getIdent())) || (!filterOut && !thisItem.getIdent().equals(item.getIdent()))) {
                continue;
            }
            // question
            Material material = item.getQuestion().getQuestion();
            if (material != null) {
                String htmlContent = material.renderAsHtmlForEditor();
                // parse filenames
                returnSet.addAll(getMediaFileNames(htmlContent));
            }
            // responses
            List responseList = item.getQuestion().getResponses();
            Iterator responseIterator = responseList.iterator();
            while (responseIterator.hasNext()) {
                Response response = (Response) responseIterator.next();
                Material responseMat = response.getContent();
                // parse filenames
                if (responseMat != null) {
                    returnSet.addAll(getMediaFileNames(responseMat.renderAsHtmlForEditor()));
                }
                // response-level feedback
                Material responseFeedbackMat = QTIEditHelper.getFeedbackOlatRespMaterial(item, response.getIdent());
                if (responseFeedbackMat != null) {
                    returnSet.addAll(getMediaFileNames(responseFeedbackMat.renderAsHtmlForEditor()));
                }
            }
            // feedback
            Material masteryMat = QTIEditHelper.getFeedbackMasteryMaterial(item);
            if (masteryMat != null) {
                returnSet.addAll(getMediaFileNames(masteryMat.renderAsHtmlForEditor()));
            }
            Material failureMat = QTIEditHelper.getFeedbackFailMaterial(item);
            if (failureMat != null) {
                returnSet.addAll(getMediaFileNames(failureMat.renderAsHtmlForEditor()));
            }
        }
    }
    return returnSet;
}
Also used : ChoiceResponse(org.olat.ims.qti.editor.beecom.objects.ChoiceResponse) FIBResponse(org.olat.ims.qti.editor.beecom.objects.FIBResponse) Response(org.olat.ims.qti.editor.beecom.objects.Response) EssayResponse(org.olat.ims.qti.editor.beecom.objects.EssayResponse) Item(org.olat.ims.qti.editor.beecom.objects.Item) VFSItem(org.olat.core.util.vfs.VFSItem) Iterator(java.util.Iterator) ArrayList(java.util.ArrayList) List(java.util.List) Material(org.olat.ims.qti.editor.beecom.objects.Material) Section(org.olat.ims.qti.editor.beecom.objects.Section) HashSet(java.util.HashSet)

Example 9 with Section

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

the class QTIEditHelper method createSection.

/**
 * Creates an empty section
 * @param trans
 * @return Section
 */
public static Section createSection(Translator trans) {
    Section section = new Section();
    section.setIdent(CodeHelper.getGlobalForeverUniqueID());
    section.setTitle(trans.translate("editor.newsection"));
    return section;
}
Also used : Section(org.olat.ims.qti.editor.beecom.objects.Section)

Example 10 with Section

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

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