use of uk.ac.ed.ph.jqtiplus.value.OrderedValue in project OpenOLAT by OpenOLAT.
the class CorrectResponsesUtil method getCorrectOrderedIdentifierResponses.
public static final List<Identifier> getCorrectOrderedIdentifierResponses(AssessmentItem assessmentItem, Interaction interaction) {
List<Identifier> 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.ORDERED)) {
List<FieldValue> values = correctResponse.getFieldValues();
Value value = FieldValue.computeValue(Cardinality.ORDERED, values);
if (value instanceof OrderedValue) {
OrderedValue multiValue = (OrderedValue) value;
multiValue.forEach(oValue -> {
if (oValue instanceof IdentifierValue) {
IdentifierValue identifierValue = (IdentifierValue) oValue;
Identifier correctAnswer = identifierValue.identifierValue();
correctAnswers.add(correctAnswer);
}
});
}
}
}
return correctAnswers;
}
use of uk.ac.ed.ph.jqtiplus.value.OrderedValue in project openolat by klemens.
the class CorrectResponsesUtil method getCorrectOrderedIdentifierResponses.
public static final List<Identifier> getCorrectOrderedIdentifierResponses(AssessmentItem assessmentItem, Interaction interaction) {
List<Identifier> 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.ORDERED)) {
List<FieldValue> values = correctResponse.getFieldValues();
Value value = FieldValue.computeValue(Cardinality.ORDERED, values);
if (value instanceof OrderedValue) {
OrderedValue multiValue = (OrderedValue) value;
multiValue.forEach(oValue -> {
if (oValue instanceof IdentifierValue) {
IdentifierValue identifierValue = (IdentifierValue) oValue;
Identifier correctAnswer = identifierValue.identifierValue();
correctAnswers.add(correctAnswer);
}
});
}
}
}
return correctAnswers;
}
Aggregations