MDL-61444 question: freeze element for users without caps
authorSimey Lameze <simey@moodle.com>
Thu, 22 Feb 2018 01:44:15 +0000 (09:44 +0800)
committerSimey Lameze <simey@moodle.com>
Thu, 22 Feb 2018 01:44:15 +0000 (09:44 +0800)
question/type/edit_question_form.php

index bdc48a9..dd3be4b 100644 (file)
@@ -201,13 +201,16 @@ abstract class question_edit_form extends question_wizard_form {
         // Any questiontype specific fields.
         $this->definition_inner($mform);
 
-        if (core_tag_tag::is_enabled('core_question', 'question')
-                && question_has_capability_on($this->question, 'tag')) {
+        if (core_tag_tag::is_enabled('core_question', 'question')) {
             $mform->addElement('header', 'tagsheader', get_string('tags'));
-        }
-        $mform->addElement('tags', 'tags', get_string('tags'),
+            $mform->addElement('tags', 'tags', get_string('tags'),
                 array('itemtype' => 'question', 'component' => 'core_question'));
 
+            if (!question_has_capability_on($this->question, 'tag')) {
+                $mform->freeze('tags');
+            }
+        }
+
         if (!empty($this->question->id)) {
             $mform->addElement('header', 'createdmodifiedheader',
                     get_string('createdmodifiedheader', 'question'));