Search in sources :

Example 6 with Mapping

use of uk.ac.ed.ph.jqtiplus.node.item.response.declaration.Mapping in project openolat by klemens.

the class AssessmentItemFactory method appendPairMapping.

public static Mapping appendPairMapping(ResponseDeclaration responseDeclaration, Map<DirectedPairValue, Double> map) {
    Mapping mapping = new Mapping(responseDeclaration);
    mapping.setDefaultValue(0d);
    responseDeclaration.setMapping(mapping);
    for (Map.Entry<DirectedPairValue, Double> entry : map.entrySet()) {
        MapEntry mapEntry = new MapEntry(mapping);
        mapEntry.setMapKey(entry.getKey());
        mapEntry.setMappedValue(entry.getValue());
        mapping.getMapEntries().add(mapEntry);
    }
    return mapping;
}
Also used : MapEntry(uk.ac.ed.ph.jqtiplus.node.item.response.declaration.MapEntry) Mapping(uk.ac.ed.ph.jqtiplus.node.item.response.declaration.Mapping) DirectedPairValue(uk.ac.ed.ph.jqtiplus.value.DirectedPairValue) Map(java.util.Map)

Example 7 with Mapping

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

the class HotspotAssessmentItemBuilder method extractScoreEvaluationMode.

private void extractScoreEvaluationMode() {
    boolean hasMapping = false;
    if (hotspotInteraction != null) {
        ResponseDeclaration responseDeclaration = assessmentItem.getResponseDeclaration(hotspotInteraction.getResponseIdentifier());
        if (responseDeclaration != null) {
            Mapping mapping = responseDeclaration.getMapping();
            hasMapping = (mapping != null && mapping.getMapEntries() != null && mapping.getMapEntries().size() > 0);
            if (hasMapping) {
                scoreMapping = new HashMap<>();
                for (MapEntry entry : mapping.getMapEntries()) {
                    SingleValue sValue = entry.getMapKey();
                    if (sValue instanceof IdentifierValue) {
                        Identifier identifier = ((IdentifierValue) sValue).identifierValue();
                        scoreMapping.put(identifier, entry.getMappedValue());
                    }
                }
            }
        }
    }
    scoreEvaluation = hasMapping ? ScoreEvaluation.perAnswer : ScoreEvaluation.allCorrectAnswers;
}
Also used : MapEntry(uk.ac.ed.ph.jqtiplus.node.item.response.declaration.MapEntry) SingleValue(uk.ac.ed.ph.jqtiplus.value.SingleValue) Identifier(uk.ac.ed.ph.jqtiplus.types.Identifier) ComplexReferenceIdentifier(uk.ac.ed.ph.jqtiplus.types.ComplexReferenceIdentifier) Mapping(uk.ac.ed.ph.jqtiplus.node.item.response.declaration.Mapping) IdentifierValue(uk.ac.ed.ph.jqtiplus.value.IdentifierValue) ResponseDeclaration(uk.ac.ed.ph.jqtiplus.node.item.response.declaration.ResponseDeclaration)

Example 8 with Mapping

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

the class MatchAssessmentItemBuilder method extractScoreEvaluationMode.

private void extractScoreEvaluationMode() {
    boolean hasMapping = false;
    if (matchInteraction != null) {
        ResponseDeclaration responseDeclaration = assessmentItem.getResponseDeclaration(matchInteraction.getResponseIdentifier());
        if (responseDeclaration != null) {
            Mapping mapping = responseDeclaration.getMapping();
            hasMapping = (mapping != null && mapping.getMapEntries() != null && mapping.getMapEntries().size() > 0);
            if (hasMapping) {
                scoreMapping = new HashMap<>();
                for (MapEntry entry : mapping.getMapEntries()) {
                    SingleValue sValue = entry.getMapKey();
                    if (sValue instanceof DirectedPairValue) {
                        Identifier sourceIdentifier = ((DirectedPairValue) sValue).sourceValue();
                        Identifier destIdentifier = ((DirectedPairValue) sValue).destValue();
                        scoreMapping.put(new DirectedPairValue(sourceIdentifier, destIdentifier), entry.getMappedValue());
                    }
                }
            }
        }
    }
    scoreEvaluation = hasMapping ? ScoreEvaluation.perAnswer : ScoreEvaluation.allCorrectAnswers;
}
Also used : MapEntry(uk.ac.ed.ph.jqtiplus.node.item.response.declaration.MapEntry) SingleValue(uk.ac.ed.ph.jqtiplus.value.SingleValue) Identifier(uk.ac.ed.ph.jqtiplus.types.Identifier) ComplexReferenceIdentifier(uk.ac.ed.ph.jqtiplus.types.ComplexReferenceIdentifier) Mapping(uk.ac.ed.ph.jqtiplus.node.item.response.declaration.Mapping) 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 9 with Mapping

use of uk.ac.ed.ph.jqtiplus.node.item.response.declaration.Mapping 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 10 with Mapping

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

the class AssessmentItemFactory method appendPairMapping.

public static Mapping appendPairMapping(ResponseDeclaration responseDeclaration, Map<DirectedPairValue, Double> map) {
    Mapping mapping = new Mapping(responseDeclaration);
    mapping.setDefaultValue(0d);
    responseDeclaration.setMapping(mapping);
    for (Map.Entry<DirectedPairValue, Double> entry : map.entrySet()) {
        MapEntry mapEntry = new MapEntry(mapping);
        mapEntry.setMapKey(entry.getKey());
        mapEntry.setMappedValue(entry.getValue());
        mapping.getMapEntries().add(mapEntry);
    }
    return mapping;
}
Also used : MapEntry(uk.ac.ed.ph.jqtiplus.node.item.response.declaration.MapEntry) Mapping(uk.ac.ed.ph.jqtiplus.node.item.response.declaration.Mapping) DirectedPairValue(uk.ac.ed.ph.jqtiplus.value.DirectedPairValue) Map(java.util.Map)

Aggregations

MapEntry (uk.ac.ed.ph.jqtiplus.node.item.response.declaration.MapEntry)18 Mapping (uk.ac.ed.ph.jqtiplus.node.item.response.declaration.Mapping)18 Identifier (uk.ac.ed.ph.jqtiplus.types.Identifier)12 ResponseDeclaration (uk.ac.ed.ph.jqtiplus.node.item.response.declaration.ResponseDeclaration)10 ComplexReferenceIdentifier (uk.ac.ed.ph.jqtiplus.types.ComplexReferenceIdentifier)10 SingleValue (uk.ac.ed.ph.jqtiplus.value.SingleValue)10 IdentifierValue (uk.ac.ed.ph.jqtiplus.value.IdentifierValue)8 Map (java.util.Map)6 CorrectResponse (uk.ac.ed.ph.jqtiplus.node.item.CorrectResponse)6 DirectedPairValue (uk.ac.ed.ph.jqtiplus.value.DirectedPairValue)6 FieldValue (uk.ac.ed.ph.jqtiplus.node.shared.FieldValue)4 StringValue (uk.ac.ed.ph.jqtiplus.value.StringValue)4 ArrayList (java.util.ArrayList)2 AssessmentItemFactory.appendAssociationMatchResponseDeclaration (org.olat.ims.qti21.model.xml.AssessmentItemFactory.appendAssociationMatchResponseDeclaration)2 AssessmentItemFactory.createHottextCorrectResponseDeclaration (org.olat.ims.qti21.model.xml.AssessmentItemFactory.createHottextCorrectResponseDeclaration)2 AssessmentItemFactory.createMatchResponseDeclaration (org.olat.ims.qti21.model.xml.AssessmentItemFactory.createMatchResponseDeclaration)2 TextEntryAlternative (org.olat.ims.qti21.model.xml.interactions.FIBAssessmentItemBuilder.TextEntryAlternative)2 QtiAttributeException (uk.ac.ed.ph.jqtiplus.exception.QtiAttributeException)2