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

FXOLAT-393: block access to a test after first successful attempt

parent f9facfaa
No related branches found
No related tags found
No related merge requests found
...@@ -141,6 +141,8 @@ public class IQEditController extends ActivateableTabbableDefaultController impl ...@@ -141,6 +141,8 @@ public class IQEditController extends ActivateableTabbableDefaultController impl
public static final String CONFIG_KEY_SUMMARY = "summary"; public static final String CONFIG_KEY_SUMMARY = "summary";
/** configuration key: max attempts*/ /** configuration key: max attempts*/
public static final String CONFIG_KEY_ATTEMPTS = "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*/ /** configuration key: minimal score*/
public static final String CONFIG_KEY_MINSCORE = "minscore"; public static final String CONFIG_KEY_MINSCORE = "minscore";
/** configuration key: maximal score*/ /** configuration key: maximal score*/
...@@ -540,6 +542,7 @@ public class IQEditController extends ActivateableTabbableDefaultController impl ...@@ -540,6 +542,7 @@ public class IQEditController extends ActivateableTabbableDefaultController impl
// Only tests have a limitation on number of attempts // Only tests have a limitation on number of attempts
if (type.equals(AssessmentInstance.QMD_ENTRY_TYPE_ASSESS)) { if (type.equals(AssessmentInstance.QMD_ENTRY_TYPE_ASSESS)) {
moduleConfiguration.set(CONFIG_KEY_ATTEMPTS, modConfigForm.getAttempts()); moduleConfiguration.set(CONFIG_KEY_ATTEMPTS, modConfigForm.getAttempts());
moduleConfiguration.set(CONFIG_KEY_BLOCK_AFTER_SUCCESS, new Boolean(modConfigForm.isBlockAfterSuccess()));
} }
fireEvent(urequest, NodeEditController.NODECONFIG_CHANGED_EVENT); fireEvent(urequest, NodeEditController.NODECONFIG_CHANGED_EVENT);
......
...@@ -64,6 +64,7 @@ class IQEditForm extends FormBasicController { ...@@ -64,6 +64,7 @@ class IQEditForm extends FormBasicController {
private SelectionElement enableSuspend; private SelectionElement enableSuspend;
private SingleSelection summary; private SingleSelection summary;
private SelectionElement limitAttempts; private SelectionElement limitAttempts;
private SelectionElement blockAfterSuccess;
private IntegerElement attempts; private IntegerElement attempts;
private SingleSelection menuRenderOptions; private SingleSelection menuRenderOptions;
private SelectionElement scoreInfo; private SelectionElement scoreInfo;
...@@ -166,6 +167,11 @@ class IQEditForm extends FormBasicController { ...@@ -166,6 +167,11 @@ class IQEditForm extends FormBasicController {
attempts.setMinValueCheck(1, null); attempts.setMinValueCheck(1, null);
attempts.setMaxValueCheck(20, 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); uifactory.addSpacerElement("s1", formLayout, true);
// Only assessments have a limitation on number of attempts // Only assessments have a limitation on number of attempts
...@@ -176,6 +182,8 @@ class IQEditForm extends FormBasicController { ...@@ -176,6 +182,8 @@ class IQEditForm extends FormBasicController {
limitAttempts.select("xx", false); limitAttempts.select("xx", false);
limitAttempts.setVisible(false); limitAttempts.setVisible(false);
attempts.setVisible(false); attempts.setVisible(false);
blockAfterSuccess.select("xx", false);
blockAfterSuccess.setVisible(false);
} }
Boolean CdisplayMenu = (Boolean)modConfig.get(IQEditController.CONFIG_KEY_DISPLAYMENU); Boolean CdisplayMenu = (Boolean)modConfig.get(IQEditController.CONFIG_KEY_DISPLAYMENU);
...@@ -461,6 +469,10 @@ class IQEditForm extends FormBasicController { ...@@ -461,6 +469,10 @@ class IQEditForm extends FormBasicController {
return a == 0 ? null : attempts.getIntValue(); return a == 0 ? null : attempts.getIntValue();
} }
boolean isBlockAfterSuccess() {
return blockAfterSuccess.isSelected(0);
}
/** /**
* *
* @return true if only section title should be rendered * @return true if only section title should be rendered
......
...@@ -522,6 +522,17 @@ public class IQRunController extends BasicController implements GenericEventList ...@@ -522,6 +522,17 @@ public class IQRunController extends BasicController implements GenericEventList
AssessableCourseNode acn = (AssessableCourseNode)courseNode; // assessment nodes are assesable AssessableCourseNode acn = (AssessableCourseNode)courseNode; // assessment nodes are assesable
ScoreEvaluation scoreEval = acn.getUserScoreEvaluation(userCourseEnv); 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(); Identity identity = userCourseEnv.getIdentityEnvironment().getIdentity();
myContent.contextPut("score", AssessmentHelper.getRoundedScore(scoreEval.getScore())); myContent.contextPut("score", AssessmentHelper.getRoundedScore(scoreEval.getScore()));
myContent.contextPut("hasPassedValue", (scoreEval.getPassed() == null ? Boolean.FALSE : Boolean.TRUE)); myContent.contextPut("hasPassedValue", (scoreEval.getPassed() == null ? Boolean.FALSE : Boolean.TRUE));
......
...@@ -87,7 +87,7 @@ ...@@ -87,7 +87,7 @@
#end ##END of if showResultsOnHomePage ... #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> <div class="o_course_run_statusinfo">$r.translate("attempts.nomoreattempts")</div>
#if ($hasDisc) #if ($hasDisc)
<div class="o_course_run_disclaimer"> <div class="o_course_run_disclaimer">
......
...@@ -155,6 +155,7 @@ passed.yes=Bestanden ...@@ -155,6 +155,7 @@ passed.yes=Bestanden
passed.yourpassed=Status passed.yourpassed=Status
preview.points.set=Punkte f\u00FCr Vorschau wurden gesetzt. preview.points.set=Punkte f\u00FCr Vorschau wurden gesetzt.
qti.form.limit.attempts=Anzahl L\u00F6sungsversuche limitieren 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=Maximale Anzahl L\u00F6sungsversuche
qti.form.attempts.noLimit=unlimitiert qti.form.attempts.noLimit=unlimitiert
qti.form.date.end=bis qti.form.date.end=bis
......
...@@ -142,6 +142,7 @@ qti.form.date.start.error.mandatory=At least a starting date must be indicated. ...@@ -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.enablecancel=Allow to cancel
qti.form.enablesuspend=Allow to suspend qti.form.enablesuspend=Allow to suspend
qti.form.limit.attempts=Limit the number of attempts 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.menudisplay=Show menu navigation
qti.form.menuenable=Allow menu navigation qti.form.menuenable=Allow menu navigation
qti.form.menurender=Menu layout qti.form.menurender=Menu layout
......
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