use of uk.ac.ed.ph.jqtiplus.node.test.outcome.processing.SetOutcomeValue in project openolat by klemens.
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 klemens.
the class AssessmentTestFactory method createAssessmentTest.
/**
* Create an assessmentTest object but without items
*
* @param title
* @return
*/
public static AssessmentTest createAssessmentTest(String title, String sectionTitle) {
AssessmentTest assessmentTest = new AssessmentTest();
assessmentTest.setIdentifier(IdentifierGenerator.newAsString("test"));
assessmentTest.setTitle(title);
assessmentTest.setToolName(QTI21Constants.TOOLNAME);
assessmentTest.setToolVersion(Settings.getVersion());
// outcome score
OutcomeDeclaration scoreOutcomeDeclaration = new OutcomeDeclaration(assessmentTest);
scoreOutcomeDeclaration.setIdentifier(QTI21Constants.SCORE_IDENTIFIER);
scoreOutcomeDeclaration.setCardinality(Cardinality.SINGLE);
scoreOutcomeDeclaration.setBaseType(BaseType.FLOAT);
assessmentTest.getOutcomeDeclarations().add(scoreOutcomeDeclaration);
// test part
TestPart part = createTestPart(assessmentTest);
appendAssessmentSection(sectionTitle, part);
// outcome processing
OutcomeProcessing outcomeProcessing = new OutcomeProcessing(assessmentTest);
assessmentTest.setOutcomeProcessing(outcomeProcessing);
SetOutcomeValue outcomeRule = new SetOutcomeValue(outcomeProcessing);
outcomeRule.setIdentifier(QTI21Constants.SCORE_IDENTIFIER);
Sum sum = new Sum(outcomeRule);
outcomeRule.getExpressions().add(sum);
TestVariables testVariables = new TestVariables(sum);
testVariables.setVariableIdentifier(QTI21Constants.SCORE_IDENTIFIER);
sum.getExpressions().add(testVariables);
outcomeProcessing.getOutcomeRules().add(outcomeRule);
return assessmentTest;
}
use of uk.ac.ed.ph.jqtiplus.node.test.outcome.processing.SetOutcomeValue in project openolat by klemens.
the class TestFeedbackBuilder method findFeedbackRuleInSetOutcomeVariable.
private boolean findFeedbackRuleInSetOutcomeVariable(OutcomeRule responseRule, Identifier feedbackIdentifier) {
if (responseRule instanceof OutcomeCondition) {
OutcomeCondition outcomeCondition = (OutcomeCondition) responseRule;
OutcomeIf outcomeIf = outcomeCondition.getOutcomeIf();
List<OutcomeRule> ifOutcomeRules = outcomeIf.getOutcomeRules();
for (OutcomeRule ifOutcomeRule : ifOutcomeRules) {
if (ifOutcomeRule instanceof SetOutcomeValue) {
SetOutcomeValue setOutcomeValue = (SetOutcomeValue) ifOutcomeRule;
if (findFeedbackRuleInExpression(setOutcomeValue.getExpression(), feedbackIdentifier)) {
return true;
}
}
}
}
return false;
}
use of uk.ac.ed.ph.jqtiplus.node.test.outcome.processing.SetOutcomeValue in project OpenOLAT by OpenOLAT.
the class AssessmentTestBuilder method buildTestScore.
/* Overall score of this test
<setOutcomeValue identifier="SCORE">
<sum>
<testVariables variableIdentifier="SCORE" />
</sum>
</setOutcomeValue>
*/
private void buildTestScore() {
if (testScoreRule == null) {
SetOutcomeValue scoreRule = new SetOutcomeValue(assessmentTest);
scoreRule.setIdentifier(QTI21Constants.SCORE_IDENTIFIER);
Sum sum = new Sum(scoreRule);
scoreRule.getExpressions().add(sum);
TestVariables testVariables = new TestVariables(sum);
sum.getExpressions().add(testVariables);
testVariables.setVariableIdentifier(QTI21Constants.SCORE_IDENTIFIER);
assessmentTest.getOutcomeProcessing().getOutcomeRules().add(0, scoreRule);
testScoreRule = scoreRule;
}
if (minScoreRule == null) {
OutcomeCondition scoreRule = AssessmentTestFactory.createMinScoreRule(assessmentTest);
assessmentTest.getOutcomeProcessing().getOutcomeRules().add(1, scoreRule);
minScoreRule = scoreRule;
}
}
use of uk.ac.ed.ph.jqtiplus.node.test.outcome.processing.SetOutcomeValue in project OpenOLAT by OpenOLAT.
the class TestFeedbackBuilder method findFeedbackRuleInSetOutcomeVariable.
private boolean findFeedbackRuleInSetOutcomeVariable(OutcomeRule responseRule, Identifier feedbackIdentifier) {
if (responseRule instanceof OutcomeCondition) {
OutcomeCondition outcomeCondition = (OutcomeCondition) responseRule;
OutcomeIf outcomeIf = outcomeCondition.getOutcomeIf();
List<OutcomeRule> ifOutcomeRules = outcomeIf.getOutcomeRules();
for (OutcomeRule ifOutcomeRule : ifOutcomeRules) {
if (ifOutcomeRule instanceof SetOutcomeValue) {
SetOutcomeValue setOutcomeValue = (SetOutcomeValue) ifOutcomeRule;
if (findFeedbackRuleInExpression(setOutcomeValue.getExpression(), feedbackIdentifier)) {
return true;
}
}
}
}
return false;
}
Aggregations