Search in sources :

Example 11 with OutcomeCondition

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

the class AssessmentTestBuilder method buildFeedback.

private void buildFeedback(TestFeedbackBuilder feedbackBuilder, boolean passed) {
    if (htmlBuilder.containsSomething(feedbackBuilder.getText())) {
        TestFeedback testFeedback;
        if (feedbackBuilder.getTestFeedback() == null) {
            testFeedback = AssessmentTestFactory.createTestFeedbackModal(assessmentTest, IdentifierGenerator.newAsIdentifier("fm"), feedbackBuilder.getTitle(), feedbackBuilder.getText());
            assessmentTest.getTestFeedbacks().add(testFeedback);
        } else {
            testFeedback = feedbackBuilder.getTestFeedback();
            testFeedback.setTitle(feedbackBuilder.getTitle());
            htmlBuilder.appendHtml(testFeedback, feedbackBuilder.getText());
        }
        OutcomeCondition outcomeCondition = AssessmentTestFactory.createTestFeedbackModalCondition(assessmentTest, passed, testFeedback.getOutcomeValue());
        assessmentTest.getOutcomeProcessing().getOutcomeRules().add(outcomeCondition);
    } else if (feedbackBuilder.getTestFeedback() != null) {
        assessmentTest.getTestFeedbacks().remove(feedbackBuilder.getTestFeedback());
    }
}
Also used : TestFeedback(uk.ac.ed.ph.jqtiplus.node.test.TestFeedback) OutcomeCondition(uk.ac.ed.ph.jqtiplus.node.test.outcome.processing.OutcomeCondition)

Example 12 with OutcomeCondition

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

the class TestFeedbackBuilder method findFeedbackMatch.

private boolean findFeedbackMatch(OutcomeRule outcomeRule, boolean pass, ComplexReferenceIdentifier id) {
    if (outcomeRule instanceof OutcomeCondition) {
        OutcomeCondition outcomeCondition = (OutcomeCondition) outcomeRule;
        OutcomeIf outcomeIf = outcomeCondition.getOutcomeIf();
        if (outcomeIf != null && outcomeIf.getExpressions().size() == 1) {
            Expression mustBeAnd = outcomeIf.getExpressions().get(0);
            if (mustBeAnd instanceof And && mustBeAnd.getExpressions().size() == 1) {
                Expression mustBeMatch = mustBeAnd.getExpressions().get(0);
                if (mustBeMatch instanceof Match && mustBeMatch.getExpressions().size() == 2) {
                    return findFeedbackMatch((Match) mustBeMatch, pass, id);
                }
            }
        }
    }
    return false;
}
Also used : Expression(uk.ac.ed.ph.jqtiplus.node.expression.Expression) OutcomeIf(uk.ac.ed.ph.jqtiplus.node.test.outcome.processing.OutcomeIf) And(uk.ac.ed.ph.jqtiplus.node.expression.operator.And) OutcomeCondition(uk.ac.ed.ph.jqtiplus.node.test.outcome.processing.OutcomeCondition) Match(uk.ac.ed.ph.jqtiplus.node.expression.operator.Match)

Example 13 with OutcomeCondition

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

Example 14 with OutcomeCondition

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

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

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