use of uk.ac.ed.ph.jqtiplus.node.item.interaction.MatchInteraction in project OpenOLAT by OpenOLAT.
the class QTI21AssessmentItemStatisticsController method interactionControllerFactory.
private Component interactionControllerFactory(UserRequest ureq, Interaction interaction, StatisticsItem itemStats) {
Controller interactionCtrl = null;
if (interaction instanceof ChoiceInteraction) {
interactionCtrl = new SimpleChoiceInteractionStatisticsController(ureq, getWindowControl(), itemRef, item, (ChoiceInteraction) interaction, itemStats, resourceResult);
} else if (interaction instanceof MatchInteraction) {
String responseIdentifier = interaction.getResponseIdentifier().toString();
if (responseIdentifier.startsWith("KPRIM_") || QTI21QuestionType.hasClass(interaction, QTI21Constants.CSS_MATCH_KPRIM)) {
interactionCtrl = new KPrimStatisticsController(ureq, getWindowControl(), itemRef, item, (MatchInteraction) interaction, resourceResult);
} else {
interactionCtrl = new MatchStatisticsController(ureq, getWindowControl(), itemRef, item, (MatchInteraction) interaction, resourceResult);
}
} else if (interaction instanceof HotspotInteraction) {
interactionCtrl = new HotspotInteractionStatisticsController(ureq, getWindowControl(), itemRef, item, (HotspotInteraction) interaction, itemStats, resourceResult);
} else if (interaction instanceof HottextInteraction) {
interactionCtrl = new HottextInteractionStatisticsController(ureq, getWindowControl(), itemRef, item, (HottextInteraction) interaction, itemStats, resourceResult);
}
if (interactionCtrl == null) {
interactionCtrl = new UnsupportedInteractionController(ureq, getWindowControl(), interaction);
}
listenTo(interactionCtrl);
return interactionCtrl.getInitialComponent();
}
use of uk.ac.ed.ph.jqtiplus.node.item.interaction.MatchInteraction in project OpenOLAT by OpenOLAT.
the class KPrimAssessmentItemBuilder method getQuestionBlocks.
/**
* @return A copy of the list of blocks which make the question.
* The list is a copy and modification will not be persisted.
*/
public List<Block> getQuestionBlocks() {
List<Block> blocks = assessmentItem.getItemBody().getBlocks();
List<Block> questionBlocks = new ArrayList<>(blocks.size());
for (Block block : blocks) {
if (block instanceof MatchInteraction) {
break;
} else {
questionBlocks.add(block);
}
}
return questionBlocks;
}
use of uk.ac.ed.ph.jqtiplus.node.item.interaction.MatchInteraction in project OpenOLAT by OpenOLAT.
the class KPrimAssessmentItemBuilder method extractMatchInteraction.
private void extractMatchInteraction() {
try (StringOutput sb = new StringOutput()) {
List<Block> blocks = assessmentItem.getItemBody().getBlocks();
for (Block block : blocks) {
if (block instanceof MatchInteraction) {
matchInteraction = (MatchInteraction) block;
responseIdentifier = matchInteraction.getResponseIdentifier();
shuffle = matchInteraction.getShuffle();
cssClass = matchInteraction.getClassAttr();
break;
} else {
serializeJqtiObject(block, sb);
}
}
question = sb.toString();
} catch (IOException e) {
log.error("", e);
}
}
use of uk.ac.ed.ph.jqtiplus.node.item.interaction.MatchInteraction in project OpenOLAT by OpenOLAT.
the class MatchAssessmentItemBuilder method getQuestionBlocks.
/**
* @return A copy of the list of blocks which make the question.
* The list is a copy and modification will not be persisted.
*/
public List<Block> getQuestionBlocks() {
List<Block> blocks = assessmentItem.getItemBody().getBlocks();
List<Block> questionBlocks = new ArrayList<>(blocks.size());
for (Block block : blocks) {
if (block instanceof MatchInteraction) {
break;
} else {
questionBlocks.add(block);
}
}
return questionBlocks;
}
use of uk.ac.ed.ph.jqtiplus.node.item.interaction.MatchInteraction in project OpenOLAT by OpenOLAT.
the class AssessmentItemFactory method appendMatchInteractionTrueFalse.
public static MatchInteraction appendMatchInteractionTrueFalse(ItemBody itemBody, String unanswered, String right, String wrong, Identifier responseDeclarationId) {
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 sourceMatchSet = new SimpleMatchSet(matchInteraction);
matchInteraction.getSimpleMatchSets().add(sourceMatchSet);
String[] sources = new String[] { "A", "B" };
for (int i = 0; i < sources.length; i++) {
appendSimpleAssociableChoice(sourceMatchSet, sources[i], 1, 1);
}
SimpleMatchSet targetMatchSet = new SimpleMatchSet(matchInteraction);
matchInteraction.getSimpleMatchSets().add(targetMatchSet);
String[] targets = new String[] { unanswered, right, wrong };
for (int i = 0; i < targets.length; i++) {
appendSimpleAssociableChoice(targetMatchSet, targets[i], 0, 0);
}
return matchInteraction;
}
Aggregations