Search in sources :

Example 1 with BooleanValue

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

the class QTI21ServiceImpl method recordOutcomeVariable.

private void recordOutcomeVariable(AssessmentTestSession candidateSession, OutcomeVariable outcomeVariable, Map<Identifier, String> outcomes) {
    Identifier identifier = outcomeVariable.getIdentifier();
    Value computedValue = outcomeVariable.getComputedValue();
    if (QtiConstants.VARIABLE_DURATION_IDENTIFIER.equals(identifier)) {
        log.audit(candidateSession.getKey() + " :: " + outcomeVariable.getIdentifier() + " - " + stringifyQtiValue(computedValue));
    } else if (QTI21Constants.SCORE_IDENTIFIER.equals(identifier)) {
        if (computedValue instanceof NumberValue) {
            double score = ((NumberValue) computedValue).doubleValue();
            candidateSession.setScore(new BigDecimal(score));
        }
    } else if (QTI21Constants.PASS_IDENTIFIER.equals(identifier)) {
        if (computedValue instanceof BooleanValue) {
            boolean pass = ((BooleanValue) computedValue).booleanValue();
            candidateSession.setPassed(pass);
        }
    }
    try {
        outcomes.put(identifier, stringifyQtiValue(computedValue));
    } catch (Exception e) {
        log.error("", e);
    }
}
Also used : Identifier(uk.ac.ed.ph.jqtiplus.types.Identifier) NumberValue(uk.ac.ed.ph.jqtiplus.value.NumberValue) BooleanValue(uk.ac.ed.ph.jqtiplus.value.BooleanValue) Value(uk.ac.ed.ph.jqtiplus.value.Value) NumberValue(uk.ac.ed.ph.jqtiplus.value.NumberValue) RecordValue(uk.ac.ed.ph.jqtiplus.value.RecordValue) BooleanValue(uk.ac.ed.ph.jqtiplus.value.BooleanValue) SingleValue(uk.ac.ed.ph.jqtiplus.value.SingleValue) BigDecimal(java.math.BigDecimal) QtiXmlInterpretationException(uk.ac.ed.ph.jqtiplus.reading.QtiXmlInterpretationException) TransformerException(javax.xml.transform.TransformerException) IOException(java.io.IOException) XmlResourceNotFoundException(uk.ac.ed.ph.jqtiplus.xmlutils.XmlResourceNotFoundException) OLATRuntimeException(org.olat.core.logging.OLATRuntimeException)

Example 2 with BooleanValue

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

the class AssessmentTestDisplayController method collectOutcomeVariablesForItemSession.

private void collectOutcomeVariablesForItemSession(ItemResult resultNode, AssessmentItemSession itemSession) {
    BigDecimal score = null;
    Boolean pass = null;
    for (final ItemVariable itemVariable : resultNode.getItemVariables()) {
        if (itemVariable instanceof OutcomeVariable) {
            OutcomeVariable outcomeVariable = (OutcomeVariable) itemVariable;
            Identifier identifier = outcomeVariable.getIdentifier();
            if (QTI21Constants.SCORE_IDENTIFIER.equals(identifier)) {
                Value value = itemVariable.getComputedValue();
                if (value instanceof FloatValue) {
                    score = new BigDecimal(((FloatValue) value).doubleValue());
                } else if (value instanceof IntegerValue) {
                    score = new BigDecimal(((IntegerValue) value).intValue());
                }
            } else if (QTI21Constants.PASS_IDENTIFIER.equals(identifier)) {
                Value value = itemVariable.getComputedValue();
                if (value instanceof BooleanValue) {
                    pass = ((BooleanValue) value).booleanValue();
                }
            }
        }
    }
    if (score != null) {
        itemSession.setScore(score);
    }
    if (pass != null) {
        itemSession.setPassed(pass);
    }
}
Also used : Identifier(uk.ac.ed.ph.jqtiplus.types.Identifier) IntegerValue(uk.ac.ed.ph.jqtiplus.value.IntegerValue) BooleanValue(uk.ac.ed.ph.jqtiplus.value.BooleanValue) Value(uk.ac.ed.ph.jqtiplus.value.Value) NumberValue(uk.ac.ed.ph.jqtiplus.value.NumberValue) FloatValue(uk.ac.ed.ph.jqtiplus.value.FloatValue) IntegerValue(uk.ac.ed.ph.jqtiplus.value.IntegerValue) BooleanValue(uk.ac.ed.ph.jqtiplus.value.BooleanValue) ItemVariable(uk.ac.ed.ph.jqtiplus.node.result.ItemVariable) FloatValue(uk.ac.ed.ph.jqtiplus.value.FloatValue) OutcomeVariable(uk.ac.ed.ph.jqtiplus.node.result.OutcomeVariable) BigDecimal(java.math.BigDecimal)

Example 3 with BooleanValue

use of uk.ac.ed.ph.jqtiplus.value.BooleanValue in project openolat by klemens.

the class AssessmentTestFactory method createOutcomeDeclaration.

public static OutcomeDeclaration createOutcomeDeclaration(AssessmentTest assessmentTest, Identifier identifier, boolean defaultValue) {
    OutcomeDeclaration outcomeDeclaration = new OutcomeDeclaration(assessmentTest);
    outcomeDeclaration.setIdentifier(identifier);
    outcomeDeclaration.setCardinality(Cardinality.SINGLE);
    outcomeDeclaration.setBaseType(BaseType.BOOLEAN);
    DefaultValue defaultVal = new DefaultValue(outcomeDeclaration);
    outcomeDeclaration.setDefaultValue(defaultVal);
    FieldValue fieldValue = new FieldValue(defaultVal);
    BooleanValue booleanValue = defaultValue ? BooleanValue.TRUE : BooleanValue.FALSE;
    fieldValue.setSingleValue(booleanValue);
    defaultVal.getFieldValues().add(fieldValue);
    return outcomeDeclaration;
}
Also used : DefaultValue(uk.ac.ed.ph.jqtiplus.node.shared.declaration.DefaultValue) BooleanValue(uk.ac.ed.ph.jqtiplus.value.BooleanValue) FieldValue(uk.ac.ed.ph.jqtiplus.node.shared.FieldValue) OutcomeDeclaration(uk.ac.ed.ph.jqtiplus.node.outcome.declaration.OutcomeDeclaration)

Example 4 with BooleanValue

use of uk.ac.ed.ph.jqtiplus.value.BooleanValue in project openolat by klemens.

the class AssessmentTestDisplayController method collectOutcomeVariablesForItemSession.

private void collectOutcomeVariablesForItemSession(ItemResult resultNode, AssessmentItemSession itemSession) {
    BigDecimal score = null;
    Boolean pass = null;
    for (final ItemVariable itemVariable : resultNode.getItemVariables()) {
        if (itemVariable instanceof OutcomeVariable) {
            OutcomeVariable outcomeVariable = (OutcomeVariable) itemVariable;
            Identifier identifier = outcomeVariable.getIdentifier();
            if (QTI21Constants.SCORE_IDENTIFIER.equals(identifier)) {
                Value value = itemVariable.getComputedValue();
                if (value instanceof FloatValue) {
                    score = new BigDecimal(((FloatValue) value).doubleValue());
                } else if (value instanceof IntegerValue) {
                    score = new BigDecimal(((IntegerValue) value).intValue());
                }
            } else if (QTI21Constants.PASS_IDENTIFIER.equals(identifier)) {
                Value value = itemVariable.getComputedValue();
                if (value instanceof BooleanValue) {
                    pass = ((BooleanValue) value).booleanValue();
                }
            }
        }
    }
    if (score != null) {
        itemSession.setScore(score);
    }
    if (pass != null) {
        itemSession.setPassed(pass);
    }
}
Also used : Identifier(uk.ac.ed.ph.jqtiplus.types.Identifier) IntegerValue(uk.ac.ed.ph.jqtiplus.value.IntegerValue) BooleanValue(uk.ac.ed.ph.jqtiplus.value.BooleanValue) Value(uk.ac.ed.ph.jqtiplus.value.Value) NumberValue(uk.ac.ed.ph.jqtiplus.value.NumberValue) FloatValue(uk.ac.ed.ph.jqtiplus.value.FloatValue) IntegerValue(uk.ac.ed.ph.jqtiplus.value.IntegerValue) BooleanValue(uk.ac.ed.ph.jqtiplus.value.BooleanValue) ItemVariable(uk.ac.ed.ph.jqtiplus.node.result.ItemVariable) FloatValue(uk.ac.ed.ph.jqtiplus.value.FloatValue) OutcomeVariable(uk.ac.ed.ph.jqtiplus.node.result.OutcomeVariable) BigDecimal(java.math.BigDecimal)

Example 5 with BooleanValue

use of uk.ac.ed.ph.jqtiplus.value.BooleanValue in project openolat by klemens.

the class TestFeedbackBuilder method findBaseValue.

private boolean findBaseValue(Expression expression, boolean value) {
    if (expression instanceof BaseValue) {
        BaseValue bValue = (BaseValue) expression;
        SingleValue sValue = bValue.getSingleValue();
        if (sValue instanceof BooleanValue) {
            BooleanValue booleanValue = (BooleanValue) sValue;
            return booleanValue.booleanValue() == value;
        }
    }
    return false;
}
Also used : SingleValue(uk.ac.ed.ph.jqtiplus.value.SingleValue) BaseValue(uk.ac.ed.ph.jqtiplus.node.expression.general.BaseValue) BooleanValue(uk.ac.ed.ph.jqtiplus.value.BooleanValue)

Aggregations

BooleanValue (uk.ac.ed.ph.jqtiplus.value.BooleanValue)10 Identifier (uk.ac.ed.ph.jqtiplus.types.Identifier)6 NumberValue (uk.ac.ed.ph.jqtiplus.value.NumberValue)6 Value (uk.ac.ed.ph.jqtiplus.value.Value)6 BigDecimal (java.math.BigDecimal)4 ItemVariable (uk.ac.ed.ph.jqtiplus.node.result.ItemVariable)4 OutcomeVariable (uk.ac.ed.ph.jqtiplus.node.result.OutcomeVariable)4 FloatValue (uk.ac.ed.ph.jqtiplus.value.FloatValue)4 IntegerValue (uk.ac.ed.ph.jqtiplus.value.IntegerValue)4 SingleValue (uk.ac.ed.ph.jqtiplus.value.SingleValue)4 IOException (java.io.IOException)2 TransformerException (javax.xml.transform.TransformerException)2 OLATRuntimeException (org.olat.core.logging.OLATRuntimeException)2 BaseValue (uk.ac.ed.ph.jqtiplus.node.expression.general.BaseValue)2 OutcomeDeclaration (uk.ac.ed.ph.jqtiplus.node.outcome.declaration.OutcomeDeclaration)2 FieldValue (uk.ac.ed.ph.jqtiplus.node.shared.FieldValue)2 DefaultValue (uk.ac.ed.ph.jqtiplus.node.shared.declaration.DefaultValue)2 QtiXmlInterpretationException (uk.ac.ed.ph.jqtiplus.reading.QtiXmlInterpretationException)2 RecordValue (uk.ac.ed.ph.jqtiplus.value.RecordValue)2 XmlResourceNotFoundException (uk.ac.ed.ph.jqtiplus.xmlutils.XmlResourceNotFoundException)2