use of uk.ac.ed.ph.jqtiplus.node.item.interaction.choice.SimpleAssociableChoice in project OpenOLAT by OpenOLAT.
the class CSVToAssessmentItemConverter method processChoice_kprim.
private void processChoice_kprim(String[] parts, KPrimAssessmentItemBuilder kprimBuilder) {
String firstPart = parts[0].toLowerCase();
String answer = parts[1];
Identifier correctIncorrectIdentifier;
if ("+".equals(firstPart)) {
correctIncorrectIdentifier = QTI21Constants.CORRECT_IDENTIFIER;
} else {
correctIncorrectIdentifier = QTI21Constants.WRONG_IDENTIFIER;
}
List<SimpleAssociableChoice> choices = kprimBuilder.getKprimChoices();
SimpleAssociableChoice choice = choices.get(kprimPosition);
P choiceText = AssessmentItemFactory.getParagraph(choice, answer);
choice.getFlowStatics().clear();
choice.getFlowStatics().add(choiceText);
kprimBuilder.setAssociation(choice.getIdentifier(), correctIncorrectIdentifier);
kprimPosition++;
}
use of uk.ac.ed.ph.jqtiplus.node.item.interaction.choice.SimpleAssociableChoice in project openolat by klemens.
the class KPrimAssessmentItemBuilder method createAssessmentItem.
private static AssessmentItem createAssessmentItem(String title, String defaultAnswer) {
AssessmentItem assessmentItem = AssessmentItemFactory.createAssessmentItem(QTI21QuestionType.kprim, title);
NodeGroupList nodeGroups = assessmentItem.getNodeGroups();
double maxScore = 1.0d;
Identifier responseDeclarationId = Identifier.assumedLegal("KPRIM_RESPONSE_1");
// define correct answer
ResponseDeclaration responseDeclaration = createKPrimResponseDeclaration(assessmentItem, responseDeclarationId, new HashMap<>(), maxScore);
nodeGroups.getResponseDeclarationGroup().getResponseDeclarations().add(responseDeclaration);
appendDefaultOutcomeDeclarations(assessmentItem, maxScore);
// the single choice interaction
ItemBody itemBody = appendDefaultItemBody(assessmentItem);
MatchInteraction matchInteraction = appendMatchInteractionForKPrim(itemBody, responseDeclarationId, defaultAnswer);
List<String> cssClasses = new ArrayList<>();
cssClasses.add(QTI21Constants.CSS_MATCH_KPRIM);
matchInteraction.setClassAttr(cssClasses);
SimpleMatchSet matchSet = matchInteraction.getSimpleMatchSets().get(0);
Map<Identifier, Identifier> associations = new HashMap<>();
for (SimpleAssociableChoice choice : matchSet.getSimpleAssociableChoices()) {
associations.put(choice.getIdentifier(), QTI21Constants.WRONG_IDENTIFIER);
}
appendAssociationKPrimResponseDeclaration(responseDeclaration, associations, 1.0);
// response processing
ResponseProcessing responseProcessing = createResponseProcessing(assessmentItem, responseDeclarationId);
assessmentItem.getNodeGroups().getResponseProcessingGroup().setResponseProcessing(responseProcessing);
return assessmentItem;
}
use of uk.ac.ed.ph.jqtiplus.node.item.interaction.choice.SimpleAssociableChoice in project openolat by klemens.
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;
}
use of uk.ac.ed.ph.jqtiplus.node.item.interaction.choice.SimpleAssociableChoice in project openolat by klemens.
the class AssessmentItemFactory method appendMatchInteraction.
public static MatchInteraction appendMatchInteraction(ItemBody itemBody, Identifier responseDeclarationId) {
MatchInteraction matchInteraction = new MatchInteraction(itemBody);
matchInteraction.setResponseIdentifier(responseDeclarationId);
matchInteraction.setMaxAssociations(0);
matchInteraction.setShuffle(false);
itemBody.getBlocks().add(matchInteraction);
PromptGroup prompts = new PromptGroup(matchInteraction);
matchInteraction.getNodeGroups().add(prompts);
SimpleMatchSet sourceMatchSet = new SimpleMatchSet(matchInteraction);
matchInteraction.getSimpleMatchSets().add(sourceMatchSet);
String[] sources = new String[] { "A", "B" };
for (int i = 0; i < sources.length; i++) {
SimpleAssociableChoice sourceChoice = new SimpleAssociableChoice(sourceMatchSet);
sourceChoice.setMatchMax(0);
sourceChoice.setMatchMin(0);
sourceChoice.setIdentifier(IdentifierGenerator.newNumberAsIdentifier(sources[i]));
P question = getParagraph(sourceChoice, sources[i]);
sourceChoice.getFlowStatics().add(question);
sourceMatchSet.getSimpleAssociableChoices().add(sourceChoice);
}
SimpleMatchSet targetMatchSet = new SimpleMatchSet(matchInteraction);
matchInteraction.getSimpleMatchSets().add(targetMatchSet);
String[] targets = new String[] { "M", "N" };
for (int i = 0; i < targets.length; i++) {
SimpleAssociableChoice targetChoice = new SimpleAssociableChoice(sourceMatchSet);
targetChoice.setMatchMax(0);
targetChoice.setMatchMin(0);
targetChoice.setIdentifier(IdentifierGenerator.newNumberAsIdentifier(targets[i]));
P question = getParagraph(targetChoice, targets[i]);
targetChoice.getFlowStatics().add(question);
targetMatchSet.getSimpleAssociableChoices().add(targetChoice);
}
return matchInteraction;
}
use of uk.ac.ed.ph.jqtiplus.node.item.interaction.choice.SimpleAssociableChoice in project openolat by klemens.
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;
}
Aggregations