Search in sources :

Example 1 with OutcomeElse

use of uk.ac.ed.ph.jqtiplus.node.test.outcome.processing.OutcomeElse 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 2 with OutcomeElse

use of uk.ac.ed.ph.jqtiplus.node.test.outcome.processing.OutcomeElse 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)

Aggregations

BaseValue (uk.ac.ed.ph.jqtiplus.node.expression.general.BaseValue)2 Gte (uk.ac.ed.ph.jqtiplus.node.expression.operator.Gte)2 OutcomeCondition (uk.ac.ed.ph.jqtiplus.node.test.outcome.processing.OutcomeCondition)2 OutcomeElse (uk.ac.ed.ph.jqtiplus.node.test.outcome.processing.OutcomeElse)2 OutcomeIf (uk.ac.ed.ph.jqtiplus.node.test.outcome.processing.OutcomeIf)2 SetOutcomeValue (uk.ac.ed.ph.jqtiplus.node.test.outcome.processing.SetOutcomeValue)2 FloatValue (uk.ac.ed.ph.jqtiplus.value.FloatValue)2