MDL-45376 Completion: Form locking is still not working right
authorsam marshall <s.marshall@open.ac.uk>
Thu, 1 May 2014 17:08:06 +0000 (18:08 +0100)
committersam marshall <s.marshall@open.ac.uk>
Thu, 1 May 2014 17:08:46 +0000 (18:08 +0100)
On submit of the form, it called 'freeze' on the completion-related
fields (even though they shouldn't have been frozen because you
already clicked the unlock button).

course/moodleform_mod.php

index 7dc4436..545a909 100644 (file)
@@ -224,8 +224,10 @@ abstract class moodleform_mod extends moodleform {
                 // is changed, maybe someone has completed it now)
                 $mform->getElement('completionunlocked')->setValue(1);
             } else {
-                // Has the element been unlocked?
-                if ($mform->exportValue('unlockcompletion')) {
+                // Has the element been unlocked, either by the button being pressed
+                // in this request, or the field already being set from a previous one?
+                if ($mform->exportValue('unlockcompletion') ||
+                        $mform->exportValue('completionunlocked')) {
                     // Yes, add in warning text and set the hidden variable
                     $mform->insertElementBefore(
                         $mform->createElement('static', 'completedunlocked',