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();
}
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);
}
}
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);
}
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);
}
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);
}
Aggregations