use of uk.ac.ed.ph.jqtiplus.value.IdentifierValue in project openolat by klemens.
the class AssessmentItemFactory method createModalFeedbackRuleWithConditions.
public static ResponseCondition createModalFeedbackRuleWithConditions(ResponseProcessing responseProcessing, Identifier feedbackIdentifier, Identifier responseIdentifier, Cardinality cardinality, List<ModalFeedbackCondition> conditions) {
ResponseCondition rule = new ResponseCondition(responseProcessing);
/*
<responseCondition>
<responseIf>
<and>
<equal toleranceMode="exact">
<variable identifier="SCORE" />
<baseValue baseType="float">
4
</baseValue>
</equal>
</and>
<setOutcomeValue identifier="FEEDBACKMODAL">
<multiple>
<variable identifier="FEEDBACKMODAL" />
<baseValue baseType="identifier">
Feedback2074019497
</baseValue>
</multiple>
</setOutcomeValue>
</responseIf>
</responseCondition>
*/
ResponseIf responseIf = new ResponseIf(rule);
rule.setResponseIf(responseIf);
{
// rule
And and = new And(responseIf);
responseIf.getExpressions().add(and);
for (ModalFeedbackCondition condition : conditions) {
appendModalFeedbackCondition(condition, responseIdentifier, cardinality, and);
}
}
{
// outcome
SetOutcomeValue feedbackVar = new SetOutcomeValue(responseIf);
feedbackVar.setIdentifier(QTI21Constants.FEEDBACKMODAL_IDENTIFIER);
Multiple multiple = new Multiple(feedbackVar);
feedbackVar.setExpression(multiple);
Variable variable = new Variable(multiple);
variable.setIdentifier(ComplexReferenceIdentifier.parseString(QTI21Constants.FEEDBACKMODAL));
multiple.getExpressions().add(variable);
BaseValue feedbackVal = new BaseValue(feedbackVar);
feedbackVal.setBaseTypeAttrValue(BaseType.IDENTIFIER);
feedbackVal.setSingleValue(new IdentifierValue(feedbackIdentifier));
multiple.getExpressions().add(feedbackVal);
responseIf.getResponseRules().add(feedbackVar);
}
return rule;
}
use of uk.ac.ed.ph.jqtiplus.value.IdentifierValue in project openolat by klemens.
the class AssessmentItemFactory method createModalFeedbackBasicRule.
public static ResponseCondition createModalFeedbackBasicRule(ResponseProcessing responseProcessing, Identifier feedbackIdentifier, String inCorrect, boolean hint) {
ResponseCondition rule = new ResponseCondition(responseProcessing);
/*
<responseIf>
<and>
<match>
<baseValue baseType="identifier">correct</baseValue>
<variable identifier="FEEDBACKBASIC" />
</match>
</and>
<setOutcomeValue identifier="FEEDBACKMODAL">
<multiple>
<variable identifier="FEEDBACKMODAL" />
<baseValue baseType="identifier">Feedback261171147</baseValue>
</multiple>
</setOutcomeValue>
</responseIf>
*/
ResponseIf responseIf = new ResponseIf(rule);
rule.setResponseIf(responseIf);
{
// rule
And and = new And(responseIf);
responseIf.getExpressions().add(and);
Match match = new Match(and);
and.getExpressions().add(match);
BaseValue feedbackVal = new BaseValue(match);
feedbackVal.setBaseTypeAttrValue(BaseType.IDENTIFIER);
feedbackVal.setSingleValue(new IdentifierValue(inCorrect));
match.getExpressions().add(feedbackVal);
Variable variable = new Variable(match);
variable.setIdentifier(ComplexReferenceIdentifier.parseString(QTI21Constants.FEEDBACKBASIC));
match.getExpressions().add(variable);
// not match the HINT
if (hint) {
IsNull isNull = new IsNull(and);
and.getExpressions().add(isNull);
Variable hintVar = new Variable(isNull);
hintVar.setIdentifier(QTI21Constants.HINT_FEEDBACKMODAL_CLX_IDENTIFIER);
isNull.getExpressions().add(hintVar);
}
}
{
// outcome
SetOutcomeValue feedbackVar = new SetOutcomeValue(responseIf);
feedbackVar.setIdentifier(QTI21Constants.FEEDBACKMODAL_IDENTIFIER);
Multiple multiple = new Multiple(feedbackVar);
feedbackVar.setExpression(multiple);
Variable variable = new Variable(multiple);
variable.setIdentifier(ComplexReferenceIdentifier.parseString(QTI21Constants.FEEDBACKMODAL));
multiple.getExpressions().add(variable);
BaseValue feedbackVal = new BaseValue(feedbackVar);
feedbackVal.setBaseTypeAttrValue(BaseType.IDENTIFIER);
feedbackVal.setSingleValue(new IdentifierValue(feedbackIdentifier));
multiple.getExpressions().add(feedbackVal);
responseIf.getResponseRules().add(feedbackVar);
}
return rule;
}
use of uk.ac.ed.ph.jqtiplus.value.IdentifierValue in project openolat by klemens.
the class AssessmentItemFactory method appendVariableBaseValue.
/*
<variable identifier="SCORE" />
<baseValue baseType="float">4</baseValue>
*/
/**
* @param var
* @param value
* @param responseIdentifier
* @param parentExpression
* @param reverse if true, reverse the order, first baseValue and then variable
*/
private static void appendVariableBaseValue(ModalFeedbackCondition.Variable var, String value, Identifier responseIdentifier, Expression parentExpression, boolean reverse) {
Variable variable = new Variable(parentExpression);
BaseValue bValue = new BaseValue(parentExpression);
if (reverse) {
parentExpression.getExpressions().add(bValue);
parentExpression.getExpressions().add(variable);
} else {
parentExpression.getExpressions().add(variable);
parentExpression.getExpressions().add(bValue);
}
switch(var) {
case score:
bValue.setBaseTypeAttrValue(BaseType.FLOAT);
bValue.setSingleValue(new FloatValue(Double.parseDouble(value)));
variable.setIdentifier(QTI21Constants.SCORE_CLX_IDENTIFIER);
break;
case attempts:
bValue.setBaseTypeAttrValue(BaseType.INTEGER);
bValue.setSingleValue(new IntegerValue(Integer.parseInt(value)));
variable.setIdentifier(QTI21Constants.NUM_ATTEMPTS_CLX_IDENTIFIER);
break;
case response:
bValue.setBaseTypeAttrValue(BaseType.IDENTIFIER);
bValue.setSingleValue(new IdentifierValue(Identifier.parseString(value)));
variable.setIdentifier(ComplexReferenceIdentifier.parseString(responseIdentifier.toString()));
break;
}
}
use of uk.ac.ed.ph.jqtiplus.value.IdentifierValue in project openolat by klemens.
the class AssessmentItemFactory method appendIdentifierValue.
private static void appendIdentifierValue(CorrectResponse correctResponse, Identifier correctResponseId) {
FieldValue fieldValue = new FieldValue(correctResponse);
IdentifierValue identifierValue = new IdentifierValue(correctResponseId);
fieldValue.setSingleValue(identifierValue);
correctResponse.getFieldValues().add(fieldValue);
}
use of uk.ac.ed.ph.jqtiplus.value.IdentifierValue in project openolat by klemens.
the class AssessmentRenderFunctionsTest method valueContains_multipleValues.
@Test
public void valueContains_multipleValues() {
Value identifierValues = MultipleValue.createMultipleValue(new IdentifierValue(Identifier.parseString("reference-id")), new IdentifierValue(Identifier.parseString("reference-id")));
Assert.assertTrue(AssessmentRenderFunctions.valueContains(identifierValues, Identifier.parseString("reference-id")));
Assert.assertFalse(AssessmentRenderFunctions.valueContains(identifierValues, Identifier.parseString("noid")));
}
Aggregations