Search in sources :

Example 6 with FlowFormItem

use of org.olat.ims.qti21.ui.components.FlowFormItem in project OpenOLAT by OpenOLAT.

the class MatchScoreController method createMatchWrapper.

private MatchWrapper createMatchWrapper(SimpleAssociableChoice choice) {
    FlowFormItem summaryEl = new FlowFormItem("summary_" + count++, itemFileRef);
    summaryEl.setFlowStatics(choice.getFlowStatics());
    summaryEl.setMapperUri(mapperUri);
    scoreCont.add(summaryEl);
    return new MatchWrapper(choice.getIdentifier(), choice, summaryEl);
}
Also used : FlowFormItem(org.olat.ims.qti21.ui.components.FlowFormItem)

Example 7 with FlowFormItem

use of org.olat.ims.qti21.ui.components.FlowFormItem in project OpenOLAT by OpenOLAT.

the class SingleChoiceEditorController method wrapAnswer.

private void wrapAnswer(UserRequest ureq, SimpleChoice choice) {
    List<FlowStatic> choiceFlow = choice.getFlowStatics();
    String choiceContent = itemBuilder.getHtmlHelper().flowStaticString(choiceFlow);
    String choiceId = "answer" + count++;
    RichTextElement choiceEl = uifactory.addRichTextElementForQTI21(choiceId, "form.imd.answer", choiceContent, 8, -1, itemContainer, answersCont, ureq.getUserSession(), getWindowControl());
    choiceEl.setEnabled(!readOnly);
    choiceEl.setVisible(!readOnly);
    choiceEl.getEditorConfiguration().setSimplestTextModeAllowed(TextMode.oneLine);
    choiceEl.setUserObject(choice);
    answersCont.add("choiceId", choiceEl);
    String choiceRoId = "answerro" + count++;
    FlowFormItem choiceReadOnlyEl = new FlowFormItem(choiceRoId, itemFile);
    choiceReadOnlyEl.setFlowStatics(choiceFlow);
    choiceReadOnlyEl.setMapperUri(mapperUri);
    answersCont.add(choiceRoId, choiceReadOnlyEl);
    FormLink removeLink = uifactory.addFormLink("rm-".concat(choiceId), "rm", "", null, answersCont, Link.NONTRANSLATED);
    removeLink.setIconLeftCSS("o_icon o_icon-lg o_icon_delete");
    removeLink.setEnabled(!restrictedEdit && !readOnly);
    answersCont.add(removeLink);
    answersCont.add("rm-".concat(choiceId), removeLink);
    FormLink addLink = uifactory.addFormLink("add-".concat(choiceId), "add", "", null, answersCont, Link.NONTRANSLATED);
    addLink.setIconLeftCSS("o_icon o_icon-lg o_icon_add");
    addLink.setEnabled(!restrictedEdit && !readOnly);
    answersCont.add(addLink);
    answersCont.add("add-".concat(choiceId), addLink);
    FormLink upLink = uifactory.addFormLink("up-".concat(choiceId), "up", "", null, answersCont, Link.NONTRANSLATED);
    upLink.setIconLeftCSS("o_icon o_icon-lg o_icon_move_up");
    upLink.setEnabled(!restrictedEdit && !readOnly);
    answersCont.add(upLink);
    answersCont.add("up-".concat(choiceId), upLink);
    FormLink downLink = uifactory.addFormLink("down-".concat(choiceId), "down", "", null, answersCont, Link.NONTRANSLATED);
    downLink.setIconLeftCSS("o_icon o_icon-lg o_icon_move_down");
    downLink.setEnabled(!restrictedEdit && !readOnly);
    answersCont.add(downLink);
    answersCont.add("down-".concat(choiceId), downLink);
    choiceWrappers.add(new SimpleChoiceWrapper(choice, choiceEl, choiceReadOnlyEl, removeLink, addLink, upLink, downLink));
}
Also used : RichTextElement(org.olat.core.gui.components.form.flexible.elements.RichTextElement) FlowStatic(uk.ac.ed.ph.jqtiplus.node.content.basic.FlowStatic) FlowFormItem(org.olat.ims.qti21.ui.components.FlowFormItem) FormLink(org.olat.core.gui.components.form.flexible.elements.FormLink)

Example 8 with FlowFormItem

use of org.olat.ims.qti21.ui.components.FlowFormItem in project openolat by klemens.

the class MatchEditorController method initForm.

@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
    FormLayoutContainer metadata = FormLayoutContainer.createDefaultFormLayout("metadata", getTranslator());
    if (itemBuilder.getQuestionType() == QTI21QuestionType.matchdraganddrop) {
        metadata.setFormContextHelp("Test editor QTI 2.1 in detail#details_testeditor_fragetypen_draganddrop");
    } else {
        metadata.setFormContextHelp("Test editor QTI 2.1 in detail#details_testeditor_fragetypen_match");
    }
    metadata.setRootForm(mainForm);
    formLayout.add(metadata);
    formLayout.add("metadata", metadata);
    titleEl = uifactory.addTextElement("title", "form.imd.title", -1, itemBuilder.getTitle(), metadata);
    titleEl.setElementCssClass("o_sel_assessment_item_title");
    titleEl.setMandatory(true);
    titleEl.setEnabled(!readOnly);
    String description = itemBuilder.getQuestion();
    textEl = uifactory.addRichTextElementForQTI21("desc", "form.imd.descr", description, 8, -1, itemContainer, metadata, ureq.getUserSession(), getWindowControl());
    textEl.setEnabled(!readOnly);
    textEl.setVisible(!readOnly);
    if (readOnly) {
        FlowFormItem textReadOnlyEl = new FlowFormItem("descro", itemFile);
        textReadOnlyEl.setLabel("form.imd.descr", null);
        textReadOnlyEl.setBlocks(itemBuilder.getQuestionBlocks());
        textReadOnlyEl.setMapperUri(mapperUri);
        metadata.add(textReadOnlyEl);
    }
    // shuffle
    String[] yesnoValues = new String[] { translate("yes"), translate("no") };
    shuffleEl = uifactory.addRadiosHorizontal("shuffle", "form.imd.shuffle", metadata, yesnoKeys, yesnoValues);
    shuffleEl.setEnabled(!restrictedEdit && !readOnly);
    if (itemBuilder.isShuffle()) {
        shuffleEl.select("y", true);
    } else {
        shuffleEl.select("n", true);
    }
    // single choice / multiple choice
    String[] singleMultiValues = new String[] { translate("form.imd.match.single.choice"), translate("form.imd.match.multiple.choice") };
    singleMultiEl = uifactory.addRadiosHorizontal("singleMulti", "form.imd.match.single.multiple", metadata, singleMultiKeys, singleMultiValues);
    singleMultiEl.setElementCssClass("o_sel_match_single");
    singleMultiEl.setEnabled(!restrictedEdit && !readOnly);
    singleMultiEl.addActionListener(FormEvent.ONCHANGE);
    if (itemBuilder.isMultipleChoice()) {
        singleMultiEl.select(singleMultiKeys[1], true);
    } else {
        singleMultiEl.select(singleMultiKeys[0], true);
    }
    if (itemBuilder.getQuestionType() == QTI21QuestionType.matchdraganddrop) {
        String[] layoutValues = new String[] { translate("form.imd.layout.left"), translate("form.imd.layout.top"), translate("form.imd.layout.right"), translate("form.imd.layout.bottom") };
        layoutEl = uifactory.addRadiosHorizontal("layout", "form.imd.layout", metadata, layoutKeys, layoutValues);
        layoutEl.setElementCssClass("o_sel_match_layout");
        layoutEl.setEnabled(!restrictedEdit && !readOnly);
        boolean found = false;
        for (String layoutKey : layoutKeys) {
            if (itemBuilder.hasMatchInteractionClass(layoutKey)) {
                layoutEl.select(layoutKey, true);
                found = true;
            }
        }
        if (!found) {
            layoutEl.select(layoutKeys[0], true);
        }
    }
    // responses
    String page = velocity_root + "/match_choices.html";
    answersCont = FormLayoutContainer.createCustomFormLayout("answers", getTranslator(), page);
    answersCont.setRootForm(mainForm);
    answersCont.contextPut("showHeaders", (itemBuilder.getQuestionType() == QTI21QuestionType.matchdraganddrop));
    formLayout.add(answersCont);
    formLayout.add("answers", answersCont);
    MatchInteraction interaction = itemBuilder.getMatchInteraction();
    if (interaction != null) {
        List<SimpleAssociableChoice> sourceChoices = itemBuilder.getSourceChoices();
        for (SimpleAssociableChoice sourceChoice : sourceChoices) {
            wrapAnswer(ureq, sourceChoice, sourceWrappers);
        }
        List<SimpleAssociableChoice> targetChoices = itemBuilder.getTargetChoices();
        for (SimpleAssociableChoice targetChoice : targetChoices) {
            wrapAnswer(ureq, targetChoice, targetWrappers);
        }
    }
    answersCont.contextPut("sourceChoices", sourceWrappers);
    answersCont.contextPut("targetChoices", targetWrappers);
    answersCont.contextPut("restrictedEdit", restrictedEdit || readOnly);
    answersCont.contextPut("responseIdentifier", itemBuilder.getResponseIdentifier());
    int maxAssociations = itemBuilder.getMatchInteraction().getMaxAssociations();
    answersCont.contextPut("interactionMaxAssociations", maxAssociations);
    JSAndCSSFormItem js = new JSAndCSSFormItem("js", new String[] { "js/jquery/qti/jquery.match.js" });
    formLayout.add(js);
    if (!readOnly) {
        uifactory.addFormSubmitButton("submit", answersCont);
    }
    if (!restrictedEdit && !readOnly) {
        addColumnButton = uifactory.addFormLink("add.match.column", answersCont, Link.BUTTON);
        addColumnButton.setElementCssClass("o_sel_match_add_column");
        addColumnButton.setIconLeftCSS("o_icon o_icon_add");
        addRowButton = uifactory.addFormLink("add.match.row", answersCont, Link.BUTTON);
        addRowButton.setElementCssClass("o_sel_match_add_row");
        addRowButton.setIconLeftCSS("o_icon o_icon_add");
    }
}
Also used : MatchInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.MatchInteraction) FlowFormItem(org.olat.ims.qti21.ui.components.FlowFormItem) AssessmentItemFactory.createSimpleAssociableChoice(org.olat.ims.qti21.model.xml.AssessmentItemFactory.createSimpleAssociableChoice) SimpleAssociableChoice(uk.ac.ed.ph.jqtiplus.node.item.interaction.choice.SimpleAssociableChoice) JSAndCSSFormItem(org.olat.core.gui.components.htmlheader.jscss.JSAndCSSFormItem) FormLayoutContainer(org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer)

Example 9 with FlowFormItem

use of org.olat.ims.qti21.ui.components.FlowFormItem in project openolat by klemens.

the class MultipleChoiceEditorController method initForm.

@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
    FormLayoutContainer metadata = FormLayoutContainer.createDefaultFormLayout_2_10("metadata", getTranslator());
    metadata.setFormContextHelp("Test editor QTI 2.1 in detail#details_testeditor_fragetypen_mc");
    metadata.setRootForm(mainForm);
    formLayout.add(metadata);
    formLayout.add("metadata", metadata);
    titleEl = uifactory.addTextElement("title", "form.imd.title", -1, itemBuilder.getTitle(), metadata);
    titleEl.setElementCssClass("o_sel_assessment_item_title");
    titleEl.setMandatory(true);
    titleEl.setEnabled(!readOnly);
    String description = itemBuilder.getQuestion();
    textEl = uifactory.addRichTextElementForQTI21("desc", "form.imd.descr", description, 8, -1, itemContainer, metadata, ureq.getUserSession(), getWindowControl());
    textEl.setVisible(!readOnly);
    if (readOnly) {
        FlowFormItem choiceReadOnlyEl = new FlowFormItem("descro", itemFile);
        choiceReadOnlyEl.setLabel("form.imd.descr", null);
        choiceReadOnlyEl.setBlocks(itemBuilder.getQuestionBlocks());
        choiceReadOnlyEl.setMapperUri(mapperUri);
        metadata.add(choiceReadOnlyEl);
    }
    // shuffle
    String[] yesnoValues = new String[] { translate("yes"), translate("no") };
    shuffleEl = uifactory.addRadiosHorizontal("shuffle", "form.imd.shuffle", metadata, yesnoKeys, yesnoValues);
    shuffleEl.setEnabled(!restrictedEdit && !readOnly);
    if (itemBuilder.isShuffle()) {
        shuffleEl.select("y", true);
    } else {
        shuffleEl.select("n", true);
    }
    // layout
    String[] layoutValues = new String[] { translate("form.imd.layout.vertical"), translate("form.imd.layout.horizontal") };
    orientationEl = uifactory.addRadiosHorizontal("layout", "form.imd.layout", metadata, layoutKeys, layoutValues);
    orientationEl.setEnabled(!restrictedEdit && !readOnly);
    if (itemBuilder.getOrientation() == null || Orientation.VERTICAL.equals(itemBuilder.getOrientation())) {
        orientationEl.select(Orientation.VERTICAL.name(), true);
    } else {
        orientationEl.select(Orientation.HORIZONTAL.name(), true);
    }
    // alignment
    String[] alignmentValues = new String[] { translate("form.imd.alignment.left"), translate("form.imd.alignment.right") };
    alignmentEl = uifactory.addRadiosHorizontal("alignment", "form.imd.alignment", metadata, alignmentKeys, alignmentValues);
    alignmentEl.setEnabled(!restrictedEdit && !readOnly);
    if (itemBuilder.hasClassAttr(QTI21Constants.CHOICE_ALIGN_RIGHT)) {
        alignmentEl.select(alignmentKeys[1], true);
    } else {
        alignmentEl.select(alignmentKeys[0], true);
    }
    // responses
    String page = velocity_root + "/multiple_choices.html";
    answersCont = FormLayoutContainer.createCustomFormLayout("answers", getTranslator(), page);
    answersCont.setRootForm(mainForm);
    formLayout.add(answersCont);
    formLayout.add("answers", answersCont);
    ChoiceInteraction interaction = itemBuilder.getChoiceInteraction();
    if (interaction != null) {
        List<SimpleChoice> choices = itemBuilder.getChoices();
        for (SimpleChoice choice : choices) {
            wrapAnswer(ureq, choice);
        }
    }
    answersCont.contextPut("choices", choiceWrappers);
    answersCont.contextPut("restrictedEdit", restrictedEdit || readOnly);
    recalculateUpDownLinks();
    // Submit Button
    FormLayoutContainer buttonsContainer = FormLayoutContainer.createDefaultFormLayout_2_10("buttons", getTranslator());
    buttonsContainer.setElementCssClass("o_sel_choices_save");
    buttonsContainer.setRootForm(mainForm);
    buttonsContainer.setVisible(!readOnly);
    formLayout.add(buttonsContainer);
    formLayout.add("buttons", buttonsContainer);
    uifactory.addFormSubmitButton("submit", buttonsContainer);
}
Also used : SimpleChoice(uk.ac.ed.ph.jqtiplus.node.item.interaction.choice.SimpleChoice) FlowFormItem(org.olat.ims.qti21.ui.components.FlowFormItem) FormLayoutContainer(org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer) ChoiceInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.ChoiceInteraction)

Example 10 with FlowFormItem

use of org.olat.ims.qti21.ui.components.FlowFormItem in project openolat by klemens.

the class SingleChoiceEditorController method wrapAnswer.

private void wrapAnswer(UserRequest ureq, SimpleChoice choice) {
    List<FlowStatic> choiceFlow = choice.getFlowStatics();
    String choiceContent = itemBuilder.getHtmlHelper().flowStaticString(choiceFlow);
    String choiceId = "answer" + count++;
    RichTextElement choiceEl = uifactory.addRichTextElementForQTI21(choiceId, "form.imd.answer", choiceContent, 8, -1, itemContainer, answersCont, ureq.getUserSession(), getWindowControl());
    choiceEl.setEnabled(!readOnly);
    choiceEl.setVisible(!readOnly);
    choiceEl.getEditorConfiguration().setSimplestTextModeAllowed(TextMode.oneLine);
    choiceEl.setUserObject(choice);
    answersCont.add("choiceId", choiceEl);
    String choiceRoId = "answerro" + count++;
    FlowFormItem choiceReadOnlyEl = new FlowFormItem(choiceRoId, itemFile);
    choiceReadOnlyEl.setFlowStatics(choiceFlow);
    choiceReadOnlyEl.setMapperUri(mapperUri);
    answersCont.add(choiceRoId, choiceReadOnlyEl);
    FormLink removeLink = uifactory.addFormLink("rm-".concat(choiceId), "rm", "", null, answersCont, Link.NONTRANSLATED);
    removeLink.setIconLeftCSS("o_icon o_icon-lg o_icon_delete");
    removeLink.setEnabled(!restrictedEdit && !readOnly);
    answersCont.add(removeLink);
    answersCont.add("rm-".concat(choiceId), removeLink);
    FormLink addLink = uifactory.addFormLink("add-".concat(choiceId), "add", "", null, answersCont, Link.NONTRANSLATED);
    addLink.setIconLeftCSS("o_icon o_icon-lg o_icon_add");
    addLink.setEnabled(!restrictedEdit && !readOnly);
    answersCont.add(addLink);
    answersCont.add("add-".concat(choiceId), addLink);
    FormLink upLink = uifactory.addFormLink("up-".concat(choiceId), "up", "", null, answersCont, Link.NONTRANSLATED);
    upLink.setIconLeftCSS("o_icon o_icon-lg o_icon_move_up");
    upLink.setEnabled(!restrictedEdit && !readOnly);
    answersCont.add(upLink);
    answersCont.add("up-".concat(choiceId), upLink);
    FormLink downLink = uifactory.addFormLink("down-".concat(choiceId), "down", "", null, answersCont, Link.NONTRANSLATED);
    downLink.setIconLeftCSS("o_icon o_icon-lg o_icon_move_down");
    downLink.setEnabled(!restrictedEdit && !readOnly);
    answersCont.add(downLink);
    answersCont.add("down-".concat(choiceId), downLink);
    choiceWrappers.add(new SimpleChoiceWrapper(choice, choiceEl, choiceReadOnlyEl, removeLink, addLink, upLink, downLink));
}
Also used : RichTextElement(org.olat.core.gui.components.form.flexible.elements.RichTextElement) FlowStatic(uk.ac.ed.ph.jqtiplus.node.content.basic.FlowStatic) FlowFormItem(org.olat.ims.qti21.ui.components.FlowFormItem) FormLink(org.olat.core.gui.components.form.flexible.elements.FormLink)

Aggregations

FlowFormItem (org.olat.ims.qti21.ui.components.FlowFormItem)30 FormLayoutContainer (org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer)18 FormLink (org.olat.core.gui.components.form.flexible.elements.FormLink)12 RichTextElement (org.olat.core.gui.components.form.flexible.elements.RichTextElement)12 FlowStatic (uk.ac.ed.ph.jqtiplus.node.content.basic.FlowStatic)12 VFSContainer (org.olat.core.util.vfs.VFSContainer)10 JSAndCSSFormItem (org.olat.core.gui.components.htmlheader.jscss.JSAndCSSFormItem)6 MatchInteraction (uk.ac.ed.ph.jqtiplus.node.item.interaction.MatchInteraction)6 SimpleAssociableChoice (uk.ac.ed.ph.jqtiplus.node.item.interaction.choice.SimpleAssociableChoice)6 AssessmentItemFactory.createSimpleAssociableChoice (org.olat.ims.qti21.model.xml.AssessmentItemFactory.createSimpleAssociableChoice)4 ChoiceInteraction (uk.ac.ed.ph.jqtiplus.node.item.interaction.ChoiceInteraction)4 SimpleChoice (uk.ac.ed.ph.jqtiplus.node.item.interaction.choice.SimpleChoice)4 File (java.io.File)2 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 List (java.util.List)2 Map (java.util.Map)2 Collectors (java.util.stream.Collectors)2 Size (org.olat.core.commons.services.image.Size)2 UserRequest (org.olat.core.gui.UserRequest)2