diff --git a/src/main/java/org/olat/ims/qti21/ui/editor/_i18n/LocalStrings_de.properties b/src/main/java/org/olat/ims/qti21/ui/editor/_i18n/LocalStrings_de.properties index 89d5382b0405d2a2fe447eb66a7a5cf2ec2f198d..e71fe9fefb33183ed910d81a91d492937dc60c5a 100644 --- a/src/main/java/org/olat/ims/qti21/ui/editor/_i18n/LocalStrings_de.properties +++ b/src/main/java/org/olat/ims/qti21/ui/editor/_i18n/LocalStrings_de.properties @@ -45,6 +45,7 @@ error.cardinality.answer=Single choice erlaubt nur eine korrekte Antwort. error.double=$org.olat.ims.qti21.ui\:error.double error.import.question=Die Frage konnte wegen eine unerwartete Fehler nicht importiert werden error.integer=$org.olat.ims.qti21.ui\:error.integer +error.integer.positive=Es muss ein Zahl zwischen 0 und 2147483647. error.lock=Dieser Test/Fragebogen wird momentan vom Benutzer {0} editiert und ist deshalb gesperrt. error.lock.title=Test gesperrt error.lower.tolerance=Die untere Schranke muss kleiner - gleich als die L\u00F6sung sein. diff --git a/src/main/java/org/olat/ims/qti21/ui/editor/_i18n/LocalStrings_en.properties b/src/main/java/org/olat/ims/qti21/ui/editor/_i18n/LocalStrings_en.properties index 65e5c09e4169a8be00946332b22e909a026a2984..00ce39b1e06715ba0bdc35b111ae5681f0355385 100644 --- a/src/main/java/org/olat/ims/qti21/ui/editor/_i18n/LocalStrings_en.properties +++ b/src/main/java/org/olat/ims/qti21/ui/editor/_i18n/LocalStrings_en.properties @@ -45,6 +45,7 @@ error.cardinality.answer=Single choice allow only one correct answer. error.double=$org.olat.ims.qti21.ui\:error.double error.import.question=An unexpected error happens during import of a question. error.integer=$org.olat.ims.qti21.ui\:error.integer +error.integer.positive=It needs a number between 0 and 2147483647. error.lock=This test/questionnaire is being edited by user {0} at the moment and therefore locked. error.lock.title=Test locked error.lower.tolerance=The lower bound need to be smaller than or equal to the solution. diff --git a/src/main/java/org/olat/ims/qti21/ui/editor/_i18n/LocalStrings_fr.properties b/src/main/java/org/olat/ims/qti21/ui/editor/_i18n/LocalStrings_fr.properties index 883270a3cb00791e8bc4303601d3a2a032602458..89faacda1d3a88f06a5ec444418577d72f1f36bd 100644 --- a/src/main/java/org/olat/ims/qti21/ui/editor/_i18n/LocalStrings_fr.properties +++ b/src/main/java/org/olat/ims/qti21/ui/editor/_i18n/LocalStrings_fr.properties @@ -46,6 +46,7 @@ error.cardinality.answer=Choix simple n'autorise qu'une seule r\u00E9ponse corre error.double=$org.olat.ims.qti21.ui\:error.double error.import.question=Une erreur inattendue s'est produite pendant l'importation de la question. error.integer=$org.olat.ims.qti21.ui\:error.integer +error.integer.positive=Le nombre doit se situer entre 0 et 2147483647. error.lock=Ce test / questionnaire est \u00E9dit\u00E9 par {0} en ce moment et est bloqu\u00E9. error.lock.title=Test bloqu\u00E9 error.lower.tolerance=La limite inf\u00E9rieure doit \u00EAtre plus petite ou \u00E9gale \u00E0 la solution. diff --git a/src/main/java/org/olat/ims/qti21/ui/editor/interactions/EssayEditorController.java b/src/main/java/org/olat/ims/qti21/ui/editor/interactions/EssayEditorController.java index bde5a2dd3f39088978f480f61e55e0d084e6c1d3..5bdc4dba55c315b72330939b0fdd83fec4ea2e74 100644 --- a/src/main/java/org/olat/ims/qti21/ui/editor/interactions/EssayEditorController.java +++ b/src/main/java/org/olat/ims/qti21/ui/editor/interactions/EssayEditorController.java @@ -146,7 +146,7 @@ public class EssayEditorController extends FormBasicController { public Integer getValue(TextElement integerEl) { String val = integerEl.getValue(); Integer integer = null; - if(StringHelper.isLong(val)) { + if(isInteger(val)) { return Integer.parseInt(val); } return integer; @@ -154,7 +154,7 @@ public class EssayEditorController extends FormBasicController { @Override protected boolean validateFormLogic(UserRequest ureq) { - boolean allOk = true; + boolean allOk = super.validateFormLogic(ureq); titleEl.clearError(); if(!StringHelper.containsNonWhitespace(titleEl.getValue())) { @@ -166,7 +166,7 @@ public class EssayEditorController extends FormBasicController { allOk &= validateInteger(heightEl); allOk &= validateInteger(minWordsEl); allOk &= validateInteger(maxWordsEl); - return allOk & super.validateFormLogic(ureq); + return allOk; } private boolean validateInteger(TextElement integerEl) { @@ -177,11 +177,26 @@ public class EssayEditorController extends FormBasicController { if(!StringHelper.isLong(integerEl.getValue())) { integerEl.setErrorKey("form.error.nointeger", null); allOk &= false; + } else if(!isInteger(integerEl.getValue())) { + integerEl.setErrorKey("error.integer.positive", null); + allOk &= false; } } return allOk; } + + private boolean isInteger(String val) { + if(StringHelper.isLong(val)) { + try { + int num = Integer.parseInt(val); + return num >= 0; + } catch(NumberFormatException e) { + return false; + } + } + return false; + } @Override protected void formOK(UserRequest ureq) {