Search in sources :

Example 6 with Expression

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;
}
Also used : ComplexReferenceIdentifier(uk.ac.ed.ph.jqtiplus.types.ComplexReferenceIdentifier) Expression(uk.ac.ed.ph.jqtiplus.node.expression.Expression) FloatOrVariableRef(uk.ac.ed.ph.jqtiplus.types.FloatOrVariableRef) Correct(uk.ac.ed.ph.jqtiplus.node.expression.general.Correct)

Example 7 with Expression

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;
        }
    }
}
Also used : SetOutcomeValue(uk.ac.ed.ph.jqtiplus.node.item.response.processing.SetOutcomeValue) AssessmentItemFactory.findBaseValueInExpression(org.olat.ims.qti21.model.xml.AssessmentItemFactory.findBaseValueInExpression) Expression(uk.ac.ed.ph.jqtiplus.node.expression.Expression) And(uk.ac.ed.ph.jqtiplus.node.expression.operator.And) ArrayList(java.util.ArrayList) ResponseIf(uk.ac.ed.ph.jqtiplus.node.item.response.processing.ResponseIf) ResponseCondition(uk.ac.ed.ph.jqtiplus.node.item.response.processing.ResponseCondition)

Example 8 with Expression

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;
}
Also used : AssessmentItemFactory.findBaseValueInExpression(org.olat.ims.qti21.model.xml.AssessmentItemFactory.findBaseValueInExpression) Expression(uk.ac.ed.ph.jqtiplus.node.expression.Expression) ResponseIf(uk.ac.ed.ph.jqtiplus.node.item.response.processing.ResponseIf)

Example 9 with Expression

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;
}
Also used : ComplexReferenceIdentifier(uk.ac.ed.ph.jqtiplus.types.ComplexReferenceIdentifier) Expression(uk.ac.ed.ph.jqtiplus.node.expression.Expression) FloatOrVariableRef(uk.ac.ed.ph.jqtiplus.types.FloatOrVariableRef) Correct(uk.ac.ed.ph.jqtiplus.node.expression.general.Correct)

Example 10 with Expression

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;
}
Also used : AssessmentItemFactory.findBaseValueInExpression(org.olat.ims.qti21.model.xml.AssessmentItemFactory.findBaseValueInExpression) Expression(uk.ac.ed.ph.jqtiplus.node.expression.Expression) ResponseIf(uk.ac.ed.ph.jqtiplus.node.item.response.processing.ResponseIf)

Aggregations

Expression (uk.ac.ed.ph.jqtiplus.node.expression.Expression)22 BaseValue (uk.ac.ed.ph.jqtiplus.node.expression.general.BaseValue)8 And (uk.ac.ed.ph.jqtiplus.node.expression.operator.And)8 ResponseIf (uk.ac.ed.ph.jqtiplus.node.item.response.processing.ResponseIf)8 ResponseCondition (uk.ac.ed.ph.jqtiplus.node.item.response.processing.ResponseCondition)6 SetOutcomeValue (uk.ac.ed.ph.jqtiplus.node.item.response.processing.SetOutcomeValue)6 ComplexReferenceIdentifier (uk.ac.ed.ph.jqtiplus.types.ComplexReferenceIdentifier)6 SingleValue (uk.ac.ed.ph.jqtiplus.value.SingleValue)6 AssessmentItemFactory.findBaseValueInExpression (org.olat.ims.qti21.model.xml.AssessmentItemFactory.findBaseValueInExpression)4 Variable (uk.ac.ed.ph.jqtiplus.node.expression.general.Variable)4 ResponseRule (uk.ac.ed.ph.jqtiplus.node.item.response.processing.ResponseRule)4 FloatValue (uk.ac.ed.ph.jqtiplus.value.FloatValue)4 IdentifierValue (uk.ac.ed.ph.jqtiplus.value.IdentifierValue)4 ArrayList (java.util.ArrayList)2 Correct (uk.ac.ed.ph.jqtiplus.node.expression.general.Correct)2 Equal (uk.ac.ed.ph.jqtiplus.node.expression.operator.Equal)2 Match (uk.ac.ed.ph.jqtiplus.node.expression.operator.Match)2 CorrectResponse (uk.ac.ed.ph.jqtiplus.node.item.CorrectResponse)2 ResponseDeclaration (uk.ac.ed.ph.jqtiplus.node.item.response.declaration.ResponseDeclaration)2 TemplateDeclaration (uk.ac.ed.ph.jqtiplus.node.item.template.declaration.TemplateDeclaration)2