@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
setFormTitle("form.title", null);
UserCourseEnvironment userCourseEnv = assessedIdentityWrapper.getUserCourseEnvironment();
ScoreEvaluation scoreEval = userCourseEnv.getScoreAccounting().evalCourseNode(assessableCourseNode);
if (scoreEval == null) scoreEval = new ScoreEvaluation(null, null);
if (hasAttempts) {
attemptsValue = assessableCourseNode.getUserAttempts(userCourseEnv);
attempts = uifactory.addIntegerElement("attempts", "form.attempts", (attemptsValue == null ? 0 : attemptsValue.intValue()), formLayout);
attempts.setDisplaySize(3);
attempts.setMinValueCheck(0, null);
}
if (hasScore) {
min = assessableCourseNode.getMinScoreConfiguration();
max = assessableCourseNode.getMaxScoreConfiguration();
if (hasPassed) {
cut = assessableCourseNode.getCutValueConfiguration();
}
minVal = uifactory.addStaticTextElement("minval", "form.min", ((min == null) ? translate("form.valueUndefined") : min.toString()), formLayout);
maxVal = uifactory.addStaticTextElement("maxval", "form.max", ((max == null) ? translate("form.valueUndefined") : max.toString()), formLayout);
// Use init variables from wrapper, already loaded from db
scoreValue = scoreEval.getScore();
score = uifactory.addTextElement("score","form.score" , 10, "", formLayout);
score.setDisplaySize(4);
score.setExampleKey("form.score.rounded", null);
if (scoreValue != null) {
score.setValue(AssessmentHelper.getRoundedScore(scoreValue));
}
score.setRegexMatchCheck("(\\d+)||(\\d+\\.\\d{1,3})", "form.error.wrongFloat");
}
if (hasPassed) {
if (cut != null) {
// Display cut value if defined
cutVal = uifactory.addStaticTextElement(
"cutval","form.cut" ,
((cut == null) ? translate("form.valueUndefined") : cut.toString()),
formLayout
);
}
String[] trueFalseKeys = new String[] { "undefined", "true", "false" };
String[] passedNotPassedValues = new String[] {
translate("form.passed.undefined"),
translate("form.passed.true"),
translate("form.passed.false")
};
//passed = new StaticSingleSelectionElement("form.passed", trueFalseKeys, passedNotPassedValues);
passed = uifactory.addRadiosVertical("passed", "form.passed", formLayout, trueFalseKeys, passedNotPassedValues);
Boolean passedValue = scoreEval.getPassed();
passed.select(passedValue == null ? "undefined" :passedValue.toString(), true);
// When cut value is defined, no manual passed possible
passed.setEnabled(cut == null);
}