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);
}
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;
}
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);
}
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);
}
}
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;
}
Aggregations