Search in sources :

Example 31 with ItemBody

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

the class AssessmentItemFactory method createSingleChoice.

public static AssessmentItem createSingleChoice(String title, String defaultAnswer) {
    AssessmentItem assessmentItem = 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) ItemBody(uk.ac.ed.ph.jqtiplus.node.content.ItemBody) ChoiceInteraction(uk.ac.ed.ph.jqtiplus.node.item.interaction.ChoiceInteraction) AssessmentItem(uk.ac.ed.ph.jqtiplus.node.item.AssessmentItem) ResponseProcessing(uk.ac.ed.ph.jqtiplus.node.item.response.processing.ResponseProcessing) ResponseDeclaration(uk.ac.ed.ph.jqtiplus.node.item.response.declaration.ResponseDeclaration)

Example 32 with ItemBody

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

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