use of uk.ac.ed.ph.jqtiplus.node.expression.operator.IsNull in project OpenOLAT by OpenOLAT.
the class HotspotAssessmentItemBuilder method buildMainScoreRulePerAnswer.
private void buildMainScoreRulePerAnswer(ResponseCondition rule) {
/*
<responseCondition>
<responseIf>
<not>
<isNull>
<variable identifier="RESPONSE_1" />
</isNull>
</not>
<setOutcomeValue identifier="SCORE">
<sum>
<variable identifier="SCORE" />
<mapResponse identifier="RESPONSE_1" />
</sum>
</setOutcomeValue>
<setOutcomeValue identifier="FEEDBACKBASIC">
<baseValue baseType="identifier">incorrect</baseValue>
</setOutcomeValue>
</responseIf>
</responseCondition>
*/
// if no response
ResponseIf responseIf = new ResponseIf(rule);
rule.setResponseIf(responseIf);
Not not = new Not(responseIf);
responseIf.getExpressions().add(not);
IsNull isNull = new IsNull(not);
not.getExpressions().add(isNull);
Variable variable = new Variable(isNull);
variable.setIdentifier(ComplexReferenceIdentifier.parseString(responseIdentifier.toString()));
isNull.getExpressions().add(variable);
{
// outcome score
SetOutcomeValue scoreOutcome = new SetOutcomeValue(responseIf);
scoreOutcome.setIdentifier(QTI21Constants.SCORE_IDENTIFIER);
responseIf.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(hotspotInteraction.getResponseIdentifier());
sum.getExpressions().add(mapResponse);
}
{
// outcome feedback
SetOutcomeValue incorrectOutcomeValue = new SetOutcomeValue(responseIf);
incorrectOutcomeValue.setIdentifier(QTI21Constants.FEEDBACKBASIC_IDENTIFIER);
responseIf.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.expression.operator.IsNull in project OpenOLAT by OpenOLAT.
the class KPrimAssessmentItemBuilder method buildMainKPrimScoreRule.
/**
* The score is 100% if 4 correct responses, 50% if 3 correct
* responses and 0 otherwise.
*
* @param rule
*/
private void buildMainKPrimScoreRule(ResponseCondition rule) {
/*
<responseCondition>
<responseIf>
<isNull>
<variable identifier="RESPONSE"/>
</isNull>
<setOutcomeValue identifier="SCORE">
<baseValue baseType="float">0.0</baseValue>
</setOutcomeValue>
</responseIf>
<responseElse>
<setOutcomeValue identifier="SCORE">
<mapResponse identifier="RESPONSE"/>
</setOutcomeValue>
</responseElse>
</responseCondition>
*/
ResponseIf responseIf = new ResponseIf(rule);
rule.setResponseIf(responseIf);
{
// if no response
IsNull isNull = new IsNull(responseIf);
responseIf.getExpressions().add(isNull);
Variable variable = new Variable(isNull);
variable.setIdentifier(ComplexReferenceIdentifier.parseString(responseIdentifier.toString()));
isNull.getExpressions().add(variable);
SetOutcomeValue incorrectOutcomeValue = new SetOutcomeValue(responseIf);
incorrectOutcomeValue.setIdentifier(QTI21Constants.FEEDBACKBASIC_IDENTIFIER);
responseIf.getResponseRules().add(incorrectOutcomeValue);
BaseValue incorrectValue = new BaseValue(incorrectOutcomeValue);
incorrectValue.setBaseTypeAttrValue(BaseType.IDENTIFIER);
incorrectValue.setSingleValue(QTI21Constants.EMPTY_IDENTIFIER_VALUE);
incorrectOutcomeValue.setExpression(incorrectValue);
}
ResponseElseIf responseElseIf = new ResponseElseIf(rule);
rule.getResponseElseIfs().add(responseElseIf);
{
// match the correct answers -> 100%
Match match = new Match(responseElseIf);
responseElseIf.getExpressions().add(match);
Variable scoreVar = new Variable(match);
ComplexReferenceIdentifier choiceResponseIdentifier = ComplexReferenceIdentifier.parseString(matchInteraction.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);
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);
}
{
// set outcome
SetOutcomeValue correctOutcomeValue = new SetOutcomeValue(responseIf);
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);
}
ResponseElse responseElse = new ResponseElse(rule);
rule.setResponseElse(responseElse);
/* Not perfect ->
<setOutcomeValue identifier="SCORE">
<sum>
<mapResponse identifier="KPRIM_RESPONSE_1"/>
</sum>
</setOutcomeValue>
*/
{
// outcome feedback
SetOutcomeValue halfScoreOutcomeValue = new SetOutcomeValue(responseIf);
halfScoreOutcomeValue.setIdentifier(QTI21Constants.SCORE_IDENTIFIER);
responseElse.getResponseRules().add(halfScoreOutcomeValue);
Sum sum = new Sum(halfScoreOutcomeValue);
halfScoreOutcomeValue.setExpression(sum);
MapResponse mapResponse = new MapResponse(sum);
mapResponse.setIdentifier(responseIdentifier);
sum.getExpressions().add(mapResponse);
SetOutcomeValue incorrectOutcomeValue = new SetOutcomeValue(responseIf);
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.expression.operator.IsNull in project OpenOLAT by OpenOLAT.
the class AssessmentItemFactory method createCorrectSolutionModalFeedbackBasicRule.
/**
* Generate the special case for "correct solution" feedback which is almost the same as
* incorrect feedback.
*
* @param responseProcessing
* @param feedbackIdentifier
* @return
*/
public static ResponseCondition createCorrectSolutionModalFeedbackBasicRule(ResponseProcessing responseProcessing, Identifier correctSolutionFeedbackIdentifier, Identifier incorrectFeedbackIdentifier, boolean hint) {
ResponseCondition rule = new ResponseCondition(responseProcessing);
/*
<responseIf>
<and>
<match>
<baseValue baseType="identifier">incorrect</baseValue>
<variable identifier="FEEDBACKBASIC" />
</match>
</and>
<setOutcomeValue identifier="FEEDBACKMODAL">
<multiple>
<variable identifier="FEEDBACKMODAL" />
<baseValue baseType="identifier">Feedback261171147</baseValue>
</multiple>
</setOutcomeValue>
<setOutcomeValue identifier="SOLUTIONMODAL">
<baseValue baseType="identifier">Feedback261171147</baseValue>
</setOutcomeValue>
</responseIf>
*/
ResponseIf responseIf = new ResponseIf(rule);
rule.setResponseIf(responseIf);
{
// rule
And and = new And(responseIf);
responseIf.getExpressions().add(and);
Match match = new Match(and);
and.getExpressions().add(match);
BaseValue feedbackVal = new BaseValue(match);
feedbackVal.setBaseTypeAttrValue(BaseType.IDENTIFIER);
feedbackVal.setSingleValue(new IdentifierValue(QTI21Constants.INCORRECT));
match.getExpressions().add(feedbackVal);
Variable variable = new Variable(match);
variable.setIdentifier(ComplexReferenceIdentifier.parseString(QTI21Constants.FEEDBACKBASIC));
match.getExpressions().add(variable);
// not match the HINT
if (hint) {
IsNull isNull = new IsNull(and);
and.getExpressions().add(isNull);
Variable hintVar = new Variable(isNull);
hintVar.setIdentifier(QTI21Constants.HINT_FEEDBACKMODAL_CLX_IDENTIFIER);
isNull.getExpressions().add(hintVar);
}
}
if (incorrectFeedbackIdentifier != null) {
// outcome incorrect
SetOutcomeValue feedbackVar = new SetOutcomeValue(responseIf);
feedbackVar.setIdentifier(QTI21Constants.FEEDBACKMODAL_IDENTIFIER);
Multiple multiple = new Multiple(feedbackVar);
feedbackVar.setExpression(multiple);
Variable variable = new Variable(multiple);
variable.setIdentifier(ComplexReferenceIdentifier.parseString(QTI21Constants.FEEDBACKMODAL));
multiple.getExpressions().add(variable);
BaseValue feedbackVal = new BaseValue(feedbackVar);
feedbackVal.setBaseTypeAttrValue(BaseType.IDENTIFIER);
feedbackVal.setSingleValue(new IdentifierValue(incorrectFeedbackIdentifier));
multiple.getExpressions().add(feedbackVal);
responseIf.getResponseRules().add(feedbackVar);
}
if (correctSolutionFeedbackIdentifier != null) {
// outcome correct solution
SetOutcomeValue feedbackVar = new SetOutcomeValue(responseIf);
feedbackVar.setIdentifier(QTI21Constants.CORRECT_SOLUTION_IDENTIFIER);
BaseValue feedbackVal = new BaseValue(feedbackVar);
feedbackVal.setBaseTypeAttrValue(BaseType.IDENTIFIER);
feedbackVal.setSingleValue(new IdentifierValue(correctSolutionFeedbackIdentifier));
feedbackVar.getExpressions().add(feedbackVal);
responseIf.getResponseRules().add(feedbackVar);
}
return rule;
}
use of uk.ac.ed.ph.jqtiplus.node.expression.operator.IsNull in project OpenOLAT by OpenOLAT.
the class AssessmentItemFactory method createModalFeedbackBasicRule.
public static ResponseCondition createModalFeedbackBasicRule(ResponseProcessing responseProcessing, Identifier feedbackIdentifier, String inCorrect, boolean hint) {
ResponseCondition rule = new ResponseCondition(responseProcessing);
/*
<responseIf>
<and>
<match>
<baseValue baseType="identifier">correct</baseValue>
<variable identifier="FEEDBACKBASIC" />
</match>
</and>
<setOutcomeValue identifier="FEEDBACKMODAL">
<multiple>
<variable identifier="FEEDBACKMODAL" />
<baseValue baseType="identifier">Feedback261171147</baseValue>
</multiple>
</setOutcomeValue>
</responseIf>
*/
ResponseIf responseIf = new ResponseIf(rule);
rule.setResponseIf(responseIf);
{
// rule
And and = new And(responseIf);
responseIf.getExpressions().add(and);
Match match = new Match(and);
and.getExpressions().add(match);
BaseValue feedbackVal = new BaseValue(match);
feedbackVal.setBaseTypeAttrValue(BaseType.IDENTIFIER);
feedbackVal.setSingleValue(new IdentifierValue(inCorrect));
match.getExpressions().add(feedbackVal);
Variable variable = new Variable(match);
variable.setIdentifier(ComplexReferenceIdentifier.parseString(QTI21Constants.FEEDBACKBASIC));
match.getExpressions().add(variable);
// not match the HINT
if (hint) {
IsNull isNull = new IsNull(and);
and.getExpressions().add(isNull);
Variable hintVar = new Variable(isNull);
hintVar.setIdentifier(QTI21Constants.HINT_FEEDBACKMODAL_CLX_IDENTIFIER);
isNull.getExpressions().add(hintVar);
}
}
{
// outcome
SetOutcomeValue feedbackVar = new SetOutcomeValue(responseIf);
feedbackVar.setIdentifier(QTI21Constants.FEEDBACKMODAL_IDENTIFIER);
Multiple multiple = new Multiple(feedbackVar);
feedbackVar.setExpression(multiple);
Variable variable = new Variable(multiple);
variable.setIdentifier(ComplexReferenceIdentifier.parseString(QTI21Constants.FEEDBACKMODAL));
multiple.getExpressions().add(variable);
BaseValue feedbackVal = new BaseValue(feedbackVar);
feedbackVal.setBaseTypeAttrValue(BaseType.IDENTIFIER);
feedbackVal.setSingleValue(new IdentifierValue(feedbackIdentifier));
multiple.getExpressions().add(feedbackVal);
responseIf.getResponseRules().add(feedbackVar);
}
return rule;
}
use of uk.ac.ed.ph.jqtiplus.node.expression.operator.IsNull in project OpenOLAT by OpenOLAT.
the class LobAssessmentItemBuilder method buildMainEssayFeedbackRule.
private void buildMainEssayFeedbackRule(ResponseCondition rule) {
/*
<responseCondition>
<responseIf>
<isNull>
<variable identifier="RESPONSE_1" />
</isNull>
<setOutcomeValue identifier="FEEDBACKBASIC">
<baseValue baseType="identifier">
empty
</baseValue>
</setOutcomeValue>
</responseIf>
</responseCondition>
*/
ResponseIf responseIf = new ResponseIf(rule);
rule.setResponseIf(responseIf);
{
IsNull isNull = new IsNull(responseIf);
responseIf.getExpressions().add(isNull);
Variable variable = new Variable(isNull);
variable.setIdentifier(ComplexReferenceIdentifier.parseString(responseIdentifier.toString()));
isNull.getExpressions().add(variable);
SetOutcomeValue feedbackOutcomeValue = new SetOutcomeValue(responseIf);
feedbackOutcomeValue.setIdentifier(QTI21Constants.FEEDBACKBASIC_IDENTIFIER);
responseIf.getResponseRules().add(feedbackOutcomeValue);
BaseValue incorrectValue = new BaseValue(feedbackOutcomeValue);
incorrectValue.setBaseTypeAttrValue(BaseType.IDENTIFIER);
incorrectValue.setSingleValue(QTI21Constants.EMPTY_IDENTIFIER_VALUE);
feedbackOutcomeValue.setExpression(incorrectValue);
}
ResponseElseIf responseElseIf = new ResponseElseIf(rule);
rule.getResponseElseIfs().add(responseElseIf);
{
Not not = new Not(responseElseIf);
responseElseIf.getExpressions().add(not);
IsNull isNull = new IsNull(responseIf);
not.getExpressions().add(isNull);
Variable variable = new Variable(isNull);
variable.setIdentifier(ComplexReferenceIdentifier.parseString(responseIdentifier.toString()));
isNull.getExpressions().add(variable);
SetOutcomeValue feedbackOutcomeValue = new SetOutcomeValue(responseIf);
feedbackOutcomeValue.setIdentifier(QTI21Constants.FEEDBACKBASIC_IDENTIFIER);
responseElseIf.getResponseRules().add(feedbackOutcomeValue);
BaseValue answeredValue = new BaseValue(feedbackOutcomeValue);
answeredValue.setBaseTypeAttrValue(BaseType.IDENTIFIER);
answeredValue.setSingleValue(QTI21Constants.ANSWERED_IDENTIFIER_VALUE);
feedbackOutcomeValue.setExpression(answeredValue);
}
}
Aggregations