Search in sources :

Example 6 with CorrectResponse

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

the class HotspotAssessmentItemBuilder method extractCorrectAnswers.

private void extractCorrectAnswers() {
    correctAnswers = new ArrayList<>(5);
    if (hotspotInteraction != null) {
        ResponseDeclaration responseDeclaration = assessmentItem.getResponseDeclaration(hotspotInteraction.getResponseIdentifier());
        if (responseDeclaration != null) {
            if (responseDeclaration.getCorrectResponse() != null) {
                CorrectResponse correctResponse = responseDeclaration.getCorrectResponse();
                extractIdentifiersFromCorrectResponse(correctResponse, correctAnswers);
            }
            cardinality = responseDeclaration.getCardinality();
        }
    }
}
Also used : QtiNodesExtractor.extractIdentifiersFromCorrectResponse(org.olat.ims.qti21.model.xml.QtiNodesExtractor.extractIdentifiersFromCorrectResponse) CorrectResponse(uk.ac.ed.ph.jqtiplus.node.item.CorrectResponse) ResponseDeclaration(uk.ac.ed.ph.jqtiplus.node.item.response.declaration.ResponseDeclaration)

Example 7 with CorrectResponse

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

the class KPrimAssessmentItemBuilder 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 destinationId = dpValue.destValue();
                    associations.put(sourceId, destinationId);
                }
            }
        }
    }
}
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) 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 8 with CorrectResponse

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

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)

Example 9 with CorrectResponse

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

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

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

the class AssessmentItemFactory method createHotspotEntryResponseDeclarationSingle.

/*
	<responseDeclaration identifier="RESPONSE" cardinality="single" baseType="identifier">
		<correctResponse>
			<value>Choice0</value>
		</correctResponse>
	</responseDeclaration>
	*/
public static ResponseDeclaration createHotspotEntryResponseDeclarationSingle(AssessmentItem assessmentItem, Identifier responseIdentifier, Identifier correctAnswerIdentifier) {
    ResponseDeclaration responseDeclaration = new ResponseDeclaration(assessmentItem);
    responseDeclaration.setIdentifier(responseIdentifier);
    responseDeclaration.setCardinality(Cardinality.SINGLE);
    responseDeclaration.setBaseType(BaseType.IDENTIFIER);
    // correct response
    CorrectResponse correctResponse = new CorrectResponse(responseDeclaration);
    responseDeclaration.setCorrectResponse(correctResponse);
    appendIdentifierValue(correctResponse, correctAnswerIdentifier);
    return responseDeclaration;
}
Also used : CorrectResponse(uk.ac.ed.ph.jqtiplus.node.item.CorrectResponse) ResponseDeclaration(uk.ac.ed.ph.jqtiplus.node.item.response.declaration.ResponseDeclaration)

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