use of uk.ac.ed.ph.jqtiplus.node.item.response.processing.SetOutcomeValue in project OpenOLAT by OpenOLAT.
the class AssessmentItemFactory method createModalFeedbackResponseConditionByScore.
/**
* This generate a response rule which compare the max score and the score
* to set the feedback as "correct".
*
* <responseCondition>
* <responseIf>
* <and>
* <not>
* <match>
* <variable identifier="FEEDBACKBASIC" />
* <baseValue baseType="identifier">empty</baseValue>
* </match>
* </not>
* <equal toleranceMode="exact">
* <variable identifier="SCORE" />
* <variable identifier="MAXSCORE" />
* </equal>
* </and>
* <setOutcomeValue identifier="FEEDBACKBASIC">
* <baseValue baseType="identifier">correct</baseValue>
* </setOutcomeValue>
* </responseIf>
* </responseCondition>
*/
public static ResponseCondition createModalFeedbackResponseConditionByScore(ResponseProcessing responseProcessing) {
ResponseCondition responseCondition = new ResponseCondition(responseProcessing);
ResponseIf responseIf = new ResponseIf(responseCondition);
responseCondition.setResponseIf(responseIf);
And and = new And(responseIf);
responseIf.getExpressions().add(and);
Not not = new Not(and);
and.getExpressions().add(not);
Match match = new Match(not);
not.getExpressions().add(match);
Variable feedbackbasicVar = new Variable(match);
feedbackbasicVar.setIdentifier(QTI21Constants.FEEDBACKBASIC_CLX_IDENTIFIER);
match.getExpressions().add(feedbackbasicVar);
BaseValue emptyValue = new BaseValue(match);
emptyValue.setBaseTypeAttrValue(BaseType.IDENTIFIER);
emptyValue.setSingleValue(QTI21Constants.EMPTY_IDENTIFIER_VALUE);
match.getExpressions().add(emptyValue);
// SCORE >= MAXSCORE ( > is for security and special case where the max score is smalle than the sum of correct answers)
Gte greaterOrEqual = new Gte(and);
and.getExpressions().add(greaterOrEqual);
Variable scoreVar = new Variable(greaterOrEqual);
scoreVar.setIdentifier(QTI21Constants.SCORE_CLX_IDENTIFIER);
greaterOrEqual.getExpressions().add(scoreVar);
Variable maxScoreVar = new Variable(greaterOrEqual);
maxScoreVar.setIdentifier(QTI21Constants.MAXSCORE_CLX_IDENTIFIER);
greaterOrEqual.getExpressions().add(maxScoreVar);
// outcome value
SetOutcomeValue correctOutcomeValue = new SetOutcomeValue(responseIf);
correctOutcomeValue.setIdentifier(QTI21Constants.FEEDBACKBASIC_IDENTIFIER);
responseIf.getResponseRules().add(correctOutcomeValue);
BaseValue correctValue = new BaseValue(correctOutcomeValue);
correctValue.setBaseTypeAttrValue(BaseType.IDENTIFIER);
correctValue.setSingleValue(QTI21Constants.CORRECT_IDENTIFIER_VALUE);
correctOutcomeValue.setExpression(correctValue);
return responseCondition;
}
use of uk.ac.ed.ph.jqtiplus.node.item.response.processing.SetOutcomeValue in project OpenOLAT by OpenOLAT.
the class AssessmentItemFactory method appendSetOutcomeScoreMaxScore.
/*
<setOutcomeValue identifier="SCORE">
<sum>
<variable identifier="SCORE"/>
<variable identifier="MAXSCORE"/>
</sum>
</setOutcomeValue>
*/
public static void appendSetOutcomeScoreMaxScore(ResponseConditionChild responseCondition) {
SetOutcomeValue scoreOutcomeValue = new SetOutcomeValue(responseCondition);
scoreOutcomeValue.setIdentifier(QTI21Constants.SCORE_IDENTIFIER);
responseCondition.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);
}
use of uk.ac.ed.ph.jqtiplus.node.item.response.processing.SetOutcomeValue in project OpenOLAT by OpenOLAT.
the class AssessmentItemFactory method appendSetOutcomeScoreMapResponse.
/*
<setOutcomeValue identifier="SCORE">
<sum>
<variable identifier="SCORE"/>
<mapResponse identifier="RESPONSE_1"/>
</sum>
</setOutcomeValue>
*/
public static void appendSetOutcomeScoreMapResponse(ResponseConditionChild responseCondition, Identifier responseIdentifier) {
SetOutcomeValue scoreOutcome = new SetOutcomeValue(responseCondition);
scoreOutcome.setIdentifier(QTI21Constants.SCORE_IDENTIFIER);
responseCondition.getResponseRules().add(scoreOutcome);
Sum sum = new Sum(scoreOutcome);
scoreOutcome.getExpressions().add(sum);
Variable scoreVar = new Variable(sum);
scoreVar.setIdentifier(QTI21Constants.SCORE_CLX_IDENTIFIER);
sum.getExpressions().add(scoreVar);
MapResponse mapResponse = new MapResponse(sum);
mapResponse.setIdentifier(responseIdentifier);
sum.getExpressions().add(mapResponse);
}
use of uk.ac.ed.ph.jqtiplus.node.item.response.processing.SetOutcomeValue in project OpenOLAT by OpenOLAT.
the class HottextAssessmentItemBuilder method buildMainScoreRuleAllCorrectAnswers.
private void buildMainScoreRuleAllCorrectAnswers(ResponseCondition rule) {
/*
<responseCondition>
<responseIf>
<match>
<variable identifier="RESPONSE_1" />
<correct identifier="RESPONSE_1" />
</match>
<setOutcomeValue identifier="SCORE">
<sum>
<variable identifier="SCORE" />
<variable identifier="MAXSCORE" />
</sum>
</setOutcomeValue>
<setOutcomeValue identifier="FEEDBACKBASIC">
<baseValue baseType="identifier">correct</baseValue>
</setOutcomeValue>
</responseIf>
<responseElse>
<setOutcomeValue identifier="FEEDBACKBASIC">
<baseValue baseType="identifier">incorrect</baseValue>
</setOutcomeValue>
</responseElse>
</responseCondition>
*/
// simple as build with / without feedback
ensureFeedbackBasicOutcomeDeclaration();
ResponseIf responseIf = new ResponseIf(rule);
rule.setResponseIf(responseIf);
{
// match the correct answers
matchCorrectAnswers(responseIf);
}
{
// outcome score
SetOutcomeValue scoreOutcomeValue = new SetOutcomeValue(responseIf);
scoreOutcomeValue.setIdentifier(QTI21Constants.SCORE_IDENTIFIER);
responseIf.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(responseIf);
correctOutcomeValue.setIdentifier(QTI21Constants.FEEDBACKBASIC_IDENTIFIER);
responseIf.getResponseRules().add(correctOutcomeValue);
BaseValue correctValue = new BaseValue(correctOutcomeValue);
correctValue.setBaseTypeAttrValue(BaseType.IDENTIFIER);
correctValue.setSingleValue(QTI21Constants.CORRECT_IDENTIFIER_VALUE);
correctOutcomeValue.setExpression(correctValue);
}
ResponseElse responseElse = new ResponseElse(rule);
rule.setResponseElse(responseElse);
{
// outcome feedback
SetOutcomeValue incorrectOutcomeValue = new SetOutcomeValue(responseElse);
incorrectOutcomeValue.setIdentifier(QTI21Constants.FEEDBACKBASIC_IDENTIFIER);
responseElse.getResponseRules().add(incorrectOutcomeValue);
BaseValue incorrectValue = new BaseValue(incorrectOutcomeValue);
incorrectValue.setBaseTypeAttrValue(BaseType.IDENTIFIER);
incorrectValue.setSingleValue(QTI21Constants.INCORRECT_IDENTIFIER_VALUE);
incorrectOutcomeValue.setExpression(incorrectValue);
}
}
use of uk.ac.ed.ph.jqtiplus.node.item.response.processing.SetOutcomeValue in project OpenOLAT by OpenOLAT.
the class MultipleChoiceAssessmentItemBuilder method buildMainScoreRuleAllCorrectAnswers.
private void buildMainScoreRuleAllCorrectAnswers(ResponseCondition rule) {
/*
<responseCondition>
<responseIf>
<match>
<variable identifier="RESPONSE_1" />
<correct identifier="RESPONSE_1" />
</match>
<setOutcomeValue identifier="SCORE">
<sum>
<variable identifier="SCORE" />
<variable identifier="MAXSCORE" />
</sum>
</setOutcomeValue>
<setOutcomeValue identifier="FEEDBACKBASIC">
<baseValue baseType="identifier">correct</baseValue>
</setOutcomeValue>
</responseIf>
<responseElse>
<setOutcomeValue identifier="FEEDBACKBASIC">
<baseValue baseType="identifier">incorrect</baseValue>
</setOutcomeValue>
</responseElse>
</responseCondition>
*/
// simple as build with / without feedback
ensureFeedbackBasicOutcomeDeclaration();
ResponseIf responseIf = new ResponseIf(rule);
rule.setResponseIf(responseIf);
{
// match the correct answers
Match match = new Match(responseIf);
responseIf.getExpressions().add(match);
Variable scoreVar = new Variable(match);
ComplexReferenceIdentifier choiceResponseIdentifier = ComplexReferenceIdentifier.parseString(choiceInteraction.getResponseIdentifier().toString());
scoreVar.setIdentifier(choiceResponseIdentifier);
match.getExpressions().add(scoreVar);
Correct correct = new Correct(match);
correct.setIdentifier(choiceResponseIdentifier);
match.getExpressions().add(correct);
}
{
// outcome score
SetOutcomeValue scoreOutcomeValue = new SetOutcomeValue(responseIf);
scoreOutcomeValue.setIdentifier(QTI21Constants.SCORE_IDENTIFIER);
responseIf.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(responseIf);
correctOutcomeValue.setIdentifier(QTI21Constants.FEEDBACKBASIC_IDENTIFIER);
responseIf.getResponseRules().add(correctOutcomeValue);
BaseValue correctValue = new BaseValue(correctOutcomeValue);
correctValue.setBaseTypeAttrValue(BaseType.IDENTIFIER);
correctValue.setSingleValue(QTI21Constants.CORRECT_IDENTIFIER_VALUE);
correctOutcomeValue.setExpression(correctValue);
}
ResponseElse responseElse = new ResponseElse(rule);
rule.setResponseElse(responseElse);
{
// outcome feedback
SetOutcomeValue incorrectOutcomeValue = new SetOutcomeValue(responseElse);
incorrectOutcomeValue.setIdentifier(QTI21Constants.FEEDBACKBASIC_IDENTIFIER);
responseElse.getResponseRules().add(incorrectOutcomeValue);
BaseValue incorrectValue = new BaseValue(incorrectOutcomeValue);
incorrectValue.setBaseTypeAttrValue(BaseType.IDENTIFIER);
incorrectValue.setSingleValue(QTI21Constants.INCORRECT_IDENTIFIER_VALUE);
incorrectOutcomeValue.setExpression(incorrectValue);
}
}
Aggregations