use of uk.ac.ed.ph.jqtiplus.node.item.interaction.choice.Choice in project openolat by klemens.
the class AssessmentObjectVelocityRenderDecorator method getVisibleOrderedChoices.
public List<SimpleAssociableChoice> getVisibleOrderedChoices(MatchInteraction interaction, int pos) {
try {
List<SimpleAssociableChoice> choices;
if (interaction.getShuffle()) {
List<Identifier> choiceOrders = itemSessionState.getShuffledInteractionChoiceOrder(interaction.getResponseIdentifier());
Map<Identifier, SimpleAssociableChoice> idTochoice = new HashMap<>();
List<SimpleAssociableChoice> allChoices = interaction.getSimpleMatchSets().get(pos).getSimpleAssociableChoices();
for (SimpleAssociableChoice allChoice : allChoices) {
idTochoice.put(allChoice.getIdentifier(), allChoice);
}
choices = new ArrayList<>();
for (Identifier choiceOrder : choiceOrders) {
SimpleAssociableChoice choice = idTochoice.get(choiceOrder);
if (choice != null) {
choices.add(choice);
}
}
} else {
choices = interaction.getSimpleMatchSets().get(pos).getSimpleAssociableChoices();
}
return choices.stream().filter((choice) -> isVisible(choice, itemSessionState)).collect(Collectors.toList());
} catch (Exception e) {
log.error("", e);
return null;
}
}
use of uk.ac.ed.ph.jqtiplus.node.item.interaction.choice.Choice in project openolat by klemens.
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 uk.ac.ed.ph.jqtiplus.node.item.interaction.choice.Choice in project OpenOLAT by OpenOLAT.
the class AssessmentObjectVelocityRenderDecorator method getVisibleOrderedSimpleChoices.
public List<SimpleChoice> getVisibleOrderedSimpleChoices(OrderInteraction interaction) {
List<SimpleChoice> choices;
if (interaction.getShuffle()) {
// <xsl:variable name="shuffledChoiceOrders" select="$itemSessionState/qw:shuffledInteractionChoiceOrder"
// as="element(qw:shuffledInteractionChoiceOrder)*"/>
// <xsl:variable name="choiceSequence" as="xs:string?"
// select="$shuffledChoiceOrders[@responseIdentifier=$interaction/@responseIdentifier]/@choiceSequence"/>
List<Identifier> choiceOrders = itemSessionState.getShuffledInteractionChoiceOrder(interaction.getResponseIdentifier());
choices = new ArrayList<>();
for (Identifier choiceOrder : choiceOrders) {
choices.add(interaction.getSimpleChoice(choiceOrder));
}
} else {
choices = interaction.getSimpleChoices();
}
return choices.stream().filter((choice) -> isVisible(choice, itemSessionState)).collect(Collectors.toList());
}
use of uk.ac.ed.ph.jqtiplus.node.item.interaction.choice.Choice in project OpenOLAT by OpenOLAT.
the class AssessmentObjectVelocityRenderDecorator method getVisibleOrderedChoices.
public List<GapChoice> getVisibleOrderedChoices(GapMatchInteraction interaction) {
List<GapChoice> choices;
if (interaction.getShuffle()) {
// <xsl:variable name="shuffledChoiceOrders" select="$itemSessionState/qw:shuffledInteractionChoiceOrder"
// as="element(qw:shuffledInteractionChoiceOrder)*"/>
// <xsl:variable name="choiceSequence" as="xs:string?"
// select="$shuffledChoiceOrders[@responseIdentifier=$interaction/@responseIdentifier]/@choiceSequence"/>
List<Identifier> choiceOrders = itemSessionState.getShuffledInteractionChoiceOrder(interaction.getResponseIdentifier());
choices = new ArrayList<>();
for (Identifier choiceOrder : choiceOrders) {
choices.add(interaction.getGapChoice(choiceOrder));
}
} else {
choices = new ArrayList<>(interaction.getGapChoices());
}
return choices.stream().filter((choice) -> isVisible(choice, itemSessionState)).collect(Collectors.toList());
}
use of uk.ac.ed.ph.jqtiplus.node.item.interaction.choice.Choice in project OpenOLAT by OpenOLAT.
the class AssessmentObjectVelocityRenderDecorator method getVisibleOrderedChoices.
public List<SimpleAssociableChoice> getVisibleOrderedChoices(MatchInteraction interaction, int pos) {
try {
List<SimpleAssociableChoice> choices;
if (interaction.getShuffle()) {
List<Identifier> choiceOrders = itemSessionState.getShuffledInteractionChoiceOrder(interaction.getResponseIdentifier());
Map<Identifier, SimpleAssociableChoice> idTochoice = new HashMap<>();
List<SimpleAssociableChoice> allChoices = interaction.getSimpleMatchSets().get(pos).getSimpleAssociableChoices();
for (SimpleAssociableChoice allChoice : allChoices) {
idTochoice.put(allChoice.getIdentifier(), allChoice);
}
choices = new ArrayList<>();
for (Identifier choiceOrder : choiceOrders) {
SimpleAssociableChoice choice = idTochoice.get(choiceOrder);
if (choice != null) {
choices.add(choice);
}
}
} else {
choices = interaction.getSimpleMatchSets().get(pos).getSimpleAssociableChoices();
}
return choices.stream().filter((choice) -> isVisible(choice, itemSessionState)).collect(Collectors.toList());
} catch (Exception e) {
log.error("", e);
return null;
}
}
Aggregations