Merge branch 'MDL-48773_m32v1' of https://github.com/sbourget/moodle
authorDan Poltawski <dan@moodle.com>
Tue, 23 Aug 2016 07:18:16 +0000 (08:18 +0100)
committerDan Poltawski <dan@moodle.com>
Tue, 23 Aug 2016 07:18:16 +0000 (08:18 +0100)
mod/choice/mod_form.php

index 8256390..512c051 100644 (file)
@@ -34,6 +34,12 @@ class mod_choice_mod_form extends moodleform_mod {
         $mform->addElement('selectyesno', 'allowupdate', get_string("allowupdate", "choice"));
 
         $mform->addElement('selectyesno', 'allowmultiple', get_string('allowmultiple', 'choice'));
+        if ($this->_instance) {
+            if ($DB->count_records('choice_answers', array('choiceid' => $this->_instance)) > 0) {
+                // Prevent user from toggeling the number of allowed answers once there are submissions.
+                $mform->freeze('allowmultiple');
+            }
+        }
 
         $mform->addElement('selectyesno', 'limitanswers', get_string('limitanswers', 'choice'));
         $mform->addHelpButton('limitanswers', 'limitanswers', 'choice');