Skip to content

Commit 187d2a2

Browse files
author
David Monllao
committed
Merge branch 'MDL-62532-35' of git://github.com/rezaies/moodle into MOODLE_35_STABLE
2 parents c6755d6 + b23e651 commit 187d2a2

File tree

2 files changed

+46
-0
lines changed

2 files changed

+46
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
@core @core_question @javascript
2+
Feature: The questions can be tagged
3+
In order to tag questions
4+
As a teacher
5+
I want to see the standard tags in the tags field
6+
7+
Background:
8+
Given the following "users" exist:
9+
| username | firstname | lastname | email |
10+
| teacher1 | Teacher | 1 | teacher1@example.com |
11+
And the following "courses" exist:
12+
| fullname | shortname | format |
13+
| Course 1 | C1 | weeks |
14+
And the following "course enrolments" exist:
15+
| user | course | role |
16+
| teacher1 | C1 | editingteacher |
17+
And the following "tags" exist:
18+
| name | isstandard |
19+
| foo | 1 |
20+
| bar | 1 |
21+
22+
Scenario: The tags autocomplete should include standard tags
23+
When I log in as "teacher1"
24+
And I am on "Course 1" course homepage
25+
And I navigate to "Questions" node in "Course administration > Question bank"
26+
And I press "Create a new question ..."
27+
And I set the field "item_qtype_truefalse" to "1"
28+
And I press "Add"
29+
And I expand all fieldsets
30+
And I open the autocomplete suggestions list
31+
Then "foo" "autocomplete_suggestions" should exist
32+
And "bar" "autocomplete_suggestions" should exist

question/type/edit_question_form.php

+14
Original file line numberDiff line numberDiff line change
@@ -316,6 +316,8 @@ protected function get_per_answer_fields($mform, $label, $gradeoptions,
316316
* @param object $mform The form being built
317317
*/
318318
protected function add_tag_fields($mform) {
319+
global $CFG, $DB;
320+
319321
$hastagcapability = question_has_capability_on($this->question, 'tag');
320322
// Is the question category in a course context?
321323
$qcontext = $this->categorycontext;
@@ -332,6 +334,18 @@ protected function add_tag_fields($mform) {
332334
foreach ($tags as $tag) {
333335
$tagstrings[$tag->name] = $tag->name;
334336
}
337+
338+
$showstandard = core_tag_area::get_showstandard('core_question', 'question');
339+
if ($showstandard != core_tag_tag::HIDE_STANDARD) {
340+
$namefield = empty($CFG->keeptagnamecase) ? 'name' : 'rawname';
341+
$standardtags = $DB->get_records('tag',
342+
array('isstandard' => 1, 'tagcollid' => core_tag_area::get_collection('core', 'question')),
343+
$namefield, 'id,' . $namefield);
344+
foreach ($standardtags as $standardtag) {
345+
$tagstrings[$standardtag->$namefield] = $standardtag->$namefield;
346+
}
347+
}
348+
335349
$options = [
336350
'tags' => true,
337351
'multiple' => true,

0 commit comments

Comments
 (0)