mirror of
https://github.com/moodle/moodle.git
synced 2025-04-21 00:12:56 +02:00
Merge branch 'MDL-62532-master' of git://github.com/rezaies/moodle
This commit is contained in:
commit
8cb2821928
32
question/tests/behat/edit_questions_standard_tags.feature
Normal file
32
question/tests/behat/edit_questions_standard_tags.feature
Normal file
@ -0,0 +1,32 @@
|
||||
@core @core_question @javascript
|
||||
Feature: The questions can be tagged
|
||||
In order to tag questions
|
||||
As a teacher
|
||||
I want to see the standard tags in the tags field
|
||||
|
||||
Background:
|
||||
Given the following "users" exist:
|
||||
| username | firstname | lastname | email |
|
||||
| teacher1 | Teacher | 1 | teacher1@example.com |
|
||||
And the following "courses" exist:
|
||||
| fullname | shortname | format |
|
||||
| Course 1 | C1 | weeks |
|
||||
And the following "course enrolments" exist:
|
||||
| user | course | role |
|
||||
| teacher1 | C1 | editingteacher |
|
||||
And the following "tags" exist:
|
||||
| name | isstandard |
|
||||
| foo | 1 |
|
||||
| bar | 1 |
|
||||
|
||||
Scenario: The tags autocomplete should include standard tags
|
||||
When I log in as "teacher1"
|
||||
And I am on "Course 1" course homepage
|
||||
And I navigate to "Questions" node in "Course administration > Question bank"
|
||||
And I press "Create a new question ..."
|
||||
And I set the field "item_qtype_truefalse" to "1"
|
||||
And I press "Add"
|
||||
And I expand all fieldsets
|
||||
And I open the autocomplete suggestions list
|
||||
Then "foo" "autocomplete_suggestions" should exist
|
||||
And "bar" "autocomplete_suggestions" should exist
|
@ -316,6 +316,8 @@ abstract class question_edit_form extends question_wizard_form {
|
||||
* @param object $mform The form being built
|
||||
*/
|
||||
protected function add_tag_fields($mform) {
|
||||
global $CFG, $DB;
|
||||
|
||||
$hastagcapability = question_has_capability_on($this->question, 'tag');
|
||||
// Is the question category in a course context?
|
||||
$qcontext = $this->categorycontext;
|
||||
@ -332,6 +334,18 @@ abstract class question_edit_form extends question_wizard_form {
|
||||
foreach ($tags as $tag) {
|
||||
$tagstrings[$tag->name] = $tag->name;
|
||||
}
|
||||
|
||||
$showstandard = core_tag_area::get_showstandard('core_question', 'question');
|
||||
if ($showstandard != core_tag_tag::HIDE_STANDARD) {
|
||||
$namefield = empty($CFG->keeptagnamecase) ? 'name' : 'rawname';
|
||||
$standardtags = $DB->get_records('tag',
|
||||
array('isstandard' => 1, 'tagcollid' => core_tag_area::get_collection('core', 'question')),
|
||||
$namefield, 'id,' . $namefield);
|
||||
foreach ($standardtags as $standardtag) {
|
||||
$tagstrings[$standardtag->$namefield] = $standardtag->$namefield;
|
||||
}
|
||||
}
|
||||
|
||||
$options = [
|
||||
'tags' => true,
|
||||
'multiple' => true,
|
||||
|
Loading…
x
Reference in New Issue
Block a user