Search in sources :

Example 16 with FlowFormItem

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

the class EssayEditorController method initForm.

@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
    setFormContextHelp("Test editor QTI 2.1 in detail#details_testeditor_fragetypen_freetext");
    titleEl = uifactory.addTextElement("title", "form.imd.title", -1, itemBuilder.getTitle(), formLayout);
    titleEl.setElementCssClass("o_sel_assessment_item_title");
    titleEl.setMandatory(true);
    titleEl.setEnabled(!readOnly);
    String relativePath = rootDirectory.toPath().relativize(itemFile.toPath().getParent()).toString();
    VFSContainer itemContainer = (VFSContainer) rootContainer.resolve(relativePath);
    String description = itemBuilder.getQuestion();
    textEl = uifactory.addRichTextElementForQTI21("desc", "form.imd.descr", description, 12, -1, itemContainer, formLayout, ureq.getUserSession(), getWindowControl());
    textEl.setElementCssClass("o_sel_assessment_item_question");
    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);
        formLayout.add(textReadOnlyEl);
    }
    String placeholder = itemBuilder.getPlaceholder();
    placeholderEl = uifactory.addTextElement("placeholder", "fib.placeholder", 256, placeholder, formLayout);
    placeholderEl.setEnabled(!readOnly);
    // width (expectedLength), height (expectedLines)
    String expectedLength = getValue(itemBuilder.getExpectedLength());
    lengthEl = uifactory.addTextElement("cols", "essay.expectedLength", -1, expectedLength, formLayout);
    lengthEl.setEnabled(!restrictedEdit && !readOnly);
    lengthEl.setVisible(StringHelper.containsNonWhitespace(expectedLength));
    String expectedLines = getValue(itemBuilder.getExpectedLines());
    heightEl = uifactory.addTextElement("rows", "essay.rows", -1, expectedLines, formLayout);
    heightEl.setEnabled(!restrictedEdit && !readOnly);
    // words count min. max. (maxStrings)
    String minStrings = getValue(itemBuilder.getMinStrings());
    minWordsEl = uifactory.addTextElement("min.strings", "essay.min.strings", -1, minStrings, formLayout);
    minWordsEl.setEnabled(!restrictedEdit && !readOnly);
    String maxStrings = getValue(itemBuilder.getMaxStrings());
    maxWordsEl = uifactory.addTextElement("max.strings", "essay.max.strings", -1, maxStrings, formLayout);
    maxWordsEl.setEnabled(!restrictedEdit && !readOnly);
    // Submit Button
    FormLayoutContainer buttonsContainer = FormLayoutContainer.createButtonLayout("buttons", getTranslator());
    buttonsContainer.setRootForm(mainForm);
    buttonsContainer.setElementCssClass("o_sel_lob_save");
    buttonsContainer.setVisible(!readOnly);
    formLayout.add(buttonsContainer);
    uifactory.addFormSubmitButton("submit", buttonsContainer);
}
Also used : FlowFormItem(org.olat.ims.qti21.ui.components.FlowFormItem) VFSContainer(org.olat.core.util.vfs.VFSContainer) FormLayoutContainer(org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer)

Example 17 with FlowFormItem

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

the class KPrimEditorController method initForm.

@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
    FormLayoutContainer metadata = FormLayoutContainer.createDefaultFormLayout("metadata", getTranslator());
    metadata.setFormContextHelp("Test editor QTI 2.1 in detail#details_testeditor_fragetypen_kprim");
    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);
    }
    // layout
    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 + "/kprim_choices.html";
    answersCont = FormLayoutContainer.createCustomFormLayout("answers", getTranslator(), page);
    answersCont.setRootForm(mainForm);
    formLayout.add(answersCont);
    formLayout.add("answers", answersCont);
    MatchInteraction interaction = itemBuilder.getMatchInteraction();
    if (interaction != null) {
        List<SimpleAssociableChoice> choices = itemBuilder.getKprimChoices();
        for (SimpleAssociableChoice choice : choices) {
            wrapAnswer(ureq, choice);
        }
    }
    answersCont.contextPut("choices", choiceWrappers);
    answersCont.contextPut("restrictedEdit", restrictedEdit || readOnly);
    recalculateUpDownLinks();
    // Submit Button
    FormLayoutContainer buttonsContainer = FormLayoutContainer.createDefaultFormLayout("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 : MatchInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.MatchInteraction) FlowFormItem(org.olat.ims.qti21.ui.components.FlowFormItem) SimpleAssociableChoice(uk.ac.ed.ph.jqtiplus.node.item.interaction.choice.SimpleAssociableChoice) FormLayoutContainer(org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer)

Example 18 with FlowFormItem

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

the class SingleChoiceEditorController 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_sc");
    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);
    textEl.setEnabled(!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);
    }
    // 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);
    }
    // layout
    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 + "/simple_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.setRootForm(mainForm);
    buttonsContainer.setElementCssClass("o_sel_choices_save");
    buttonsContainer.setVisible(!readOnly);
    formLayout.add(buttonsContainer);
    formLayout.add("buttons", buttonsContainer);
    if (!readOnly) {
        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 19 with FlowFormItem

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

the class UploadEditorController method initForm.

@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
    setFormContextHelp("Test editor QTI 2.1 in detail#details_testeditor_fragetypen_fileupload");
    titleEl = uifactory.addTextElement("title", "form.imd.title", -1, itemBuilder.getTitle(), formLayout);
    titleEl.setElementCssClass("o_sel_assessment_item_title");
    titleEl.setMandatory(true);
    titleEl.setEnabled(!readOnly);
    String relativePath = rootDirectory.toPath().relativize(itemFile.toPath().getParent()).toString();
    VFSContainer itemContainer = (VFSContainer) rootContainer.resolve(relativePath);
    String description = itemBuilder.getQuestion();
    textEl = uifactory.addRichTextElementForQTI21("desc", "form.imd.descr", description, 16, -1, itemContainer, formLayout, ureq.getUserSession(), getWindowControl());
    textEl.setElementCssClass("o_sel_assessment_item_question");
    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);
        formLayout.add(textReadOnlyEl);
    }
    // Submit Button
    FormLayoutContainer buttonsContainer = FormLayoutContainer.createButtonLayout("buttons", getTranslator());
    buttonsContainer.setRootForm(mainForm);
    buttonsContainer.setElementCssClass("o_sel_lob_save");
    buttonsContainer.setVisible(!readOnly);
    formLayout.add(buttonsContainer);
    uifactory.addFormSubmitButton("submit", buttonsContainer);
}
Also used : FlowFormItem(org.olat.ims.qti21.ui.components.FlowFormItem) VFSContainer(org.olat.core.util.vfs.VFSContainer) FormLayoutContainer(org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer)

Example 20 with FlowFormItem

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

the class MatchEditorController method wrapAnswer.

private void wrapAnswer(UserRequest ureq, SimpleAssociableChoice choice, List<MatchWrapper> wrappers) {
    List<FlowStatic> choiceFlow = choice.getFlowStatics();
    String choiceContent = itemBuilder.getHtmlHelper().flowStaticString(choiceFlow);
    String choiceId = "answer" + count++;
    RichTextElement choiceEl = uifactory.addRichTextElementForQTI21Match(choiceId, "form.imd.answer", choiceContent, 4, -1, itemContainer, answersCont, ureq.getUserSession(), getWindowControl());
    choiceEl.setUserObject(choice);
    choiceEl.setEnabled(!readOnly);
    choiceEl.setVisible(!readOnly);
    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 deleteButton = uifactory.addFormLink("del_" + (count++), "delete", "delete", null, answersCont, Link.NONTRANSLATED);
    deleteButton.setIconLeftCSS("o_icon o_icon_delete_item");
    deleteButton.setVisible(!restrictedEdit && !readOnly);
    deleteButton.setI18nKey("");
    MatchWrapper wrapper = new MatchWrapper(choice, choiceEl, choiceReadOnlyEl, deleteButton);
    deleteButton.setUserObject(wrapper);
    wrappers.add(wrapper);
}
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