Search in sources :

Example 1 with SetOutcomeValue

use of uk.ac.ed.ph.jqtiplus.node.test.outcome.processing.SetOutcomeValue in project OpenOLAT by OpenOLAT.

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;
                }
            }
        }
    }
}
Also used : SetOutcomeValue(uk.ac.ed.ph.jqtiplus.node.test.outcome.processing.SetOutcomeValue) OutcomeCondition(uk.ac.ed.ph.jqtiplus.node.test.outcome.processing.OutcomeCondition) OutcomeRule(uk.ac.ed.ph.jqtiplus.node.test.outcome.processing.OutcomeRule)

Example 2 with SetOutcomeValue

use of uk.ac.ed.ph.jqtiplus.node.test.outcome.processing.SetOutcomeValue in project OpenOLAT by OpenOLAT.

the class AssessmentTestBuilder method buildFeedback.

private void buildFeedback() {
    // remove outcome rules
    List<OutcomeRule> outcomeRules = assessmentTest.getOutcomeProcessing().getOutcomeRules();
    for (Iterator<OutcomeRule> outcomeRuleIt = outcomeRules.iterator(); outcomeRuleIt.hasNext(); ) {
        OutcomeRule outcomeRule = outcomeRuleIt.next();
        if (outcomeRule instanceof OutcomeCondition) {
            OutcomeCondition outcomeCondition = (OutcomeCondition) outcomeRule;
            if (outcomeCondition.getOutcomeIf() != null && outcomeCondition.getOutcomeIf().getOutcomeRules().size() == 1) {
                OutcomeRule outcomeValue = outcomeCondition.getOutcomeIf().getOutcomeRules().get(0);
                if (outcomeValue instanceof SetOutcomeValue) {
                    SetOutcomeValue setOutcomeValue = (SetOutcomeValue) outcomeValue;
                    if (QTI21Constants.FEEDBACKMODAL_IDENTIFIER.equals(setOutcomeValue.getIdentifier())) {
                        outcomeRuleIt.remove();
                    }
                }
            }
        }
    }
    // set the feedbackmodal outcome declaration if needed
    if (passedFeedback != null || failedFeedback != null) {
        OutcomeDeclaration outcomeDeclaration = assessmentTest.getOutcomeDeclaration(QTI21Constants.FEEDBACKMODAL_IDENTIFIER);
        if (outcomeDeclaration == null) {
            OutcomeDeclaration feedbackModalOutcomeDeclaration = AssessmentTestFactory.createTestFeedbackModalOutcomeDeclaration(assessmentTest);
            assessmentTest.getOutcomeDeclarations().add(feedbackModalOutcomeDeclaration);
        }
    }
    if (passedFeedback != null) {
        buildFeedback(passedFeedback, true);
    }
    if (failedFeedback != null) {
        buildFeedback(failedFeedback, false);
    }
}
Also used : SetOutcomeValue(uk.ac.ed.ph.jqtiplus.node.test.outcome.processing.SetOutcomeValue) OutcomeCondition(uk.ac.ed.ph.jqtiplus.node.test.outcome.processing.OutcomeCondition) OutcomeRule(uk.ac.ed.ph.jqtiplus.node.test.outcome.processing.OutcomeRule) OutcomeDeclaration(uk.ac.ed.ph.jqtiplus.node.outcome.declaration.OutcomeDeclaration)

Example 3 with SetOutcomeValue

use of uk.ac.ed.ph.jqtiplus.node.test.outcome.processing.SetOutcomeValue in project OpenOLAT by OpenOLAT.

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;
}
Also used : AssessmentTest(uk.ac.ed.ph.jqtiplus.node.test.AssessmentTest) SetOutcomeValue(uk.ac.ed.ph.jqtiplus.node.test.outcome.processing.SetOutcomeValue) OutcomeProcessing(uk.ac.ed.ph.jqtiplus.node.test.outcome.processing.OutcomeProcessing) TestPart(uk.ac.ed.ph.jqtiplus.node.test.TestPart) Sum(uk.ac.ed.ph.jqtiplus.node.expression.operator.Sum) TestVariables(uk.ac.ed.ph.jqtiplus.node.expression.outcome.TestVariables) OutcomeDeclaration(uk.ac.ed.ph.jqtiplus.node.outcome.declaration.OutcomeDeclaration)

Example 4 with SetOutcomeValue

use of uk.ac.ed.ph.jqtiplus.node.test.outcome.processing.SetOutcomeValue in project openolat by klemens.

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;
    }
}
Also used : SetOutcomeValue(uk.ac.ed.ph.jqtiplus.node.test.outcome.processing.SetOutcomeValue) OutcomeCondition(uk.ac.ed.ph.jqtiplus.node.test.outcome.processing.OutcomeCondition) Sum(uk.ac.ed.ph.jqtiplus.node.expression.operator.Sum) TestVariables(uk.ac.ed.ph.jqtiplus.node.expression.outcome.TestVariables)

Example 5 with SetOutcomeValue

use of uk.ac.ed.ph.jqtiplus.node.test.outcome.processing.SetOutcomeValue in project openolat by klemens.

the class AssessmentTestBuilder method buildFeedback.

private void buildFeedback() {
    // remove outcome rules
    List<OutcomeRule> outcomeRules = assessmentTest.getOutcomeProcessing().getOutcomeRules();
    for (Iterator<OutcomeRule> outcomeRuleIt = outcomeRules.iterator(); outcomeRuleIt.hasNext(); ) {
        OutcomeRule outcomeRule = outcomeRuleIt.next();
        if (outcomeRule instanceof OutcomeCondition) {
            OutcomeCondition outcomeCondition = (OutcomeCondition) outcomeRule;
            if (outcomeCondition.getOutcomeIf() != null && outcomeCondition.getOutcomeIf().getOutcomeRules().size() == 1) {
                OutcomeRule outcomeValue = outcomeCondition.getOutcomeIf().getOutcomeRules().get(0);
                if (outcomeValue instanceof SetOutcomeValue) {
                    SetOutcomeValue setOutcomeValue = (SetOutcomeValue) outcomeValue;
                    if (QTI21Constants.FEEDBACKMODAL_IDENTIFIER.equals(setOutcomeValue.getIdentifier())) {
                        outcomeRuleIt.remove();
                    }
                }
            }
        }
    }
    // set the feedbackmodal outcome declaration if needed
    if (passedFeedback != null || failedFeedback != null) {
        OutcomeDeclaration outcomeDeclaration = assessmentTest.getOutcomeDeclaration(QTI21Constants.FEEDBACKMODAL_IDENTIFIER);
        if (outcomeDeclaration == null) {
            OutcomeDeclaration feedbackModalOutcomeDeclaration = AssessmentTestFactory.createTestFeedbackModalOutcomeDeclaration(assessmentTest);
            assessmentTest.getOutcomeDeclarations().add(feedbackModalOutcomeDeclaration);
        }
    }
    if (passedFeedback != null) {
        buildFeedback(passedFeedback, true);
    }
    if (failedFeedback != null) {
        buildFeedback(failedFeedback, false);
    }
}
Also used : SetOutcomeValue(uk.ac.ed.ph.jqtiplus.node.test.outcome.processing.SetOutcomeValue) OutcomeCondition(uk.ac.ed.ph.jqtiplus.node.test.outcome.processing.OutcomeCondition) OutcomeRule(uk.ac.ed.ph.jqtiplus.node.test.outcome.processing.OutcomeRule) OutcomeDeclaration(uk.ac.ed.ph.jqtiplus.node.outcome.declaration.OutcomeDeclaration)

Aggregations

SetOutcomeValue (uk.ac.ed.ph.jqtiplus.node.test.outcome.processing.SetOutcomeValue)16 OutcomeCondition (uk.ac.ed.ph.jqtiplus.node.test.outcome.processing.OutcomeCondition)14 OutcomeIf (uk.ac.ed.ph.jqtiplus.node.test.outcome.processing.OutcomeIf)8 OutcomeRule (uk.ac.ed.ph.jqtiplus.node.test.outcome.processing.OutcomeRule)6 BaseValue (uk.ac.ed.ph.jqtiplus.node.expression.general.BaseValue)4 Variable (uk.ac.ed.ph.jqtiplus.node.expression.general.Variable)4 Sum (uk.ac.ed.ph.jqtiplus.node.expression.operator.Sum)4 TestVariables (uk.ac.ed.ph.jqtiplus.node.expression.outcome.TestVariables)4 OutcomeDeclaration (uk.ac.ed.ph.jqtiplus.node.outcome.declaration.OutcomeDeclaration)4 And (uk.ac.ed.ph.jqtiplus.node.expression.operator.And)2 Gte (uk.ac.ed.ph.jqtiplus.node.expression.operator.Gte)2 Lt (uk.ac.ed.ph.jqtiplus.node.expression.operator.Lt)2 Match (uk.ac.ed.ph.jqtiplus.node.expression.operator.Match)2 Multiple (uk.ac.ed.ph.jqtiplus.node.expression.operator.Multiple)2 AssessmentTest (uk.ac.ed.ph.jqtiplus.node.test.AssessmentTest)2 TestPart (uk.ac.ed.ph.jqtiplus.node.test.TestPart)2 OutcomeElse (uk.ac.ed.ph.jqtiplus.node.test.outcome.processing.OutcomeElse)2 OutcomeProcessing (uk.ac.ed.ph.jqtiplus.node.test.outcome.processing.OutcomeProcessing)2 FloatValue (uk.ac.ed.ph.jqtiplus.value.FloatValue)2 IdentifierValue (uk.ac.ed.ph.jqtiplus.value.IdentifierValue)2