Search in sources :

Example 6 with BaseValue

use of uk.ac.ed.ph.jqtiplus.node.expression.general.BaseValue in project OpenOLAT by OpenOLAT.

the class AssessmentItemFactory method appendSetOutcomeFeedbackIncorrect.

/*
	<setOutcomeValue identifier="FEEDBACKBASIC">
		<baseValue baseType="identifier">incorrect</baseValue>
	</setOutcomeValue>
	*/
public static void appendSetOutcomeFeedbackIncorrect(ResponseConditionChild responseCondition) {
    SetOutcomeValue incorrectOutcomeValue = new SetOutcomeValue(responseCondition);
    incorrectOutcomeValue.setIdentifier(QTI21Constants.FEEDBACKBASIC_IDENTIFIER);
    responseCondition.getResponseRules().add(incorrectOutcomeValue);
    BaseValue incorrectValue = new BaseValue(incorrectOutcomeValue);
    incorrectValue.setBaseTypeAttrValue(BaseType.IDENTIFIER);
    incorrectValue.setSingleValue(QTI21Constants.INCORRECT_IDENTIFIER_VALUE);
    incorrectOutcomeValue.setExpression(incorrectValue);
}
Also used : SetOutcomeValue(uk.ac.ed.ph.jqtiplus.node.item.response.processing.SetOutcomeValue) BaseValue(uk.ac.ed.ph.jqtiplus.node.expression.general.BaseValue)

Example 7 with BaseValue

use of uk.ac.ed.ph.jqtiplus.node.expression.general.BaseValue in project OpenOLAT by OpenOLAT.

the class AssessmentItemFactory method findBaseValueInExpression.

public static boolean findBaseValueInExpression(Expression expression, Identifier feedbackIdentifier) {
    if (expression instanceof BaseValue) {
        BaseValue bValue = (BaseValue) expression;
        SingleValue sValue = bValue.getSingleValue();
        if (sValue instanceof IdentifierValue) {
            IdentifierValue iValue = (IdentifierValue) sValue;
            if (feedbackIdentifier.equals(iValue.identifierValue())) {
                return true;
            }
        }
    } else {
        List<Expression> childExpressions = expression.getExpressions();
        for (Expression childExpression : childExpressions) {
            if (findBaseValueInExpression(childExpression, feedbackIdentifier)) {
                return true;
            }
        }
    }
    return false;
}
Also used : SingleValue(uk.ac.ed.ph.jqtiplus.value.SingleValue) Expression(uk.ac.ed.ph.jqtiplus.node.expression.Expression) BaseValue(uk.ac.ed.ph.jqtiplus.node.expression.general.BaseValue) IdentifierValue(uk.ac.ed.ph.jqtiplus.value.IdentifierValue)

Example 8 with BaseValue

use of uk.ac.ed.ph.jqtiplus.node.expression.general.BaseValue in project OpenOLAT by OpenOLAT.

the class AssessmentItemFactory method appendSetOutcomeFeedbackCorrect.

/*
	<setOutcomeValue identifier="FEEDBACKBASIC">
		<baseValue baseType="identifier">
			correct
		</baseValue>
	</setOutcomeValue>
	*/
public static void appendSetOutcomeFeedbackCorrect(ResponseConditionChild responseCondition) {
    SetOutcomeValue correctOutcomeValue = new SetOutcomeValue(responseCondition);
    correctOutcomeValue.setIdentifier(QTI21Constants.FEEDBACKBASIC_IDENTIFIER);
    responseCondition.getResponseRules().add(correctOutcomeValue);
    BaseValue correctValue = new BaseValue(correctOutcomeValue);
    correctValue.setBaseTypeAttrValue(BaseType.IDENTIFIER);
    correctValue.setSingleValue(QTI21Constants.CORRECT_IDENTIFIER_VALUE);
    correctOutcomeValue.setExpression(correctValue);
}
Also used : SetOutcomeValue(uk.ac.ed.ph.jqtiplus.node.item.response.processing.SetOutcomeValue) BaseValue(uk.ac.ed.ph.jqtiplus.node.expression.general.BaseValue)

Example 9 with BaseValue

use of uk.ac.ed.ph.jqtiplus.node.expression.general.BaseValue in project OpenOLAT by OpenOLAT.

the class AssessmentTestBuilder method buildCutValue.

/*	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>
	*/
private void buildCutValue() {
    if (cutValue != null) {
        OutcomeDeclaration passDeclaration = assessmentTest.getOutcomeDeclaration(QTI21Constants.PASS_IDENTIFIER);
        if (passDeclaration == null) {
            passDeclaration = AssessmentTestFactory.createOutcomeDeclaration(assessmentTest, QTI21Constants.PASS_IDENTIFIER, false);
            assessmentTest.getOutcomeDeclarations().add(passDeclaration);
        }
        boolean updated = false;
        if (cutValueRule != null && cutValueRule.getOutcomeIf().getExpressions().size() > 0) {
            Expression gte = cutValueRule.getOutcomeIf().getExpressions().get(0);
            if (gte.getExpressions().size() > 1) {
                Expression baseValue = gte.getExpressions().get(1);
                if (baseValue instanceof BaseValue) {
                    BaseValue value = (BaseValue) baseValue;
                    value.setSingleValue(new FloatValue(cutValue.doubleValue()));
                    updated = true;
                }
            }
        }
        if (!updated) {
            assessmentTest.getOutcomeProcessing().getOutcomeRules().remove(cutValueRule);
            cutValueRule = AssessmentTestFactory.createCutValueRule(assessmentTest, cutValue);
            assessmentTest.getOutcomeProcessing().getOutcomeRules().add(cutValueRule);
        }
    } else if (cutValueRule != null) {
        assessmentTest.getOutcomeProcessing().getOutcomeRules().remove(cutValueRule);
    }
}
Also used : Expression(uk.ac.ed.ph.jqtiplus.node.expression.Expression) BaseValue(uk.ac.ed.ph.jqtiplus.node.expression.general.BaseValue) FloatValue(uk.ac.ed.ph.jqtiplus.value.FloatValue) OutcomeDeclaration(uk.ac.ed.ph.jqtiplus.node.outcome.declaration.OutcomeDeclaration)

Example 10 with BaseValue

use of uk.ac.ed.ph.jqtiplus.node.expression.general.BaseValue in project OpenOLAT by OpenOLAT.

the class TestFeedbackBuilder method findFeedbackRuleInExpression.

private boolean findFeedbackRuleInExpression(Expression expression, Identifier feedbackIdentifier) {
    if (expression instanceof BaseValue) {
        BaseValue bValue = (BaseValue) expression;
        SingleValue sValue = bValue.getSingleValue();
        if (sValue instanceof IdentifierValue) {
            IdentifierValue iValue = (IdentifierValue) sValue;
            if (feedbackIdentifier.equals(iValue.identifierValue())) {
                return true;
            }
        }
    } else {
        List<Expression> childExpressions = expression.getExpressions();
        for (Expression childExpression : childExpressions) {
            if (findFeedbackRuleInExpression(childExpression, feedbackIdentifier)) {
                return true;
            }
        }
    }
    return false;
}
Also used : SingleValue(uk.ac.ed.ph.jqtiplus.value.SingleValue) Expression(uk.ac.ed.ph.jqtiplus.node.expression.Expression) BaseValue(uk.ac.ed.ph.jqtiplus.node.expression.general.BaseValue) IdentifierValue(uk.ac.ed.ph.jqtiplus.value.IdentifierValue)

Aggregations

BaseValue (uk.ac.ed.ph.jqtiplus.node.expression.general.BaseValue)56 SetOutcomeValue (uk.ac.ed.ph.jqtiplus.node.item.response.processing.SetOutcomeValue)42 Variable (uk.ac.ed.ph.jqtiplus.node.expression.general.Variable)40 ResponseIf (uk.ac.ed.ph.jqtiplus.node.item.response.processing.ResponseIf)38 Match (uk.ac.ed.ph.jqtiplus.node.expression.operator.Match)24 Sum (uk.ac.ed.ph.jqtiplus.node.expression.operator.Sum)24 ResponseElse (uk.ac.ed.ph.jqtiplus.node.item.response.processing.ResponseElse)20 IdentifierValue (uk.ac.ed.ph.jqtiplus.value.IdentifierValue)20 Correct (uk.ac.ed.ph.jqtiplus.node.expression.general.Correct)18 ResponseCondition (uk.ac.ed.ph.jqtiplus.node.item.response.processing.ResponseCondition)18 IsNull (uk.ac.ed.ph.jqtiplus.node.expression.operator.IsNull)16 MapResponse (uk.ac.ed.ph.jqtiplus.node.expression.general.MapResponse)14 And (uk.ac.ed.ph.jqtiplus.node.expression.operator.And)14 ComplexReferenceIdentifier (uk.ac.ed.ph.jqtiplus.types.ComplexReferenceIdentifier)14 FloatValue (uk.ac.ed.ph.jqtiplus.value.FloatValue)12 ResponseElseIf (uk.ac.ed.ph.jqtiplus.node.item.response.processing.ResponseElseIf)10 Expression (uk.ac.ed.ph.jqtiplus.node.expression.Expression)8 Multiple (uk.ac.ed.ph.jqtiplus.node.expression.operator.Multiple)8 SingleValue (uk.ac.ed.ph.jqtiplus.value.SingleValue)8 Equal (uk.ac.ed.ph.jqtiplus.node.expression.operator.Equal)6