use of uk.ac.ed.ph.jqtiplus.node.item.interaction.MatchInteraction 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.MatchInteraction 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;
}
use of uk.ac.ed.ph.jqtiplus.node.item.interaction.MatchInteraction in project openolat by klemens.
the class AlienItemAnalyzer method checkKprim.
private void checkKprim(Report report) {
List<Interaction> interactions = item.getItemBody().findInteractions();
if (interactions != null && interactions.size() == 1) {
Interaction interaction = interactions.get(0);
if (interaction instanceof MatchInteraction) {
report.addAlternative(QTI21QuestionType.match);
report.addAlternative(QTI21QuestionType.matchdraganddrop);
}
}
}
use of uk.ac.ed.ph.jqtiplus.node.item.interaction.MatchInteraction in project openolat by klemens.
the class AssessmentObjectComponentRenderer method getInteractionTemplate.
private String getInteractionTemplate(QtiNode interaction) {
String interactionName;
switch(interaction.getQtiClassName()) {
case "matchInteraction":
{
MatchInteraction matchInteraction = (MatchInteraction) interaction;
interactionName = interaction.getQtiClassName();
if (matchInteraction.getResponseIdentifier().toString().startsWith("KPRIM_")) {
interactionName += "_kprim";
} else if (hasClass(matchInteraction, QTI21Constants.CSS_MATCH_DRAG_AND_DROP)) {
interactionName += "_dnd";
} else if (hasClass(matchInteraction, QTI21Constants.CSS_MATCH_TRUE_FALSE)) {
interactionName += "_truefalse";
} else if (hasClass(matchInteraction, QTI21Constants.CSS_MATCH_KPRIM)) {
interactionName += "_kprim";
}
break;
}
case "mathEntryInteraction":
{
if (!CoreSpringFactory.getImpl(QTI21Module.class).isMathAssessExtensionEnabled()) {
interactionName = "mathEntryInteractionNotEnabled";
break;
}
}
default:
interactionName = interaction.getQtiClassName();
break;
}
String templateName = interactionName.substring(0, 1).toLowerCase().concat(interactionName.substring(1));
return velocity_root + "/" + templateName + ".html";
}
use of uk.ac.ed.ph.jqtiplus.node.item.interaction.MatchInteraction in project openolat by klemens.
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();
}
Aggregations