Search in sources :

Example 1 with IntegerValue

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

the class AssessmentRenderFunctionsTest method valueContains_multipleAlienValues.

@Test
public void valueContains_multipleAlienValues() {
    Value identifierValues = MultipleValue.createMultipleValue(new IntegerValue(6), new IntegerValue(7));
    Assert.assertFalse(AssessmentRenderFunctions.valueContains(identifierValues, Identifier.parseString("6")));
    Assert.assertFalse(AssessmentRenderFunctions.valueContains(identifierValues, Identifier.parseString("noid")));
}
Also used : IntegerValue(uk.ac.ed.ph.jqtiplus.value.IntegerValue) OrderedValue(uk.ac.ed.ph.jqtiplus.value.OrderedValue) IntegerValue(uk.ac.ed.ph.jqtiplus.value.IntegerValue) MultipleValue(uk.ac.ed.ph.jqtiplus.value.MultipleValue) NullValue(uk.ac.ed.ph.jqtiplus.value.NullValue) Value(uk.ac.ed.ph.jqtiplus.value.Value) IdentifierValue(uk.ac.ed.ph.jqtiplus.value.IdentifierValue) Test(org.junit.Test)

Example 2 with IntegerValue

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

the class AssessmentRenderFunctionsTest method valueContains_orderedAlienValues.

@Test
public void valueContains_orderedAlienValues() {
    Value identifierValues = OrderedValue.createOrderedValue(new IntegerValue(6), new IntegerValue(7));
    Assert.assertFalse(AssessmentRenderFunctions.valueContains(identifierValues, Identifier.parseString("7")));
    Assert.assertFalse(AssessmentRenderFunctions.valueContains(identifierValues, Identifier.parseString("noid")));
}
Also used : IntegerValue(uk.ac.ed.ph.jqtiplus.value.IntegerValue) OrderedValue(uk.ac.ed.ph.jqtiplus.value.OrderedValue) IntegerValue(uk.ac.ed.ph.jqtiplus.value.IntegerValue) MultipleValue(uk.ac.ed.ph.jqtiplus.value.MultipleValue) NullValue(uk.ac.ed.ph.jqtiplus.value.NullValue) Value(uk.ac.ed.ph.jqtiplus.value.Value) IdentifierValue(uk.ac.ed.ph.jqtiplus.value.IdentifierValue) Test(org.junit.Test)

Example 3 with IntegerValue

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

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

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

the class AssessmentItemFactory method appendVariableBaseValue.

/*
		<variable identifier="SCORE" />
		<baseValue baseType="float">4</baseValue>
	 */
/**
 * @param var
 * @param value
 * @param responseIdentifier
 * @param parentExpression
 * @param reverse if true, reverse the order, first baseValue and then variable
 */
private static void appendVariableBaseValue(ModalFeedbackCondition.Variable var, String value, Identifier responseIdentifier, Expression parentExpression, boolean reverse) {
    Variable variable = new Variable(parentExpression);
    BaseValue bValue = new BaseValue(parentExpression);
    if (reverse) {
        parentExpression.getExpressions().add(bValue);
        parentExpression.getExpressions().add(variable);
    } else {
        parentExpression.getExpressions().add(variable);
        parentExpression.getExpressions().add(bValue);
    }
    switch(var) {
        case score:
            bValue.setBaseTypeAttrValue(BaseType.FLOAT);
            bValue.setSingleValue(new FloatValue(Double.parseDouble(value)));
            variable.setIdentifier(QTI21Constants.SCORE_CLX_IDENTIFIER);
            break;
        case attempts:
            bValue.setBaseTypeAttrValue(BaseType.INTEGER);
            bValue.setSingleValue(new IntegerValue(Integer.parseInt(value)));
            variable.setIdentifier(QTI21Constants.NUM_ATTEMPTS_CLX_IDENTIFIER);
            break;
        case response:
            bValue.setBaseTypeAttrValue(BaseType.IDENTIFIER);
            bValue.setSingleValue(new IdentifierValue(Identifier.parseString(value)));
            variable.setIdentifier(ComplexReferenceIdentifier.parseString(responseIdentifier.toString()));
            break;
    }
}
Also used : Variable(uk.ac.ed.ph.jqtiplus.node.expression.general.Variable) BaseValue(uk.ac.ed.ph.jqtiplus.node.expression.general.BaseValue) IntegerValue(uk.ac.ed.ph.jqtiplus.value.IntegerValue) IdentifierValue(uk.ac.ed.ph.jqtiplus.value.IdentifierValue) FloatValue(uk.ac.ed.ph.jqtiplus.value.FloatValue)

Aggregations

IntegerValue (uk.ac.ed.ph.jqtiplus.value.IntegerValue)10 IdentifierValue (uk.ac.ed.ph.jqtiplus.value.IdentifierValue)8 Value (uk.ac.ed.ph.jqtiplus.value.Value)8 MultipleValue (uk.ac.ed.ph.jqtiplus.value.MultipleValue)6 OrderedValue (uk.ac.ed.ph.jqtiplus.value.OrderedValue)6 Test (org.junit.Test)4 FloatValue (uk.ac.ed.ph.jqtiplus.value.FloatValue)4 NullValue (uk.ac.ed.ph.jqtiplus.value.NullValue)4 BigDecimal (java.math.BigDecimal)2 ArrayList (java.util.ArrayList)2 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)2 BaseValue (uk.ac.ed.ph.jqtiplus.node.expression.general.BaseValue)2 Variable (uk.ac.ed.ph.jqtiplus.node.expression.general.Variable)2 CorrectResponse (uk.ac.ed.ph.jqtiplus.node.item.CorrectResponse)2 ResponseDeclaration (uk.ac.ed.ph.jqtiplus.node.item.response.declaration.ResponseDeclaration)2 ItemVariable (uk.ac.ed.ph.jqtiplus.node.result.ItemVariable)2 OutcomeVariable (uk.ac.ed.ph.jqtiplus.node.result.OutcomeVariable)2 FieldValue (uk.ac.ed.ph.jqtiplus.node.shared.FieldValue)2 Identifier (uk.ac.ed.ph.jqtiplus.types.Identifier)2 BooleanValue (uk.ac.ed.ph.jqtiplus.value.BooleanValue)2