use of uk.ac.ed.ph.jqtiplus.node.item.interaction.HotspotInteraction in project openolat by klemens.
the class AssessmentItemFactory method appendHotspotInteraction.
public static HotspotInteraction appendHotspotInteraction(ItemBody itemBody, Identifier responseDeclarationId, Identifier correctResponseId) {
HotspotInteraction hotspotInteraction = new HotspotInteraction(itemBody);
hotspotInteraction.setResponseIdentifier(responseDeclarationId);
hotspotInteraction.setMaxChoices(1);
itemBody.getBlocks().add(hotspotInteraction);
Object graphicObject = new Object(hotspotInteraction);
graphicObject.setType("image/png");
graphicObject.setWidth("400");
graphicObject.setHeight("320");
hotspotInteraction.setObject(graphicObject);
HotspotChoice choice = new HotspotChoice(hotspotInteraction);
choice.setIdentifier(correctResponseId);
choice.setFixed(Boolean.FALSE);
choice.setShape(Shape.CIRCLE);
List<Integer> coords = new ArrayList<>();
coords.add(new Integer(55));
coords.add(new Integer(77));
coords.add(new Integer(8));
choice.setCoords(coords);
hotspotInteraction.getHotspotChoices().add(choice);
return hotspotInteraction;
}
use of uk.ac.ed.ph.jqtiplus.node.item.interaction.HotspotInteraction in project openolat by klemens.
the class AssessmentItemBuilderTest method buildAssessmentItem_hotspot.
@Test
public void buildAssessmentItem_hotspot() throws IOException, URISyntaxException {
QtiSerializer qtiSerializer = new QtiSerializer(new JqtiExtensionManager());
HotspotAssessmentItemBuilder itemBuilder = new HotspotAssessmentItemBuilder("Hotspot", qtiSerializer);
if (build.booleanValue()) {
itemBuilder.build();
}
AssessmentItem assessmentItem = itemBuilder.getAssessmentItem();
ItemValidationResult itemResult = serializeAndReload(assessmentItem);
AssessmentItem reloadedItem = itemResult.getResolvedAssessmentItem().getItemLookup().extractIfSuccessful();
List<Interaction> interactions = reloadedItem.getItemBody().findInteractions();
Assert.assertNotNull(interactions);
Assert.assertEquals(1, interactions.size());
Assert.assertTrue(interactions.get(0) instanceof HotspotInteraction);
HotspotInteraction interaction = (HotspotInteraction) interactions.get(0);
Assert.assertNotNull(interaction.getResponseIdentifier());
ResponseDeclaration responseDeclaration = reloadedItem.getResponseDeclaration(interaction.getResponseIdentifier());
Assert.assertNotNull(responseDeclaration);
}
use of uk.ac.ed.ph.jqtiplus.node.item.interaction.HotspotInteraction 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.HotspotInteraction in project OpenOLAT by OpenOLAT.
the class HotspotAssessmentItemBuilder 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 HotspotInteraction) {
break;
} else {
questionBlocks.add(block);
}
}
return questionBlocks;
}
use of uk.ac.ed.ph.jqtiplus.node.item.interaction.HotspotInteraction in project OpenOLAT by OpenOLAT.
the class AssessmentItemFactory method appendHotspotInteraction.
public static HotspotInteraction appendHotspotInteraction(ItemBody itemBody, Identifier responseDeclarationId, Identifier correctResponseId) {
HotspotInteraction hotspotInteraction = new HotspotInteraction(itemBody);
hotspotInteraction.setResponseIdentifier(responseDeclarationId);
hotspotInteraction.setMaxChoices(1);
itemBody.getBlocks().add(hotspotInteraction);
Object graphicObject = new Object(hotspotInteraction);
graphicObject.setType("image/png");
graphicObject.setWidth("400");
graphicObject.setHeight("320");
hotspotInteraction.setObject(graphicObject);
HotspotChoice choice = new HotspotChoice(hotspotInteraction);
choice.setIdentifier(correctResponseId);
choice.setFixed(Boolean.FALSE);
choice.setShape(Shape.CIRCLE);
List<Integer> coords = new ArrayList<>();
coords.add(new Integer(55));
coords.add(new Integer(77));
coords.add(new Integer(8));
choice.setCoords(coords);
hotspotInteraction.getHotspotChoices().add(choice);
return hotspotInteraction;
}
Aggregations