Search in sources :

Example 1 with OutcomesProcessing

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

the class OutcomesProcessingParser method parse.

/**
 * @see org.olat.ims.qti.editor.beecom.IParser#parse(org.dom4j.Element)
 */
public Object parse(Element element) {
    // assert element.getName().equalsIgnoreCase("outcomes_processing");
    OutcomesProcessing outcomesProcessing = new OutcomesProcessing();
    List decvars = element.selectNodes("*/decvar");
    if (decvars.size() == 0)
        return outcomesProcessing;
    Element decvar = (Element) decvars.get(0);
    for (Iterator iter = decvar.attributeIterator(); iter.hasNext(); ) {
        Attribute attr = (Attribute) iter.next();
        outcomesProcessing.setField(attr.getName(), attr.getValue());
    }
    return outcomesProcessing;
}
Also used : Attribute(org.dom4j.Attribute) Element(org.dom4j.Element) OutcomesProcessing(org.olat.ims.qti.editor.beecom.objects.OutcomesProcessing) Iterator(java.util.Iterator) List(java.util.List)

Example 2 with OutcomesProcessing

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

the class AssessmentController method event.

/**
 * @see org.olat.core.gui.control.DefaultController#event(org.olat.core.gui.UserRequest,
 *      org.olat.core.gui.components.Component, org.olat.core.gui.control.Event)
 */
public void event(UserRequest ureq, Component source, Event event) {
    if (source == main) {
        if (event.getCommand().equals("sao")) {
            // asessment options submitted
            // Handle all data that is useless in survey mode
            String newTitle = ureq.getParameter("title");
            String oldTitle = assessment.getTitle();
            boolean hasTitleChange = newTitle != null && !newTitle.equals(oldTitle);
            String newObjectives = ureq.getParameter("objectives");
            String oldObjectives = assessment.getObjectives();
            boolean hasObjectivesChange = newObjectives != null && !newObjectives.equals(oldObjectives);
            NodeBeforeChangeEvent nce = new NodeBeforeChangeEvent();
            if (hasTitleChange) {
                nce.setNewTitle(newTitle);
            }
            if (hasObjectivesChange) {
                nce.setNewObjectives(newObjectives);
            }
            if (hasTitleChange || hasObjectivesChange) {
                // create a memento first
                fireEvent(ureq, nce);
                // then apply changes
                assessment.setTitle(newTitle);
                assessment.setObjectives(newObjectives);
            }
            // 
            if (!surveyMode && !restrictedEdit) {
                // ordering
                assessment.getSelection_ordering().setOrderType(ureq.getParameter("order_type"));
                assessment.getSelection_ordering().setSelectionNumber(ureq.getParameter("selection_number"));
                main.contextPut("order_type", assessment.getSelection_ordering().getOrderType());
                main.contextPut("selection_number", String.valueOf(assessment.getSelection_ordering().getSelectionNumber()));
                Control tmpControl = QTIEditHelper.getControl(assessment);
                boolean oldInheritControls = assessment.isInheritControls();
                boolean newInheritControls = ureq.getParameter("inheritswitch").equals("Yes");
                assessment.setInheritControls(newInheritControls);
                String feedbackswitchTmp = ureq.getParameter("feedbackswitch");
                String hintswitchTmp = ureq.getParameter("hintswitch");
                String solutionswitchTmp = ureq.getParameter("solutionswitch");
                tmpControl.setSwitches(feedbackswitchTmp, hintswitchTmp, solutionswitchTmp);
                if (tmpControl.getHint() != Control.CTRL_UNDEF || tmpControl.getHint() != Control.CTRL_UNDEF || tmpControl.getSolution() != Control.CTRL_UNDEF)
                    assessment.setInheritControls(true);
                if (oldInheritControls && !newInheritControls) {
                    tmpControl.setSwitches(Control.CTRL_UNDEF, Control.CTRL_UNDEF, Control.CTRL_UNDEF);
                    assessment.setInheritControls(false);
                }
                OutcomesProcessing outcomesProcessing = assessment.getOutcomes_processing();
                if (outcomesProcessing == null) {
                    // Create outcomes processing object if it doesn't already exist.
                    // Happens
                    // when creating a new assessment
                    outcomesProcessing = new OutcomesProcessing();
                    assessment.setOutcomes_processing(outcomesProcessing);
                }
                String cutval = ureq.getParameter(OutcomesProcessing.CUTVALUE);
                try {
                    Float.parseFloat(cutval);
                } catch (NumberFormatException nfe) {
                    cutval = "0.0";
                    this.showWarning("error.cutval");
                }
                outcomesProcessing.setField(OutcomesProcessing.CUTVALUE, cutval);
                main.contextPut(OutcomesProcessing.CUTVALUE, cutval);
                if (ureq.getParameter("duration").equals("Yes")) {
                    String durationMin = ureq.getParameter("duration_min");
                    String durationSec = ureq.getParameter("duration_sec");
                    try {
                        Integer.parseInt(durationMin);
                        int sec = Integer.parseInt(durationSec);
                        if (sec > 60)
                            throw new NumberFormatException();
                    } catch (NumberFormatException nfe) {
                        durationMin = "0";
                        durationSec = "0";
                        this.showWarning("error.duration");
                    }
                    Duration d = new Duration(durationMin, durationSec);
                    assessment.setDuration(d);
                    main.contextPut("duration", assessment.getDuration());
                } else {
                    assessment.setDuration(null);
                    main.contextRemove("duration");
                }
            }
            qtiPackage.serializeQTIDocument();
            // refresh for removing dirty marking of button even if nothing changed
            main.setDirty(true);
        }
    }
}
Also used : WindowControl(org.olat.core.gui.control.WindowControl) Control(org.olat.ims.qti.editor.beecom.objects.Control) OutcomesProcessing(org.olat.ims.qti.editor.beecom.objects.OutcomesProcessing) Duration(org.olat.ims.qti.editor.beecom.objects.Duration)

Example 3 with OutcomesProcessing

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

the class QTIWordExport method renderAssessment.

public static void renderAssessment(Assessment assessment, OpenXMLDocument document, Translator translator) {
    String title = assessment.getTitle();
    document.appendTitle(title);
    OutcomesProcessing outcomesProcessing = assessment.getOutcomes_processing();
    if (outcomesProcessing != null) {
        String cutValue = outcomesProcessing.getField(OutcomesProcessing.CUTVALUE);
        String cutValueLabel = translator.translate("cut_value");
        document.appendText(cutValueLabel + ": " + cutValue, true);
    }
    String objectives = assessment.getObjectives();
    document.appendText(objectives, true);
}
Also used : OutcomesProcessing(org.olat.ims.qti.editor.beecom.objects.OutcomesProcessing)

Example 4 with OutcomesProcessing

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

the class OutcomesProcessingParser method parse.

/**
 * @see org.olat.ims.qti.editor.beecom.IParser#parse(org.dom4j.Element)
 */
public Object parse(Element element) {
    // assert element.getName().equalsIgnoreCase("outcomes_processing");
    OutcomesProcessing outcomesProcessing = new OutcomesProcessing();
    List decvars = element.selectNodes("*/decvar");
    if (decvars.size() == 0)
        return outcomesProcessing;
    Element decvar = (Element) decvars.get(0);
    for (Iterator iter = decvar.attributeIterator(); iter.hasNext(); ) {
        Attribute attr = (Attribute) iter.next();
        outcomesProcessing.setField(attr.getName(), attr.getValue());
    }
    return outcomesProcessing;
}
Also used : Attribute(org.dom4j.Attribute) Element(org.dom4j.Element) OutcomesProcessing(org.olat.ims.qti.editor.beecom.objects.OutcomesProcessing) Iterator(java.util.Iterator) List(java.util.List)

Example 5 with OutcomesProcessing

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

the class AssessmentController method event.

/**
 * @see org.olat.core.gui.control.DefaultController#event(org.olat.core.gui.UserRequest,
 *      org.olat.core.gui.components.Component, org.olat.core.gui.control.Event)
 */
public void event(UserRequest ureq, Component source, Event event) {
    if (source == main) {
        if (event.getCommand().equals("sao")) {
            // asessment options submitted
            // Handle all data that is useless in survey mode
            String newTitle = ureq.getParameter("title");
            String oldTitle = assessment.getTitle();
            boolean hasTitleChange = newTitle != null && !newTitle.equals(oldTitle);
            String newObjectives = ureq.getParameter("objectives");
            String oldObjectives = assessment.getObjectives();
            boolean hasObjectivesChange = newObjectives != null && !newObjectives.equals(oldObjectives);
            NodeBeforeChangeEvent nce = new NodeBeforeChangeEvent();
            if (hasTitleChange) {
                nce.setNewTitle(newTitle);
            }
            if (hasObjectivesChange) {
                nce.setNewObjectives(newObjectives);
            }
            if (hasTitleChange || hasObjectivesChange) {
                // create a memento first
                fireEvent(ureq, nce);
                // then apply changes
                assessment.setTitle(newTitle);
                assessment.setObjectives(newObjectives);
            }
            // 
            if (!surveyMode && !restrictedEdit) {
                // ordering
                assessment.getSelection_ordering().setOrderType(ureq.getParameter("order_type"));
                assessment.getSelection_ordering().setSelectionNumber(ureq.getParameter("selection_number"));
                main.contextPut("order_type", assessment.getSelection_ordering().getOrderType());
                main.contextPut("selection_number", String.valueOf(assessment.getSelection_ordering().getSelectionNumber()));
                Control tmpControl = QTIEditHelper.getControl(assessment);
                boolean oldInheritControls = assessment.isInheritControls();
                boolean newInheritControls = ureq.getParameter("inheritswitch").equals("Yes");
                assessment.setInheritControls(newInheritControls);
                String feedbackswitchTmp = ureq.getParameter("feedbackswitch");
                String hintswitchTmp = ureq.getParameter("hintswitch");
                String solutionswitchTmp = ureq.getParameter("solutionswitch");
                tmpControl.setSwitches(feedbackswitchTmp, hintswitchTmp, solutionswitchTmp);
                if (tmpControl.getHint() != Control.CTRL_UNDEF || tmpControl.getHint() != Control.CTRL_UNDEF || tmpControl.getSolution() != Control.CTRL_UNDEF)
                    assessment.setInheritControls(true);
                if (oldInheritControls && !newInheritControls) {
                    tmpControl.setSwitches(Control.CTRL_UNDEF, Control.CTRL_UNDEF, Control.CTRL_UNDEF);
                    assessment.setInheritControls(false);
                }
                OutcomesProcessing outcomesProcessing = assessment.getOutcomes_processing();
                if (outcomesProcessing == null) {
                    // Create outcomes processing object if it doesn't already exist.
                    // Happens
                    // when creating a new assessment
                    outcomesProcessing = new OutcomesProcessing();
                    assessment.setOutcomes_processing(outcomesProcessing);
                }
                String cutval = ureq.getParameter(OutcomesProcessing.CUTVALUE);
                try {
                    Float.parseFloat(cutval);
                } catch (NumberFormatException nfe) {
                    cutval = "0.0";
                    this.showWarning("error.cutval");
                }
                outcomesProcessing.setField(OutcomesProcessing.CUTVALUE, cutval);
                main.contextPut(OutcomesProcessing.CUTVALUE, cutval);
                if (ureq.getParameter("duration").equals("Yes")) {
                    String durationMin = ureq.getParameter("duration_min");
                    String durationSec = ureq.getParameter("duration_sec");
                    try {
                        Integer.parseInt(durationMin);
                        int sec = Integer.parseInt(durationSec);
                        if (sec > 60)
                            throw new NumberFormatException();
                    } catch (NumberFormatException nfe) {
                        durationMin = "0";
                        durationSec = "0";
                        this.showWarning("error.duration");
                    }
                    Duration d = new Duration(durationMin, durationSec);
                    assessment.setDuration(d);
                    main.contextPut("duration", assessment.getDuration());
                } else {
                    assessment.setDuration(null);
                    main.contextRemove("duration");
                }
            }
            qtiPackage.serializeQTIDocument();
            // refresh for removing dirty marking of button even if nothing changed
            main.setDirty(true);
        }
    }
}
Also used : WindowControl(org.olat.core.gui.control.WindowControl) Control(org.olat.ims.qti.editor.beecom.objects.Control) OutcomesProcessing(org.olat.ims.qti.editor.beecom.objects.OutcomesProcessing) Duration(org.olat.ims.qti.editor.beecom.objects.Duration)

Aggregations

OutcomesProcessing (org.olat.ims.qti.editor.beecom.objects.OutcomesProcessing)10 Control (org.olat.ims.qti.editor.beecom.objects.Control)6 Iterator (java.util.Iterator)4 List (java.util.List)4 Attribute (org.dom4j.Attribute)4 Element (org.dom4j.Element)4 Assessment (org.olat.ims.qti.editor.beecom.objects.Assessment)4 File (java.io.File)2 ArrayList (java.util.ArrayList)2 WindowControl (org.olat.core.gui.control.WindowControl)2 Duration (org.olat.ims.qti.editor.beecom.objects.Duration)2 Metadata (org.olat.ims.qti.editor.beecom.objects.Metadata)2 QTIObject (org.olat.ims.qti.editor.beecom.objects.QTIObject)2 Section (org.olat.ims.qti.editor.beecom.objects.Section)2 SelectionOrdering (org.olat.ims.qti.editor.beecom.objects.SelectionOrdering)2 AssessmentTestBuilder (org.olat.ims.qti21.model.xml.AssessmentTestBuilder)2 AssessmentSection (uk.ac.ed.ph.jqtiplus.node.test.AssessmentSection)2 AssessmentTest (uk.ac.ed.ph.jqtiplus.node.test.AssessmentTest)2 ItemSessionControl (uk.ac.ed.ph.jqtiplus.node.test.ItemSessionControl)2 TestPart (uk.ac.ed.ph.jqtiplus.node.test.TestPart)2