Search in sources :

Example 81 with FormLayoutContainer

use of org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer in project OpenOLAT by OpenOLAT.

the class HotspotEditorController method initForm.

@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
    setFormContextHelp("Test editor QTI 2.1 in detail#details_testeditor_fragetypen_hotspot");
    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 question = itemBuilder.getQuestion();
    textEl = uifactory.addRichTextElementForQTI21("desc", "form.imd.descr", question, 8, -1, itemContainer, formLayout, ureq.getUserSession(), getWindowControl());
    textEl.addActionListener(FormEvent.ONCLICK);
    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[] cardinalityKeys = new String[] { Cardinality.SINGLE.name(), Cardinality.MULTIPLE.name() };
    String[] cardinalityValues = new String[] { translate(Cardinality.SINGLE.name()), translate(Cardinality.MULTIPLE.name()) };
    cardinalityEl = uifactory.addRadiosHorizontal("form.imd.cardinality", formLayout, cardinalityKeys, cardinalityValues);
    cardinalityEl.setElementCssClass("o_sel_assessment_item_cardinality");
    cardinalityEl.setEnabled(!restrictedEdit && !readOnly);
    if (itemBuilder.isSingleChoice()) {
        cardinalityEl.select(cardinalityKeys[0], true);
    } else {
        cardinalityEl.select(cardinalityKeys[1], true);
    }
    responsiveEl = uifactory.addCheckboxesHorizontal("form.imd.responsive", formLayout, onKeys, new String[] { "" });
    responsiveEl.setHelpText(translate("form.imd.responsive.hint"));
    responsiveEl.setEnabled(!restrictedEdit && !readOnly);
    if (itemBuilder.isResponsive()) {
        responsiveEl.select(onKeys[0], true);
    }
    initialBackgroundImage = getCurrentBackground();
    backgroundEl = uifactory.addFileElement(getWindowControl(), "form.imd.background", "form.imd.background", formLayout);
    backgroundEl.setEnabled(!restrictedEdit && !readOnly);
    if (initialBackgroundImage != null) {
        backgroundEl.setInitialFile(initialBackgroundImage);
    }
    backgroundEl.addActionListener(FormEvent.ONCHANGE);
    backgroundEl.setDeleteEnabled(true);
    backgroundEl.limitToMimeType(mimeTypes, "error.mimetype", new String[] { mimeTypes.toString() });
    String[] resizeKeys = new String[] { "no" };
    String[] resizeValues = new String[] { translate("form.imd.background.resize.no") };
    resizeEl = uifactory.addRadiosHorizontal("form.imd.background.resize", formLayout, resizeKeys, resizeValues);
    resizeEl.setVisible(false);
    resizeEl.setEnabled(!readOnly);
    if (initialBackgroundImage != null) {
        Size size = imageService.getSize(new LocalFileImpl(initialBackgroundImage), null);
        optimizeResizeEl(size, false);
    }
    // responses
    String page = velocity_root + "/hotspots.html";
    hotspotsCont = FormLayoutContainer.createCustomFormLayout("answers", getTranslator(), page);
    hotspotsCont.getFormItemComponent().addListener(this);
    hotspotsCont.setLabel("new.spots", null);
    hotspotsCont.setRootForm(mainForm);
    hotspotsCont.contextPut("mapperUri", backgroundMapperUri);
    hotspotsCont.contextPut("restrictedEdit", restrictedEdit || readOnly);
    JSAndCSSFormItem js = new JSAndCSSFormItem("js", new String[] { "js/jquery/openolat/jquery.drawing.js" });
    formLayout.add(js);
    formLayout.add(hotspotsCont);
    newCircleButton = uifactory.addFormLink("new.circle", "new.circle", null, hotspotsCont, Link.BUTTON);
    newCircleButton.setIconLeftCSS("o_icon o_icon-lg o_icon_circle");
    newCircleButton.setVisible(!restrictedEdit && !readOnly);
    newRectButton = uifactory.addFormLink("new.rectangle", "new.rectangle", null, hotspotsCont, Link.BUTTON);
    newRectButton.setIconLeftCSS("o_icon o_icon-lg o_icon_rectangle");
    newRectButton.setVisible(!restrictedEdit && !readOnly);
    updateBackground();
    String[] emptyKeys = new String[0];
    correctHotspotsEl = uifactory.addCheckboxesHorizontal("form.imd.correct.spots", formLayout, emptyKeys, emptyKeys);
    correctHotspotsEl.setElementCssClass("o_sel_assessment_item_correct_spots");
    correctHotspotsEl.setEnabled(!restrictedEdit && !readOnly);
    correctHotspotsEl.addActionListener(FormEvent.ONCHANGE);
    rebuildWrappersAndCorrectSelection();
    HotspotLayouts[] layouts = HotspotLayouts.values();
    String[] layoutKeys = new String[layouts.length];
    String[] layoutValues = new String[layouts.length];
    for (int i = layouts.length; i-- > 0; ) {
        layoutKeys[i] = layouts[i].cssClass();
        layoutValues[i] = translate("hotspot.layout." + layouts[i].name());
    }
    layoutEl = uifactory.addDropdownSingleselect("hotspot.layout", "hotspot.layout", formLayout, layoutKeys, layoutValues, null);
    layoutEl.addActionListener(FormEvent.ONCHANGE);
    layoutEl.setEnabled(!readOnly);
    boolean found = false;
    for (int i = layoutKeys.length; i-- > 0; ) {
        if (itemBuilder.hasHotspotInteractionClass(layoutKeys[i])) {
            layoutEl.select(layoutKeys[i], true);
            found = true;
        }
    }
    if (!found) {
        layoutEl.select(layoutKeys[0], true);
    }
    shadowEl = uifactory.addCheckboxesHorizontal("hotspot.layout.shadow", "hotspot.layout.shadow", formLayout, onKeys, new String[] { "" });
    shadowEl.setEnabled(!readOnly);
    if (!itemBuilder.hasHotspotInteractionClass(QTI21Constants.CSS_HOTSPOT_DISABLE_SHADOW)) {
        shadowEl.select(onKeys[0], true);
    }
    updateLayoutCssClass();
    // Submit Button
    FormLayoutContainer buttonsContainer = FormLayoutContainer.createButtonLayout("buttons", getTranslator());
    buttonsContainer.setElementCssClass("o_sel_hotspots_save");
    buttonsContainer.setRootForm(mainForm);
    buttonsContainer.setVisible(!readOnly);
    formLayout.add(buttonsContainer);
    uifactory.addFormSubmitButton("submit", buttonsContainer);
}
Also used : FlowFormItem(org.olat.ims.qti21.ui.components.FlowFormItem) HotspotLayouts(org.olat.ims.qti21.QTI21Constants.HotspotLayouts) Size(org.olat.core.commons.services.image.Size) JSAndCSSFormItem(org.olat.core.gui.components.htmlheader.jscss.JSAndCSSFormItem) VFSContainer(org.olat.core.util.vfs.VFSContainer) LocalFileImpl(org.olat.core.util.vfs.LocalFileImpl) FormLayoutContainer(org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer)

Example 82 with FormLayoutContainer

use of org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer in project OpenOLAT by OpenOLAT.

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 83 with FormLayoutContainer

use of org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer in project OpenOLAT by OpenOLAT.

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 84 with FormLayoutContainer

use of org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer in project OpenOLAT by OpenOLAT.

the class TrueFalseEditorController 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);
    }
    // responses
    String page = velocity_root + "/match_truefalse.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) {
            wrapSource(ureq, sourceChoice, sourceWrappers);
        }
        List<TargetWrapper> targetChoices = itemBuilder.getTargetChoices().stream().map(c -> new TargetWrapper(c)).collect(Collectors.toList());
        answersCont.contextPut("targetChoices", targetChoices);
    }
    answersCont.contextPut("sourceChoices", sourceWrappers);
    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) {
        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) Util(org.olat.core.util.Util) AssessmentItemFactory.createSimpleAssociableChoice(org.olat.ims.qti21.model.xml.AssessmentItemFactory.createSimpleAssociableChoice) FormEvent(org.olat.core.gui.components.form.flexible.impl.FormEvent) AssessmentItemEvent(org.olat.ims.qti21.ui.editor.events.AssessmentItemEvent) Identifier(uk.ac.ed.ph.jqtiplus.types.Identifier) HashMap(java.util.HashMap) QTI21QuestionType(org.olat.ims.qti21.model.QTI21QuestionType) FormItem(org.olat.core.gui.components.form.flexible.FormItem) ArrayList(java.util.ArrayList) FormBasicController(org.olat.core.gui.components.form.flexible.impl.FormBasicController) FormItemContainer(org.olat.core.gui.components.form.flexible.FormItemContainer) RichTextElement(org.olat.core.gui.components.form.flexible.elements.RichTextElement) Map(java.util.Map) JSAndCSSFormItem(org.olat.core.gui.components.htmlheader.jscss.JSAndCSSFormItem) AssessmentTestEditorController(org.olat.ims.qti21.ui.editor.AssessmentTestEditorController) FlowStatic(uk.ac.ed.ph.jqtiplus.node.content.basic.FlowStatic) Link(org.olat.core.gui.components.link.Link) WindowControl(org.olat.core.gui.control.WindowControl) ResourcesMapper(org.olat.ims.qti21.ui.ResourcesMapper) SimpleAssociableChoice(uk.ac.ed.ph.jqtiplus.node.item.interaction.choice.SimpleAssociableChoice) FlowFormItem(org.olat.ims.qti21.ui.components.FlowFormItem) Collectors(java.util.stream.Collectors) Controller(org.olat.core.gui.control.Controller) CodeHelper(org.olat.core.util.CodeHelper) File(java.io.File) TextElement(org.olat.core.gui.components.form.flexible.elements.TextElement) VFSContainer(org.olat.core.util.vfs.VFSContainer) MatchAssessmentItemBuilder(org.olat.ims.qti21.model.xml.interactions.MatchAssessmentItemBuilder) List(java.util.List) FormLink(org.olat.core.gui.components.form.flexible.elements.FormLink) MatchInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.MatchInteraction) UserRequest(org.olat.core.gui.UserRequest) FormLayoutContainer(org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer) 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 85 with FormLayoutContainer

use of org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer in project OpenOLAT by OpenOLAT.

the class AssessmentTestFeedbackEditorController method initForm.

@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
    setFormContextHelp("Test editor QTI 2.1 in detail#details_testeditor_feedback");
    String relativePath = rootDirectory.toPath().relativize(testFile.toPath().getParent()).toString();
    VFSContainer itemContainer = (VFSContainer) rootContainer.resolve(relativePath);
    // correct feedback
    TestFeedbackBuilder passedFeedback = testBuilder.getPassedFeedback();
    String passedTitle = passedFeedback == null ? "" : passedFeedback.getTitle();
    feedbackPassedTitleEl = uifactory.addTextElement("correctTitle", "form.test.correct.title", -1, passedTitle, formLayout);
    feedbackPassedTitleEl.setUserObject(passedFeedback);
    feedbackPassedTitleEl.setEnabled(!restrictedEdit);
    String passedText = passedFeedback == null ? "" : passedFeedback.getText();
    feedbackPassedTextEl = uifactory.addRichTextElementForQTI21("correctText", "form.test.correct.text", passedText, 8, -1, itemContainer, formLayout, ureq.getUserSession(), getWindowControl());
    feedbackPassedTextEl.getEditorConfiguration().setSimplestTextModeAllowed(TextMode.oneLine);
    feedbackPassedTextEl.setEnabled(!restrictedEdit);
    feedbackPassedTextEl.getEditorConfiguration().setFileBrowserUploadRelPath("media");
    // incorrect feedback
    TestFeedbackBuilder failedFeedback = testBuilder.getFailedFeedback();
    String failedTitle = failedFeedback == null ? "" : failedFeedback.getTitle();
    feedbackFailedTitleEl = uifactory.addTextElement("incorrectTitle", "form.test.incorrect.title", -1, failedTitle, formLayout);
    feedbackFailedTitleEl.setUserObject(failedFeedback);
    feedbackFailedTitleEl.setEnabled(!restrictedEdit);
    String fialedText = failedFeedback == null ? "" : failedFeedback.getText();
    feedbackFailedTextEl = uifactory.addRichTextElementForQTI21("incorrectText", "form.test.incorrect.text", fialedText, 8, -1, itemContainer, formLayout, ureq.getUserSession(), getWindowControl());
    feedbackFailedTextEl.getEditorConfiguration().setSimplestTextModeAllowed(TextMode.oneLine);
    feedbackFailedTextEl.setEnabled(!restrictedEdit);
    feedbackFailedTextEl.getEditorConfiguration().setFileBrowserUploadRelPath("media");
    // Submit Button
    FormLayoutContainer buttonsContainer = FormLayoutContainer.createButtonLayout("buttons", getTranslator());
    buttonsContainer.setRootForm(mainForm);
    formLayout.add(buttonsContainer);
    saveButton = uifactory.addFormSubmitButton("submit", buttonsContainer);
    // check the cut value
    sync();
}
Also used : TestFeedbackBuilder(org.olat.ims.qti21.model.xml.TestFeedbackBuilder) VFSContainer(org.olat.core.util.vfs.VFSContainer) FormLayoutContainer(org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer)

Aggregations

FormLayoutContainer (org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer)844 ArrayList (java.util.ArrayList)96 DefaultFlexiColumnModel (org.olat.core.gui.components.form.flexible.impl.elements.table.DefaultFlexiColumnModel)76 FlexiTableColumnModel (org.olat.core.gui.components.form.flexible.impl.elements.table.FlexiTableColumnModel)76 Date (java.util.Date)56 UserPropertyHandler (org.olat.user.propertyhandlers.UserPropertyHandler)56 TextElement (org.olat.core.gui.components.form.flexible.elements.TextElement)42 FormLink (org.olat.core.gui.components.form.flexible.elements.FormLink)40 FormItem (org.olat.core.gui.components.form.flexible.FormItem)38 StaticFlexiCellRenderer (org.olat.core.gui.components.form.flexible.impl.elements.table.StaticFlexiCellRenderer)32 Translator (org.olat.core.gui.translator.Translator)30 Identity (org.olat.core.id.Identity)30 VFSContainer (org.olat.core.util.vfs.VFSContainer)28 File (java.io.File)26 MultipleSelectionElement (org.olat.core.gui.components.form.flexible.elements.MultipleSelectionElement)26 BusinessGroup (org.olat.group.BusinessGroup)26 HashMap (java.util.HashMap)22 HashSet (java.util.HashSet)22 TextFlexiCellRenderer (org.olat.core.gui.components.form.flexible.impl.elements.table.TextFlexiCellRenderer)22 StaticTextElement (org.olat.core.gui.components.form.flexible.elements.StaticTextElement)20