Search in sources :

Example 31 with SingleValue

use of uk.ac.ed.ph.jqtiplus.value.SingleValue in project OpenOLAT by OpenOLAT.

the class AssessmentObjectVelocityRenderDecorator method getResponseValueForField.

public String getResponseValueForField(Value value, String field) {
    String responseValue;
    // for math entry interaction
    if (value instanceof RecordValue) {
        Identifier fieldIdentifier = Identifier.assumedLegal(field);
        RecordValue recordValue = (RecordValue) value;
        SingleValue sValue = recordValue.get(fieldIdentifier);
        responseValue = sValue == null ? null : sValue.toQtiString();
    } else {
        responseValue = null;
    }
    return responseValue;
}
Also used : Identifier(uk.ac.ed.ph.jqtiplus.types.Identifier) SingleValue(uk.ac.ed.ph.jqtiplus.value.SingleValue) RecordValue(uk.ac.ed.ph.jqtiplus.value.RecordValue)

Example 32 with SingleValue

use of uk.ac.ed.ph.jqtiplus.value.SingleValue in project OpenOLAT by OpenOLAT.

the class AssessmentRenderFunctions method extractMathsContentPmathml.

/*
	  <xsl:function name="qw:extract-maths-content-pmathml" as="element(m:math)">
	    <xsl:param name="valueHolder" as="element()"/>
	    <xsl:choose>
	      <xsl:when test="qw:is-maths-content-value($valueHolder)">
	        <xsl:variable name="pmathmlString" select="$valueHolder/qw:value[@fieldIdentifier='PMathML']" as="xs:string"/>
	        <xsl:variable name="pmathmlDocNode" select="saxon:parse($pmathmlString)" as="document-node()"/>
	        <xsl:copy-of select="$pmathmlDocNode/*"/>
	      </xsl:when>
	      <xsl:otherwise>
	        <xsl:message terminate="yes">
	          Expected value <xsl:copy-of select="$valueHolder"/> to be a MathsContent value
	        </xsl:message>
	      </xsl:otherwise>
	    </xsl:choose>
	  </xsl:function>
	*/
public static String extractMathsContentPmathml(Value value) {
    if (value.hasCardinality(Cardinality.RECORD)) {
        RecordValue recordValue = (RecordValue) value;
        for (Map.Entry<Identifier, SingleValue> entry : recordValue.entrySet()) {
            final Identifier itemIdentifier = entry.getKey();
            final SingleValue itemValue = entry.getValue();
            if (itemValue.hasBaseType(BaseType.STRING) && FIELD_PMATHML_IDENTIFIER.equals(itemIdentifier)) {
                return ((StringValue) itemValue).stringValue();
            }
        }
    }
    return "";
}
Also used : Identifier(uk.ac.ed.ph.jqtiplus.types.Identifier) SingleValue(uk.ac.ed.ph.jqtiplus.value.SingleValue) RecordValue(uk.ac.ed.ph.jqtiplus.value.RecordValue) StringValue(uk.ac.ed.ph.jqtiplus.value.StringValue) Map(java.util.Map)

Example 33 with SingleValue

use of uk.ac.ed.ph.jqtiplus.value.SingleValue in project OpenOLAT by OpenOLAT.

the class AssessmentRenderFunctions method isMathsContentValue.

// <xsl:sequence select="boolean($valueHolder[@cardinality='record'
// and qw:value[@baseType='string' and @fieldIdentifier='MathsContentClass'
// and string(qw:value)='org.qtitools.mathassess']])"/>
public static boolean isMathsContentValue(Value value) {
    if (value.hasCardinality(Cardinality.RECORD)) {
        RecordValue recordValue = (RecordValue) value;
        for (Map.Entry<Identifier, SingleValue> entry : recordValue.entrySet()) {
            final Identifier itemIdentifier = entry.getKey();
            final SingleValue itemValue = entry.getValue();
            if (itemValue.hasBaseType(BaseType.STRING) && MATHS_CONTENT_RECORD_VARIABLE_IDENTIFIER.equals(itemIdentifier)) {
                return true;
            }
        }
    }
    return false;
}
Also used : Identifier(uk.ac.ed.ph.jqtiplus.types.Identifier) SingleValue(uk.ac.ed.ph.jqtiplus.value.SingleValue) RecordValue(uk.ac.ed.ph.jqtiplus.value.RecordValue) Map(java.util.Map)

Example 34 with SingleValue

use of uk.ac.ed.ph.jqtiplus.value.SingleValue 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 35 with SingleValue

use of uk.ac.ed.ph.jqtiplus.value.SingleValue in project OpenOLAT by OpenOLAT.

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)

Aggregations

SingleValue (uk.ac.ed.ph.jqtiplus.value.SingleValue)52 Identifier (uk.ac.ed.ph.jqtiplus.types.Identifier)30 ResponseDeclaration (uk.ac.ed.ph.jqtiplus.node.item.response.declaration.ResponseDeclaration)20 FieldValue (uk.ac.ed.ph.jqtiplus.node.shared.FieldValue)18 IdentifierValue (uk.ac.ed.ph.jqtiplus.value.IdentifierValue)18 DirectedPairValue (uk.ac.ed.ph.jqtiplus.value.DirectedPairValue)16 CorrectResponse (uk.ac.ed.ph.jqtiplus.node.item.CorrectResponse)14 MapEntry (uk.ac.ed.ph.jqtiplus.node.item.response.declaration.MapEntry)14 RecordValue (uk.ac.ed.ph.jqtiplus.value.RecordValue)14 ArrayList (java.util.ArrayList)12 BaseValue (uk.ac.ed.ph.jqtiplus.node.expression.general.BaseValue)12 ComplexReferenceIdentifier (uk.ac.ed.ph.jqtiplus.types.ComplexReferenceIdentifier)12 Mapping (uk.ac.ed.ph.jqtiplus.node.item.response.declaration.Mapping)10 Value (uk.ac.ed.ph.jqtiplus.value.Value)10 MultipleValue (uk.ac.ed.ph.jqtiplus.value.MultipleValue)8 Map (java.util.Map)6 Expression (uk.ac.ed.ph.jqtiplus.node.expression.Expression)6 StringValue (uk.ac.ed.ph.jqtiplus.value.StringValue)6 AssessmentItemFactory.appendAssociationMatchResponseDeclaration (org.olat.ims.qti21.model.xml.AssessmentItemFactory.appendAssociationMatchResponseDeclaration)4 AssessmentItemFactory.createMatchResponseDeclaration (org.olat.ims.qti21.model.xml.AssessmentItemFactory.createMatchResponseDeclaration)4