use of uk.ac.ed.ph.jqtiplus.node.item.interaction.choice.SimpleAssociableChoice in project openolat by klemens.
the class MatchEditorController method doAddTargetColumn.
private void doAddTargetColumn(UserRequest ureq) {
SimpleAssociableChoice newChoice = createSimpleAssociableChoice("Text", itemBuilder.getTargetMatchSet());
newChoice.setMatchMax(0);
itemBuilder.getTargetMatchSet().getSimpleAssociableChoices().add(newChoice);
wrapAnswer(ureq, newChoice, targetWrappers);
answersCont.setDirty(true);
}
use of uk.ac.ed.ph.jqtiplus.node.item.interaction.choice.SimpleAssociableChoice in project openolat by klemens.
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");
}
}
use of uk.ac.ed.ph.jqtiplus.node.item.interaction.choice.SimpleAssociableChoice in project openolat by klemens.
the class MatchScoreController method sync.
private List<MatchWrapper> sync(SimpleMatchSet matchSet, List<MatchWrapper> wrappers) {
Map<Identifier, MatchWrapper> currentMapping = wrappers.stream().collect(Collectors.toMap(w -> w.getChoiceIdentifier(), w -> w));
List<MatchWrapper> newWrappers = new ArrayList<>();
List<SimpleAssociableChoice> choices = matchSet.getSimpleAssociableChoices();
for (SimpleAssociableChoice choice : choices) {
if (currentMapping.containsKey(choice.getIdentifier())) {
newWrappers.add(currentMapping.get(choice.getIdentifier()));
} else {
newWrappers.add(createMatchWrapper(choice));
}
}
return newWrappers;
}
use of uk.ac.ed.ph.jqtiplus.node.item.interaction.choice.SimpleAssociableChoice in project openolat by klemens.
the class MatchScoreController method initForm.
@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
super.initForm(formLayout, listener, ureq);
setFormContextHelp("Test editor QTI 2.1 in detail#details_testeditor_score");
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[] 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.addActionListener(FormEvent.ONCHANGE);
assessmentModeEl.setEnabled(!restrictedEdit && !readOnly);
if (itemBuilder.getScoreEvaluationMode() == ScoreEvaluation.perAnswer) {
assessmentModeEl.select(ScoreEvaluation.perAnswer.name(), true);
} else {
assessmentModeEl.select(ScoreEvaluation.allCorrectAnswers.name(), true);
}
String scorePage = velocity_root + "/match_score.html";
scoreCont = FormLayoutContainer.createCustomFormLayout("scores", getTranslator(), scorePage);
formLayout.add(scoreCont);
scoreCont.setLabel(null, null);
scoreCont.setVisible(assessmentModeEl.isSelected(1));
scoreCont.contextPut("sourceLeft", Boolean.valueOf(sourceLeft));
for (SimpleAssociableChoice choice : itemBuilder.getSourceMatchSet().getSimpleAssociableChoices()) {
sourceWrappers.add(createMatchWrapper(choice));
}
scoreCont.contextPut("sourceChoices", sourceWrappers);
for (SimpleAssociableChoice choice : itemBuilder.getTargetMatchSet().getSimpleAssociableChoices()) {
targetWrappers.add(createMatchWrapper(choice));
}
scoreCont.contextPut("targetChoices", targetWrappers);
forgeScoreElements();
// Submit Button
FormLayoutContainer buttonsContainer = FormLayoutContainer.createButtonLayout("buttons", getTranslator());
buttonsContainer.setRootForm(mainForm);
buttonsContainer.setVisible(!readOnly);
formLayout.add(buttonsContainer);
uifactory.addFormSubmitButton("submit", buttonsContainer);
}
use of uk.ac.ed.ph.jqtiplus.node.item.interaction.choice.SimpleAssociableChoice 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");
}
}
Aggregations