Search in sources :

Example 1 with OutcomeVariable

use of uk.ac.ed.ph.jqtiplus.node.result.OutcomeVariable 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 2 with OutcomeVariable

use of uk.ac.ed.ph.jqtiplus.node.result.OutcomeVariable in project OpenOLAT by OpenOLAT.

the class AssessmentResultController method extractOutcomeVariable.

private void extractOutcomeVariable(List<ItemVariable> itemVariables, Results results) {
    for (ItemVariable itemVariable : itemVariables) {
        if (itemVariable instanceof OutcomeVariable) {
            if (QTI21Constants.SCORE_IDENTIFIER.equals(itemVariable.getIdentifier())) {
                Double score = getOutcomeNumberVariable(itemVariable);
                results.setScore(score);
                results.setAutoScore(score);
            } else if (QTI21Constants.MAXSCORE_IDENTIFIER.equals(itemVariable.getIdentifier())) {
                results.setMaxScore(getOutcomeNumberVariable(itemVariable));
            } else if (QTI21Constants.PASS_IDENTIFIER.equals(itemVariable.getIdentifier())) {
                results.setPass(getOutcomeBooleanVariable(itemVariable));
            }
        }
    }
}
Also used : ItemVariable(uk.ac.ed.ph.jqtiplus.node.result.ItemVariable) OutcomeVariable(uk.ac.ed.ph.jqtiplus.node.result.OutcomeVariable)

Example 3 with OutcomeVariable

use of uk.ac.ed.ph.jqtiplus.node.result.OutcomeVariable 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 4 with OutcomeVariable

use of uk.ac.ed.ph.jqtiplus.node.result.OutcomeVariable 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 5 with OutcomeVariable

use of uk.ac.ed.ph.jqtiplus.node.result.OutcomeVariable in project openolat by klemens.

the class AssessmentResultController method extractOutcomeVariable.

private void extractOutcomeVariable(List<ItemVariable> itemVariables, Results results) {
    for (ItemVariable itemVariable : itemVariables) {
        if (itemVariable instanceof OutcomeVariable) {
            if (QTI21Constants.SCORE_IDENTIFIER.equals(itemVariable.getIdentifier())) {
                Double score = getOutcomeNumberVariable(itemVariable);
                results.setScore(score);
                results.setAutoScore(score);
            } else if (QTI21Constants.MAXSCORE_IDENTIFIER.equals(itemVariable.getIdentifier())) {
                results.setMaxScore(getOutcomeNumberVariable(itemVariable));
            } else if (QTI21Constants.PASS_IDENTIFIER.equals(itemVariable.getIdentifier())) {
                results.setPass(getOutcomeBooleanVariable(itemVariable));
            }
        }
    }
}
Also used : ItemVariable(uk.ac.ed.ph.jqtiplus.node.result.ItemVariable) OutcomeVariable(uk.ac.ed.ph.jqtiplus.node.result.OutcomeVariable)

Aggregations

ItemVariable (uk.ac.ed.ph.jqtiplus.node.result.ItemVariable)6 OutcomeVariable (uk.ac.ed.ph.jqtiplus.node.result.OutcomeVariable)6 Identifier (uk.ac.ed.ph.jqtiplus.types.Identifier)4 BooleanValue (uk.ac.ed.ph.jqtiplus.value.BooleanValue)4 FloatValue (uk.ac.ed.ph.jqtiplus.value.FloatValue)4 IntegerValue (uk.ac.ed.ph.jqtiplus.value.IntegerValue)4 NumberValue (uk.ac.ed.ph.jqtiplus.value.NumberValue)4 Value (uk.ac.ed.ph.jqtiplus.value.Value)4 BigDecimal (java.math.BigDecimal)2