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