Search in sources :

Example 6 with PromptGroup

use of uk.ac.ed.ph.jqtiplus.group.item.interaction.PromptGroup in project openolat by klemens.

the class AssessmentItemFactory method appendMatchInteractionTrueFalse.

public static MatchInteraction appendMatchInteractionTrueFalse(ItemBody itemBody, String unanswered, String right, String wrong, Identifier responseDeclarationId) {
    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 sourceMatchSet = new SimpleMatchSet(matchInteraction);
    matchInteraction.getSimpleMatchSets().add(sourceMatchSet);
    String[] sources = new String[] { "A", "B" };
    for (int i = 0; i < sources.length; i++) {
        appendSimpleAssociableChoice(sourceMatchSet, sources[i], 1, 1);
    }
    SimpleMatchSet targetMatchSet = new SimpleMatchSet(matchInteraction);
    matchInteraction.getSimpleMatchSets().add(targetMatchSet);
    String[] targets = new String[] { unanswered, right, wrong };
    for (int i = 0; i < targets.length; i++) {
        appendSimpleAssociableChoice(targetMatchSet, targets[i], 0, 0);
    }
    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) PromptGroup(uk.ac.ed.ph.jqtiplus.group.item.interaction.PromptGroup)

Example 7 with PromptGroup

use of uk.ac.ed.ph.jqtiplus.group.item.interaction.PromptGroup in project openolat by klemens.

the class AssessmentItemFactory method createSingleChoiceInteraction.

public static ChoiceInteraction createSingleChoiceInteraction(AssessmentItem assessmentItem, Identifier responseDeclarationId, Orientation orientation, List<String> classAtrr) {
    ChoiceInteraction choiceInteraction = new ChoiceInteraction(assessmentItem.getItemBody());
    choiceInteraction.setMaxChoices(1);
    choiceInteraction.setShuffle(true);
    if (orientation != null) {
        choiceInteraction.setOrientation(orientation);
    }
    choiceInteraction.setResponseIdentifier(responseDeclarationId);
    if (classAtrr != null && classAtrr.size() > 0) {
        choiceInteraction.setClassAttr(classAtrr);
    }
    PromptGroup prompts = new PromptGroup(choiceInteraction);
    choiceInteraction.getNodeGroups().add(prompts);
    SimpleChoiceGroup singleChoices = new SimpleChoiceGroup(choiceInteraction);
    choiceInteraction.getNodeGroups().add(singleChoices);
    return choiceInteraction;
}
Also used : ChoiceInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.ChoiceInteraction) PromptGroup(uk.ac.ed.ph.jqtiplus.group.item.interaction.PromptGroup) SimpleChoiceGroup(uk.ac.ed.ph.jqtiplus.group.item.interaction.choice.SimpleChoiceGroup)

Example 8 with PromptGroup

use of uk.ac.ed.ph.jqtiplus.group.item.interaction.PromptGroup in project OpenOLAT by OpenOLAT.

the class AssessmentItemFactory method appendMatchInteractionTrueFalse.

public static MatchInteraction appendMatchInteractionTrueFalse(ItemBody itemBody, String unanswered, String right, String wrong, Identifier responseDeclarationId) {
    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 sourceMatchSet = new SimpleMatchSet(matchInteraction);
    matchInteraction.getSimpleMatchSets().add(sourceMatchSet);
    String[] sources = new String[] { "A", "B" };
    for (int i = 0; i < sources.length; i++) {
        appendSimpleAssociableChoice(sourceMatchSet, sources[i], 1, 1);
    }
    SimpleMatchSet targetMatchSet = new SimpleMatchSet(matchInteraction);
    matchInteraction.getSimpleMatchSets().add(targetMatchSet);
    String[] targets = new String[] { unanswered, right, wrong };
    for (int i = 0; i < targets.length; i++) {
        appendSimpleAssociableChoice(targetMatchSet, targets[i], 0, 0);
    }
    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) PromptGroup(uk.ac.ed.ph.jqtiplus.group.item.interaction.PromptGroup)

Example 9 with PromptGroup

use of uk.ac.ed.ph.jqtiplus.group.item.interaction.PromptGroup in project OpenOLAT by OpenOLAT.

the class AssessmentItemFactory method createMultipleChoiceInteraction.

public static ChoiceInteraction createMultipleChoiceInteraction(AssessmentItem assessmentItem, Identifier responseDeclarationId, Orientation orientation, List<String> classAtrr) {
    ChoiceInteraction choiceInteraction = new ChoiceInteraction(assessmentItem.getItemBody());
    choiceInteraction.setMaxChoices(0);
    choiceInteraction.setShuffle(true);
    if (orientation != null) {
        choiceInteraction.setOrientation(orientation);
    }
    if (classAtrr != null && classAtrr.size() > 0) {
        choiceInteraction.setClassAttr(classAtrr);
    }
    choiceInteraction.setResponseIdentifier(responseDeclarationId);
    PromptGroup prompts = new PromptGroup(choiceInteraction);
    choiceInteraction.getNodeGroups().add(prompts);
    SimpleChoiceGroup singleChoices = new SimpleChoiceGroup(choiceInteraction);
    choiceInteraction.getNodeGroups().add(singleChoices);
    return choiceInteraction;
}
Also used : ChoiceInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.ChoiceInteraction) PromptGroup(uk.ac.ed.ph.jqtiplus.group.item.interaction.PromptGroup) SimpleChoiceGroup(uk.ac.ed.ph.jqtiplus.group.item.interaction.choice.SimpleChoiceGroup)

Example 10 with PromptGroup

use of uk.ac.ed.ph.jqtiplus.group.item.interaction.PromptGroup in project OpenOLAT by OpenOLAT.

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)

Aggregations

PromptGroup (uk.ac.ed.ph.jqtiplus.group.item.interaction.PromptGroup)14 SimpleChoiceGroup (uk.ac.ed.ph.jqtiplus.group.item.interaction.choice.SimpleChoiceGroup)6 ChoiceInteraction (uk.ac.ed.ph.jqtiplus.node.item.interaction.ChoiceInteraction)6 MatchInteraction (uk.ac.ed.ph.jqtiplus.node.item.interaction.MatchInteraction)6 SimpleMatchSet (uk.ac.ed.ph.jqtiplus.node.item.interaction.choice.SimpleMatchSet)6 P (uk.ac.ed.ph.jqtiplus.node.content.xhtml.text.P)4 SimpleAssociableChoice (uk.ac.ed.ph.jqtiplus.node.item.interaction.choice.SimpleAssociableChoice)4 TextRun (uk.ac.ed.ph.jqtiplus.node.content.basic.TextRun)2 HottextInteraction (uk.ac.ed.ph.jqtiplus.node.item.interaction.HottextInteraction)2