From b71f21bda9211b0f817fb937067415d804023fd4 Mon Sep 17 00:00:00 2001 From: Simey Lameze Date: Thu, 5 Apr 2018 07:54:50 +0800 Subject: [PATCH] MDL-61837 core_question: replace tag fields on edit page --- question/type/edit_question_form.php | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/question/type/edit_question_form.php b/question/type/edit_question_form.php index c1e1666b28d..a371764ae02 100644 --- a/question/type/edit_question_form.php +++ b/question/type/edit_question_form.php @@ -327,8 +327,17 @@ abstract class question_edit_form extends question_wizard_form { $iseditingcontextcourseoractivity = !empty($editingcoursecontext); $mform->addElement('header', 'tagsheader', get_string('tags')); - $mform->addElement('tags', 'tags', get_string('tags'), - array('itemtype' => 'question', 'component' => 'core_question')); + $tags = \core_tag_tag::get_tags_by_area_in_contexts('core_question', 'question', $this->contexts->all()); + $tagstrings = []; + foreach ($tags as $tag) { + $tagstrings[$tag->name] = $tag->name; + } + $options = [ + 'tags' => true, + 'multiple' => true, + 'noselectionstring' => get_string('anytags', 'quiz'), + ]; + $mform->addElement('autocomplete', 'tags', get_string('tags'), $tagstrings, $options); if (!$hastagcapability) { $mform->hardFreeze('tags'); @@ -341,8 +350,7 @@ abstract class question_edit_form extends question_wizard_form { $coursetagheader = get_string('questionformtagheader', 'core_question', $editingcoursecontext->get_context_name(true)); $mform->addElement('header', 'coursetagsheader', $coursetagheader); - $mform->addElement('tags', 'coursetags', get_string('tags'), - array('itemtype' => 'question', 'component' => 'core_question')); + $mform->addElement('autocomplete', 'coursetags', get_string('tags'), $tagstrings, $options); if (!$hastagcapability) { $mform->hardFreeze('coursetags');