use of uk.ac.ed.ph.jqtiplus.value.BooleanValue in project openolat by klemens.
the class QTI21ServiceImpl method recordOutcomeVariable.
private void recordOutcomeVariable(AssessmentTestSession candidateSession, OutcomeVariable outcomeVariable, Map<Identifier, String> outcomes) {
Identifier identifier = outcomeVariable.getIdentifier();
Value computedValue = outcomeVariable.getComputedValue();
if (QtiConstants.VARIABLE_DURATION_IDENTIFIER.equals(identifier)) {
log.audit(candidateSession.getKey() + " :: " + outcomeVariable.getIdentifier() + " - " + stringifyQtiValue(computedValue));
} else if (QTI21Constants.SCORE_IDENTIFIER.equals(identifier)) {
if (computedValue instanceof NumberValue) {
double score = ((NumberValue) computedValue).doubleValue();
candidateSession.setScore(new BigDecimal(score));
}
} else if (QTI21Constants.PASS_IDENTIFIER.equals(identifier)) {
if (computedValue instanceof BooleanValue) {
boolean pass = ((BooleanValue) computedValue).booleanValue();
candidateSession.setPassed(pass);
}
}
try {
outcomes.put(identifier, stringifyQtiValue(computedValue));
} catch (Exception e) {
log.error("", e);
}
}
use of uk.ac.ed.ph.jqtiplus.value.BooleanValue in project OpenOLAT by OpenOLAT.
the class AssessmentTestDisplayController method processOutcomeVariables.
private void processOutcomeVariables(TestResult resultNode, TestPlanInfos testPlanInfos, boolean submit) {
Float score = null;
Boolean pass = null;
double completion = testPlanInfos.getCompletion();
for (final ItemVariable itemVariable : resultNode.getItemVariables()) {
if (itemVariable instanceof OutcomeVariable) {
OutcomeVariable outcomeVariable = (OutcomeVariable) itemVariable;
Identifier identifier = outcomeVariable.getIdentifier();
if (QTI21Constants.SCORE_IDENTIFIER.equals(identifier)) {
Value value = itemVariable.getComputedValue();
if (value instanceof NumberValue) {
score = (float) ((NumberValue) value).doubleValue();
}
} else if (QTI21Constants.PASS_IDENTIFIER.equals(identifier)) {
Value value = itemVariable.getComputedValue();
if (value instanceof BooleanValue) {
pass = ((BooleanValue) value).booleanValue();
}
}
}
}
if (submit) {
outcomesListener.submit(score, pass, completion, candidateSession.getKey());
} else if (candidateSession != null && candidateSession.getFinishTime() == null) {
// don't change the outcome if the test is finished
outcomesListener.updateOutcomes(score, pass, completion);
}
}
use of uk.ac.ed.ph.jqtiplus.value.BooleanValue in project OpenOLAT by OpenOLAT.
the class TestFeedbackBuilder method findBaseValue.
private boolean findBaseValue(Expression expression, boolean value) {
if (expression instanceof BaseValue) {
BaseValue bValue = (BaseValue) expression;
SingleValue sValue = bValue.getSingleValue();
if (sValue instanceof BooleanValue) {
BooleanValue booleanValue = (BooleanValue) sValue;
return booleanValue.booleanValue() == value;
}
}
return false;
}
use of uk.ac.ed.ph.jqtiplus.value.BooleanValue in project OpenOLAT by OpenOLAT.
the class AssessmentTestFactory method createOutcomeDeclaration.
public static OutcomeDeclaration createOutcomeDeclaration(AssessmentTest assessmentTest, Identifier identifier, boolean defaultValue) {
OutcomeDeclaration outcomeDeclaration = new OutcomeDeclaration(assessmentTest);
outcomeDeclaration.setIdentifier(identifier);
outcomeDeclaration.setCardinality(Cardinality.SINGLE);
outcomeDeclaration.setBaseType(BaseType.BOOLEAN);
DefaultValue defaultVal = new DefaultValue(outcomeDeclaration);
outcomeDeclaration.setDefaultValue(defaultVal);
FieldValue fieldValue = new FieldValue(defaultVal);
BooleanValue booleanValue = defaultValue ? BooleanValue.TRUE : BooleanValue.FALSE;
fieldValue.setSingleValue(booleanValue);
defaultVal.getFieldValues().add(fieldValue);
return outcomeDeclaration;
}
use of uk.ac.ed.ph.jqtiplus.value.BooleanValue in project openolat by klemens.
the class AssessmentTestDisplayController method processOutcomeVariables.
private void processOutcomeVariables(TestResult resultNode, TestPlanInfos testPlanInfos, boolean submit) {
Float score = null;
Boolean pass = null;
double completion = testPlanInfos.getCompletion();
for (final ItemVariable itemVariable : resultNode.getItemVariables()) {
if (itemVariable instanceof OutcomeVariable) {
OutcomeVariable outcomeVariable = (OutcomeVariable) itemVariable;
Identifier identifier = outcomeVariable.getIdentifier();
if (QTI21Constants.SCORE_IDENTIFIER.equals(identifier)) {
Value value = itemVariable.getComputedValue();
if (value instanceof NumberValue) {
score = (float) ((NumberValue) value).doubleValue();
}
} else if (QTI21Constants.PASS_IDENTIFIER.equals(identifier)) {
Value value = itemVariable.getComputedValue();
if (value instanceof BooleanValue) {
pass = ((BooleanValue) value).booleanValue();
}
}
}
}
if (submit) {
outcomesListener.submit(score, pass, completion, candidateSession.getKey());
} else if (candidateSession != null && candidateSession.getFinishTime() == null) {
// don't change the outcome if the test is finished
outcomesListener.updateOutcomes(score, pass, completion);
}
}
Aggregations