Search in sources :

Example 1 with Feedback

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

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

the class QTIEditHelper method getFeedbackMaterial.

/**
 * @param object
 * @param sIdent
 * @return
 */
public static Material getFeedbackMaterial(QTIObject object, String sIdent) {
    Feedback feedback = getFeedback(object, sIdent);
    Material mat = null;
    try {
        mat = (Material) feedback.getMaterials().get(0);
    } catch (NullPointerException e) {
    // feedback is null
    }
    return mat;
}
Also used : Feedback(org.olat.ims.qti.editor.beecom.objects.Feedback) Material(org.olat.ims.qti.editor.beecom.objects.Material)

Example 3 with Feedback

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

the class QTIEditHelper method setFeedback.

/**
 * Set feedback
 * @param object
 * @param feedbackString
 * @param sIdent
 */
public static void setFeedback(QTIObject object, String feedbackString, String sIdent) {
    List<Feedback> feedbacks = getFeedbacks(object);
    Feedback feedback = getFeedback(sIdent, feedbacks);
    if (feedbackString == null || feedbackString.trim().length() == 0) {
        feedbacks.remove(feedback);
        return;
    }
    if (feedback != null) {
        feedbackString = feedbackString.trim();
        List matList = feedback.getMaterials();
        if (matList.size() > 0) {
            Material mat = (Material) feedback.getMaterials().get(0);
            if (mat == null) {
                mat = new Material();
                mat.getElements().add(new Mattext(feedbackString));
                feedback.getMaterials().add(mat);
            } else if (mat.getElements().size() > 0) {
                mat.getElements().set(0, new Mattext(feedbackString));
            } else {
                mat.getElements().add(new Mattext(feedbackString));
            }
        } else {
            Material mat = new Material();
            mat.getElements().add(new Mattext(feedbackString));
            feedback.getMaterials().add(mat);
        }
    } else {
        Feedback newFeedback = new Feedback();
        newFeedback.setIdent(sIdent);
        newFeedback.setView("All");
        Mattext newMattext = new Mattext(feedbackString);
        List<QTIObject> newMattextL = new ArrayList<>();
        newMattextL.add(newMattext);
        Material material = new Material();
        material.setElements(newMattextL);
        List<Material> newMaterialL = new ArrayList<>();
        newMaterialL.add(material);
        newFeedback.setMaterials(newMaterialL);
        feedbacks.add(newFeedback);
    }
}
Also used : Mattext(org.olat.ims.qti.editor.beecom.objects.Mattext) QTIObject(org.olat.ims.qti.editor.beecom.objects.QTIObject) Feedback(org.olat.ims.qti.editor.beecom.objects.Feedback) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) Material(org.olat.ims.qti.editor.beecom.objects.Material)

Example 4 with Feedback

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

the class QTIEditHelper method setFeedback.

/**
 * Set feedback
 * @param object
 * @param feedbackString
 * @param sIdent
 */
public static void setFeedback(QTIObject object, String feedbackString, String sIdent) {
    List<Feedback> feedbacks = getFeedbacks(object);
    Feedback feedback = getFeedback(sIdent, feedbacks);
    if (feedbackString == null || feedbackString.trim().length() == 0) {
        feedbacks.remove(feedback);
        return;
    }
    if (feedback != null) {
        feedbackString = feedbackString.trim();
        List matList = feedback.getMaterials();
        if (matList.size() > 0) {
            Material mat = (Material) feedback.getMaterials().get(0);
            if (mat == null) {
                mat = new Material();
                mat.getElements().add(new Mattext(feedbackString));
                feedback.getMaterials().add(mat);
            } else if (mat.getElements().size() > 0) {
                mat.getElements().set(0, new Mattext(feedbackString));
            } else {
                mat.getElements().add(new Mattext(feedbackString));
            }
        } else {
            Material mat = new Material();
            mat.getElements().add(new Mattext(feedbackString));
            feedback.getMaterials().add(mat);
        }
    } else {
        Feedback newFeedback = new Feedback();
        newFeedback.setIdent(sIdent);
        newFeedback.setView("All");
        Mattext newMattext = new Mattext(feedbackString);
        List<QTIObject> newMattextL = new ArrayList<>();
        newMattextL.add(newMattext);
        Material material = new Material();
        material.setElements(newMattextL);
        List<Material> newMaterialL = new ArrayList<>();
        newMaterialL.add(material);
        newFeedback.setMaterials(newMaterialL);
        feedbacks.add(newFeedback);
    }
}
Also used : Mattext(org.olat.ims.qti.editor.beecom.objects.Mattext) QTIObject(org.olat.ims.qti.editor.beecom.objects.QTIObject) Feedback(org.olat.ims.qti.editor.beecom.objects.Feedback) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) Material(org.olat.ims.qti.editor.beecom.objects.Material)

Example 5 with Feedback

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

the class QTIEditHelper method getFeedbackMaterial.

/**
 * @param object
 * @param sIdent
 * @return
 */
public static Material getFeedbackMaterial(QTIObject object, String sIdent) {
    Feedback feedback = getFeedback(object, sIdent);
    Material mat = null;
    try {
        mat = (Material) feedback.getMaterials().get(0);
    } catch (NullPointerException e) {
    // feedback is null
    }
    return mat;
}
Also used : Feedback(org.olat.ims.qti.editor.beecom.objects.Feedback) Material(org.olat.ims.qti.editor.beecom.objects.Material)

Aggregations

Feedback (org.olat.ims.qti.editor.beecom.objects.Feedback)8 ArrayList (java.util.ArrayList)4 List (java.util.List)4 Material (org.olat.ims.qti.editor.beecom.objects.Material)4 Iterator (java.util.Iterator)2 Attribute (org.dom4j.Attribute)2 Element (org.dom4j.Element)2 VFSItem (org.olat.core.util.vfs.VFSItem)2 Assessment (org.olat.ims.qti.editor.beecom.objects.Assessment)2 Item (org.olat.ims.qti.editor.beecom.objects.Item)2 Mattext (org.olat.ims.qti.editor.beecom.objects.Mattext)2 QTIObject (org.olat.ims.qti.editor.beecom.objects.QTIObject)2 Section (org.olat.ims.qti.editor.beecom.objects.Section)2