Search in sources :

Example 1 with NumberValue

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

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

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 3 with NumberValue

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

the class AssessmentTestDisplayController method processOutcomeVariables.

private void processOutcomeVariables(TestResult resultNode, TestPlanInfos testPlanInfos, boolean submit) {
    Float score = null;
    Boolean pass = null;
    double completion = testPlanInfos.getCompletion();
    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 NumberValue) {
                    score = (float) ((NumberValue) value).doubleValue();
                }
            } else if (QTI21Constants.PASS_IDENTIFIER.equals(identifier)) {
                Value value = itemVariable.getComputedValue();
                if (value instanceof BooleanValue) {
                    pass = ((BooleanValue) value).booleanValue();
                }
            }
        }
    }
    if (submit) {
        outcomesListener.submit(score, pass, completion, candidateSession.getKey());
    } else if (candidateSession != null && candidateSession.getFinishTime() == null) {
        // don't change the outcome if the test is finished
        outcomesListener.updateOutcomes(score, pass, completion);
    }
}
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) 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) OutcomeVariable(uk.ac.ed.ph.jqtiplus.node.result.OutcomeVariable)

Example 4 with NumberValue

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

the class AssessmentTestDisplayController method processOutcomeVariables.

private void processOutcomeVariables(TestResult resultNode, TestPlanInfos testPlanInfos, boolean submit) {
    Float score = null;
    Boolean pass = null;
    double completion = testPlanInfos.getCompletion();
    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 NumberValue) {
                    score = (float) ((NumberValue) value).doubleValue();
                }
            } else if (QTI21Constants.PASS_IDENTIFIER.equals(identifier)) {
                Value value = itemVariable.getComputedValue();
                if (value instanceof BooleanValue) {
                    pass = ((BooleanValue) value).booleanValue();
                }
            }
        }
    }
    if (submit) {
        outcomesListener.submit(score, pass, completion, candidateSession.getKey());
    } else if (candidateSession != null && candidateSession.getFinishTime() == null) {
        // don't change the outcome if the test is finished
        outcomesListener.updateOutcomes(score, pass, completion);
    }
}
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) 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) OutcomeVariable(uk.ac.ed.ph.jqtiplus.node.result.OutcomeVariable)

Aggregations

Identifier (uk.ac.ed.ph.jqtiplus.types.Identifier)4 BooleanValue (uk.ac.ed.ph.jqtiplus.value.BooleanValue)4 NumberValue (uk.ac.ed.ph.jqtiplus.value.NumberValue)4 Value (uk.ac.ed.ph.jqtiplus.value.Value)4 IOException (java.io.IOException)2 BigDecimal (java.math.BigDecimal)2 TransformerException (javax.xml.transform.TransformerException)2 OLATRuntimeException (org.olat.core.logging.OLATRuntimeException)2 ItemVariable (uk.ac.ed.ph.jqtiplus.node.result.ItemVariable)2 OutcomeVariable (uk.ac.ed.ph.jqtiplus.node.result.OutcomeVariable)2 QtiXmlInterpretationException (uk.ac.ed.ph.jqtiplus.reading.QtiXmlInterpretationException)2 FloatValue (uk.ac.ed.ph.jqtiplus.value.FloatValue)2 IntegerValue (uk.ac.ed.ph.jqtiplus.value.IntegerValue)2 RecordValue (uk.ac.ed.ph.jqtiplus.value.RecordValue)2 SingleValue (uk.ac.ed.ph.jqtiplus.value.SingleValue)2 XmlResourceNotFoundException (uk.ac.ed.ph.jqtiplus.xmlutils.XmlResourceNotFoundException)2