Search in sources :

Example 1 with BaseTypeAndCardinality

use of uk.ac.ed.ph.jqtiplus.node.shared.BaseTypeAndCardinality in project OpenOLAT by OpenOLAT.

the class QtiNodesExtractor method extractIdentifiersFromCorrectResponse.

public static void extractIdentifiersFromCorrectResponse(CorrectResponse correctResponse, List<Identifier> correctAnswers) {
    BaseTypeAndCardinality responseDeclaration = correctResponse.getParent();
    if (responseDeclaration.hasCardinality(Cardinality.MULTIPLE)) {
        Value value = FieldValue.computeValue(Cardinality.MULTIPLE, correctResponse.getFieldValues());
        if (value instanceof MultipleValue) {
            MultipleValue multiValue = (MultipleValue) value;
            for (SingleValue sValue : multiValue.getAll()) {
                if (sValue instanceof IdentifierValue) {
                    IdentifierValue identifierValue = (IdentifierValue) sValue;
                    Identifier correctAnswer = identifierValue.identifierValue();
                    correctAnswers.add(correctAnswer);
                }
            }
        }
    } else if (responseDeclaration.hasCardinality(Cardinality.SINGLE)) {
        Value value = FieldValue.computeValue(Cardinality.SINGLE, correctResponse.getFieldValues());
        if (value instanceof IdentifierValue) {
            IdentifierValue identifierValue = (IdentifierValue) value;
            correctAnswers.add(identifierValue.identifierValue());
        }
    }
}
Also used : BaseTypeAndCardinality(uk.ac.ed.ph.jqtiplus.node.shared.BaseTypeAndCardinality) SingleValue(uk.ac.ed.ph.jqtiplus.value.SingleValue) Identifier(uk.ac.ed.ph.jqtiplus.types.Identifier) MultipleValue(uk.ac.ed.ph.jqtiplus.value.MultipleValue) BaseValue(uk.ac.ed.ph.jqtiplus.node.expression.general.BaseValue) DefaultValue(uk.ac.ed.ph.jqtiplus.node.shared.declaration.DefaultValue) IdentifierValue(uk.ac.ed.ph.jqtiplus.value.IdentifierValue) SetOutcomeValue(uk.ac.ed.ph.jqtiplus.node.test.outcome.processing.SetOutcomeValue) FloatValue(uk.ac.ed.ph.jqtiplus.value.FloatValue) MultipleValue(uk.ac.ed.ph.jqtiplus.value.MultipleValue) Value(uk.ac.ed.ph.jqtiplus.value.Value) FieldValue(uk.ac.ed.ph.jqtiplus.node.shared.FieldValue) SingleValue(uk.ac.ed.ph.jqtiplus.value.SingleValue) DirectedPairValue(uk.ac.ed.ph.jqtiplus.value.DirectedPairValue) IdentifierValue(uk.ac.ed.ph.jqtiplus.value.IdentifierValue)

Example 2 with BaseTypeAndCardinality

use of uk.ac.ed.ph.jqtiplus.node.shared.BaseTypeAndCardinality in project openolat by klemens.

the class QtiNodesExtractor method extractIdentifiersFromCorrectResponse.

public static void extractIdentifiersFromCorrectResponse(CorrectResponse correctResponse, List<Identifier> correctAnswers) {
    BaseTypeAndCardinality responseDeclaration = correctResponse.getParent();
    if (responseDeclaration.hasCardinality(Cardinality.MULTIPLE)) {
        Value value = FieldValue.computeValue(Cardinality.MULTIPLE, correctResponse.getFieldValues());
        if (value instanceof MultipleValue) {
            MultipleValue multiValue = (MultipleValue) value;
            for (SingleValue sValue : multiValue.getAll()) {
                if (sValue instanceof IdentifierValue) {
                    IdentifierValue identifierValue = (IdentifierValue) sValue;
                    Identifier correctAnswer = identifierValue.identifierValue();
                    correctAnswers.add(correctAnswer);
                }
            }
        }
    } else if (responseDeclaration.hasCardinality(Cardinality.SINGLE)) {
        Value value = FieldValue.computeValue(Cardinality.SINGLE, correctResponse.getFieldValues());
        if (value instanceof IdentifierValue) {
            IdentifierValue identifierValue = (IdentifierValue) value;
            correctAnswers.add(identifierValue.identifierValue());
        }
    }
}
Also used : BaseTypeAndCardinality(uk.ac.ed.ph.jqtiplus.node.shared.BaseTypeAndCardinality) SingleValue(uk.ac.ed.ph.jqtiplus.value.SingleValue) Identifier(uk.ac.ed.ph.jqtiplus.types.Identifier) MultipleValue(uk.ac.ed.ph.jqtiplus.value.MultipleValue) BaseValue(uk.ac.ed.ph.jqtiplus.node.expression.general.BaseValue) DefaultValue(uk.ac.ed.ph.jqtiplus.node.shared.declaration.DefaultValue) IdentifierValue(uk.ac.ed.ph.jqtiplus.value.IdentifierValue) SetOutcomeValue(uk.ac.ed.ph.jqtiplus.node.test.outcome.processing.SetOutcomeValue) FloatValue(uk.ac.ed.ph.jqtiplus.value.FloatValue) MultipleValue(uk.ac.ed.ph.jqtiplus.value.MultipleValue) Value(uk.ac.ed.ph.jqtiplus.value.Value) FieldValue(uk.ac.ed.ph.jqtiplus.node.shared.FieldValue) SingleValue(uk.ac.ed.ph.jqtiplus.value.SingleValue) DirectedPairValue(uk.ac.ed.ph.jqtiplus.value.DirectedPairValue) IdentifierValue(uk.ac.ed.ph.jqtiplus.value.IdentifierValue)

Aggregations

BaseValue (uk.ac.ed.ph.jqtiplus.node.expression.general.BaseValue)2 BaseTypeAndCardinality (uk.ac.ed.ph.jqtiplus.node.shared.BaseTypeAndCardinality)2 FieldValue (uk.ac.ed.ph.jqtiplus.node.shared.FieldValue)2 DefaultValue (uk.ac.ed.ph.jqtiplus.node.shared.declaration.DefaultValue)2 SetOutcomeValue (uk.ac.ed.ph.jqtiplus.node.test.outcome.processing.SetOutcomeValue)2 Identifier (uk.ac.ed.ph.jqtiplus.types.Identifier)2 DirectedPairValue (uk.ac.ed.ph.jqtiplus.value.DirectedPairValue)2 FloatValue (uk.ac.ed.ph.jqtiplus.value.FloatValue)2 IdentifierValue (uk.ac.ed.ph.jqtiplus.value.IdentifierValue)2 MultipleValue (uk.ac.ed.ph.jqtiplus.value.MultipleValue)2 SingleValue (uk.ac.ed.ph.jqtiplus.value.SingleValue)2 Value (uk.ac.ed.ph.jqtiplus.value.Value)2