use of uk.ac.ed.ph.jqtiplus.node.expression.Expression in project OpenOLAT by OpenOLAT.
the class FIBAssessmentItemBuilder method extractNumericalEntrySettings.
private static boolean extractNumericalEntrySettings(NumericalEntry numericalEntry, Equal equal) {
Expression variableOrCorrect = equal.getExpressions().get(0);
Expression correctOrVariable = equal.getExpressions().get(1);
Correct correct = null;
if (variableOrCorrect instanceof Correct) {
correct = (Correct) variableOrCorrect;
} else if (correctOrVariable instanceof Correct) {
correct = (Correct) correctOrVariable;
}
ComplexReferenceIdentifier reponseIdentifer = ComplexReferenceIdentifier.assumedLegal(numericalEntry.getResponseIdentifier().toString());
if (correct != null && correct.getIdentifier().equals(reponseIdentifer)) {
numericalEntry.setToleranceMode(equal.getToleranceMode());
List<FloatOrVariableRef> tolerances = equal.getTolerances();
if (tolerances != null && tolerances.size() == 2) {
double lowerTolerance = tolerances.get(0).getConstantFloatValue().doubleValue();
numericalEntry.setLowerTolerance(lowerTolerance);
double upperTolerance = tolerances.get(1).getConstantFloatValue().doubleValue();
numericalEntry.setUpperTolerance(upperTolerance);
}
return true;
}
return false;
}
use of uk.ac.ed.ph.jqtiplus.node.expression.Expression in project OpenOLAT by OpenOLAT.
the class ModalFeedbackBuilder method extractConditions.
public void extractConditions() {
ResponseCondition feedbackRule = findFeedbackResponseCondition(modalFeedback.getIdentifier(), QTI21Constants.FEEDBACKMODAL_IDENTIFIER);
ResponseIf responseIf = feedbackRule.getResponseIf();
if (responseIf != null && responseIf.getExpressions() != null && responseIf.getExpressions().size() == 1 && responseIf.getExpressions().get(0) instanceof And && responseIf.getResponseRules().size() == 1 && responseIf.getResponseRules().get(0) instanceof SetOutcomeValue) {
And and = (And) responseIf.getExpression();
List<Expression> conditionElements = and.getExpressions();
List<ModalFeedbackCondition> extractedConditions = new ArrayList<>();
for (Expression conditionElement : conditionElements) {
ModalFeedbackCondition condition = extractCondition(conditionElement);
if (condition != null) {
extractedConditions.add(condition);
}
}
if (extractedConditions != null) {
conditions = extractedConditions;
}
}
}
use of uk.ac.ed.ph.jqtiplus.node.expression.Expression in project OpenOLAT by OpenOLAT.
the class ModalFeedbackBuilder method findBaseValueInExpressionsOfResponseIf.
private boolean findBaseValueInExpressionsOfResponseIf(ResponseCondition responseCondition, Identifier feedbackIdentifier) {
if (responseCondition == null)
return false;
ResponseIf responseIf = responseCondition.getResponseIf();
List<Expression> expressions = responseIf.getExpressions();
for (Expression expression : expressions) {
if (findBaseValueInExpression(expression, feedbackIdentifier)) {
return true;
}
}
return false;
}
use of uk.ac.ed.ph.jqtiplus.node.expression.Expression in project openolat by klemens.
the class FIBAssessmentItemBuilder method extractNumericalEntrySettings.
private static boolean extractNumericalEntrySettings(NumericalEntry numericalEntry, Equal equal) {
Expression variableOrCorrect = equal.getExpressions().get(0);
Expression correctOrVariable = equal.getExpressions().get(1);
Correct correct = null;
if (variableOrCorrect instanceof Correct) {
correct = (Correct) variableOrCorrect;
} else if (correctOrVariable instanceof Correct) {
correct = (Correct) correctOrVariable;
}
ComplexReferenceIdentifier reponseIdentifer = ComplexReferenceIdentifier.assumedLegal(numericalEntry.getResponseIdentifier().toString());
if (correct != null && correct.getIdentifier().equals(reponseIdentifer)) {
numericalEntry.setToleranceMode(equal.getToleranceMode());
List<FloatOrVariableRef> tolerances = equal.getTolerances();
if (tolerances != null && tolerances.size() == 2) {
double lowerTolerance = tolerances.get(0).getConstantFloatValue().doubleValue();
numericalEntry.setLowerTolerance(lowerTolerance);
double upperTolerance = tolerances.get(1).getConstantFloatValue().doubleValue();
numericalEntry.setUpperTolerance(upperTolerance);
}
return true;
}
return false;
}
use of uk.ac.ed.ph.jqtiplus.node.expression.Expression in project openolat by klemens.
the class ModalFeedbackBuilder method findBaseValueInExpressionsOfResponseIf.
private boolean findBaseValueInExpressionsOfResponseIf(ResponseCondition responseCondition, Identifier feedbackIdentifier) {
if (responseCondition == null)
return false;
ResponseIf responseIf = responseCondition.getResponseIf();
List<Expression> expressions = responseIf.getExpressions();
for (Expression expression : expressions) {
if (findBaseValueInExpression(expression, feedbackIdentifier)) {
return true;
}
}
return false;
}
Aggregations