Search in sources :

Example 36 with MatchInteraction

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;
}
Also used : MatchInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.MatchInteraction) SimpleMatchSet(uk.ac.ed.ph.jqtiplus.node.item.interaction.choice.SimpleMatchSet) P(uk.ac.ed.ph.jqtiplus.node.content.xhtml.text.P) SimpleAssociableChoice(uk.ac.ed.ph.jqtiplus.node.item.interaction.choice.SimpleAssociableChoice) PromptGroup(uk.ac.ed.ph.jqtiplus.group.item.interaction.PromptGroup)

Example 37 with 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;
}
Also used : MatchInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.MatchInteraction) SimpleMatchSet(uk.ac.ed.ph.jqtiplus.node.item.interaction.choice.SimpleMatchSet) P(uk.ac.ed.ph.jqtiplus.node.content.xhtml.text.P) SimpleAssociableChoice(uk.ac.ed.ph.jqtiplus.node.item.interaction.choice.SimpleAssociableChoice) PromptGroup(uk.ac.ed.ph.jqtiplus.group.item.interaction.PromptGroup) TextRun(uk.ac.ed.ph.jqtiplus.node.content.basic.TextRun)

Example 38 with 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);
        }
    }
}
Also used : MatchInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.MatchInteraction) Interaction(uk.ac.ed.ph.jqtiplus.node.item.interaction.Interaction) MatchInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.MatchInteraction)

Example 39 with MatchInteraction

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";
}
Also used : MatchInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.MatchInteraction) GraphicGapMatchInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.GraphicGapMatchInteraction) GapMatchInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.GapMatchInteraction) QTI21Module(org.olat.ims.qti21.QTI21Module) AssessmentRenderFunctions.contentAsString(org.olat.ims.qti21.ui.components.AssessmentRenderFunctions.contentAsString)

Example 40 with MatchInteraction

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();
}
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)

Aggregations

MatchInteraction (uk.ac.ed.ph.jqtiplus.node.item.interaction.MatchInteraction)40 SimpleAssociableChoice (uk.ac.ed.ph.jqtiplus.node.item.interaction.choice.SimpleAssociableChoice)18 ArrayList (java.util.ArrayList)12 SimpleMatchSet (uk.ac.ed.ph.jqtiplus.node.item.interaction.choice.SimpleMatchSet)12 Block (uk.ac.ed.ph.jqtiplus.node.content.basic.Block)10 HashMap (java.util.HashMap)8 AssessmentItem (uk.ac.ed.ph.jqtiplus.node.item.AssessmentItem)8 ResponseDeclaration (uk.ac.ed.ph.jqtiplus.node.item.response.declaration.ResponseDeclaration)8 Identifier (uk.ac.ed.ph.jqtiplus.types.Identifier)8 IOException (java.io.IOException)6 List (java.util.List)6 FormLayoutContainer (org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer)6 StringOutput (org.olat.core.gui.render.StringOutput)6 AssessmentItemFactory.appendMatchInteraction (org.olat.ims.qti21.model.xml.AssessmentItemFactory.appendMatchInteraction)6 ChoiceInteraction (uk.ac.ed.ph.jqtiplus.node.item.interaction.ChoiceInteraction)6 HotspotInteraction (uk.ac.ed.ph.jqtiplus.node.item.interaction.HotspotInteraction)6 Interaction (uk.ac.ed.ph.jqtiplus.node.item.interaction.Interaction)6 FlowFormItem (org.olat.ims.qti21.ui.components.FlowFormItem)5 Map (java.util.Map)4 Collectors (java.util.stream.Collectors)4