Search in sources :

Example 11 with SetOutcomeValue

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

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

Example 12 with SetOutcomeValue

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

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 13 with SetOutcomeValue

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

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

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

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