use of org.olat.ims.qti21.ui.components.FlowFormItem in project openolat by klemens.
the class MultipleChoiceEditorController method wrapAnswer.
private void wrapAnswer(UserRequest ureq, SimpleChoice choice) {
List<FlowStatic> choiceFlow = choice.getFlowStatics();
String choiceContent = itemBuilder.getHtmlHelper().flowStaticString(choice.getFlowStatics());
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));
}
use of org.olat.ims.qti21.ui.components.FlowFormItem in project openolat by klemens.
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);
}
}
use of org.olat.ims.qti21.ui.components.FlowFormItem in project openolat by klemens.
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);
}
use of org.olat.ims.qti21.ui.components.FlowFormItem in project openolat by klemens.
the class DrawingEditorController method initForm.
@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
setFormContextHelp("Test editor QTI 2.1 in detail#details_testeditor_fragetypen_drawing");
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);
}
initialBackgroundImage = getCurrentBackground();
backgroundEl = uifactory.addFileElement(getWindowControl(), "form.imd.background", "form.imd.background", formLayout);
backgroundEl.setPreview(ureq.getUserSession(), true);
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() });
// 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);
}
use of org.olat.ims.qti21.ui.components.FlowFormItem in project openolat by klemens.
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);
}
Aggregations