use of uk.ac.ed.ph.jqtiplus.node.item.response.processing.ResponseCondition in project OpenOLAT by OpenOLAT.
the class SingleChoiceAssessmentItemBuilder method buildMainScoreRule.
@Override
protected void buildMainScoreRule(List<OutcomeDeclaration> outcomeDeclarations, List<ResponseRule> responseRules) {
ResponseCondition rule = new ResponseCondition(assessmentItem.getResponseProcessing());
responseRules.add(0, rule);
if (scoreEvaluation == ScoreEvaluation.perAnswer) {
buildMainScoreRulePerAnswer(rule);
} else {
buildMainScoreRuleAllCorrectAnswers(rule);
}
}
use of uk.ac.ed.ph.jqtiplus.node.item.response.processing.ResponseCondition in project openolat by klemens.
the class FIBAssessmentItemBuilder method buildModalFeedbacksAndHints.
@Override
protected void buildModalFeedbacksAndHints(List<OutcomeDeclaration> outcomeDeclarations, List<ResponseRule> responseRules) {
if (correctFeedback != null || incorrectFeedback != null) {
if (scoreEvaluation == ScoreEvaluation.perAnswer) {
ResponseCondition responseCondition = AssessmentItemFactory.createModalFeedbackResponseConditionByScore(assessmentItem.getResponseProcessing());
responseRules.add(responseCondition);
}
}
super.buildModalFeedbacksAndHints(outcomeDeclarations, responseRules);
}
use of uk.ac.ed.ph.jqtiplus.node.item.response.processing.ResponseCondition in project openolat by klemens.
the class FIBAssessmentItemBuilder method buildMainScoreRuleAllCorrectAnswers.
private void buildMainScoreRuleAllCorrectAnswers(List<ResponseRule> responseRules) {
/*
<responseCondition>
<responseIf>
<and>
<match>
<value>-1.0</value>
<correct identifier="RESPONSE_1" />
</match>
<equal toleranceMode="relative" tolerance="0.1 0.1" includeLowerBound="true" includeUpperBound="true">
<correct identifier="RESPONSE_2" />
<variable identifier="RESPONSE_2" />
</equal>
</and>
<setOutcomeValue identifier="SCORE">
<sum>
<variable identifier="SCORE" />
<variable identifier="MAXSCORE" />
</sum>
</setOutcomeValue>
<setOutcomeValue identifier="FEEDBACKBASIC">
<baseValue baseType="identifier">
incorrect
</baseValue>
</setOutcomeValue>
</responseIf>
</responseCondition>
*/
// add condition
ResponseCondition rule = new ResponseCondition(assessmentItem.getResponseProcessing());
responseRules.add(0, rule);
{
// match all
ResponseIf responseElseIf = new ResponseIf(rule);
rule.setResponseIf(responseElseIf);
// rule.getResponseElseIfs().add(responseElseIf);
And and = new And(responseElseIf);
responseElseIf.setExpression(and);
for (Map.Entry<String, AbstractEntry> textEntryEntry : responseIdentifierToTextEntry.entrySet()) {
AbstractEntry abstractEntry = textEntryEntry.getValue();
if (abstractEntry instanceof TextEntry) {
Match match = new Match(and);
and.getExpressions().add(match);
TextEntry textEntry = (TextEntry) abstractEntry;
BaseValue variable = new BaseValue(match);
variable.setBaseTypeAttrValue(BaseType.FLOAT);
variable.setSingleValue(new FloatValue(-1.0d));
match.getExpressions().add(variable);
MapResponse correct = new MapResponse(match);
correct.setIdentifier(textEntry.getResponseIdentifier());
match.getExpressions().add(correct);
} else if (abstractEntry instanceof NumericalEntry) {
NumericalEntry numericalEntry = (NumericalEntry) abstractEntry;
Equal equal = new Equal(and);
equal.setToleranceMode(numericalEntry.getToleranceMode());
if (numericalEntry.getLowerTolerance() != null && numericalEntry.getUpperTolerance() != null) {
List<FloatOrVariableRef> tolerances = new ArrayList<>();
tolerances.add(new FloatOrVariableRef(numericalEntry.getLowerTolerance().doubleValue()));
tolerances.add(new FloatOrVariableRef(numericalEntry.getUpperTolerance().doubleValue()));
equal.setTolerances(tolerances);
}
equal.setIncludeLowerBound(Boolean.TRUE);
equal.setIncludeUpperBound(Boolean.TRUE);
and.getExpressions().add(equal);
ComplexReferenceIdentifier responseIdentifier = ComplexReferenceIdentifier.assumedLegal(numericalEntry.getResponseIdentifier().toString());
Correct correct = new Correct(equal);
correct.setIdentifier(responseIdentifier);
equal.getExpressions().add(correct);
Variable variable = new Variable(equal);
variable.setIdentifier(responseIdentifier);
equal.getExpressions().add(variable);
}
}
{
// outcome max score -> score
SetOutcomeValue scoreOutcomeValue = new SetOutcomeValue(responseElseIf);
scoreOutcomeValue.setIdentifier(QTI21Constants.SCORE_IDENTIFIER);
responseElseIf.getResponseRules().add(scoreOutcomeValue);
Sum sum = new Sum(scoreOutcomeValue);
scoreOutcomeValue.getExpressions().add(sum);
Variable scoreVar = new Variable(sum);
scoreVar.setIdentifier(QTI21Constants.SCORE_CLX_IDENTIFIER);
sum.getExpressions().add(scoreVar);
Variable maxScoreVar = new Variable(sum);
maxScoreVar.setIdentifier(QTI21Constants.MAXSCORE_CLX_IDENTIFIER);
sum.getExpressions().add(maxScoreVar);
}
{
// outcome feedback
SetOutcomeValue correctOutcomeValue = new SetOutcomeValue(responseElseIf);
correctOutcomeValue.setIdentifier(QTI21Constants.FEEDBACKBASIC_IDENTIFIER);
responseElseIf.getResponseRules().add(correctOutcomeValue);
BaseValue correctValue = new BaseValue(correctOutcomeValue);
correctValue.setBaseTypeAttrValue(BaseType.IDENTIFIER);
correctValue.setSingleValue(QTI21Constants.CORRECT_IDENTIFIER_VALUE);
correctOutcomeValue.setExpression(correctValue);
}
}
{
// else feedback incorrect
ResponseElse responseElse = new ResponseElse(rule);
rule.setResponseElse(responseElse);
{
// outcome feedback
SetOutcomeValue correctOutcomeValue = new SetOutcomeValue(responseElse);
correctOutcomeValue.setIdentifier(QTI21Constants.FEEDBACKBASIC_IDENTIFIER);
responseElse.getResponseRules().add(correctOutcomeValue);
BaseValue correctValue = new BaseValue(correctOutcomeValue);
correctValue.setBaseTypeAttrValue(BaseType.IDENTIFIER);
correctValue.setSingleValue(QTI21Constants.INCORRECT_IDENTIFIER_VALUE);
correctOutcomeValue.setExpression(correctValue);
}
}
}
use of uk.ac.ed.ph.jqtiplus.node.item.response.processing.ResponseCondition in project openolat by klemens.
the class HotspotAssessmentItemBuilder method buildMainScoreRule.
@Override
protected void buildMainScoreRule(List<OutcomeDeclaration> outcomeDeclarations, List<ResponseRule> responseRules) {
ResponseCondition rule = new ResponseCondition(assessmentItem.getResponseProcessing());
responseRules.add(0, rule);
if (scoreEvaluation == ScoreEvaluation.perAnswer) {
buildMainScoreRulePerAnswer(rule);
} else {
buildMainScoreRuleAllCorrectAnswers(rule);
}
}
use of uk.ac.ed.ph.jqtiplus.node.item.response.processing.ResponseCondition in project openolat by klemens.
the class HottextAssessmentItemBuilder method buildMainScoreRule.
@Override
protected void buildMainScoreRule(List<OutcomeDeclaration> outcomeDeclarations, List<ResponseRule> responseRules) {
ResponseCondition rule = new ResponseCondition(assessmentItem.getResponseProcessing());
responseRules.add(0, rule);
if (scoreEvaluation == ScoreEvaluation.perAnswer) {
buildMainScoreRulePerAnswer(rule);
} else {
buildMainScoreRuleAllCorrectAnswers(rule);
}
}
Aggregations