Skip to content
Snippets Groups Projects
Commit b304d9d8 authored by srosse's avatar srosse
Browse files

OO-3526: better validation of inputs in the correction workflow

parent d9b06d5a
No related branches found
No related tags found
No related merge requests found
......@@ -159,6 +159,13 @@ public class CorrectionIdentityAssessmentItemController extends FormBasicControl
protected void doDispose() {
//
}
@Override
protected boolean validateFormLogic(UserRequest ureq) {
boolean allOk = super.validateFormLogic(ureq);
allOk &= identityInteractionsCtrl.validateFormLogic(ureq);
return allOk;
}
@Override
protected void formOK(UserRequest ureq) {
......@@ -175,13 +182,17 @@ public class CorrectionIdentityAssessmentItemController extends FormBasicControl
@Override
protected void formInnerEvent(UserRequest ureq, FormItem source, FormEvent event) {
if(saveNextQuestionButton == source) {
doSave();
fireEvent(ureq, Event.CHANGED_EVENT);
fireEvent(ureq, new NextAssessmentItemEvent());
if(identityInteractionsCtrl.validateFormLogic(ureq)) {
doSave();
fireEvent(ureq, Event.CHANGED_EVENT);
fireEvent(ureq, new NextAssessmentItemEvent());
}
} else if(saveBackOverviewButton == source) {
doSave();
fireEvent(ureq, Event.CHANGED_EVENT);
fireEvent(ureq, Event.BACK_EVENT);
if(identityInteractionsCtrl.validateFormLogic(ureq)) {
doSave();
fireEvent(ureq, Event.CHANGED_EVENT);
fireEvent(ureq, Event.BACK_EVENT);
}
} else {
super.formInnerEvent(ureq, source, event);
}
......
......@@ -374,10 +374,13 @@ public class CorrectionIdentityInteractionsController extends FormBasicControlle
el.clearError();
if(StringHelper.containsNonWhitespace(el.getValue())) {
Double minScore = QtiNodesExtractor.extractMinScore(assessmentItem);
Double maxScore = QtiNodesExtractor.extractMaxScore(assessmentItem);
try {
// check with the parse algorithm of BigDecimal first
new BigDecimal(el.getValue()).doubleValue();
Double minScore = QtiNodesExtractor.extractMinScore(assessmentItem);
Double maxScore = QtiNodesExtractor.extractMaxScore(assessmentItem);
double score = parseDouble(el);
boolean boundariesOk = true;
if(minScore != null && score < minScore.doubleValue()) {
......@@ -394,6 +397,7 @@ public class CorrectionIdentityInteractionsController extends FormBasicControlle
}
allOk &= boundariesOk;
} catch (NumberFormatException e) {
logWarn("Cannot parse the score: " + el.getValue(), null);
el.setErrorKey("error.double.format", null);
allOk &= false;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment