use of uk.ac.ed.ph.jqtiplus.value.IntegerValue in project openolat by klemens.
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 klemens.
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 klemens.
the class CorrectResponsesUtil method getCorrectIntegerResponses.
public static final List<Integer> getCorrectIntegerResponses(AssessmentItem assessmentItem, Interaction interaction) {
List<Integer> correctAnswers = new ArrayList<>(5);
ResponseDeclaration responseDeclaration = assessmentItem.getResponseDeclaration(interaction.getResponseIdentifier());
if (responseDeclaration != null && responseDeclaration.getCorrectResponse() != null) {
CorrectResponse correctResponse = responseDeclaration.getCorrectResponse();
if (correctResponse.getCardinality().isOneOf(Cardinality.SINGLE)) {
List<FieldValue> values = correctResponse.getFieldValues();
Value value = FieldValue.computeValue(Cardinality.SINGLE, values);
if (value instanceof IntegerValue) {
IntegerValue identifierValue = (IntegerValue) value;
correctAnswers.add(identifierValue.intValue());
}
} else if (correctResponse.getCardinality().isOneOf(Cardinality.MULTIPLE)) {
Value value = FieldValue.computeValue(Cardinality.MULTIPLE, correctResponse.getFieldValues());
if (value instanceof MultipleValue) {
MultipleValue multiValue = (MultipleValue) value;
for (SingleValue sValue : multiValue.getAll()) {
if (sValue instanceof IntegerValue) {
IntegerValue identifierValue = (IntegerValue) value;
correctAnswers.add(identifierValue.intValue());
}
}
}
}
}
return correctAnswers;
}
use of uk.ac.ed.ph.jqtiplus.value.IntegerValue in project OpenOLAT by OpenOLAT.
the class CorrectResponsesUtil method getCorrectIntegerResponses.
public static final List<Integer> getCorrectIntegerResponses(AssessmentItem assessmentItem, Interaction interaction) {
List<Integer> correctAnswers = new ArrayList<>(5);
ResponseDeclaration responseDeclaration = assessmentItem.getResponseDeclaration(interaction.getResponseIdentifier());
if (responseDeclaration != null && responseDeclaration.getCorrectResponse() != null) {
CorrectResponse correctResponse = responseDeclaration.getCorrectResponse();
if (correctResponse.getCardinality().isOneOf(Cardinality.SINGLE)) {
List<FieldValue> values = correctResponse.getFieldValues();
Value value = FieldValue.computeValue(Cardinality.SINGLE, values);
if (value instanceof IntegerValue) {
IntegerValue identifierValue = (IntegerValue) value;
correctAnswers.add(identifierValue.intValue());
}
} else if (correctResponse.getCardinality().isOneOf(Cardinality.MULTIPLE)) {
Value value = FieldValue.computeValue(Cardinality.MULTIPLE, correctResponse.getFieldValues());
if (value instanceof MultipleValue) {
MultipleValue multiValue = (MultipleValue) value;
for (SingleValue sValue : multiValue.getAll()) {
if (sValue instanceof IntegerValue) {
IntegerValue identifierValue = (IntegerValue) value;
correctAnswers.add(identifierValue.intValue());
}
}
}
}
}
return correctAnswers;
}
use of uk.ac.ed.ph.jqtiplus.value.IntegerValue in project OpenOLAT by OpenOLAT.
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