use of uk.ac.ed.ph.jqtiplus.node.shared.FieldValue in project OpenOLAT by OpenOLAT.
the class FIBAssessmentItemBuilder method extractNumericalEntrySettings.
public static void extractNumericalEntrySettings(AssessmentItem item, NumericalEntry numericalEntry, ResponseDeclaration responseDeclaration, AtomicInteger countAlternatives, DoubleAdder mappedScore) {
Double solution = null;
CorrectResponse correctResponse = responseDeclaration.getCorrectResponse();
if (correctResponse != null && correctResponse.getFieldValues().size() > 0) {
List<FieldValue> fValues = correctResponse.getFieldValues();
SingleValue sValue = fValues.get(0).getSingleValue();
if (sValue instanceof FloatValue) {
solution = ((FloatValue) sValue).doubleValue();
numericalEntry.setSolution(solution);
}
}
// search the equal
List<ResponseRule> responseRules = item.getResponseProcessing().getResponseRules();
a_a: for (ResponseRule responseRule : responseRules) {
if (responseRule instanceof ResponseCondition) {
ResponseCondition condition = (ResponseCondition) responseRule;
ResponseIf responseIf = condition.getResponseIf();
if (responseIf != null && responseIf.getExpressions().size() > 0) {
// first is an and/equal/
Expression potentialEqualOrAnd = responseIf.getExpressions().get(0);
if (potentialEqualOrAnd instanceof And) {
And and = (And) potentialEqualOrAnd;
for (Expression potentialEqual : and.getExpressions()) {
if (potentialEqual instanceof Equal && potentialEqual.getExpressions().size() == 2 && extractNumericalEntrySettings(numericalEntry, (Equal) potentialEqual)) {
break a_a;
}
}
} else if (potentialEqualOrAnd instanceof Equal) {
if (extractNumericalEntrySettings(numericalEntry, (Equal) potentialEqualOrAnd)) {
// find to score as outcome value
if (responseIf.getResponseRules() != null && responseIf.getResponseRules().size() == 1 && responseIf.getResponseRules().get(0) instanceof SetOutcomeValue) {
SetOutcomeValue outcomeValue = (SetOutcomeValue) responseIf.getResponseRules().get(0);
if (outcomeValue.getExpressions() != null && outcomeValue.getExpressions().size() == 1 && outcomeValue.getExpressions().get(0) instanceof BaseValue) {
BaseValue bValue = (BaseValue) outcomeValue.getExpressions().get(0);
SingleValue sValue = bValue.getSingleValue();
if (sValue instanceof FloatValue) {
FloatValue fValue = (FloatValue) sValue;
numericalEntry.setScore(fValue.doubleValue());
mappedScore.add(fValue.doubleValue());
countAlternatives.incrementAndGet();
}
}
}
break a_a;
}
}
}
}
}
// toleranceMode cannot be empty
if (numericalEntry.getToleranceMode() == null) {
numericalEntry.setToleranceMode(ToleranceMode.EXACT);
}
}
use of uk.ac.ed.ph.jqtiplus.node.shared.FieldValue in project openolat by klemens.
the class KPrimAssessmentItemBuilder method extractCorrectResponse.
private void extractCorrectResponse() {
associations = new HashMap<>();
if (matchInteraction != null) {
ResponseDeclaration responseDeclaration = assessmentItem.getResponseDeclaration(matchInteraction.getResponseIdentifier());
if (responseDeclaration != null && responseDeclaration.getCorrectResponse() != null) {
CorrectResponse correctResponse = responseDeclaration.getCorrectResponse();
List<FieldValue> values = correctResponse.getFieldValues();
for (FieldValue value : values) {
SingleValue sValue = value.getSingleValue();
if (sValue instanceof DirectedPairValue) {
DirectedPairValue dpValue = (DirectedPairValue) sValue;
Identifier sourceId = dpValue.sourceValue();
Identifier destinationId = dpValue.destValue();
associations.put(sourceId, destinationId);
}
}
}
}
}
use of uk.ac.ed.ph.jqtiplus.node.shared.FieldValue in project openolat by klemens.
the class SingleChoiceAssessmentItemBuilder method extract.
@Override
public void extract() {
super.extract();
if (choiceInteraction != null) {
ResponseDeclaration responseDeclaration = assessmentItem.getResponseDeclaration(choiceInteraction.getResponseIdentifier());
if (responseDeclaration != null && responseDeclaration.getCorrectResponse() != null) {
CorrectResponse correctResponse = responseDeclaration.getCorrectResponse();
List<FieldValue> values = correctResponse.getFieldValues();
Value value = FieldValue.computeValue(Cardinality.SINGLE, values);
if (value instanceof IdentifierValue) {
IdentifierValue identifierValue = (IdentifierValue) value;
correctAnswer = identifierValue.identifierValue();
}
}
}
}
use of uk.ac.ed.ph.jqtiplus.node.shared.FieldValue in project openolat by klemens.
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 klemens.
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);
}
Aggregations