Search in sources :

Example 6 with HotspotInteraction

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;
}
Also used : HotspotInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.HotspotInteraction) HotspotChoice(uk.ac.ed.ph.jqtiplus.node.item.interaction.graphic.HotspotChoice) ArrayList(java.util.ArrayList) Object(uk.ac.ed.ph.jqtiplus.node.content.xhtml.object.Object)

Example 7 with 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);
}
Also used : HotspotInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.HotspotInteraction) JqtiExtensionManager(uk.ac.ed.ph.jqtiplus.JqtiExtensionManager) QtiSerializer(uk.ac.ed.ph.jqtiplus.serialization.QtiSerializer) TextEntryInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.TextEntryInteraction) ExtendedTextInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.ExtendedTextInteraction) HotspotInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.HotspotInteraction) Interaction(uk.ac.ed.ph.jqtiplus.node.item.interaction.Interaction) ChoiceInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.ChoiceInteraction) MatchInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.MatchInteraction) HotspotAssessmentItemBuilder(org.olat.ims.qti21.model.xml.interactions.HotspotAssessmentItemBuilder) ResolvedAssessmentItem(uk.ac.ed.ph.jqtiplus.resolution.ResolvedAssessmentItem) AssessmentItem(uk.ac.ed.ph.jqtiplus.node.item.AssessmentItem) ResponseDeclaration(uk.ac.ed.ph.jqtiplus.node.item.response.declaration.ResponseDeclaration) ItemValidationResult(uk.ac.ed.ph.jqtiplus.validation.ItemValidationResult) Test(org.junit.Test)

Example 8 with HotspotInteraction

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();
}
Also used : MatchInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.MatchInteraction) KPrimStatisticsController(org.olat.ims.qti21.ui.statistics.interactions.KPrimStatisticsController) HotspotInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.HotspotInteraction) HottextInteractionStatisticsController(org.olat.ims.qti21.ui.statistics.interactions.HottextInteractionStatisticsController) ChoiceInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.ChoiceInteraction) SimpleChoiceInteractionStatisticsController(org.olat.ims.qti21.ui.statistics.interactions.SimpleChoiceInteractionStatisticsController) HottextInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.HottextInteraction) MatchStatisticsController(org.olat.ims.qti21.ui.statistics.interactions.MatchStatisticsController) UnsupportedInteractionController(org.olat.ims.qti21.ui.statistics.interactions.UnsupportedInteractionController) TextEntryInteractionsStatisticsController(org.olat.ims.qti21.ui.statistics.interactions.TextEntryInteractionsStatisticsController) HotspotInteractionStatisticsController(org.olat.ims.qti21.ui.statistics.interactions.HotspotInteractionStatisticsController) MatchStatisticsController(org.olat.ims.qti21.ui.statistics.interactions.MatchStatisticsController) UserFilterController(org.olat.modules.assessment.ui.UserFilterController) SimpleChoiceInteractionStatisticsController(org.olat.ims.qti21.ui.statistics.interactions.SimpleChoiceInteractionStatisticsController) KPrimStatisticsController(org.olat.ims.qti21.ui.statistics.interactions.KPrimStatisticsController) HottextInteractionStatisticsController(org.olat.ims.qti21.ui.statistics.interactions.HottextInteractionStatisticsController) Controller(org.olat.core.gui.control.Controller) BasicController(org.olat.core.gui.control.controller.BasicController) UnsupportedInteractionController(org.olat.ims.qti21.ui.statistics.interactions.UnsupportedInteractionController) HotspotInteractionStatisticsController(org.olat.ims.qti21.ui.statistics.interactions.HotspotInteractionStatisticsController)

Example 9 with HotspotInteraction

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;
}
Also used : HotspotInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.HotspotInteraction) AssessmentItemFactory.appendHotspotInteraction(org.olat.ims.qti21.model.xml.AssessmentItemFactory.appendHotspotInteraction) ArrayList(java.util.ArrayList) Block(uk.ac.ed.ph.jqtiplus.node.content.basic.Block)

Example 10 with HotspotInteraction

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;
}
Also used : HotspotInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.HotspotInteraction) HotspotChoice(uk.ac.ed.ph.jqtiplus.node.item.interaction.graphic.HotspotChoice) ArrayList(java.util.ArrayList) Object(uk.ac.ed.ph.jqtiplus.node.content.xhtml.object.Object)

Aggregations

HotspotInteraction (uk.ac.ed.ph.jqtiplus.node.item.interaction.HotspotInteraction)12 ChoiceInteraction (uk.ac.ed.ph.jqtiplus.node.item.interaction.ChoiceInteraction)6 ArrayList (java.util.ArrayList)4 AssessmentItemFactory.appendHotspotInteraction (org.olat.ims.qti21.model.xml.AssessmentItemFactory.appendHotspotInteraction)4 Block (uk.ac.ed.ph.jqtiplus.node.content.basic.Block)4 HottextInteraction (uk.ac.ed.ph.jqtiplus.node.item.interaction.HottextInteraction)4 MatchInteraction (uk.ac.ed.ph.jqtiplus.node.item.interaction.MatchInteraction)4 ResponseDeclaration (uk.ac.ed.ph.jqtiplus.node.item.response.declaration.ResponseDeclaration)4 IOException (java.io.IOException)2 Test (org.junit.Test)2 Controller (org.olat.core.gui.control.Controller)2 BasicController (org.olat.core.gui.control.controller.BasicController)2 StringOutput (org.olat.core.gui.render.StringOutput)2 HotspotAssessmentItemBuilder (org.olat.ims.qti21.model.xml.interactions.HotspotAssessmentItemBuilder)2 HotspotInteractionStatisticsController (org.olat.ims.qti21.ui.statistics.interactions.HotspotInteractionStatisticsController)2 HottextInteractionStatisticsController (org.olat.ims.qti21.ui.statistics.interactions.HottextInteractionStatisticsController)2 KPrimStatisticsController (org.olat.ims.qti21.ui.statistics.interactions.KPrimStatisticsController)2 MatchStatisticsController (org.olat.ims.qti21.ui.statistics.interactions.MatchStatisticsController)2 SimpleChoiceInteractionStatisticsController (org.olat.ims.qti21.ui.statistics.interactions.SimpleChoiceInteractionStatisticsController)2 TextEntryInteractionsStatisticsController (org.olat.ims.qti21.ui.statistics.interactions.TextEntryInteractionsStatisticsController)2