Search in sources :

Example 26 with ItemBody

use of uk.ac.ed.ph.jqtiplus.node.content.ItemBody in project openolat by klemens.

the class HotspotAssessmentItemBuilder method createAssessmentItem.

private static AssessmentItem createAssessmentItem(String title) {
    AssessmentItem assessmentItem = AssessmentItemFactory.createAssessmentItem(QTI21QuestionType.hotspot, title);
    // define the response
    Identifier responseDeclarationId = Identifier.assumedLegal("RESPONSE_1");
    Identifier correctResponseId = IdentifierGenerator.newNumberAsIdentifier("hc");
    ResponseDeclaration responseDeclaration = createHotspotEntryResponseDeclarationSingle(assessmentItem, responseDeclarationId, correctResponseId);
    assessmentItem.getNodeGroups().getResponseDeclarationGroup().getResponseDeclarations().add(responseDeclaration);
    // outcomes
    appendDefaultOutcomeDeclarations(assessmentItem, 1.0d);
    ItemBody itemBody = appendDefaultItemBody(assessmentItem);
    appendHotspotInteraction(itemBody, responseDeclarationId, 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) 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) ResponseDeclaration(uk.ac.ed.ph.jqtiplus.node.item.response.declaration.ResponseDeclaration)

Example 27 with ItemBody

use of uk.ac.ed.ph.jqtiplus.node.content.ItemBody 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 28 with ItemBody

use of uk.ac.ed.ph.jqtiplus.node.content.ItemBody 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 29 with ItemBody

use of uk.ac.ed.ph.jqtiplus.node.content.ItemBody in project openolat by klemens.

the class SingleChoiceAssessmentItemBuilder method createAssessmentItem.

private static AssessmentItem createAssessmentItem(String title, String defaultAnswer) {
    AssessmentItem assessmentItem = AssessmentItemFactory.createAssessmentItem(QTI21QuestionType.sc, title);
    // define correct answer
    Identifier responseDeclarationId = Identifier.assumedLegal("RESPONSE_1");
    Identifier correctResponseId = IdentifierGenerator.newAsIdentifier("sc");
    ResponseDeclaration responseDeclaration = createSingleChoiceCorrectResponseDeclaration(assessmentItem, responseDeclarationId, correctResponseId);
    assessmentItem.getNodeGroups().getResponseDeclarationGroup().getResponseDeclarations().add(responseDeclaration);
    // outcomes
    appendDefaultOutcomeDeclarations(assessmentItem, 1.0d);
    // the single choice interaction
    ItemBody itemBody = appendDefaultItemBody(assessmentItem);
    ChoiceInteraction choiceInteraction = appendChoiceInteraction(itemBody, responseDeclarationId, 1, 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) 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) AssessmentItemFactory.createSingleChoiceCorrectResponseDeclaration(org.olat.ims.qti21.model.xml.AssessmentItemFactory.createSingleChoiceCorrectResponseDeclaration) ResponseDeclaration(uk.ac.ed.ph.jqtiplus.node.item.response.declaration.ResponseDeclaration)

Example 30 with ItemBody

use of uk.ac.ed.ph.jqtiplus.node.content.ItemBody in project openolat by klemens.

the class UploadAssessmentItemBuilder method createAssessmentItem.

private static AssessmentItem createAssessmentItem(String title) {
    AssessmentItem assessmentItem = AssessmentItemFactory.createAssessmentItem(QTI21QuestionType.upload, title);
    // define the response
    Identifier responseDeclarationId = Identifier.assumedLegal("RESPONSE_1");
    ResponseDeclaration responseDeclaration = createUploadResponseDeclaration(assessmentItem, responseDeclarationId);
    assessmentItem.getNodeGroups().getResponseDeclarationGroup().getResponseDeclarations().add(responseDeclaration);
    // outcomes
    appendDefaultOutcomeDeclarations(assessmentItem, 1.0d);
    ItemBody itemBody = appendDefaultItemBody(assessmentItem);
    appendUploadInteraction(itemBody, responseDeclarationId);
    // response processing
    ResponseProcessing responseProcessing = createResponseProcessing(assessmentItem, responseDeclarationId);
    assessmentItem.getNodeGroups().getResponseProcessingGroup().setResponseProcessing(responseProcessing);
    return assessmentItem;
}
Also used : Identifier(uk.ac.ed.ph.jqtiplus.types.Identifier) ItemBody(uk.ac.ed.ph.jqtiplus.node.content.ItemBody) AssessmentItemFactory.appendDefaultItemBody(org.olat.ims.qti21.model.xml.AssessmentItemFactory.appendDefaultItemBody) 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.createUploadResponseDeclaration(org.olat.ims.qti21.model.xml.AssessmentItemFactory.createUploadResponseDeclaration)

Aggregations

ItemBody (uk.ac.ed.ph.jqtiplus.node.content.ItemBody)32 AssessmentItem (uk.ac.ed.ph.jqtiplus.node.item.AssessmentItem)28 ResponseDeclaration (uk.ac.ed.ph.jqtiplus.node.item.response.declaration.ResponseDeclaration)22 ResponseProcessing (uk.ac.ed.ph.jqtiplus.node.item.response.processing.ResponseProcessing)22 Identifier (uk.ac.ed.ph.jqtiplus.types.Identifier)22 AssessmentItemFactory.appendDefaultItemBody (org.olat.ims.qti21.model.xml.AssessmentItemFactory.appendDefaultItemBody)20 AssessmentItemFactory.createResponseProcessing (org.olat.ims.qti21.model.xml.AssessmentItemFactory.createResponseProcessing)20 ComplexReferenceIdentifier (uk.ac.ed.ph.jqtiplus.types.ComplexReferenceIdentifier)16 NodeGroupList (uk.ac.ed.ph.jqtiplus.group.NodeGroupList)8 ArrayList (java.util.ArrayList)6 Test (org.junit.Test)6 Block (uk.ac.ed.ph.jqtiplus.node.content.basic.Block)6 ChoiceInteraction (uk.ac.ed.ph.jqtiplus.node.item.interaction.ChoiceInteraction)6 MatchInteraction (uk.ac.ed.ph.jqtiplus.node.item.interaction.MatchInteraction)6 HashMap (java.util.HashMap)4 StreamResult (javax.xml.transform.stream.StreamResult)4 StringOutput (org.olat.core.gui.render.StringOutput)4 AssessmentItemFactory.appendChoiceInteraction (org.olat.ims.qti21.model.xml.AssessmentItemFactory.appendChoiceInteraction)4 JqtiExtensionManager (uk.ac.ed.ph.jqtiplus.JqtiExtensionManager)4 Interaction (uk.ac.ed.ph.jqtiplus.node.item.interaction.Interaction)4