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;
}
Aggregations