Search in sources :

Example 1 with HotspotInteraction

use of uk.ac.ed.ph.jqtiplus.node.item.interaction.HotspotInteraction in project OpenOLAT by OpenOLAT.

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 2 with HotspotInteraction

use of uk.ac.ed.ph.jqtiplus.node.item.interaction.HotspotInteraction in project OpenOLAT by OpenOLAT.

the class HotspotAssessmentItemBuilder method extractHotspotInteraction.

private void extractHotspotInteraction() {
    try (StringOutput sb = new StringOutput()) {
        List<Block> blocks = assessmentItem.getItemBody().getBlocks();
        for (Block block : blocks) {
            if (block instanceof HotspotInteraction) {
                hotspotInteraction = (HotspotInteraction) block;
                responseIdentifier = hotspotInteraction.getResponseIdentifier();
                break;
            } else {
                serializeJqtiObject(block, sb);
            }
        }
        question = sb.toString();
    } catch (IOException e) {
        log.error("", e);
    }
}
Also used : HotspotInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.HotspotInteraction) AssessmentItemFactory.appendHotspotInteraction(org.olat.ims.qti21.model.xml.AssessmentItemFactory.appendHotspotInteraction) Block(uk.ac.ed.ph.jqtiplus.node.content.basic.Block) StringOutput(org.olat.core.gui.render.StringOutput) IOException(java.io.IOException)

Example 3 with HotspotInteraction

use of uk.ac.ed.ph.jqtiplus.node.item.interaction.HotspotInteraction in project OpenOLAT by OpenOLAT.

the class AssessmentObjectVelocityRenderDecorator method isSingleChoice.

/**
 * Check the maxChoices and the cardinality
 * @param interaction
 * @return
 */
public boolean isSingleChoice(Interaction interaction) {
    if (interaction instanceof ChoiceInteraction) {
        ChoiceInteraction choiceInteraction = (ChoiceInteraction) interaction;
        boolean sc = choiceInteraction.getMaxChoices() == 1;
        ResponseDeclaration responseDeclaration = assessmentItem.getResponseDeclaration(choiceInteraction.getResponseIdentifier());
        if (responseDeclaration != null && responseDeclaration.hasCardinality(Cardinality.MULTIPLE)) {
            return false;
        }
        return sc;
    } else if (interaction instanceof HottextInteraction) {
        HottextInteraction hottextInteraction = (HottextInteraction) interaction;
        boolean sc = hottextInteraction.getMaxChoices() == 1;
        ResponseDeclaration responseDeclaration = assessmentItem.getResponseDeclaration(hottextInteraction.getResponseIdentifier());
        if (responseDeclaration != null && responseDeclaration.hasCardinality(Cardinality.MULTIPLE)) {
            return false;
        }
        return sc;
    } else if (interaction instanceof HotspotInteraction) {
        HotspotInteraction hotspotInteraction = (HotspotInteraction) interaction;
        ResponseDeclaration responseDeclaration = assessmentItem.getResponseDeclaration(hotspotInteraction.getResponseIdentifier());
        if (responseDeclaration != null && responseDeclaration.hasCardinality(Cardinality.SINGLE)) {
            return true;
        }
        return false;
    }
    return false;
}
Also used : HotspotInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.HotspotInteraction) InlineChoiceInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.InlineChoiceInteraction) ChoiceInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.ChoiceInteraction) HottextInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.HottextInteraction) ResponseDeclaration(uk.ac.ed.ph.jqtiplus.node.item.response.declaration.ResponseDeclaration)

Example 4 with HotspotInteraction

use of uk.ac.ed.ph.jqtiplus.node.item.interaction.HotspotInteraction in project openolat by klemens.

the class HotspotAssessmentItemBuilder method extractHotspotInteraction.

private void extractHotspotInteraction() {
    try (StringOutput sb = new StringOutput()) {
        List<Block> blocks = assessmentItem.getItemBody().getBlocks();
        for (Block block : blocks) {
            if (block instanceof HotspotInteraction) {
                hotspotInteraction = (HotspotInteraction) block;
                responseIdentifier = hotspotInteraction.getResponseIdentifier();
                break;
            } else {
                serializeJqtiObject(block, sb);
            }
        }
        question = sb.toString();
    } catch (IOException e) {
        log.error("", e);
    }
}
Also used : HotspotInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.HotspotInteraction) AssessmentItemFactory.appendHotspotInteraction(org.olat.ims.qti21.model.xml.AssessmentItemFactory.appendHotspotInteraction) Block(uk.ac.ed.ph.jqtiplus.node.content.basic.Block) StringOutput(org.olat.core.gui.render.StringOutput) IOException(java.io.IOException)

Example 5 with HotspotInteraction

use of uk.ac.ed.ph.jqtiplus.node.item.interaction.HotspotInteraction in project openolat by klemens.

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)

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