use of uk.ac.ed.ph.jqtiplus.value.FloatValue in project openolat by klemens.
the class AssessmentItemBuilder method extractMinScore.
private void extractMinScore() {
OutcomeDeclaration outcomeDeclaration = assessmentItem.getOutcomeDeclaration(MINSCORE_IDENTIFIER);
if (outcomeDeclaration != null) {
DefaultValue defaultValue = outcomeDeclaration.getDefaultValue();
if (defaultValue != null) {
Value minScoreValue = defaultValue.evaluate();
if (minScoreValue instanceof FloatValue) {
Double minScore = new Double(((FloatValue) minScoreValue).doubleValue());
minScoreBuilder = new ScoreBuilder(minScore, outcomeDeclaration);
}
}
}
}
use of uk.ac.ed.ph.jqtiplus.value.FloatValue in project openolat by klemens.
the class AssessmentItemFactory method appendFloatValue.
private static void appendFloatValue(CorrectResponse correctResponse, double response) {
FieldValue fieldValue = new FieldValue(correctResponse);
FloatValue identifierValue = new FloatValue(response);
fieldValue.setSingleValue(identifierValue);
correctResponse.getFieldValues().add(fieldValue);
}
use of uk.ac.ed.ph.jqtiplus.value.FloatValue in project openolat by klemens.
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.value.FloatValue in project openolat by klemens.
the class AssessmentTestFactory method createOutcomeDeclaration.
public static OutcomeDeclaration createOutcomeDeclaration(AssessmentTest assessmentTest, Identifier identifier, Double defaultValue) {
OutcomeDeclaration outcomeDeclaration = new OutcomeDeclaration(assessmentTest);
outcomeDeclaration.setIdentifier(identifier);
outcomeDeclaration.setCardinality(Cardinality.SINGLE);
outcomeDeclaration.setBaseType(BaseType.FLOAT);
DefaultValue defaultVal = new DefaultValue(outcomeDeclaration);
outcomeDeclaration.setDefaultValue(defaultVal);
FieldValue fieldValue = new FieldValue(defaultVal);
FloatValue identifierValue = new FloatValue(defaultValue);
fieldValue.setSingleValue(identifierValue);
defaultVal.getFieldValues().add(fieldValue);
return outcomeDeclaration;
}
use of uk.ac.ed.ph.jqtiplus.value.FloatValue in project openolat by klemens.
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;
}
Aggregations