use of org.olat.ims.qti21.ui.components.FlowFormItem in project openolat by klemens.
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");
}
}
use of org.olat.ims.qti21.ui.components.FlowFormItem in project openolat by klemens.
the class TrueFalseEditorController method wrapSource.
private void wrapSource(UserRequest ureq, SimpleAssociableChoice choice, List<SourceWrapper> 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("");
SourceWrapper wrapper = new SourceWrapper(choice, choiceEl, choiceReadOnlyEl, deleteButton);
deleteButton.setUserObject(wrapper);
wrappers.add(wrapper);
}
use of org.olat.ims.qti21.ui.components.FlowFormItem in project openolat by klemens.
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);
}
use of org.olat.ims.qti21.ui.components.FlowFormItem in project openolat by klemens.
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);
}
use of org.olat.ims.qti21.ui.components.FlowFormItem in project openolat by klemens.
the class KPrimEditorController method wrapAnswer.
private void wrapAnswer(UserRequest ureq, SimpleAssociableChoice choice) {
List<FlowStatic> choiceFlow = choice.getFlowStatics();
String choiceContent = itemBuilder.getHtmlHelper().flowStaticString(choiceFlow);
String choiceId = "answer" + count++;
RichTextElement choiceEl = uifactory.addRichTextElementForQTI21(choiceId, "form.imd.answer", choiceContent, 8, -1, itemContainer, answersCont, ureq.getUserSession(), getWindowControl());
choiceEl.getEditorConfiguration().setSimplestTextModeAllowed(TextMode.oneLine);
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 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 KprimWrapper(choice, choiceEl, choiceReadOnlyEl, upLink, downLink));
}
Aggregations