Search in sources :

Example 6 with NodeGroupList

use of uk.ac.ed.ph.jqtiplus.group.NodeGroupList in project openolat by klemens.

the class AssessmentItemFactory method appendDefaultOutcomeDeclarations.

/**
 * Append the default outcome declaration for score, max score and feedback basic.
 *
 * @param assessmentItem
 */
public static void appendDefaultOutcomeDeclarations(AssessmentItem assessmentItem, double maxScore) {
    NodeGroupList nodeGroups = assessmentItem.getNodeGroups();
    // outcomes
    OutcomeDeclarationGroup outcomeDeclarations = nodeGroups.getOutcomeDeclarationGroup();
    // outcome score
    OutcomeDeclaration scoreOutcomeDeclaration = createOutcomeDeclarationForScore(assessmentItem);
    outcomeDeclarations.getOutcomeDeclarations().add(scoreOutcomeDeclaration);
    // outcome max score
    OutcomeDeclaration maxScoreOutcomeDeclaration = createOutcomeDeclarationForMaxScore(assessmentItem, maxScore);
    outcomeDeclarations.getOutcomeDeclarations().add(maxScoreOutcomeDeclaration);
    // outcome min score
    OutcomeDeclaration minScoreOutcomeDeclaration = createOutcomeDeclarationForMinScore(assessmentItem, 0.0d);
    outcomeDeclarations.getOutcomeDeclarations().add(minScoreOutcomeDeclaration);
    // outcome feedback
    OutcomeDeclaration feedbackOutcomeDeclaration = createOutcomeDeclarationForFeedbackBasic(assessmentItem);
    outcomeDeclarations.getOutcomeDeclarations().add(feedbackOutcomeDeclaration);
}
Also used : NodeGroupList(uk.ac.ed.ph.jqtiplus.group.NodeGroupList) OutcomeDeclarationGroup(uk.ac.ed.ph.jqtiplus.group.outcome.declaration.OutcomeDeclarationGroup) OutcomeDeclaration(uk.ac.ed.ph.jqtiplus.node.outcome.declaration.OutcomeDeclaration)

Example 7 with NodeGroupList

use of uk.ac.ed.ph.jqtiplus.group.NodeGroupList in project OpenOLAT by OpenOLAT.

the class AssessmentItemFactory method appendDefaultOutcomeDeclarations.

/**
 * Append the default outcome declaration for score, max score and feedback basic.
 *
 * @param assessmentItem
 */
public static void appendDefaultOutcomeDeclarations(AssessmentItem assessmentItem, double maxScore) {
    NodeGroupList nodeGroups = assessmentItem.getNodeGroups();
    // outcomes
    OutcomeDeclarationGroup outcomeDeclarations = nodeGroups.getOutcomeDeclarationGroup();
    // outcome score
    OutcomeDeclaration scoreOutcomeDeclaration = createOutcomeDeclarationForScore(assessmentItem);
    outcomeDeclarations.getOutcomeDeclarations().add(scoreOutcomeDeclaration);
    // outcome max score
    OutcomeDeclaration maxScoreOutcomeDeclaration = createOutcomeDeclarationForMaxScore(assessmentItem, maxScore);
    outcomeDeclarations.getOutcomeDeclarations().add(maxScoreOutcomeDeclaration);
    // outcome min score
    OutcomeDeclaration minScoreOutcomeDeclaration = createOutcomeDeclarationForMinScore(assessmentItem, 0.0d);
    outcomeDeclarations.getOutcomeDeclarations().add(minScoreOutcomeDeclaration);
    // outcome feedback
    OutcomeDeclaration feedbackOutcomeDeclaration = createOutcomeDeclarationForFeedbackBasic(assessmentItem);
    outcomeDeclarations.getOutcomeDeclarations().add(feedbackOutcomeDeclaration);
}
Also used : NodeGroupList(uk.ac.ed.ph.jqtiplus.group.NodeGroupList) OutcomeDeclarationGroup(uk.ac.ed.ph.jqtiplus.group.outcome.declaration.OutcomeDeclarationGroup) OutcomeDeclaration(uk.ac.ed.ph.jqtiplus.node.outcome.declaration.OutcomeDeclaration)

Example 8 with NodeGroupList

use of uk.ac.ed.ph.jqtiplus.group.NodeGroupList in project openolat by klemens.

the class KPrimAssessmentItemBuilder method createAssessmentItem.

private static AssessmentItem createAssessmentItem(String title, String defaultAnswer) {
    AssessmentItem assessmentItem = AssessmentItemFactory.createAssessmentItem(QTI21QuestionType.kprim, title);
    NodeGroupList nodeGroups = assessmentItem.getNodeGroups();
    double maxScore = 1.0d;
    Identifier responseDeclarationId = Identifier.assumedLegal("KPRIM_RESPONSE_1");
    // define correct answer
    ResponseDeclaration responseDeclaration = createKPrimResponseDeclaration(assessmentItem, responseDeclarationId, new HashMap<>(), maxScore);
    nodeGroups.getResponseDeclarationGroup().getResponseDeclarations().add(responseDeclaration);
    appendDefaultOutcomeDeclarations(assessmentItem, maxScore);
    // the single choice interaction
    ItemBody itemBody = appendDefaultItemBody(assessmentItem);
    MatchInteraction matchInteraction = appendMatchInteractionForKPrim(itemBody, responseDeclarationId, defaultAnswer);
    List<String> cssClasses = new ArrayList<>();
    cssClasses.add(QTI21Constants.CSS_MATCH_KPRIM);
    matchInteraction.setClassAttr(cssClasses);
    SimpleMatchSet matchSet = matchInteraction.getSimpleMatchSets().get(0);
    Map<Identifier, Identifier> associations = new HashMap<>();
    for (SimpleAssociableChoice choice : matchSet.getSimpleAssociableChoices()) {
        associations.put(choice.getIdentifier(), QTI21Constants.WRONG_IDENTIFIER);
    }
    appendAssociationKPrimResponseDeclaration(responseDeclaration, associations, 1.0);
    // response processing
    ResponseProcessing responseProcessing = createResponseProcessing(assessmentItem, responseDeclarationId);
    assessmentItem.getNodeGroups().getResponseProcessingGroup().setResponseProcessing(responseProcessing);
    return assessmentItem;
}
Also used : MatchInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.MatchInteraction) SimpleAssociableChoice(uk.ac.ed.ph.jqtiplus.node.item.interaction.choice.SimpleAssociableChoice) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) AssessmentItem(uk.ac.ed.ph.jqtiplus.node.item.AssessmentItem) AssessmentItemFactory.createResponseProcessing(org.olat.ims.qti21.model.xml.AssessmentItemFactory.createResponseProcessing) ResponseProcessing(uk.ac.ed.ph.jqtiplus.node.item.response.processing.ResponseProcessing) SimpleMatchSet(uk.ac.ed.ph.jqtiplus.node.item.interaction.choice.SimpleMatchSet) Identifier(uk.ac.ed.ph.jqtiplus.types.Identifier) ComplexReferenceIdentifier(uk.ac.ed.ph.jqtiplus.types.ComplexReferenceIdentifier) AssessmentItemFactory.appendDefaultItemBody(org.olat.ims.qti21.model.xml.AssessmentItemFactory.appendDefaultItemBody) ItemBody(uk.ac.ed.ph.jqtiplus.node.content.ItemBody) NodeGroupList(uk.ac.ed.ph.jqtiplus.group.NodeGroupList) ResponseDeclaration(uk.ac.ed.ph.jqtiplus.node.item.response.declaration.ResponseDeclaration) AssessmentItemFactory.createKPrimResponseDeclaration(org.olat.ims.qti21.model.xml.AssessmentItemFactory.createKPrimResponseDeclaration) AssessmentItemFactory.appendAssociationKPrimResponseDeclaration(org.olat.ims.qti21.model.xml.AssessmentItemFactory.appendAssociationKPrimResponseDeclaration)

Example 9 with NodeGroupList

use of uk.ac.ed.ph.jqtiplus.group.NodeGroupList in project openolat by klemens.

the class MultipleChoiceAssessmentItemBuilder method createAssessmentItem.

private static AssessmentItem createAssessmentItem(String title, String defaultAnswer) {
    AssessmentItem assessmentItem = AssessmentItemFactory.createAssessmentItem(QTI21QuestionType.mc, title);
    NodeGroupList nodeGroups = assessmentItem.getNodeGroups();
    Identifier responseDeclarationId = Identifier.assumedLegal("RESPONSE_1");
    Identifier correctResponseId = IdentifierGenerator.newAsIdentifier("mc");
    // define correct answer
    ResponseDeclaration responseDeclaration = createMultipleChoiceCorrectResponseDeclaration(assessmentItem, responseDeclarationId, Collections.singletonList(correctResponseId));
    nodeGroups.getResponseDeclarationGroup().getResponseDeclarations().add(responseDeclaration);
    // outcomes
    appendDefaultOutcomeDeclarations(assessmentItem, 1.0d);
    // the single choice interaction
    ItemBody itemBody = appendDefaultItemBody(assessmentItem);
    ChoiceInteraction choiceInteraction = appendChoiceInteraction(itemBody, responseDeclarationId, 0, true);
    appendSimpleChoice(choiceInteraction, defaultAnswer, correctResponseId);
    // response processing
    ResponseProcessing responseProcessing = createResponseProcessing(assessmentItem, responseDeclarationId);
    assessmentItem.getNodeGroups().getResponseProcessingGroup().setResponseProcessing(responseProcessing);
    return assessmentItem;
}
Also used : Identifier(uk.ac.ed.ph.jqtiplus.types.Identifier) ComplexReferenceIdentifier(uk.ac.ed.ph.jqtiplus.types.ComplexReferenceIdentifier) AssessmentItemFactory.appendDefaultItemBody(org.olat.ims.qti21.model.xml.AssessmentItemFactory.appendDefaultItemBody) ItemBody(uk.ac.ed.ph.jqtiplus.node.content.ItemBody) NodeGroupList(uk.ac.ed.ph.jqtiplus.group.NodeGroupList) ChoiceInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.ChoiceInteraction) AssessmentItemFactory.appendChoiceInteraction(org.olat.ims.qti21.model.xml.AssessmentItemFactory.appendChoiceInteraction) AssessmentItem(uk.ac.ed.ph.jqtiplus.node.item.AssessmentItem) ResponseProcessing(uk.ac.ed.ph.jqtiplus.node.item.response.processing.ResponseProcessing) AssessmentItemFactory.createResponseProcessing(org.olat.ims.qti21.model.xml.AssessmentItemFactory.createResponseProcessing) ResponseDeclaration(uk.ac.ed.ph.jqtiplus.node.item.response.declaration.ResponseDeclaration) AssessmentItemFactory.createMultipleChoiceCorrectResponseDeclaration(org.olat.ims.qti21.model.xml.AssessmentItemFactory.createMultipleChoiceCorrectResponseDeclaration)

Example 10 with NodeGroupList

use of uk.ac.ed.ph.jqtiplus.group.NodeGroupList in project openolat by klemens.

the class AssessmentItemFactory method appendDefaultItemBody.

/**
 * Append the itemBody with an empty paragraph.
 *
 * @param assessmentItem
 * @return
 */
public static ItemBody appendDefaultItemBody(AssessmentItem assessmentItem) {
    NodeGroupList nodeGroups = assessmentItem.getNodeGroups();
    // the single choice interaction
    ItemBodyGroup itemBodyGroup = nodeGroups.getItemBodyGroup();
    ItemBody itemBody = new ItemBody(assessmentItem);
    itemBodyGroup.setItemBody(itemBody);
    return itemBody;
}
Also used : ItemBodyGroup(uk.ac.ed.ph.jqtiplus.group.item.ItemBodyGroup) ItemBody(uk.ac.ed.ph.jqtiplus.node.content.ItemBody) NodeGroupList(uk.ac.ed.ph.jqtiplus.group.NodeGroupList)

Aggregations

NodeGroupList (uk.ac.ed.ph.jqtiplus.group.NodeGroupList)10 ItemBody (uk.ac.ed.ph.jqtiplus.node.content.ItemBody)8 AssessmentItemFactory.appendDefaultItemBody (org.olat.ims.qti21.model.xml.AssessmentItemFactory.appendDefaultItemBody)6 AssessmentItemFactory.createResponseProcessing (org.olat.ims.qti21.model.xml.AssessmentItemFactory.createResponseProcessing)6 AssessmentItem (uk.ac.ed.ph.jqtiplus.node.item.AssessmentItem)6 ResponseDeclaration (uk.ac.ed.ph.jqtiplus.node.item.response.declaration.ResponseDeclaration)6 ResponseProcessing (uk.ac.ed.ph.jqtiplus.node.item.response.processing.ResponseProcessing)6 ComplexReferenceIdentifier (uk.ac.ed.ph.jqtiplus.types.ComplexReferenceIdentifier)6 Identifier (uk.ac.ed.ph.jqtiplus.types.Identifier)6 ArrayList (java.util.ArrayList)4 HashMap (java.util.HashMap)4 MatchInteraction (uk.ac.ed.ph.jqtiplus.node.item.interaction.MatchInteraction)4 SimpleAssociableChoice (uk.ac.ed.ph.jqtiplus.node.item.interaction.choice.SimpleAssociableChoice)4 List (java.util.List)2 AssessmentItemFactory.appendAssociationKPrimResponseDeclaration (org.olat.ims.qti21.model.xml.AssessmentItemFactory.appendAssociationKPrimResponseDeclaration)2 AssessmentItemFactory.appendAssociationMatchResponseDeclaration (org.olat.ims.qti21.model.xml.AssessmentItemFactory.appendAssociationMatchResponseDeclaration)2 AssessmentItemFactory.appendChoiceInteraction (org.olat.ims.qti21.model.xml.AssessmentItemFactory.appendChoiceInteraction)2 AssessmentItemFactory.appendMatchInteraction (org.olat.ims.qti21.model.xml.AssessmentItemFactory.appendMatchInteraction)2 AssessmentItemFactory.createKPrimResponseDeclaration (org.olat.ims.qti21.model.xml.AssessmentItemFactory.createKPrimResponseDeclaration)2 AssessmentItemFactory.createMatchResponseDeclaration (org.olat.ims.qti21.model.xml.AssessmentItemFactory.createMatchResponseDeclaration)2