use of uk.ac.ed.ph.jqtiplus.node.item.interaction.choice.SimpleAssociableChoice in project OpenOLAT by OpenOLAT.
the class MatchAssessmentItemBuilder method extractSingleChoice.
/**
* Single choice is a special edge case where
* all source choices have matchMax=1 and all
* target choices have matchMax=0
*/
private void extractSingleChoice() {
List<SimpleAssociableChoice> sourceChoices = matchInteraction.getSimpleMatchSets().get(0).getSimpleAssociableChoices();
List<SimpleAssociableChoice> targetChoices = matchInteraction.getSimpleMatchSets().get(1).getSimpleAssociableChoices();
boolean singleChoice = true;
for (SimpleAssociableChoice sourceChoice : sourceChoices) {
if (sourceChoice.getMatchMax() != 1) {
singleChoice &= false;
}
}
for (SimpleAssociableChoice targetChoice : targetChoices) {
if (targetChoice.getMatchMax() != 0) {
singleChoice &= false;
}
}
multipleChoice = !singleChoice;
}
use of uk.ac.ed.ph.jqtiplus.node.item.interaction.choice.SimpleAssociableChoice in project OpenOLAT by OpenOLAT.
the class QTI12To21Converter method convertKPrim.
private AssessmentItemBuilder convertKPrim(Item item) {
KPrimAssessmentItemBuilder itemBuilder = new KPrimAssessmentItemBuilder("Kprim", "New answer", qtiSerializer);
convertItemBasics(item, itemBuilder);
Question question = item.getQuestion();
itemBuilder.setShuffle(question.isShuffle());
List<Response> responses = question.getResponses();
List<SimpleAssociableChoice> choices = itemBuilder.getKprimChoices();
for (int i = 0; i < 4; i++) {
Response response = responses.get(i);
SimpleAssociableChoice choice = choices.get(i);
String answer = response.getContent().renderAsHtmlForEditor();
answer = blockedHtml(answer);
if (StringHelper.isHtml(answer)) {
htmlBuilder.appendHtml(choice, answer);
} else {
P firstChoiceText = AssessmentItemFactory.getParagraph(choice, answer);
choice.getFlowStatics().clear();
choice.getFlowStatics().add(firstChoiceText);
}
if (response.isCorrect()) {
itemBuilder.setAssociation(choice.getIdentifier(), QTI21Constants.CORRECT_IDENTIFIER);
} else {
itemBuilder.setAssociation(choice.getIdentifier(), QTI21Constants.WRONG_IDENTIFIER);
}
}
double score = question.getMaxValue();
itemBuilder.setMinScore(0.0d);
itemBuilder.setMaxScore(score);
return itemBuilder;
}
use of uk.ac.ed.ph.jqtiplus.node.item.interaction.choice.SimpleAssociableChoice in project OpenOLAT by OpenOLAT.
the class AssessmentItemFactory method appendSimpleAssociableChoice.
public static void appendSimpleAssociableChoice(SimpleMatchSet matchSet, String value, int matchMax, int matchMin) {
SimpleAssociableChoice choice = new SimpleAssociableChoice(matchSet);
choice.setMatchMax(matchMax);
choice.setMatchMin(matchMin);
choice.setIdentifier(IdentifierGenerator.newNumberAsIdentifier(value));
P question = getParagraph(choice, value);
choice.getFlowStatics().add(question);
matchSet.getSimpleAssociableChoices().add(choice);
}
use of uk.ac.ed.ph.jqtiplus.node.item.interaction.choice.SimpleAssociableChoice in project OpenOLAT by OpenOLAT.
the class AssessmentItemFactory method appendMatchInteractionForKPrim.
public static MatchInteraction appendMatchInteractionForKPrim(ItemBody itemBody, Identifier responseDeclarationId, String defaultAnswer) {
MatchInteraction matchInteraction = new MatchInteraction(itemBody);
matchInteraction.setResponseIdentifier(responseDeclarationId);
matchInteraction.setMaxAssociations(4);
matchInteraction.setShuffle(false);
itemBody.getBlocks().add(matchInteraction);
PromptGroup prompts = new PromptGroup(matchInteraction);
matchInteraction.getNodeGroups().add(prompts);
SimpleMatchSet questionMatchSet = new SimpleMatchSet(matchInteraction);
matchInteraction.getSimpleMatchSets().add(questionMatchSet);
String[] classic = new String[] { "a", "b", "c", "d" };
for (int i = 0; i < 4; i++) {
SimpleAssociableChoice correctChoice = new SimpleAssociableChoice(questionMatchSet);
correctChoice.setMatchMax(1);
correctChoice.setMatchMin(1);
correctChoice.setIdentifier(IdentifierGenerator.newNumberAsIdentifier(classic[i]));
P question = getParagraph(correctChoice, defaultAnswer + " " + classic[i]);
correctChoice.getFlowStatics().add(question);
questionMatchSet.getSimpleAssociableChoices().add(correctChoice);
}
SimpleMatchSet correctWrongMatchSet = new SimpleMatchSet(matchInteraction);
matchInteraction.getSimpleMatchSets().add(correctWrongMatchSet);
SimpleAssociableChoice correctChoice = new SimpleAssociableChoice(correctWrongMatchSet);
correctChoice.setMatchMax(4);
correctChoice.setFixed(Boolean.TRUE);
correctChoice.setIdentifier(QTI21Constants.CORRECT_IDENTIFIER);
correctChoice.getFlowStatics().add(new TextRun(correctChoice, "+"));
correctWrongMatchSet.getSimpleAssociableChoices().add(correctChoice);
SimpleAssociableChoice wrongChoice = new SimpleAssociableChoice(correctWrongMatchSet);
wrongChoice.setMatchMax(4);
wrongChoice.setFixed(Boolean.TRUE);
wrongChoice.setIdentifier(QTI21Constants.WRONG_IDENTIFIER);
wrongChoice.getFlowStatics().add(new TextRun(correctChoice, "-"));
correctWrongMatchSet.getSimpleAssociableChoices().add(wrongChoice);
return matchInteraction;
}
use of uk.ac.ed.ph.jqtiplus.node.item.interaction.choice.SimpleAssociableChoice in project OpenOLAT by OpenOLAT.
the class AssessmentItemFactory method createSimpleAssociableChoice.
public static SimpleAssociableChoice createSimpleAssociableChoice(String text, SimpleMatchSet matchSet) {
SimpleAssociableChoice targetChoice = new SimpleAssociableChoice(matchSet);
targetChoice.setMatchMax(0);
targetChoice.setMatchMin(0);
targetChoice.setIdentifier(IdentifierGenerator.newNumberAsIdentifier("sa"));
P question = getParagraph(targetChoice, text);
targetChoice.getFlowStatics().add(question);
return targetChoice;
}
Aggregations