Search in sources :

Example 46 with CorrectResponse

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

the class AssessmentItemFactory method createMultipleChoiceCorrectResponseDeclaration.

public static ResponseDeclaration createMultipleChoiceCorrectResponseDeclaration(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)

Example 47 with CorrectResponse

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

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

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

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