Search in sources :

Example 41 with CorrectResponse

use of uk.ac.ed.ph.jqtiplus.node.item.CorrectResponse in project openolat by klemens.

the class MatchAssessmentItemBuilder method extractCorrectResponse.

private void extractCorrectResponse() {
    associations = new HashMap<>();
    if (matchInteraction != null) {
        ResponseDeclaration responseDeclaration = assessmentItem.getResponseDeclaration(matchInteraction.getResponseIdentifier());
        if (responseDeclaration != null && responseDeclaration.getCorrectResponse() != null) {
            CorrectResponse correctResponse = responseDeclaration.getCorrectResponse();
            List<FieldValue> values = correctResponse.getFieldValues();
            for (FieldValue value : values) {
                SingleValue sValue = value.getSingleValue();
                if (sValue instanceof DirectedPairValue) {
                    DirectedPairValue dpValue = (DirectedPairValue) sValue;
                    Identifier sourceId = dpValue.sourceValue();
                    Identifier targetId = dpValue.destValue();
                    List<Identifier> targetIds = associations.get(sourceId);
                    if (targetIds == null) {
                        targetIds = new ArrayList<>();
                        associations.put(sourceId, targetIds);
                    }
                    targetIds.add(targetId);
                }
            }
        }
    }
}
Also used : SingleValue(uk.ac.ed.ph.jqtiplus.value.SingleValue) 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) FieldValue(uk.ac.ed.ph.jqtiplus.node.shared.FieldValue) DirectedPairValue(uk.ac.ed.ph.jqtiplus.value.DirectedPairValue) AssessmentItemFactory.appendAssociationMatchResponseDeclaration(org.olat.ims.qti21.model.xml.AssessmentItemFactory.appendAssociationMatchResponseDeclaration) AssessmentItemFactory.createMatchResponseDeclaration(org.olat.ims.qti21.model.xml.AssessmentItemFactory.createMatchResponseDeclaration) ResponseDeclaration(uk.ac.ed.ph.jqtiplus.node.item.response.declaration.ResponseDeclaration)

Example 42 with CorrectResponse

use of uk.ac.ed.ph.jqtiplus.node.item.CorrectResponse in project openolat by klemens.

the class AssessmentItemFactory method createTextEntryResponseDeclaration.

/**
 * For the all answers get the point
 * @param assessmentItem
 * @param declarationId
 * @param response
 * @param alternatives
 * @return
 */
public static ResponseDeclaration createTextEntryResponseDeclaration(AssessmentItem assessmentItem, Identifier declarationId, String response, 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);
    if (alternatives != null) {
        for (TextEntryAlternative alternative : alternatives) {
            appendStringValue(correctResponse, alternative.getAlternative());
        }
    }
    return responseDeclaration;
}
Also used : CorrectResponse(uk.ac.ed.ph.jqtiplus.node.item.CorrectResponse) TextEntryAlternative(org.olat.ims.qti21.model.xml.interactions.FIBAssessmentItemBuilder.TextEntryAlternative) ResponseDeclaration(uk.ac.ed.ph.jqtiplus.node.item.response.declaration.ResponseDeclaration)

Example 43 with CorrectResponse

use of uk.ac.ed.ph.jqtiplus.node.item.CorrectResponse in project openolat by klemens.

the class AssessmentItemFactory method createNumericalEntryResponseDeclaration.

public static ResponseDeclaration createNumericalEntryResponseDeclaration(AssessmentItem assessmentItem, Identifier declarationId, double response) {
    ResponseDeclaration responseDeclaration = new ResponseDeclaration(assessmentItem);
    responseDeclaration.setIdentifier(declarationId);
    responseDeclaration.setCardinality(Cardinality.SINGLE);
    responseDeclaration.setBaseType(BaseType.FLOAT);
    // correct response
    CorrectResponse correctResponse = new CorrectResponse(responseDeclaration);
    responseDeclaration.setCorrectResponse(correctResponse);
    appendFloatValue(correctResponse, response);
    return responseDeclaration;
}
Also used : CorrectResponse(uk.ac.ed.ph.jqtiplus.node.item.CorrectResponse) ResponseDeclaration(uk.ac.ed.ph.jqtiplus.node.item.response.declaration.ResponseDeclaration)

Example 44 with CorrectResponse

use of uk.ac.ed.ph.jqtiplus.node.item.CorrectResponse in project openolat by klemens.

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 45 with CorrectResponse

use of uk.ac.ed.ph.jqtiplus.node.item.CorrectResponse in project openolat by klemens.

the class AssessmentItemFactory method appendAssociationMatchResponseDeclaration.

public static ResponseDeclaration appendAssociationMatchResponseDeclaration(ResponseDeclaration responseDeclaration, Map<Identifier, List<Identifier>> associations) {
    responseDeclaration.setCardinality(Cardinality.MULTIPLE);
    responseDeclaration.setBaseType(BaseType.DIRECTED_PAIR);
    // correct response
    CorrectResponse correctResponse = new CorrectResponse(responseDeclaration);
    responseDeclaration.setCorrectResponse(correctResponse);
    for (Map.Entry<Identifier, List<Identifier>> association : associations.entrySet()) {
        Identifier sourceChoiceId = association.getKey();
        List<Identifier> targetChoiceIds = association.getValue();
        for (Identifier targetChoiceId : targetChoiceIds) {
            DirectedPairValue dpValue = new DirectedPairValue(sourceChoiceId, targetChoiceId);
            FieldValue fValue = new FieldValue(correctResponse, dpValue);
            correctResponse.getFieldValues().add(fValue);
        }
    }
    return responseDeclaration;
}
Also used : Identifier(uk.ac.ed.ph.jqtiplus.types.Identifier) ComplexReferenceIdentifier(uk.ac.ed.ph.jqtiplus.types.ComplexReferenceIdentifier) List(java.util.List) ArrayList(java.util.ArrayList) NodeGroupList(uk.ac.ed.ph.jqtiplus.group.NodeGroupList) CorrectResponse(uk.ac.ed.ph.jqtiplus.node.item.CorrectResponse) FieldValue(uk.ac.ed.ph.jqtiplus.node.shared.FieldValue) DirectedPairValue(uk.ac.ed.ph.jqtiplus.value.DirectedPairValue) Map(java.util.Map)

Aggregations

CorrectResponse (uk.ac.ed.ph.jqtiplus.node.item.CorrectResponse)48 ResponseDeclaration (uk.ac.ed.ph.jqtiplus.node.item.response.declaration.ResponseDeclaration)40 FieldValue (uk.ac.ed.ph.jqtiplus.node.shared.FieldValue)26 Identifier (uk.ac.ed.ph.jqtiplus.types.Identifier)22 DirectedPairValue (uk.ac.ed.ph.jqtiplus.value.DirectedPairValue)20 SingleValue (uk.ac.ed.ph.jqtiplus.value.SingleValue)20 ComplexReferenceIdentifier (uk.ac.ed.ph.jqtiplus.types.ComplexReferenceIdentifier)16 ArrayList (java.util.ArrayList)14 IdentifierValue (uk.ac.ed.ph.jqtiplus.value.IdentifierValue)14 Value (uk.ac.ed.ph.jqtiplus.value.Value)14 MultipleValue (uk.ac.ed.ph.jqtiplus.value.MultipleValue)12 IntegerValue (uk.ac.ed.ph.jqtiplus.value.IntegerValue)10 OrderedValue (uk.ac.ed.ph.jqtiplus.value.OrderedValue)10 PairValue (uk.ac.ed.ph.jqtiplus.value.PairValue)10 PointValue (uk.ac.ed.ph.jqtiplus.value.PointValue)10 BaseValue (uk.ac.ed.ph.jqtiplus.node.expression.general.BaseValue)6 MapEntry (uk.ac.ed.ph.jqtiplus.node.item.response.declaration.MapEntry)6 Mapping (uk.ac.ed.ph.jqtiplus.node.item.response.declaration.Mapping)6 SetOutcomeValue (uk.ac.ed.ph.jqtiplus.node.item.response.processing.SetOutcomeValue)6 List (java.util.List)4