use of uk.ac.ed.ph.jqtiplus.node.shared.FieldValue in project OpenOLAT by OpenOLAT.
the class AssessmentTestFactory method updateDefaultValue.
public static void updateDefaultValue(OutcomeDeclaration outcomeDeclaration, Double defaultValue) {
outcomeDeclaration.setBaseType(BaseType.FLOAT);
DefaultValue defaultVal = outcomeDeclaration.getDefaultValue();
defaultVal.getFieldValues().clear();
FieldValue fieldValue = new FieldValue(defaultVal);
FloatValue identifierValue = new FloatValue(defaultValue);
fieldValue.setSingleValue(identifierValue);
defaultVal.getFieldValues().add(fieldValue);
}
use of uk.ac.ed.ph.jqtiplus.node.shared.FieldValue in project OpenOLAT by OpenOLAT.
the class AssessmentTestFactory method createOutcomeDeclaration.
public static OutcomeDeclaration createOutcomeDeclaration(AssessmentTest assessmentTest, Identifier identifier, boolean defaultValue) {
OutcomeDeclaration outcomeDeclaration = new OutcomeDeclaration(assessmentTest);
outcomeDeclaration.setIdentifier(identifier);
outcomeDeclaration.setCardinality(Cardinality.SINGLE);
outcomeDeclaration.setBaseType(BaseType.BOOLEAN);
DefaultValue defaultVal = new DefaultValue(outcomeDeclaration);
outcomeDeclaration.setDefaultValue(defaultVal);
FieldValue fieldValue = new FieldValue(defaultVal);
BooleanValue booleanValue = defaultValue ? BooleanValue.TRUE : BooleanValue.FALSE;
fieldValue.setSingleValue(booleanValue);
defaultVal.getFieldValues().add(fieldValue);
return outcomeDeclaration;
}
use of uk.ac.ed.ph.jqtiplus.node.shared.FieldValue in project OpenOLAT by OpenOLAT.
the class AssessmentTestFactory method createOutcomeDeclaration.
public static OutcomeDeclaration createOutcomeDeclaration(AssessmentTest assessmentTest, Identifier identifier, Double defaultValue) {
OutcomeDeclaration outcomeDeclaration = new OutcomeDeclaration(assessmentTest);
outcomeDeclaration.setIdentifier(identifier);
outcomeDeclaration.setCardinality(Cardinality.SINGLE);
outcomeDeclaration.setBaseType(BaseType.FLOAT);
DefaultValue defaultVal = new DefaultValue(outcomeDeclaration);
outcomeDeclaration.setDefaultValue(defaultVal);
FieldValue fieldValue = new FieldValue(defaultVal);
FloatValue identifierValue = new FloatValue(defaultValue);
fieldValue.setSingleValue(identifierValue);
defaultVal.getFieldValues().add(fieldValue);
return outcomeDeclaration;
}
use of uk.ac.ed.ph.jqtiplus.node.shared.FieldValue 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;
}
use of uk.ac.ed.ph.jqtiplus.node.shared.FieldValue in project openolat by klemens.
the class CorrectResponsesUtil method getCorrectIdentifierResponses.
public static final List<Identifier> getCorrectIdentifierResponses(AssessmentItem assessmentItem, Identifier responseIdentifier) {
List<Identifier> correctAnswers = new ArrayList<>(5);
ResponseDeclaration responseDeclaration = assessmentItem.getResponseDeclaration(responseIdentifier);
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 IdentifierValue) {
IdentifierValue identifierValue = (IdentifierValue) value;
Identifier correctAnswer = identifierValue.identifierValue();
correctAnswers.add(correctAnswer);
}
} 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 IdentifierValue) {
IdentifierValue identifierValue = (IdentifierValue) sValue;
Identifier correctAnswer = identifierValue.identifierValue();
correctAnswers.add(correctAnswer);
}
}
}
}
}
return correctAnswers;
}
Aggregations