Search in sources :

Example 1 with Gte

use of uk.ac.ed.ph.jqtiplus.node.expression.operator.Gte 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 Gte

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

the class AssessmentItemFactory method createModalFeedbackResponseConditionByScore.

/**
 * This generate a response rule which compare the max score and the score
 * to set the feedback as "correct".
 *
 *	<responseCondition>
 *		<responseIf>
 *			<and>
 *				<not>
 *					<match>
 *						<variable identifier="FEEDBACKBASIC" />
 *						<baseValue baseType="identifier">empty</baseValue>
 *					</match>
 *				</not>
 *				<equal toleranceMode="exact">
 *					<variable identifier="SCORE" />
 *					<variable identifier="MAXSCORE" />
 *				</equal>
 *			</and>
 *			<setOutcomeValue identifier="FEEDBACKBASIC">
 *				<baseValue baseType="identifier">correct</baseValue>
 *			</setOutcomeValue>
 *		</responseIf>
 *	</responseCondition>
 */
public static ResponseCondition createModalFeedbackResponseConditionByScore(ResponseProcessing responseProcessing) {
    ResponseCondition responseCondition = new ResponseCondition(responseProcessing);
    ResponseIf responseIf = new ResponseIf(responseCondition);
    responseCondition.setResponseIf(responseIf);
    And and = new And(responseIf);
    responseIf.getExpressions().add(and);
    Not not = new Not(and);
    and.getExpressions().add(not);
    Match match = new Match(not);
    not.getExpressions().add(match);
    Variable feedbackbasicVar = new Variable(match);
    feedbackbasicVar.setIdentifier(QTI21Constants.FEEDBACKBASIC_CLX_IDENTIFIER);
    match.getExpressions().add(feedbackbasicVar);
    BaseValue emptyValue = new BaseValue(match);
    emptyValue.setBaseTypeAttrValue(BaseType.IDENTIFIER);
    emptyValue.setSingleValue(QTI21Constants.EMPTY_IDENTIFIER_VALUE);
    match.getExpressions().add(emptyValue);
    // SCORE >= MAXSCORE ( > is for security and special case where the max score is smalle than the sum of correct answers)
    Gte greaterOrEqual = new Gte(and);
    and.getExpressions().add(greaterOrEqual);
    Variable scoreVar = new Variable(greaterOrEqual);
    scoreVar.setIdentifier(QTI21Constants.SCORE_CLX_IDENTIFIER);
    greaterOrEqual.getExpressions().add(scoreVar);
    Variable maxScoreVar = new Variable(greaterOrEqual);
    maxScoreVar.setIdentifier(QTI21Constants.MAXSCORE_CLX_IDENTIFIER);
    greaterOrEqual.getExpressions().add(maxScoreVar);
    // outcome value
    SetOutcomeValue correctOutcomeValue = new SetOutcomeValue(responseIf);
    correctOutcomeValue.setIdentifier(QTI21Constants.FEEDBACKBASIC_IDENTIFIER);
    responseIf.getResponseRules().add(correctOutcomeValue);
    BaseValue correctValue = new BaseValue(correctOutcomeValue);
    correctValue.setBaseTypeAttrValue(BaseType.IDENTIFIER);
    correctValue.setSingleValue(QTI21Constants.CORRECT_IDENTIFIER_VALUE);
    correctOutcomeValue.setExpression(correctValue);
    return responseCondition;
}
Also used : Not(uk.ac.ed.ph.jqtiplus.node.expression.operator.Not) Variable(uk.ac.ed.ph.jqtiplus.node.expression.general.Variable) SetOutcomeValue(uk.ac.ed.ph.jqtiplus.node.item.response.processing.SetOutcomeValue) And(uk.ac.ed.ph.jqtiplus.node.expression.operator.And) BaseValue(uk.ac.ed.ph.jqtiplus.node.expression.general.BaseValue) Gte(uk.ac.ed.ph.jqtiplus.node.expression.operator.Gte) ResponseIf(uk.ac.ed.ph.jqtiplus.node.item.response.processing.ResponseIf) ResponseCondition(uk.ac.ed.ph.jqtiplus.node.item.response.processing.ResponseCondition) Match(uk.ac.ed.ph.jqtiplus.node.expression.operator.Match)

Example 3 with Gte

use of uk.ac.ed.ph.jqtiplus.node.expression.operator.Gte 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 4 with Gte

use of uk.ac.ed.ph.jqtiplus.node.expression.operator.Gte 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 5 with Gte

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

the class AssessmentItemFactory method createModalFeedbackResponseConditionByScore.

/**
 * This generate a response rule which compare the max score and the score
 * to set the feedback as "correct".
 *
 *	<responseCondition>
 *		<responseIf>
 *			<and>
 *				<not>
 *					<match>
 *						<variable identifier="FEEDBACKBASIC" />
 *						<baseValue baseType="identifier">empty</baseValue>
 *					</match>
 *				</not>
 *				<equal toleranceMode="exact">
 *					<variable identifier="SCORE" />
 *					<variable identifier="MAXSCORE" />
 *				</equal>
 *			</and>
 *			<setOutcomeValue identifier="FEEDBACKBASIC">
 *				<baseValue baseType="identifier">correct</baseValue>
 *			</setOutcomeValue>
 *		</responseIf>
 *	</responseCondition>
 */
public static ResponseCondition createModalFeedbackResponseConditionByScore(ResponseProcessing responseProcessing) {
    ResponseCondition responseCondition = new ResponseCondition(responseProcessing);
    ResponseIf responseIf = new ResponseIf(responseCondition);
    responseCondition.setResponseIf(responseIf);
    And and = new And(responseIf);
    responseIf.getExpressions().add(and);
    Not not = new Not(and);
    and.getExpressions().add(not);
    Match match = new Match(not);
    not.getExpressions().add(match);
    Variable feedbackbasicVar = new Variable(match);
    feedbackbasicVar.setIdentifier(QTI21Constants.FEEDBACKBASIC_CLX_IDENTIFIER);
    match.getExpressions().add(feedbackbasicVar);
    BaseValue emptyValue = new BaseValue(match);
    emptyValue.setBaseTypeAttrValue(BaseType.IDENTIFIER);
    emptyValue.setSingleValue(QTI21Constants.EMPTY_IDENTIFIER_VALUE);
    match.getExpressions().add(emptyValue);
    // SCORE >= MAXSCORE ( > is for security and special case where the max score is smalle than the sum of correct answers)
    Gte greaterOrEqual = new Gte(and);
    and.getExpressions().add(greaterOrEqual);
    Variable scoreVar = new Variable(greaterOrEqual);
    scoreVar.setIdentifier(QTI21Constants.SCORE_CLX_IDENTIFIER);
    greaterOrEqual.getExpressions().add(scoreVar);
    Variable maxScoreVar = new Variable(greaterOrEqual);
    maxScoreVar.setIdentifier(QTI21Constants.MAXSCORE_CLX_IDENTIFIER);
    greaterOrEqual.getExpressions().add(maxScoreVar);
    // outcome value
    SetOutcomeValue correctOutcomeValue = new SetOutcomeValue(responseIf);
    correctOutcomeValue.setIdentifier(QTI21Constants.FEEDBACKBASIC_IDENTIFIER);
    responseIf.getResponseRules().add(correctOutcomeValue);
    BaseValue correctValue = new BaseValue(correctOutcomeValue);
    correctValue.setBaseTypeAttrValue(BaseType.IDENTIFIER);
    correctValue.setSingleValue(QTI21Constants.CORRECT_IDENTIFIER_VALUE);
    correctOutcomeValue.setExpression(correctValue);
    return responseCondition;
}
Also used : Not(uk.ac.ed.ph.jqtiplus.node.expression.operator.Not) Variable(uk.ac.ed.ph.jqtiplus.node.expression.general.Variable) SetOutcomeValue(uk.ac.ed.ph.jqtiplus.node.item.response.processing.SetOutcomeValue) And(uk.ac.ed.ph.jqtiplus.node.expression.operator.And) BaseValue(uk.ac.ed.ph.jqtiplus.node.expression.general.BaseValue) Gte(uk.ac.ed.ph.jqtiplus.node.expression.operator.Gte) ResponseIf(uk.ac.ed.ph.jqtiplus.node.item.response.processing.ResponseIf) ResponseCondition(uk.ac.ed.ph.jqtiplus.node.item.response.processing.ResponseCondition) Match(uk.ac.ed.ph.jqtiplus.node.expression.operator.Match)

Aggregations

Gte (uk.ac.ed.ph.jqtiplus.node.expression.operator.Gte)6 BaseValue (uk.ac.ed.ph.jqtiplus.node.expression.general.BaseValue)4 Match (uk.ac.ed.ph.jqtiplus.node.expression.operator.Match)4 Not (uk.ac.ed.ph.jqtiplus.node.expression.operator.Not)4 Variable (uk.ac.ed.ph.jqtiplus.node.expression.general.Variable)2 And (uk.ac.ed.ph.jqtiplus.node.expression.operator.And)2 Equal (uk.ac.ed.ph.jqtiplus.node.expression.operator.Equal)2 Gt (uk.ac.ed.ph.jqtiplus.node.expression.operator.Gt)2 Lt (uk.ac.ed.ph.jqtiplus.node.expression.operator.Lt)2 Lte (uk.ac.ed.ph.jqtiplus.node.expression.operator.Lte)2 Member (uk.ac.ed.ph.jqtiplus.node.expression.operator.Member)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 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