use of uk.ac.ed.ph.jqtiplus.node.test.outcome.processing.OutcomeCondition 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.OutcomeCondition 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.OutcomeCondition 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;
}
use of uk.ac.ed.ph.jqtiplus.node.test.outcome.processing.OutcomeCondition 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;
}
use of uk.ac.ed.ph.jqtiplus.node.test.outcome.processing.OutcomeCondition in project openolat by klemens.
the class QTI21WordExport method renderAssessmentTest.
public void renderAssessmentTest(AssessmentTest assessmentTest, OpenXMLDocument document, Translator translator) {
String title = assessmentTest.getTitle();
document.appendTitle(title);
if (assessmentTest.getOutcomeProcessing() != null) {
List<OutcomeRule> outcomeRules = assessmentTest.getOutcomeProcessing().getOutcomeRules();
for (OutcomeRule outcomeRule : outcomeRules) {
// 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) {
Double cutValue = QtiNodesExtractor.extractCutValue(outcomeCondition.getOutcomeIf());
String cutValueLabel = translator.translate("cut.value");
document.appendText(cutValueLabel + ": " + AssessmentHelper.getRoundedScore(cutValue), true);
}
}
}
}
}
Aggregations