Search in sources :

Example 1 with Gt

use of uk.ac.ed.ph.jqtiplus.node.expression.operator.Gt in project OpenOLAT by OpenOLAT.

the class AssessmentItemFactory method appendModalFeedbackCondition.

private static void appendModalFeedbackCondition(ModalFeedbackCondition condition, Identifier responseIdentifier, Cardinality cardinality, And and) {
    ModalFeedbackCondition.Variable var = condition.getVariable();
    ModalFeedbackCondition.Operator operator = condition.getOperator();
    String value = condition.getValue();
    if (var == ModalFeedbackCondition.Variable.response) {
        if (cardinality == Cardinality.MULTIPLE) {
            if (operator == ModalFeedbackCondition.Operator.equals) {
                Member member = new Member(and);
                and.getExpressions().add(member);
                appendVariableBaseValue(var, value, responseIdentifier, member, true);
            } else if (operator == ModalFeedbackCondition.Operator.notEquals) {
                Not not = new Not(and);
                and.getExpressions().add(not);
                Member member = new Member(not);
                not.getExpressions().add(member);
                appendVariableBaseValue(var, value, responseIdentifier, member, true);
            }
        } else {
            if (operator == ModalFeedbackCondition.Operator.equals) {
                Match match = new Match(and);
                and.getExpressions().add(match);
                appendVariableBaseValue(var, value, responseIdentifier, match, false);
            } else if (operator == ModalFeedbackCondition.Operator.notEquals) {
                Not not = new Not(and);
                and.getExpressions().add(not);
                Match match = new Match(not);
                not.getExpressions().add(match);
                appendVariableBaseValue(var, value, responseIdentifier, match, false);
            }
        }
    } else {
        switch(operator) {
            case bigger:
                {
                    Gt gt = new Gt(and);
                    and.getExpressions().add(gt);
                    appendVariableBaseValue(var, value, responseIdentifier, gt, false);
                    break;
                }
            case biggerEquals:
                {
                    Gte gte = new Gte(and);
                    and.getExpressions().add(gte);
                    appendVariableBaseValue(var, value, responseIdentifier, gte, false);
                    break;
                }
            case equals:
                {
                    Equal equal = new Equal(and);
                    equal.setToleranceMode(ToleranceMode.EXACT);
                    and.getExpressions().add(equal);
                    appendVariableBaseValue(var, value, responseIdentifier, equal, false);
                    break;
                }
            case notEquals:
                {
                    Not not = new Not(and);
                    and.getExpressions().add(not);
                    Equal equal = new Equal(not);
                    equal.setToleranceMode(ToleranceMode.EXACT);
                    not.getExpressions().add(equal);
                    appendVariableBaseValue(var, value, responseIdentifier, equal, false);
                    break;
                }
            case smaller:
                {
                    Lt lt = new Lt(and);
                    and.getExpressions().add(lt);
                    appendVariableBaseValue(var, value, responseIdentifier, lt, false);
                    break;
                }
            case smallerEquals:
                {
                    Lte lte = new Lte(and);
                    and.getExpressions().add(lte);
                    appendVariableBaseValue(var, value, responseIdentifier, lte, false);
                    break;
                }
        }
    }
}
Also used : Not(uk.ac.ed.ph.jqtiplus.node.expression.operator.Not) Equal(uk.ac.ed.ph.jqtiplus.node.expression.operator.Equal) Lt(uk.ac.ed.ph.jqtiplus.node.expression.operator.Lt) Gte(uk.ac.ed.ph.jqtiplus.node.expression.operator.Gte) Lte(uk.ac.ed.ph.jqtiplus.node.expression.operator.Lte) Member(uk.ac.ed.ph.jqtiplus.node.expression.operator.Member) Gt(uk.ac.ed.ph.jqtiplus.node.expression.operator.Gt) Match(uk.ac.ed.ph.jqtiplus.node.expression.operator.Match)

Example 2 with Gt

use of uk.ac.ed.ph.jqtiplus.node.expression.operator.Gt in project OpenOLAT by OpenOLAT.

the class AssessmentItemFactory method createMaxScoreBoundLimitRule.

/**
 * Rule which ensure that the final score is not above the max. score value.
 */
public static ResponseRule createMaxScoreBoundLimitRule(ResponseProcessing responseProcessing) {
    /*
		<responseCondition>
			<responseIf>
				<gt>
					<variable identifier="SCORE" /><variable identifier="MAXSCORE" />
				</gt>
				<setOutcomeValue identifier="SCORE">
					<variable identifier="MAXSCORE" />
				</setOutcomeValue>
			</responseIf>
		</responseCondition>
		*/
    ResponseCondition rule = new ResponseCondition(responseProcessing);
    ResponseIf responseIf = new ResponseIf(rule);
    rule.setResponseIf(responseIf);
    Gt gt = new Gt(responseIf);
    responseIf.setExpression(gt);
    Variable scoreVar = new Variable(gt);
    scoreVar.setIdentifier(SCORE_CLX_IDENTIFIER);
    gt.getExpressions().add(scoreVar);
    Variable maxScoreVar = new Variable(gt);
    maxScoreVar.setIdentifier(MAXSCORE_CLX_IDENTIFIER);
    gt.getExpressions().add(maxScoreVar);
    SetOutcomeValue setOutcomeValue = new SetOutcomeValue(responseIf);
    setOutcomeValue.setIdentifier(SCORE_IDENTIFIER);
    Variable maxScoreOutcomeVar = new Variable(setOutcomeValue);
    maxScoreOutcomeVar.setIdentifier(MAXSCORE_CLX_IDENTIFIER);
    setOutcomeValue.setExpression(maxScoreOutcomeVar);
    responseIf.getResponseRules().add(setOutcomeValue);
    return rule;
}
Also used : Variable(uk.ac.ed.ph.jqtiplus.node.expression.general.Variable) SetOutcomeValue(uk.ac.ed.ph.jqtiplus.node.item.response.processing.SetOutcomeValue) ResponseIf(uk.ac.ed.ph.jqtiplus.node.item.response.processing.ResponseIf) Gt(uk.ac.ed.ph.jqtiplus.node.expression.operator.Gt) ResponseCondition(uk.ac.ed.ph.jqtiplus.node.item.response.processing.ResponseCondition)

Example 3 with Gt

use of uk.ac.ed.ph.jqtiplus.node.expression.operator.Gt in project openolat by klemens.

the class AssessmentItemFactory method appendModalFeedbackCondition.

private static void appendModalFeedbackCondition(ModalFeedbackCondition condition, Identifier responseIdentifier, Cardinality cardinality, And and) {
    ModalFeedbackCondition.Variable var = condition.getVariable();
    ModalFeedbackCondition.Operator operator = condition.getOperator();
    String value = condition.getValue();
    if (var == ModalFeedbackCondition.Variable.response) {
        if (cardinality == Cardinality.MULTIPLE) {
            if (operator == ModalFeedbackCondition.Operator.equals) {
                Member member = new Member(and);
                and.getExpressions().add(member);
                appendVariableBaseValue(var, value, responseIdentifier, member, true);
            } else if (operator == ModalFeedbackCondition.Operator.notEquals) {
                Not not = new Not(and);
                and.getExpressions().add(not);
                Member member = new Member(not);
                not.getExpressions().add(member);
                appendVariableBaseValue(var, value, responseIdentifier, member, true);
            }
        } else {
            if (operator == ModalFeedbackCondition.Operator.equals) {
                Match match = new Match(and);
                and.getExpressions().add(match);
                appendVariableBaseValue(var, value, responseIdentifier, match, false);
            } else if (operator == ModalFeedbackCondition.Operator.notEquals) {
                Not not = new Not(and);
                and.getExpressions().add(not);
                Match match = new Match(not);
                not.getExpressions().add(match);
                appendVariableBaseValue(var, value, responseIdentifier, match, false);
            }
        }
    } else {
        switch(operator) {
            case bigger:
                {
                    Gt gt = new Gt(and);
                    and.getExpressions().add(gt);
                    appendVariableBaseValue(var, value, responseIdentifier, gt, false);
                    break;
                }
            case biggerEquals:
                {
                    Gte gte = new Gte(and);
                    and.getExpressions().add(gte);
                    appendVariableBaseValue(var, value, responseIdentifier, gte, false);
                    break;
                }
            case equals:
                {
                    Equal equal = new Equal(and);
                    equal.setToleranceMode(ToleranceMode.EXACT);
                    and.getExpressions().add(equal);
                    appendVariableBaseValue(var, value, responseIdentifier, equal, false);
                    break;
                }
            case notEquals:
                {
                    Not not = new Not(and);
                    and.getExpressions().add(not);
                    Equal equal = new Equal(not);
                    equal.setToleranceMode(ToleranceMode.EXACT);
                    not.getExpressions().add(equal);
                    appendVariableBaseValue(var, value, responseIdentifier, equal, false);
                    break;
                }
            case smaller:
                {
                    Lt lt = new Lt(and);
                    and.getExpressions().add(lt);
                    appendVariableBaseValue(var, value, responseIdentifier, lt, false);
                    break;
                }
            case smallerEquals:
                {
                    Lte lte = new Lte(and);
                    and.getExpressions().add(lte);
                    appendVariableBaseValue(var, value, responseIdentifier, lte, false);
                    break;
                }
        }
    }
}
Also used : Not(uk.ac.ed.ph.jqtiplus.node.expression.operator.Not) Equal(uk.ac.ed.ph.jqtiplus.node.expression.operator.Equal) Lt(uk.ac.ed.ph.jqtiplus.node.expression.operator.Lt) Gte(uk.ac.ed.ph.jqtiplus.node.expression.operator.Gte) Lte(uk.ac.ed.ph.jqtiplus.node.expression.operator.Lte) Member(uk.ac.ed.ph.jqtiplus.node.expression.operator.Member) Gt(uk.ac.ed.ph.jqtiplus.node.expression.operator.Gt) Match(uk.ac.ed.ph.jqtiplus.node.expression.operator.Match)

Example 4 with Gt

use of uk.ac.ed.ph.jqtiplus.node.expression.operator.Gt in project openolat by klemens.

the class AssessmentItemFactory method createMaxScoreBoundLimitRule.

/**
 * Rule which ensure that the final score is not above the max. score value.
 */
public static ResponseRule createMaxScoreBoundLimitRule(ResponseProcessing responseProcessing) {
    /*
		<responseCondition>
			<responseIf>
				<gt>
					<variable identifier="SCORE" /><variable identifier="MAXSCORE" />
				</gt>
				<setOutcomeValue identifier="SCORE">
					<variable identifier="MAXSCORE" />
				</setOutcomeValue>
			</responseIf>
		</responseCondition>
		*/
    ResponseCondition rule = new ResponseCondition(responseProcessing);
    ResponseIf responseIf = new ResponseIf(rule);
    rule.setResponseIf(responseIf);
    Gt gt = new Gt(responseIf);
    responseIf.setExpression(gt);
    Variable scoreVar = new Variable(gt);
    scoreVar.setIdentifier(SCORE_CLX_IDENTIFIER);
    gt.getExpressions().add(scoreVar);
    Variable maxScoreVar = new Variable(gt);
    maxScoreVar.setIdentifier(MAXSCORE_CLX_IDENTIFIER);
    gt.getExpressions().add(maxScoreVar);
    SetOutcomeValue setOutcomeValue = new SetOutcomeValue(responseIf);
    setOutcomeValue.setIdentifier(SCORE_IDENTIFIER);
    Variable maxScoreOutcomeVar = new Variable(setOutcomeValue);
    maxScoreOutcomeVar.setIdentifier(MAXSCORE_CLX_IDENTIFIER);
    setOutcomeValue.setExpression(maxScoreOutcomeVar);
    responseIf.getResponseRules().add(setOutcomeValue);
    return rule;
}
Also used : Variable(uk.ac.ed.ph.jqtiplus.node.expression.general.Variable) SetOutcomeValue(uk.ac.ed.ph.jqtiplus.node.item.response.processing.SetOutcomeValue) ResponseIf(uk.ac.ed.ph.jqtiplus.node.item.response.processing.ResponseIf) Gt(uk.ac.ed.ph.jqtiplus.node.expression.operator.Gt) ResponseCondition(uk.ac.ed.ph.jqtiplus.node.item.response.processing.ResponseCondition)

Aggregations

Gt (uk.ac.ed.ph.jqtiplus.node.expression.operator.Gt)4 Variable (uk.ac.ed.ph.jqtiplus.node.expression.general.Variable)2 Equal (uk.ac.ed.ph.jqtiplus.node.expression.operator.Equal)2 Gte (uk.ac.ed.ph.jqtiplus.node.expression.operator.Gte)2 Lt (uk.ac.ed.ph.jqtiplus.node.expression.operator.Lt)2 Lte (uk.ac.ed.ph.jqtiplus.node.expression.operator.Lte)2 Match (uk.ac.ed.ph.jqtiplus.node.expression.operator.Match)2 Member (uk.ac.ed.ph.jqtiplus.node.expression.operator.Member)2 Not (uk.ac.ed.ph.jqtiplus.node.expression.operator.Not)2 ResponseCondition (uk.ac.ed.ph.jqtiplus.node.item.response.processing.ResponseCondition)2 ResponseIf (uk.ac.ed.ph.jqtiplus.node.item.response.processing.ResponseIf)2 SetOutcomeValue (uk.ac.ed.ph.jqtiplus.node.item.response.processing.SetOutcomeValue)2