Search in sources :

Example 16 with OutcomeCondition

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;
}
Also used : SetOutcomeValue(uk.ac.ed.ph.jqtiplus.node.test.outcome.processing.SetOutcomeValue) OutcomeElse(uk.ac.ed.ph.jqtiplus.node.test.outcome.processing.OutcomeElse) OutcomeIf(uk.ac.ed.ph.jqtiplus.node.test.outcome.processing.OutcomeIf) BaseValue(uk.ac.ed.ph.jqtiplus.node.expression.general.BaseValue) OutcomeCondition(uk.ac.ed.ph.jqtiplus.node.test.outcome.processing.OutcomeCondition) Gte(uk.ac.ed.ph.jqtiplus.node.expression.operator.Gte) FloatValue(uk.ac.ed.ph.jqtiplus.value.FloatValue)

Example 17 with 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;
                }
            }
        }
    }
}
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 18 with 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;
}
Also used : Variable(uk.ac.ed.ph.jqtiplus.node.expression.general.Variable) SetOutcomeValue(uk.ac.ed.ph.jqtiplus.node.test.outcome.processing.SetOutcomeValue) OutcomeIf(uk.ac.ed.ph.jqtiplus.node.test.outcome.processing.OutcomeIf) OutcomeCondition(uk.ac.ed.ph.jqtiplus.node.test.outcome.processing.OutcomeCondition) Lt(uk.ac.ed.ph.jqtiplus.node.expression.operator.Lt)

Example 19 with 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;
}
Also used : SetOutcomeValue(uk.ac.ed.ph.jqtiplus.node.test.outcome.processing.SetOutcomeValue) OutcomeElse(uk.ac.ed.ph.jqtiplus.node.test.outcome.processing.OutcomeElse) OutcomeIf(uk.ac.ed.ph.jqtiplus.node.test.outcome.processing.OutcomeIf) BaseValue(uk.ac.ed.ph.jqtiplus.node.expression.general.BaseValue) OutcomeCondition(uk.ac.ed.ph.jqtiplus.node.test.outcome.processing.OutcomeCondition) Gte(uk.ac.ed.ph.jqtiplus.node.expression.operator.Gte) FloatValue(uk.ac.ed.ph.jqtiplus.value.FloatValue)

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

Aggregations

OutcomeCondition (uk.ac.ed.ph.jqtiplus.node.test.outcome.processing.OutcomeCondition)22 SetOutcomeValue (uk.ac.ed.ph.jqtiplus.node.test.outcome.processing.SetOutcomeValue)14 OutcomeIf (uk.ac.ed.ph.jqtiplus.node.test.outcome.processing.OutcomeIf)10 OutcomeRule (uk.ac.ed.ph.jqtiplus.node.test.outcome.processing.OutcomeRule)10 BaseValue (uk.ac.ed.ph.jqtiplus.node.expression.general.BaseValue)4 Variable (uk.ac.ed.ph.jqtiplus.node.expression.general.Variable)4 And (uk.ac.ed.ph.jqtiplus.node.expression.operator.And)4 Match (uk.ac.ed.ph.jqtiplus.node.expression.operator.Match)4 Expression (uk.ac.ed.ph.jqtiplus.node.expression.Expression)2 Gte (uk.ac.ed.ph.jqtiplus.node.expression.operator.Gte)2 Lt (uk.ac.ed.ph.jqtiplus.node.expression.operator.Lt)2 Multiple (uk.ac.ed.ph.jqtiplus.node.expression.operator.Multiple)2 Sum (uk.ac.ed.ph.jqtiplus.node.expression.operator.Sum)2 TestVariables (uk.ac.ed.ph.jqtiplus.node.expression.outcome.TestVariables)2 OutcomeDeclaration (uk.ac.ed.ph.jqtiplus.node.outcome.declaration.OutcomeDeclaration)2 TestFeedback (uk.ac.ed.ph.jqtiplus.node.test.TestFeedback)2 OutcomeElse (uk.ac.ed.ph.jqtiplus.node.test.outcome.processing.OutcomeElse)2 FloatValue (uk.ac.ed.ph.jqtiplus.value.FloatValue)2 IdentifierValue (uk.ac.ed.ph.jqtiplus.value.IdentifierValue)2