Search in sources :

Example 26 with ComplexReferenceIdentifier

use of uk.ac.ed.ph.jqtiplus.types.ComplexReferenceIdentifier in project openolat by klemens.

the class AssessmentItemFactory method matchAdditionalFeedback.

/**
 * the additional feedback have only responseIf
 *
 * @param item
 * @param feedback
 * @return
 */
public static boolean matchAdditionalFeedback(AssessmentItem item, ModalFeedback feedback) {
    List<ResponseRule> responseRules = item.getResponseProcessing().getResponseRules();
    for (ResponseRule responseRule : responseRules) {
        if (responseRule instanceof ResponseCondition) {
            ResponseCondition responseCondition = (ResponseCondition) responseRule;
            if (responseCondition.getResponseIf() == null || responseCondition.getResponseElse() != null || (responseCondition.getResponseElseIfs() != null && responseCondition.getResponseElseIfs().size() > 0)) {
                continue;
            }
            ResponseIf responseIf = responseCondition.getResponseIf();
            List<ResponseRule> ifResponseRules = responseIf.getResponseRules();
            if (ifResponseRules == null || ifResponseRules.size() != 1 || !(ifResponseRules.get(0) instanceof SetOutcomeValue)) {
                continue;
            }
            SetOutcomeValue setOutcomeValue = (SetOutcomeValue) responseIf.getResponseRules().get(0);
            if (!findBaseValueInExpression(setOutcomeValue.getExpression(), feedback.getIdentifier())) {
                continue;
            }
            List<Expression> expressions = responseIf.getExpressions();
            if (expressions == null || expressions.size() != 1 || !(expressions.get(0) instanceof And)) {
                continue;
            }
            List<Variable> variables = QueryUtils.search(Variable.class, expressions.get(0));
            if (variables != null && variables.size() == 1) {
                Variable bValue = variables.get(0);
                ComplexReferenceIdentifier identifier = bValue.getIdentifier();
                if (identifier.equals(QTI21Constants.SCORE_CLX_IDENTIFIER) || identifier.equals(QTI21Constants.NUM_ATTEMPTS_CLX_IDENTIFIER)) {
                    return true;
                }
                if (identifier.equals(QTI21Constants.CORRECT_CLX_IDENTIFIER) || identifier.equals(QTI21Constants.INCORRECT_CLX_IDENTIFIER) || identifier.equals(QTI21Constants.EMPTY_CLX_IDENTIFIER)) {
                    return false;
                }
                String identifierToString = identifier.toString();
                if (identifierToString.contains("RESPONSE_")) {
                    return true;
                }
            }
        }
    }
    return false;
}
Also used : ComplexReferenceIdentifier(uk.ac.ed.ph.jqtiplus.types.ComplexReferenceIdentifier) Variable(uk.ac.ed.ph.jqtiplus.node.expression.general.Variable) SetOutcomeValue(uk.ac.ed.ph.jqtiplus.node.item.response.processing.SetOutcomeValue) Expression(uk.ac.ed.ph.jqtiplus.node.expression.Expression) And(uk.ac.ed.ph.jqtiplus.node.expression.operator.And) ResponseIf(uk.ac.ed.ph.jqtiplus.node.item.response.processing.ResponseIf) ResponseRule(uk.ac.ed.ph.jqtiplus.node.item.response.processing.ResponseRule) ResponseCondition(uk.ac.ed.ph.jqtiplus.node.item.response.processing.ResponseCondition)

Aggregations

ComplexReferenceIdentifier (uk.ac.ed.ph.jqtiplus.types.ComplexReferenceIdentifier)26 Variable (uk.ac.ed.ph.jqtiplus.node.expression.general.Variable)24 Correct (uk.ac.ed.ph.jqtiplus.node.expression.general.Correct)22 ResponseIf (uk.ac.ed.ph.jqtiplus.node.item.response.processing.ResponseIf)20 Match (uk.ac.ed.ph.jqtiplus.node.expression.operator.Match)18 ResponseElse (uk.ac.ed.ph.jqtiplus.node.item.response.processing.ResponseElse)16 SetOutcomeValue (uk.ac.ed.ph.jqtiplus.node.item.response.processing.SetOutcomeValue)16 BaseValue (uk.ac.ed.ph.jqtiplus.node.expression.general.BaseValue)14 Sum (uk.ac.ed.ph.jqtiplus.node.expression.operator.Sum)14 MapResponse (uk.ac.ed.ph.jqtiplus.node.expression.general.MapResponse)10 IsNull (uk.ac.ed.ph.jqtiplus.node.expression.operator.IsNull)8 Expression (uk.ac.ed.ph.jqtiplus.node.expression.Expression)6 ResponseCondition (uk.ac.ed.ph.jqtiplus.node.item.response.processing.ResponseCondition)6 FloatOrVariableRef (uk.ac.ed.ph.jqtiplus.types.FloatOrVariableRef)6 ArrayList (java.util.ArrayList)4 AssessmentItemFactory.appendSetOutcomeFeedbackCorrect (org.olat.ims.qti21.model.xml.AssessmentItemFactory.appendSetOutcomeFeedbackCorrect)4 And (uk.ac.ed.ph.jqtiplus.node.expression.operator.And)4 Equal (uk.ac.ed.ph.jqtiplus.node.expression.operator.Equal)4 MapEntry (uk.ac.ed.ph.jqtiplus.node.item.response.declaration.MapEntry)4 ResponseElseIf (uk.ac.ed.ph.jqtiplus.node.item.response.processing.ResponseElseIf)4