diff --git a/src/main/java/org/olat/course/nodes/iq/IQEditController.java b/src/main/java/org/olat/course/nodes/iq/IQEditController.java index aee887a04949f9740e563557a916eb8bdd85d6ae..08a5c3fb0a25dc9f97104a63d80413d75cc3147c 100644 --- a/src/main/java/org/olat/course/nodes/iq/IQEditController.java +++ b/src/main/java/org/olat/course/nodes/iq/IQEditController.java @@ -141,6 +141,8 @@ public class IQEditController extends ActivateableTabbableDefaultController impl public static final String CONFIG_KEY_SUMMARY = "summary"; /** configuration key: max attempts*/ public static final String CONFIG_KEY_ATTEMPTS = "attempts"; + /** configuration key: max attempts*/ + public static final String CONFIG_KEY_BLOCK_AFTER_SUCCESS = "blockAfterSuccess"; /** configuration key: minimal score*/ public static final String CONFIG_KEY_MINSCORE = "minscore"; /** configuration key: maximal score*/ @@ -540,6 +542,7 @@ public class IQEditController extends ActivateableTabbableDefaultController impl // Only tests have a limitation on number of attempts if (type.equals(AssessmentInstance.QMD_ENTRY_TYPE_ASSESS)) { moduleConfiguration.set(CONFIG_KEY_ATTEMPTS, modConfigForm.getAttempts()); + moduleConfiguration.set(CONFIG_KEY_BLOCK_AFTER_SUCCESS, new Boolean(modConfigForm.isBlockAfterSuccess())); } fireEvent(urequest, NodeEditController.NODECONFIG_CHANGED_EVENT); diff --git a/src/main/java/org/olat/course/nodes/iq/IQEditForm.java b/src/main/java/org/olat/course/nodes/iq/IQEditForm.java index 668ea302f54369e9dc889cc2aad0be6110f40e0b..a1298702ee247e19eef1e2ec40d3afaafb8859a8 100644 --- a/src/main/java/org/olat/course/nodes/iq/IQEditForm.java +++ b/src/main/java/org/olat/course/nodes/iq/IQEditForm.java @@ -64,6 +64,7 @@ class IQEditForm extends FormBasicController { private SelectionElement enableSuspend; private SingleSelection summary; private SelectionElement limitAttempts; + private SelectionElement blockAfterSuccess; private IntegerElement attempts; private SingleSelection menuRenderOptions; private SelectionElement scoreInfo; @@ -166,6 +167,11 @@ class IQEditForm extends FormBasicController { attempts.setMinValueCheck(1, null); attempts.setMaxValueCheck(20, null); + //add it + blockAfterSuccess = uifactory.addCheckboxesVertical("blockAfterSuccess", "qti.form.block.afterSuccess", formLayout, new String[]{"xx"}, new String[]{null}, null, 1); + Boolean block = (Boolean) modConfig.get(IQEditController.CONFIG_KEY_BLOCK_AFTER_SUCCESS); + blockAfterSuccess.select("xx", block == null ? false : block.booleanValue() ); + uifactory.addSpacerElement("s1", formLayout, true); // Only assessments have a limitation on number of attempts @@ -176,6 +182,8 @@ class IQEditForm extends FormBasicController { limitAttempts.select("xx", false); limitAttempts.setVisible(false); attempts.setVisible(false); + blockAfterSuccess.select("xx", false); + blockAfterSuccess.setVisible(false); } Boolean CdisplayMenu = (Boolean)modConfig.get(IQEditController.CONFIG_KEY_DISPLAYMENU); @@ -461,6 +469,10 @@ class IQEditForm extends FormBasicController { return a == 0 ? null : attempts.getIntValue(); } + boolean isBlockAfterSuccess() { + return blockAfterSuccess.isSelected(0); + } + /** * * @return true if only section title should be rendered diff --git a/src/main/java/org/olat/course/nodes/iq/IQRunController.java b/src/main/java/org/olat/course/nodes/iq/IQRunController.java index 68e250e53e96ecb2a94c1c512e95baef9789d727..71a47dbe28e0071c2cdd8ba9d19b280265f55dc2 100644 --- a/src/main/java/org/olat/course/nodes/iq/IQRunController.java +++ b/src/main/java/org/olat/course/nodes/iq/IQRunController.java @@ -522,6 +522,17 @@ public class IQRunController extends BasicController implements GenericEventList AssessableCourseNode acn = (AssessableCourseNode)courseNode; // assessment nodes are assesable ScoreEvaluation scoreEval = acn.getUserScoreEvaluation(userCourseEnv); + //block if test passed (and config set to check it) + Boolean blockAfterSuccess = (Boolean)modConfig.get(IQEditController.CONFIG_KEY_BLOCK_AFTER_SUCCESS); + Boolean blocked = Boolean.FALSE; + if(blockAfterSuccess != null && blockAfterSuccess.booleanValue()) { + Boolean passed = scoreEval.getPassed(); + if(passed != null && passed.booleanValue()) { + blocked = Boolean.TRUE; + } + } + myContent.contextPut("blockAfterSuccess", blocked ); + Identity identity = userCourseEnv.getIdentityEnvironment().getIdentity(); myContent.contextPut("score", AssessmentHelper.getRoundedScore(scoreEval.getScore())); myContent.contextPut("hasPassedValue", (scoreEval.getPassed() == null ? Boolean.FALSE : Boolean.TRUE)); diff --git a/src/main/java/org/olat/course/nodes/iq/_content/testrun.html b/src/main/java/org/olat/course/nodes/iq/_content/testrun.html index ed596803fb189842b8165e4a8b0186d40468b9aa..4e4cc44265219036ec4aa203316a39913495500c 100644 --- a/src/main/java/org/olat/course/nodes/iq/_content/testrun.html +++ b/src/main/java/org/olat/course/nodes/iq/_content/testrun.html @@ -87,7 +87,7 @@ #end ##END of if showResultsOnHomePage ... - #if ($attemptsConfig && $attemptsConfig > 0 && ($attemptsConfig <= $attempts)) + #if (($attemptsConfig && $attemptsConfig > 0 && ($attemptsConfig <= $attempts)) || $blockAfterSuccess) <div class="o_course_run_statusinfo">$r.translate("attempts.nomoreattempts")</div> #if ($hasDisc) <div class="o_course_run_disclaimer"> diff --git a/src/main/java/org/olat/course/nodes/iq/_i18n/LocalStrings_de.properties b/src/main/java/org/olat/course/nodes/iq/_i18n/LocalStrings_de.properties index 5bc6cf52ca09e7afd9d24c0287e183a6640fbefe..ec694592600cf7ddad3cfbf8ce7c95c0d6489989 100644 --- a/src/main/java/org/olat/course/nodes/iq/_i18n/LocalStrings_de.properties +++ b/src/main/java/org/olat/course/nodes/iq/_i18n/LocalStrings_de.properties @@ -155,6 +155,7 @@ passed.yes=Bestanden passed.yourpassed=Status preview.points.set=Punkte f\u00FCr Vorschau wurden gesetzt. qti.form.limit.attempts=Anzahl L\u00F6sungsversuche limitieren +qti.form.block.afterSuccess=Erster bestandener L\u00F6sungsversuch z\u00E4hlt qti.form.attempts=Maximale Anzahl L\u00F6sungsversuche qti.form.attempts.noLimit=unlimitiert qti.form.date.end=bis diff --git a/src/main/java/org/olat/course/nodes/iq/_i18n/LocalStrings_en.properties b/src/main/java/org/olat/course/nodes/iq/_i18n/LocalStrings_en.properties index 00d842467ad561a74bf213875e5f8fd8b039b67a..c766d7af116140515930c725712dfbf3ad1acd68 100644 --- a/src/main/java/org/olat/course/nodes/iq/_i18n/LocalStrings_en.properties +++ b/src/main/java/org/olat/course/nodes/iq/_i18n/LocalStrings_en.properties @@ -142,6 +142,7 @@ qti.form.date.start.error.mandatory=At least a starting date must be indicated. qti.form.enablecancel=Allow to cancel qti.form.enablesuspend=Allow to suspend qti.form.limit.attempts=Limit the number of attempts +qti.form.block.afterSuccess=First successful attempt count qti.form.menudisplay=Show menu navigation qti.form.menuenable=Allow menu navigation qti.form.menurender=Menu layout