use of uk.ac.ed.ph.jqtiplus.node.expression.general.BaseValue in project openolat by klemens.
the class AssessmentItemFactory method appendSetOutcomeFeedbackIncorrect.
/*
<setOutcomeValue identifier="FEEDBACKBASIC">
<baseValue baseType="identifier">incorrect</baseValue>
</setOutcomeValue>
*/
public static void appendSetOutcomeFeedbackIncorrect(ResponseConditionChild responseCondition) {
SetOutcomeValue incorrectOutcomeValue = new SetOutcomeValue(responseCondition);
incorrectOutcomeValue.setIdentifier(QTI21Constants.FEEDBACKBASIC_IDENTIFIER);
responseCondition.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.general.BaseValue in project openolat by klemens.
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.expression.general.BaseValue in project openolat by klemens.
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.general.BaseValue in project openolat by klemens.
the class AssessmentTestBuilder method buildCutValue.
/* Passed
<outcomeCondition>
<outcomeIf>
<gte>
<sum>
<testVariables variableIdentifier="SCORE" />
</sum>
<baseValue baseType="float">
1
</baseValue>
</gte>
<setOutcomeValue identifier="PASS">
<baseValue baseType="boolean">
true
</baseValue>
</setOutcomeValue>
</outcomeIf>
<outcomeElse>
<setOutcomeValue identifier="PASS">
<baseValue baseType="boolean">
false
</baseValue>
</setOutcomeValue>
</outcomeElse>
</outcomeCondition>
*/
private void buildCutValue() {
if (cutValue != null) {
OutcomeDeclaration passDeclaration = assessmentTest.getOutcomeDeclaration(QTI21Constants.PASS_IDENTIFIER);
if (passDeclaration == null) {
passDeclaration = AssessmentTestFactory.createOutcomeDeclaration(assessmentTest, QTI21Constants.PASS_IDENTIFIER, false);
assessmentTest.getOutcomeDeclarations().add(passDeclaration);
}
boolean updated = false;
if (cutValueRule != null && cutValueRule.getOutcomeIf().getExpressions().size() > 0) {
Expression gte = cutValueRule.getOutcomeIf().getExpressions().get(0);
if (gte.getExpressions().size() > 1) {
Expression baseValue = gte.getExpressions().get(1);
if (baseValue instanceof BaseValue) {
BaseValue value = (BaseValue) baseValue;
value.setSingleValue(new FloatValue(cutValue.doubleValue()));
updated = true;
}
}
}
if (!updated) {
assessmentTest.getOutcomeProcessing().getOutcomeRules().remove(cutValueRule);
cutValueRule = AssessmentTestFactory.createCutValueRule(assessmentTest, cutValue);
assessmentTest.getOutcomeProcessing().getOutcomeRules().add(cutValueRule);
}
} else if (cutValueRule != null) {
assessmentTest.getOutcomeProcessing().getOutcomeRules().remove(cutValueRule);
}
}
use of uk.ac.ed.ph.jqtiplus.node.expression.general.BaseValue in project openolat by klemens.
the class AssessmentTestFactory method createCutValueRule.
/* Passed
<outcomeCondition>
<outcomeIf>
<gte>
<sum>
<testVariables variableIdentifier="SCORE" />
</sum>
<baseValue baseType="float">
1
</baseValue>
</gte>
<setOutcomeValue identifier="PASS">
<baseValue baseType="boolean">
true
</baseValue>
</setOutcomeValue>
</outcomeIf>
<outcomeElse>
<setOutcomeValue identifier="PASS">
<baseValue baseType="boolean">
false
</baseValue>
</setOutcomeValue>
</outcomeElse>
</outcomeCondition>
*/
public static OutcomeCondition createCutValueRule(AssessmentTest assessmentTest, Double cutValue) {
OutcomeCondition outcomeCondition = new OutcomeCondition(assessmentTest);
// if
{
OutcomeIf outcomeIf = new OutcomeIf(outcomeCondition);
outcomeCondition.setOutcomeIf(outcomeIf);
Gte gte = new Gte(outcomeIf);
outcomeIf.setExpression(gte);
{
appendSumOfTestVariables(gte);
BaseValue passed = new BaseValue(gte);
passed.setBaseTypeAttrValue(BaseType.FLOAT);
passed.setSingleValue(new FloatValue(cutValue.floatValue()));
gte.getExpressions().add(passed);
}
SetOutcomeValue passedOutcomeValue = new SetOutcomeValue(outcomeIf);
passedOutcomeValue.setIdentifier(QTI21Constants.PASS_IDENTIFIER);
outcomeIf.getOutcomeRules().add(passedOutcomeValue);
BaseValue passed = new BaseValue(passedOutcomeValue);
passed.setBaseTypeAttrValue(BaseType.BOOLEAN);
passed.setSingleValue(BooleanValue.TRUE);
passedOutcomeValue.setExpression(passed);
}
{
// else
OutcomeElse outcomeElse = new OutcomeElse(outcomeCondition);
outcomeCondition.setOutcomeElse(outcomeElse);
SetOutcomeValue notPassedOutcomeValue = new SetOutcomeValue(outcomeElse);
notPassedOutcomeValue.setIdentifier(QTI21Constants.PASS_IDENTIFIER);
outcomeElse.getOutcomeRules().add(notPassedOutcomeValue);
BaseValue notPassed = new BaseValue(notPassedOutcomeValue);
notPassed.setBaseTypeAttrValue(BaseType.BOOLEAN);
notPassed.setSingleValue(BooleanValue.FALSE);
notPassedOutcomeValue.setExpression(notPassed);
}
return outcomeCondition;
}
Aggregations