use of uk.ac.ed.ph.jqtiplus.node.test.outcome.processing.SetOutcomeValue in project OpenOLAT by OpenOLAT.
the class AssessmentTestFactory method createTestFeedbackModalCondition.
/*
<outcomeCondition>
<outcomeIf>
<and>
<match>
<baseValue baseType="boolean">
false
</baseValue>
<variable identifier="PASS" />
</match>
</and>
<setOutcomeValue identifier="FEEDBACKMODAL">
<multiple>
<variable identifier="FEEDBACKMODAL" />
<baseValue baseType="identifier">
Feedback1757237693
</baseValue>
</multiple>
</setOutcomeValue>
</outcomeIf>
</outcomeCondition>
*/
public static final OutcomeCondition createTestFeedbackModalCondition(AssessmentTest assessmentTest, boolean condition, Identifier feedbackIdentifier) {
OutcomeCondition outcomeCondition = new OutcomeCondition(assessmentTest);
OutcomeIf outcomeIf = new OutcomeIf(outcomeCondition);
outcomeCondition.setOutcomeIf(outcomeIf);
{
// condition
And and = new And(outcomeIf);
outcomeIf.getExpressions().add(and);
Match match = new Match(and);
and.getExpressions().add(match);
BaseValue feedbackVal = new BaseValue(match);
feedbackVal.setBaseTypeAttrValue(BaseType.BOOLEAN);
feedbackVal.setSingleValue(condition ? BooleanValue.TRUE : BooleanValue.FALSE);
match.getExpressions().add(feedbackVal);
Variable variable = new Variable(match);
variable.setIdentifier(ComplexReferenceIdentifier.parseString(QTI21Constants.PASS));
match.getExpressions().add(variable);
}
{
// outcome
SetOutcomeValue setOutcomeValue = new SetOutcomeValue(outcomeIf);
setOutcomeValue.setIdentifier(QTI21Constants.FEEDBACKMODAL_IDENTIFIER);
outcomeIf.getOutcomeRules().add(setOutcomeValue);
Multiple multiple = new Multiple(setOutcomeValue);
setOutcomeValue.getExpressions().add(multiple);
Variable variable = new Variable(multiple);
variable.setIdentifier(ComplexReferenceIdentifier.parseString(QTI21Constants.FEEDBACKMODAL));
multiple.getExpressions().add(variable);
BaseValue feedbackVal = new BaseValue(multiple);
feedbackVal.setBaseTypeAttrValue(BaseType.IDENTIFIER);
feedbackVal.setSingleValue(new IdentifierValue(feedbackIdentifier));
multiple.getExpressions().add(feedbackVal);
}
return outcomeCondition;
}
use of uk.ac.ed.ph.jqtiplus.node.test.outcome.processing.SetOutcomeValue in project OpenOLAT by OpenOLAT.
the class AssessmentTestFactory method createMinScoreRule.
/*
<outcomeCondition>
<outcomeIf>
<lt>
<variable identifier="SCORE"/>
<variable identifier="MINSCORE"/>
</lt>
<setOutcomeValue identifier="SCORE">
<variable identifier="MINSCORE"/>
</setOutcomeValue>
</outcomeIf>
</outcomeCondition>
*/
public static OutcomeCondition createMinScoreRule(AssessmentTest assessmentTest) {
OutcomeCondition outcomeCondition = new OutcomeCondition(assessmentTest);
OutcomeIf outcomeIf = new OutcomeIf(outcomeCondition);
outcomeCondition.setOutcomeIf(outcomeIf);
Lt lt = new Lt(outcomeIf);
outcomeIf.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(outcomeIf);
setOutcomeValue.setIdentifier(SCORE_IDENTIFIER);
Variable minScoreOutcomeVar = new Variable(setOutcomeValue);
minScoreOutcomeVar.setIdentifier(MINSCORE_CLX_IDENTIFIER);
setOutcomeValue.setExpression(minScoreOutcomeVar);
outcomeIf.getOutcomeRules().add(setOutcomeValue);
return outcomeCondition;
}
use of uk.ac.ed.ph.jqtiplus.node.test.outcome.processing.SetOutcomeValue in project OpenOLAT by OpenOLAT.
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;
}
use of uk.ac.ed.ph.jqtiplus.node.test.outcome.processing.SetOutcomeValue in project openolat by klemens.
the class AssessmentTestBuilder method extractRules.
private void extractRules() {
if (assessmentTest.getOutcomeProcessing() != null) {
List<OutcomeRule> outcomeRules = assessmentTest.getOutcomeProcessing().getOutcomeRules();
for (OutcomeRule outcomeRule : outcomeRules) {
// export test score
if (outcomeRule instanceof SetOutcomeValue) {
SetOutcomeValue setOutcomeValue = (SetOutcomeValue) outcomeRule;
if (QTI21Constants.SCORE_IDENTIFIER.equals(setOutcomeValue.getIdentifier())) {
testScoreRule = outcomeRule;
}
}
// pass rule
if (outcomeRule instanceof OutcomeCondition) {
OutcomeCondition outcomeCondition = (OutcomeCondition) outcomeRule;
boolean findIf = QtiNodesExtractor.findSetOutcomeValue(outcomeCondition.getOutcomeIf(), QTI21Constants.PASS_IDENTIFIER);
boolean findElse = QtiNodesExtractor.findSetOutcomeValue(outcomeCondition.getOutcomeElse(), QTI21Constants.PASS_IDENTIFIER);
if (findIf && findElse) {
cutValue = QtiNodesExtractor.extractCutValue(outcomeCondition.getOutcomeIf());
cutValueRule = outcomeCondition;
}
boolean findMinIf = QtiNodesExtractor.findLtValue(outcomeCondition.getOutcomeIf(), QTI21Constants.MINSCORE_IDENTIFIER) && QtiNodesExtractor.findLtValue(outcomeCondition.getOutcomeIf(), QTI21Constants.SCORE_IDENTIFIER);
if (findMinIf) {
minScoreRule = outcomeCondition;
}
}
}
}
}
use of uk.ac.ed.ph.jqtiplus.node.test.outcome.processing.SetOutcomeValue in project openolat by klemens.
the class AssessmentTestFactory method createMinScoreRule.
/*
<outcomeCondition>
<outcomeIf>
<lt>
<variable identifier="SCORE"/>
<variable identifier="MINSCORE"/>
</lt>
<setOutcomeValue identifier="SCORE">
<variable identifier="MINSCORE"/>
</setOutcomeValue>
</outcomeIf>
</outcomeCondition>
*/
public static OutcomeCondition createMinScoreRule(AssessmentTest assessmentTest) {
OutcomeCondition outcomeCondition = new OutcomeCondition(assessmentTest);
OutcomeIf outcomeIf = new OutcomeIf(outcomeCondition);
outcomeCondition.setOutcomeIf(outcomeIf);
Lt lt = new Lt(outcomeIf);
outcomeIf.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(outcomeIf);
setOutcomeValue.setIdentifier(SCORE_IDENTIFIER);
Variable minScoreOutcomeVar = new Variable(setOutcomeValue);
minScoreOutcomeVar.setIdentifier(MINSCORE_CLX_IDENTIFIER);
setOutcomeValue.setExpression(minScoreOutcomeVar);
outcomeIf.getOutcomeRules().add(setOutcomeValue);
return outcomeCondition;
}
Aggregations