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")));
}
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")));
}
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);
}
}
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);
}
}
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;
}
}
Aggregations