Search in sources :

Example 26 with Control

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

the class QTIEditHelper method createEssayItem.

/**
 * Creates a new essay item
 * @param trans
 * @return New essay item.
 */
public static Item createEssayItem(Translator trans) {
    // create item
    Item newItem = new Item();
    newItem.setIdent(EDITOR_IDENT + ":" + ITEM_TYPE_ESSAY + ":" + String.valueOf(CodeHelper.getRAMUniqueID()));
    newItem.setTitle(trans.translate("editor.newquestion"));
    newItem.setLabel("");
    // conrols
    Control control = new Control();
    List<Control> controls = new ArrayList<Control>();
    controls.add(control);
    newItem.setItemcontrols(controls);
    QTIEditHelper.setFeedbackMastery(newItem, "");
    QTIEditHelper.setFeedbackFail(newItem, "");
    EssayQuestion essayquestion = new EssayQuestion();
    essayquestion.getQuestion().getElements().add(new Mattext(trans.translate("editor.newquestiontext")));
    essayquestion.setSingleCorrect(true);
    essayquestion.setSingleCorrectScore(1);
    EssayResponse response = new EssayResponse();
    Material mat = new Material();
    mat.add(new Mattext(trans.translate("editor.newtextelement")));
    response.setContent(mat);
    essayquestion.getResponses().add(response);
    newItem.setQuestion(essayquestion);
    return newItem;
}
Also used : EssayQuestion(org.olat.ims.qti.editor.beecom.objects.EssayQuestion) 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) Mattext(org.olat.ims.qti.editor.beecom.objects.Mattext) EssayResponse(org.olat.ims.qti.editor.beecom.objects.EssayResponse) ArrayList(java.util.ArrayList) Material(org.olat.ims.qti.editor.beecom.objects.Material)

Example 27 with Control

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

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

the class QTIEditHelper method createFIBItem.

/**
 * Creates a new FIB item
 * @param trans
 * @return New fib item.
 */
public static Item createFIBItem(Translator trans) {
    // create item
    Item newItem = new Item();
    newItem.setIdent(EDITOR_IDENT + ":" + ITEM_TYPE_FIB + ":" + String.valueOf(CodeHelper.getRAMUniqueID()));
    newItem.setTitle(trans.translate("editor.newquestion"));
    newItem.setLabel("");
    // conrols
    Control control = new Control();
    List<Control> controls = new ArrayList<Control>();
    controls.add(control);
    newItem.setItemcontrols(controls);
    QTIEditHelper.setFeedbackMastery(newItem, "");
    QTIEditHelper.setFeedbackFail(newItem, "");
    FIBQuestion fibquestion = new FIBQuestion();
    fibquestion.getQuestion().getElements().add(new Mattext(trans.translate("editor.newquestiontext")));
    fibquestion.setSingleCorrect(true);
    fibquestion.setSingleCorrectScore(1);
    FIBResponse response = new FIBResponse();
    response.setType(FIBResponse.TYPE_CONTENT);
    Material mat = new Material();
    mat.add(new Mattext(trans.translate("editor.newtextelement")));
    response.setContent(mat);
    fibquestion.getResponses().add(response);
    newItem.setQuestion(fibquestion);
    return newItem;
}
Also used : FIBResponse(org.olat.ims.qti.editor.beecom.objects.FIBResponse) 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) Mattext(org.olat.ims.qti.editor.beecom.objects.Mattext) ArrayList(java.util.ArrayList) Material(org.olat.ims.qti.editor.beecom.objects.Material) FIBQuestion(org.olat.ims.qti.editor.beecom.objects.FIBQuestion)

Example 29 with Control

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

the class QTIEditHelper method createKPRIMItem.

/**
 * Creates a new Kprim item
 * @param trans
 * @return New Kprim item.
 */
public static Item createKPRIMItem(Translator trans) {
    // create item
    Item newItem = new Item();
    newItem.setIdent(EDITOR_IDENT + ":" + ITEM_TYPE_KPRIM + ":" + String.valueOf(CodeHelper.getRAMUniqueID()));
    newItem.setTitle(trans.translate("editor.newquestion"));
    newItem.setLabel("");
    // controls
    Control control = new Control();
    List<Control> controls = new ArrayList<Control>();
    controls.add(control);
    newItem.setItemcontrols(controls);
    // prepare question
    float maxValue = 1;
    ChoiceQuestion question = new ChoiceQuestion();
    question.setLable(trans.translate("editor.newquestion"));
    question.getQuestion().getElements().add(new Mattext(trans.translate("editor.newquestiontext")));
    question.setType(Question.TYPE_KPRIM);
    question.setSingleCorrect(false);
    // Kprim has always 4 answers, each of them score 1/4 of the maximum value
    ChoiceResponse newChoice = new ChoiceResponse();
    newChoice.getContent().add(new Mattext(trans.translate("editor.newresponsetext")));
    newChoice.setCorrect(false);
    newChoice.setPoints(maxValue / 4);
    question.getResponses().add(newChoice);
    ChoiceResponse newChoice2 = new ChoiceResponse();
    newChoice2.getContent().add(new Mattext(trans.translate("editor.newresponsetext")));
    newChoice2.setCorrect(false);
    newChoice2.setPoints(maxValue / 4);
    question.getResponses().add(newChoice2);
    ChoiceResponse newChoice3 = new ChoiceResponse();
    newChoice3.getContent().add(new Mattext(trans.translate("editor.newresponsetext")));
    newChoice3.setCorrect(false);
    newChoice3.setPoints(maxValue / 4);
    question.getResponses().add(newChoice3);
    ChoiceResponse newChoice4 = new ChoiceResponse();
    newChoice4.getContent().add(new Mattext(trans.translate("editor.newresponsetext")));
    newChoice4.setCorrect(false);
    newChoice4.setPoints(maxValue / 4);
    question.getResponses().add(newChoice4);
    question.setMaxValue(maxValue);
    newItem.setQuestion(question);
    QTIEditHelper.setFeedbackMastery(newItem, "");
    QTIEditHelper.setFeedbackFail(newItem, "");
    return newItem;
}
Also used : ChoiceResponse(org.olat.ims.qti.editor.beecom.objects.ChoiceResponse) 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) Mattext(org.olat.ims.qti.editor.beecom.objects.Mattext) ArrayList(java.util.ArrayList) ChoiceQuestion(org.olat.ims.qti.editor.beecom.objects.ChoiceQuestion)

Example 30 with Control

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

the class QTIEditHelper method createSCItem.

/**
 * Creates a new Single Choice item
 * @param trans
 * @return New Singe Choice item.
 */
public static Item createSCItem(Translator trans) {
    Item newItem = new Item();
    newItem.setIdent(EDITOR_IDENT + ":" + ITEM_TYPE_SC + ":" + String.valueOf(CodeHelper.getRAMUniqueID()));
    newItem.setTitle(trans.translate("editor.newquestion"));
    newItem.setLabel("");
    // controls
    Control control = new Control();
    List<Control> controls = new ArrayList<Control>();
    controls.add(control);
    newItem.setItemcontrols(controls);
    // pepare question
    ChoiceQuestion question = new ChoiceQuestion();
    question.setLable(trans.translate("editor.newquestion"));
    question.getQuestion().getElements().add(new Mattext(trans.translate("editor.newquestiontext")));
    question.setType(Question.TYPE_SC);
    question.setSingleCorrect(true);
    question.setSingleCorrectScore(1);
    ChoiceResponse newChoice = new ChoiceResponse();
    newChoice.setCorrect(true);
    newChoice.getContent().add(new Mattext(trans.translate("editor.newresponsetext")));
    question.getResponses().add(newChoice);
    QTIEditHelper.setFeedbackMastery(newItem, "");
    QTIEditHelper.setFeedbackFail(newItem, "");
    newItem.setQuestion(question);
    return newItem;
}
Also used : ChoiceResponse(org.olat.ims.qti.editor.beecom.objects.ChoiceResponse) 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) Mattext(org.olat.ims.qti.editor.beecom.objects.Mattext) ArrayList(java.util.ArrayList) ChoiceQuestion(org.olat.ims.qti.editor.beecom.objects.ChoiceQuestion)

Aggregations

Control (org.olat.ims.qti.editor.beecom.objects.Control)36 ArrayList (java.util.ArrayList)22 Item (org.olat.ims.qti.editor.beecom.objects.Item)18 VFSItem (org.olat.core.util.vfs.VFSItem)12 ChoiceQuestion (org.olat.ims.qti.editor.beecom.objects.ChoiceQuestion)12 List (java.util.List)10 WindowControl (org.olat.core.gui.control.WindowControl)10 Mattext (org.olat.ims.qti.editor.beecom.objects.Mattext)10 QTIObject (org.olat.ims.qti.editor.beecom.objects.QTIObject)10 Question (org.olat.ims.qti.editor.beecom.objects.Question)10 Iterator (java.util.Iterator)8 Duration (org.olat.ims.qti.editor.beecom.objects.Duration)8 Element (org.dom4j.Element)6 Assessment (org.olat.ims.qti.editor.beecom.objects.Assessment)6 ChoiceResponse (org.olat.ims.qti.editor.beecom.objects.ChoiceResponse)6 EssayResponse (org.olat.ims.qti.editor.beecom.objects.EssayResponse)6 FIBResponse (org.olat.ims.qti.editor.beecom.objects.FIBResponse)6 Material (org.olat.ims.qti.editor.beecom.objects.Material)6 OutcomesProcessing (org.olat.ims.qti.editor.beecom.objects.OutcomesProcessing)6 Section (org.olat.ims.qti.editor.beecom.objects.Section)6