Search in sources :

Example 86 with ResponseDeclaration

use of uk.ac.ed.ph.jqtiplus.node.item.response.declaration.ResponseDeclaration in project OpenOLAT by OpenOLAT.

the class AssessmentItemFactory method createTextEntryResponseDeclaration.

public static ResponseDeclaration createTextEntryResponseDeclaration(AssessmentItem assessmentItem, Identifier declarationId, String response, Double score, boolean caseSensitive, List<TextEntryAlternative> alternatives) {
    ResponseDeclaration responseDeclaration = new ResponseDeclaration(assessmentItem);
    responseDeclaration.setIdentifier(declarationId);
    responseDeclaration.setCardinality(Cardinality.SINGLE);
    responseDeclaration.setBaseType(BaseType.STRING);
    // correct response
    CorrectResponse correctResponse = new CorrectResponse(responseDeclaration);
    responseDeclaration.setCorrectResponse(correctResponse);
    appendStringValue(correctResponse, response);
    // mapping
    Mapping mapping = new Mapping(responseDeclaration);
    mapping.setDefaultValue(0.0d);
    responseDeclaration.setMapping(mapping);
    {
        // map correct response
        MapEntry mapEntry = new MapEntry(mapping);
        mapEntry.setMapKey(new StringValue(response));
        mapEntry.setMappedValue(score);
        mapEntry.setCaseSensitive(new Boolean(caseSensitive));
        mapping.getMapEntries().add(mapEntry);
    }
    // map alternatives
    if (alternatives != null && alternatives.size() > 0) {
        for (TextEntryAlternative alternative : alternatives) {
            if (StringHelper.containsNonWhitespace(alternative.getAlternative())) {
                MapEntry mapEntry = new MapEntry(mapping);
                mapEntry.setMapKey(new StringValue(alternative.getAlternative()));
                mapEntry.setMappedValue(score);
                mapEntry.setCaseSensitive(new Boolean(caseSensitive));
                mapping.getMapEntries().add(mapEntry);
            }
        }
    }
    return responseDeclaration;
}
Also used : MapEntry(uk.ac.ed.ph.jqtiplus.node.item.response.declaration.MapEntry) Mapping(uk.ac.ed.ph.jqtiplus.node.item.response.declaration.Mapping) CorrectResponse(uk.ac.ed.ph.jqtiplus.node.item.CorrectResponse) StringValue(uk.ac.ed.ph.jqtiplus.value.StringValue) TextEntryAlternative(org.olat.ims.qti21.model.xml.interactions.FIBAssessmentItemBuilder.TextEntryAlternative) ResponseDeclaration(uk.ac.ed.ph.jqtiplus.node.item.response.declaration.ResponseDeclaration)

Example 87 with ResponseDeclaration

use of uk.ac.ed.ph.jqtiplus.node.item.response.declaration.ResponseDeclaration in project OpenOLAT by OpenOLAT.

the class AssessmentItemFactory method createHotspotCorrectResponseDeclaration.

public static ResponseDeclaration createHotspotCorrectResponseDeclaration(AssessmentItem assessmentItem, Identifier declarationId, List<Identifier> correctResponseIds, Cardinality cardinality) {
    ResponseDeclaration responseDeclaration = new ResponseDeclaration(assessmentItem);
    responseDeclaration.setIdentifier(declarationId);
    if (cardinality != null && (cardinality == Cardinality.SINGLE || cardinality == Cardinality.MULTIPLE)) {
        responseDeclaration.setCardinality(cardinality);
    } else if (correctResponseIds == null || correctResponseIds.size() == 0 || correctResponseIds.size() > 1) {
        responseDeclaration.setCardinality(Cardinality.MULTIPLE);
    } else {
        responseDeclaration.setCardinality(Cardinality.SINGLE);
    }
    responseDeclaration.setBaseType(BaseType.IDENTIFIER);
    CorrectResponse correctResponse = new CorrectResponse(responseDeclaration);
    responseDeclaration.setCorrectResponse(correctResponse);
    for (Identifier correctResponseId : correctResponseIds) {
        appendIdentifierValue(correctResponse, correctResponseId);
    }
    return responseDeclaration;
}
Also used : Identifier(uk.ac.ed.ph.jqtiplus.types.Identifier) ComplexReferenceIdentifier(uk.ac.ed.ph.jqtiplus.types.ComplexReferenceIdentifier) CorrectResponse(uk.ac.ed.ph.jqtiplus.node.item.CorrectResponse) ResponseDeclaration(uk.ac.ed.ph.jqtiplus.node.item.response.declaration.ResponseDeclaration)

Example 88 with ResponseDeclaration

use of uk.ac.ed.ph.jqtiplus.node.item.response.declaration.ResponseDeclaration in project OpenOLAT by OpenOLAT.

the class AssessmentItemFactory method createMatchResponseDeclaration.

/**
 * Add the response declaration with correct answers (but without score mapping)
 *
 * @param assessmentItem
 * @param declarationId
 * @param associations
 * @return
 */
public static ResponseDeclaration createMatchResponseDeclaration(AssessmentItem assessmentItem, Identifier declarationId, Map<Identifier, List<Identifier>> associations) {
    ResponseDeclaration responseDeclaration = new ResponseDeclaration(assessmentItem);
    responseDeclaration.setIdentifier(declarationId);
    responseDeclaration.setCardinality(Cardinality.MULTIPLE);
    responseDeclaration.setBaseType(BaseType.DIRECTED_PAIR);
    return appendAssociationMatchResponseDeclaration(responseDeclaration, associations);
}
Also used : ResponseDeclaration(uk.ac.ed.ph.jqtiplus.node.item.response.declaration.ResponseDeclaration)

Example 89 with ResponseDeclaration

use of uk.ac.ed.ph.jqtiplus.node.item.response.declaration.ResponseDeclaration in project OpenOLAT by OpenOLAT.

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 90 with ResponseDeclaration

use of uk.ac.ed.ph.jqtiplus.node.item.response.declaration.ResponseDeclaration in project OpenOLAT by OpenOLAT.

the class AssessmentItemFactory method createHottextCorrectResponseDeclaration.

public static ResponseDeclaration createHottextCorrectResponseDeclaration(AssessmentItem assessmentItem, Identifier declarationId, List<Identifier> correctResponseIds) {
    ResponseDeclaration responseDeclaration = new ResponseDeclaration(assessmentItem);
    responseDeclaration.setIdentifier(declarationId);
    responseDeclaration.setCardinality(Cardinality.MULTIPLE);
    responseDeclaration.setBaseType(BaseType.IDENTIFIER);
    CorrectResponse correctResponse = new CorrectResponse(responseDeclaration);
    responseDeclaration.setCorrectResponse(correctResponse);
    for (Identifier correctResponseId : correctResponseIds) {
        appendIdentifierValue(correctResponse, correctResponseId);
    }
    return responseDeclaration;
}
Also used : Identifier(uk.ac.ed.ph.jqtiplus.types.Identifier) ComplexReferenceIdentifier(uk.ac.ed.ph.jqtiplus.types.ComplexReferenceIdentifier) CorrectResponse(uk.ac.ed.ph.jqtiplus.node.item.CorrectResponse) ResponseDeclaration(uk.ac.ed.ph.jqtiplus.node.item.response.declaration.ResponseDeclaration)

Aggregations

ResponseDeclaration (uk.ac.ed.ph.jqtiplus.node.item.response.declaration.ResponseDeclaration)132 Identifier (uk.ac.ed.ph.jqtiplus.types.Identifier)54 CorrectResponse (uk.ac.ed.ph.jqtiplus.node.item.CorrectResponse)40 ComplexReferenceIdentifier (uk.ac.ed.ph.jqtiplus.types.ComplexReferenceIdentifier)36 AssessmentItem (uk.ac.ed.ph.jqtiplus.node.item.AssessmentItem)28 SingleValue (uk.ac.ed.ph.jqtiplus.value.SingleValue)28 ResponseProcessing (uk.ac.ed.ph.jqtiplus.node.item.response.processing.ResponseProcessing)24 IdentifierValue (uk.ac.ed.ph.jqtiplus.value.IdentifierValue)24 ArrayList (java.util.ArrayList)22 ItemBody (uk.ac.ed.ph.jqtiplus.node.content.ItemBody)22 DirectedPairValue (uk.ac.ed.ph.jqtiplus.value.DirectedPairValue)22 AssessmentItemFactory.appendDefaultItemBody (org.olat.ims.qti21.model.xml.AssessmentItemFactory.appendDefaultItemBody)20 AssessmentItemFactory.createResponseProcessing (org.olat.ims.qti21.model.xml.AssessmentItemFactory.createResponseProcessing)20 FieldValue (uk.ac.ed.ph.jqtiplus.node.shared.FieldValue)18 Value (uk.ac.ed.ph.jqtiplus.value.Value)16 ChoiceInteraction (uk.ac.ed.ph.jqtiplus.node.item.interaction.ChoiceInteraction)14 HashMap (java.util.HashMap)12 MapEntry (uk.ac.ed.ph.jqtiplus.node.item.response.declaration.MapEntry)12 MultipleValue (uk.ac.ed.ph.jqtiplus.value.MultipleValue)12 IntegerValue (uk.ac.ed.ph.jqtiplus.value.IntegerValue)10