Search in sources :

Example 86 with FormLayoutContainer

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

the class FeedbacksEditorController method initForm.

@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
    setFormContextHelp("Test editor QTI 2.1 in detail#details_testeditor_feedback");
    formLayout.setElementCssClass("o_sel_assessment_item_feedbacks");
    DropdownItem dropdownEl = uifactory.addDropdownMenu("add.feedback.menu", null, formLayout, getTranslator());
    dropdownEl.setOrientation(DropdownOrientation.right);
    dropdownEl.setElementCssClass("o_sel_add_feedbacks");
    dropdownEl.setVisible(!restrictedEdit && !readOnly);
    dropdownEl.setEmbbeded(true);
    addHintButton = uifactory.addFormLink("add.hint.feedback", formLayout, Link.LINK);
    addHintButton.setElementCssClass("o_sel_add_hint");
    addHintButton.setVisible(enable.isEnabled(ModalFeedbackType.hint));
    dropdownEl.addElement(addHintButton);
    addCorrectSolutionButton = uifactory.addFormLink("add.correctSolution.feedback", formLayout, Link.LINK);
    addCorrectSolutionButton.setElementCssClass("o_sel_add_correct_solution");
    addCorrectSolutionButton.setVisible(enable.isEnabled(ModalFeedbackType.correctSolution));
    dropdownEl.addElement(addCorrectSolutionButton);
    addCorrectButton = uifactory.addFormLink("add.correct.feedback", formLayout, Link.LINK);
    addCorrectButton.setElementCssClass("o_sel_add_correct");
    addCorrectButton.setVisible(enable.isEnabled(ModalFeedbackType.correct));
    dropdownEl.addElement(addCorrectButton);
    addIncorrectButton = uifactory.addFormLink("add.incorrect.feedback", formLayout, Link.LINK);
    addIncorrectButton.setElementCssClass("o_sel_add_incorrect");
    addIncorrectButton.setVisible(enable.isEnabled(ModalFeedbackType.incorrect));
    dropdownEl.addElement(addIncorrectButton);
    addAnsweredButton = uifactory.addFormLink("add.answered.feedback", formLayout, Link.LINK);
    addAnsweredButton.setElementCssClass("o_sel_add_answered");
    addAnsweredButton.setVisible(enable.isEnabled(ModalFeedbackType.answered));
    dropdownEl.addElement(addAnsweredButton);
    addEmptyButton = uifactory.addFormLink("add.empty.feedback", formLayout, Link.LINK);
    addEmptyButton.setElementCssClass("o_sel_add_empty");
    addEmptyButton.setVisible(enable.isEnabled(ModalFeedbackType.empty));
    dropdownEl.addElement(addEmptyButton);
    addAdditionalButton = uifactory.addFormLink("add.additional.feedback", formLayout, Link.LINK);
    addAdditionalButton.setElementCssClass("o_sel_add_conditional");
    dropdownEl.addElement(addAdditionalButton);
    ModalFeedbackBuilder hint = itemBuilder.getHint();
    hintForm = new SimpleFeedbackForm(hint, ModalFeedbackType.hint);
    hintForm.initForm(ureq, formLayout);
    hintForm.setVisible(!hintForm.isEmpty());
    ModalFeedbackBuilder correctSolution = itemBuilder.getCorrectSolutionFeedback();
    correctSolutionForm = new SimpleFeedbackForm(correctSolution, ModalFeedbackType.correctSolution);
    correctSolutionForm.initForm(ureq, formLayout);
    correctSolutionForm.setVisible(!correctSolutionForm.isEmpty());
    ModalFeedbackBuilder correct = itemBuilder.getCorrectFeedback();
    correctForm = new SimpleFeedbackForm(correct, ModalFeedbackType.correct);
    correctForm.initForm(ureq, formLayout);
    correctForm.setVisible(!correctForm.isEmpty());
    ModalFeedbackBuilder incorrect = itemBuilder.getIncorrectFeedback();
    incorrectForm = new SimpleFeedbackForm(incorrect, ModalFeedbackType.incorrect);
    incorrectForm.initForm(ureq, formLayout);
    incorrectForm.setVisible(!incorrectForm.isEmpty());
    ModalFeedbackBuilder answered = itemBuilder.getAnsweredFeedback();
    answeredForm = new SimpleFeedbackForm(answered, ModalFeedbackType.answered);
    answeredForm.initForm(ureq, formLayout);
    answeredForm.setVisible(!answeredForm.isEmpty());
    ModalFeedbackBuilder empty = itemBuilder.getEmptyFeedback();
    emptyForm = new SimpleFeedbackForm(empty, ModalFeedbackType.empty);
    emptyForm.initForm(ureq, formLayout);
    emptyForm.setVisible(!emptyForm.isEmpty());
    List<ModalFeedbackBuilder> additionals = itemBuilder.getAdditionalFeedbackBuilders();
    if (additionals != null && additionals.size() > 0) {
        int count = 0;
        for (ModalFeedbackBuilder additional : additionals) {
            RuledFeedbackForm conditionForm = new RuledFeedbackForm(additional, ++count);
            conditionForm.initForm(ureq, formLayout);
            additionalForms.add(conditionForm);
        }
    }
    if (formLayout instanceof FormLayoutContainer) {
        FormLayoutContainer layoutCont = (FormLayoutContainer) formLayout;
        layoutCont.contextPut("additionals", additionalForms);
    }
    // Submit Button
    if (!restrictedEdit && !readOnly) {
        uifactory.addFormSubmitButton("submit", formLayout);
    }
    updateAddButtons();
}
Also used : ModalFeedbackBuilder(org.olat.ims.qti21.model.xml.ModalFeedbackBuilder) FormLayoutContainer(org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer) DropdownItem(org.olat.core.gui.components.dropdown.DropdownItem)

Example 87 with FormLayoutContainer

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

the class UnkownItemEditorController method initForm.

@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
    setFormWarning("warning.alien.assessment.item");
    convertLink = uifactory.addFormLink("convert.alien", formLayout, Link.BUTTON);
    convertLink.setEnabled(canConvert());
    if (formLayout instanceof FormLayoutContainer) {
        FormLayoutContainer layoutCont = (FormLayoutContainer) formLayout;
        String title = StringHelper.escapeHtml(item.getTitle());
        layoutCont.contextPut("title", title);
        String responseId = "responseBody" + CodeHelper.getRAMUniqueID();
        ItemBodyResultFormItem formItem = new ItemBodyResultFormItem(responseId, resolvedAssessmentItem);
        formLayout.add(responseId, formItem);
        layoutCont.contextPut("responseId", responseId);
        formItem.setLabel("form.imd.descr", null);
        formItem.setItemSessionState(itemSessionController.getItemSessionState());
        formItem.setCandidateSessionContext(new TerminatedStaticCandidateSessionContext(new InMemoryAssessmentTestSession()));
        formItem.setResourceLocator(inputResourceLocator);
        formItem.setAssessmentObjectUri(assessmentObjectUri);
        formItem.setMapperUri(mapperUri);
    }
}
Also used : ItemBodyResultFormItem(org.olat.ims.qti21.ui.components.ItemBodyResultFormItem) TerminatedStaticCandidateSessionContext(org.olat.ims.qti21.ui.assessment.TerminatedStaticCandidateSessionContext) FormLayoutContainer(org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer) InMemoryAssessmentTestSession(org.olat.ims.qti21.model.InMemoryAssessmentTestSession)

Example 88 with FormLayoutContainer

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

the class AssessmentSectionExpertOptionsEditorController method initForm.

@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
    formLayout.setElementCssClass("o_sel_assessment_section_expert_options");
    setFormContextHelp("Test editor QTI 2.1 in detail#details_testeditor_section");
    if (!editable) {
        setFormWarning("warning.alien.assessment.test");
    }
    super.initForm(formLayout, listener, ureq);
    allowSkippingEl.setHelpUrlForManualPage("Test editor QTI 2.1 in detail#details_testeditor_section");
    allowCommentEl.setHelpUrlForManualPage("Test editor QTI 2.1 in detail#details_testeditor_section");
    allowReviewEl.setHelpUrlForManualPage("Test editor QTI 2.1 in detail#details_testeditor_section");
    showSolutionEl.setHelpUrlForManualPage("Test editor QTI 2.1 in detail#details_testeditor_section");
    // visible
    String[] yesnoValues = new String[] { translate("yes"), translate("no") };
    visibleEl = uifactory.addRadiosHorizontal("visible", "form.section.visible", formLayout, yesnoKeys, yesnoValues);
    visibleEl.setElementCssClass("o_sel_assessment_section_visible");
    visibleEl.setEnabled(!restrictedEdit && editable);
    if (section.getVisible()) {
        visibleEl.select("y", true);
    } else {
        visibleEl.select("n", true);
    }
    FormLayoutContainer buttonsCont = FormLayoutContainer.createButtonLayout("butons", getTranslator());
    formLayout.add(buttonsCont);
    FormSubmit submit = uifactory.addFormSubmitButton("save", "save", buttonsCont);
    submit.setEnabled(editable);
}
Also used : FormSubmit(org.olat.core.gui.components.form.flexible.impl.elements.FormSubmit) FormLayoutContainer(org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer)

Example 89 with FormLayoutContainer

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

the class ChoiceScoreController method initForm.

@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
    setFormContextHelp(contextHelpUrl);
    super.initForm(formLayout, listener, ureq);
    ScoreBuilder minScore = itemBuilder.getMinScoreBuilder();
    String minValue = minScore == null ? "" : (minScore.getScore() == null ? "" : minScore.getScore().toString());
    minScoreEl = uifactory.addTextElement("min.score", "min.score", 8, minValue, formLayout);
    minScoreEl.setElementCssClass("o_sel_assessment_item_min_score");
    minScoreEl.setEnabled(!restrictedEdit && !readOnly);
    ScoreBuilder maxScore = itemBuilder.getMaxScoreBuilder();
    String maxValue = maxScore == null ? "" : (maxScore.getScore() == null ? "" : maxScore.getScore().toString());
    maxScoreEl = uifactory.addTextElement("max.score", "max.score", 8, maxValue, formLayout);
    maxScoreEl.setElementCssClass("o_sel_assessment_item_max_score");
    maxScoreEl.setEnabled(!restrictedEdit && !readOnly);
    String[] choiceKeys = new String[0];
    String[] choiceValues = new String[0];
    maxChoicesEl = uifactory.addDropdownSingleselect("max.choices", formLayout, choiceKeys, choiceValues, null);
    maxChoicesEl.setEnabled(!restrictedEdit && !readOnly);
    minChoicesEl = uifactory.addDropdownSingleselect("min.choices", formLayout, choiceKeys, choiceValues, null);
    minChoicesEl.setEnabled(!restrictedEdit && !readOnly);
    updateMinMaxChoices();
    String[] modeValues = new String[] { translate("form.score.assessment.all.correct"), translate("form.score.assessment.per.answer") };
    assessmentModeEl = uifactory.addRadiosHorizontal("assessment.mode", "form.score.assessment.mode", formLayout, modeKeys, modeValues);
    assessmentModeEl.setEnabled(!restrictedEdit && !readOnly);
    assessmentModeEl.addActionListener(FormEvent.ONCHANGE);
    if (itemBuilder.getScoreEvaluationMode() == ScoreEvaluation.perAnswer) {
        assessmentModeEl.select(ScoreEvaluation.perAnswer.name(), true);
    } else {
        assessmentModeEl.select(ScoreEvaluation.allCorrectAnswers.name(), true);
    }
    String scorePage = velocity_root + "/choices_score.html";
    scoreCont = FormLayoutContainer.createCustomFormLayout("scores", getTranslator(), scorePage);
    formLayout.add(scoreCont);
    scoreCont.setLabel(null, null);
    for (Choice choice : itemBuilder.getChoices()) {
        ChoiceWrapper wrapper = createChoiceWrapper(choice);
        wrappers.add(wrapper);
    }
    scoreCont.contextPut("choices", wrappers);
    scoreCont.contextPut("restrictedEdit", restrictedEdit || readOnly);
    scoreCont.setVisible(assessmentModeEl.isSelected(1));
    // Submit Button
    FormLayoutContainer buttonsContainer = FormLayoutContainer.createButtonLayout("buttons", getTranslator());
    buttonsContainer.setRootForm(mainForm);
    buttonsContainer.setVisible(!readOnly);
    formLayout.add(buttonsContainer);
    uifactory.addFormSubmitButton("submit", buttonsContainer);
}
Also used : Choice(uk.ac.ed.ph.jqtiplus.node.item.interaction.choice.Choice) SimpleChoice(uk.ac.ed.ph.jqtiplus.node.item.interaction.choice.SimpleChoice) ScoreBuilder(org.olat.ims.qti21.model.xml.ScoreBuilder) FormLayoutContainer(org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer)

Example 90 with FormLayoutContainer

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

the class AssessmentSectionOptionsEditorController method initForm.

@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
    formLayout.setElementCssClass("o_sel_assessment_section_options");
    setFormContextHelp("Test editor QTI 2.1 in detail#details_testeditor_section");
    if (!editable) {
        setFormWarning("warning.alien.assessment.test");
    }
    String title = section.getTitle();
    titleEl = uifactory.addTextElement("title", "form.metadata.title", 255, title, formLayout);
    titleEl.setEnabled(editable);
    titleEl.setMandatory(true);
    String relativePath = rootDirectory.toPath().relativize(testFile.toPath().getParent()).toString();
    VFSContainer itemContainer = (VFSContainer) rootContainer.resolve(relativePath);
    if (section.getRubricBlocks().isEmpty()) {
        RichTextElement rubricEl = uifactory.addRichTextElementForQTI21("rubric" + counter++, "form.imd.rubric", "", 12, -1, itemContainer, formLayout, ureq.getUserSession(), getWindowControl());
        rubricEl.getEditorConfiguration().setFileBrowserUploadRelPath("media");
        rubricEl.setEnabled(editable);
        rubricEls.add(rubricEl);
    } else {
        for (RubricBlock rubricBlock : section.getRubricBlocks()) {
            String rubric = htmlBuilder.blocksString(rubricBlock.getBlocks());
            RichTextElement rubricEl = uifactory.addRichTextElementForQTI21("rubric" + counter++, "form.imd.rubric", rubric, 12, -1, itemContainer, formLayout, ureq.getUserSession(), getWindowControl());
            rubricEl.getEditorConfiguration().setFileBrowserUploadRelPath("media");
            rubricEl.setEnabled(editable);
            rubricEl.setUserObject(rubricBlock);
            rubricEls.add(rubricEl);
        }
    }
    // shuffle
    String[] yesnoValues = new String[] { translate("yes"), translate("no") };
    shuffleEl = uifactory.addRadiosHorizontal("shuffle", "form.section.shuffle", formLayout, yesnoKeys, yesnoValues);
    if (section.getOrdering() != null && section.getOrdering().getShuffle()) {
        shuffleEl.select("y", true);
    } else {
        shuffleEl.select("n", true);
    }
    shuffleEl.setEnabled(!restrictedEdit && editable);
    int numOfItems = getNumOfQuestions(section);
    String[] theKeys = new String[numOfItems + 1];
    String[] theValues = new String[numOfItems + 1];
    theKeys[0] = "0";
    theValues[0] = translate("form.section.selection_all");
    for (int i = 0; i < numOfItems; i++) {
        theKeys[i + 1] = Integer.toString(i + 1);
        theValues[i + 1] = Integer.toString(i + 1);
    }
    randomSelectedEl = uifactory.addDropdownSingleselect("form.section.selection_pre", formLayout, theKeys, theValues, null);
    randomSelectedEl.setHelpText(translate("form.section.selection_pre.hover"));
    randomSelectedEl.setEnabled(!restrictedEdit && editable);
    int currentNum = section.getSelection() != null ? section.getSelection().getSelect() : 0;
    if (currentNum <= numOfItems) {
        randomSelectedEl.select(theKeys[currentNum], true);
    } else if (currentNum > numOfItems) {
        randomSelectedEl.select(theKeys[numOfItems], true);
    } else {
        randomSelectedEl.select(theKeys[0], true);
    }
    FormLayoutContainer buttonsCont = FormLayoutContainer.createButtonLayout("butons", getTranslator());
    formLayout.add(buttonsCont);
    FormSubmit submit = uifactory.addFormSubmitButton("save", "save", buttonsCont);
    submit.setEnabled(editable);
}
Also used : RichTextElement(org.olat.core.gui.components.form.flexible.elements.RichTextElement) FormSubmit(org.olat.core.gui.components.form.flexible.impl.elements.FormSubmit) VFSContainer(org.olat.core.util.vfs.VFSContainer) FormLayoutContainer(org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer) RubricBlock(uk.ac.ed.ph.jqtiplus.node.content.variable.RubricBlock)

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