use of uk.ac.ed.ph.jqtiplus.node.item.response.processing.ResponseCondition in project openolat by klemens.
the class AssessmentItemFactory method createMaxScoreBoundLimitRule.
/**
* Rule which ensure that the final score is not above the max. score value.
*/
public static ResponseRule createMaxScoreBoundLimitRule(ResponseProcessing responseProcessing) {
/*
<responseCondition>
<responseIf>
<gt>
<variable identifier="SCORE" /><variable identifier="MAXSCORE" />
</gt>
<setOutcomeValue identifier="SCORE">
<variable identifier="MAXSCORE" />
</setOutcomeValue>
</responseIf>
</responseCondition>
*/
ResponseCondition rule = new ResponseCondition(responseProcessing);
ResponseIf responseIf = new ResponseIf(rule);
rule.setResponseIf(responseIf);
Gt gt = new Gt(responseIf);
responseIf.setExpression(gt);
Variable scoreVar = new Variable(gt);
scoreVar.setIdentifier(SCORE_CLX_IDENTIFIER);
gt.getExpressions().add(scoreVar);
Variable maxScoreVar = new Variable(gt);
maxScoreVar.setIdentifier(MAXSCORE_CLX_IDENTIFIER);
gt.getExpressions().add(maxScoreVar);
SetOutcomeValue setOutcomeValue = new SetOutcomeValue(responseIf);
setOutcomeValue.setIdentifier(SCORE_IDENTIFIER);
Variable maxScoreOutcomeVar = new Variable(setOutcomeValue);
maxScoreOutcomeVar.setIdentifier(MAXSCORE_CLX_IDENTIFIER);
setOutcomeValue.setExpression(maxScoreOutcomeVar);
responseIf.getResponseRules().add(setOutcomeValue);
return rule;
}
use of uk.ac.ed.ph.jqtiplus.node.item.response.processing.ResponseCondition 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;
}
use of uk.ac.ed.ph.jqtiplus.node.item.response.processing.ResponseCondition in project openolat by klemens.
the class AssessmentItemFactory method createMinScoreBoundLimitRule.
/**
* Rule which ensure that the final score is not under the min. score value.
*/
public static ResponseRule createMinScoreBoundLimitRule(ResponseProcessing responseProcessing) {
/*
<responseCondition>
<responseIf>
<lt>
<variable identifier="SCORE" /><variable identifier="MINSCORE" />
</lt>
<setOutcomeValue identifier="SCORE">
<variable identifier="MINSCORE" />
</setOutcomeValue>
</responseIf>
</responseCondition>
*/
ResponseCondition rule = new ResponseCondition(responseProcessing);
ResponseIf responseIf = new ResponseIf(rule);
rule.setResponseIf(responseIf);
Lt lt = new Lt(responseIf);
responseIf.setExpression(lt);
Variable scoreVar = new Variable(lt);
scoreVar.setIdentifier(SCORE_CLX_IDENTIFIER);
lt.getExpressions().add(scoreVar);
Variable minScoreVar = new Variable(lt);
minScoreVar.setIdentifier(MINSCORE_CLX_IDENTIFIER);
lt.getExpressions().add(minScoreVar);
SetOutcomeValue setOutcomeValue = new SetOutcomeValue(responseIf);
setOutcomeValue.setIdentifier(SCORE_IDENTIFIER);
Variable minScoreOutcomeVar = new Variable(setOutcomeValue);
minScoreOutcomeVar.setIdentifier(MINSCORE_CLX_IDENTIFIER);
setOutcomeValue.setExpression(minScoreOutcomeVar);
responseIf.getResponseRules().add(setOutcomeValue);
return rule;
}
use of uk.ac.ed.ph.jqtiplus.node.item.response.processing.ResponseCondition in project openolat by klemens.
the class ModalFeedbackBuilder method isCorrectSolutionRule.
public boolean isCorrectSolutionRule() {
ResponseCondition feedbackRule = findFeedbackResponseCondition(modalFeedback.getIdentifier(), QTI21Constants.CORRECT_SOLUTION_IDENTIFIER);
boolean allOk = findBaseValueInExpressionsOfResponseIf(feedbackRule, QTI21Constants.INCORRECT_IDENTIFIER);
allOk |= modalFeedback.getOutcomeIdentifier() != null && QTI21Constants.CORRECT_SOLUTION_IDENTIFIER.equals(modalFeedback.getOutcomeIdentifier());
return allOk;
}
Aggregations