Merge branch 'MDL-67042-master' of git://github.com/sarjona/moodle
This commit is contained in:
@@ -366,7 +366,9 @@ class main implements renderable, templatable {
|
||||
return [];
|
||||
}
|
||||
$field = \core_customfield\field_controller::create($fieldid);
|
||||
if (!$field->supports_course_grouping()) {
|
||||
$isvisible = $field->get_configdata_property('visibility') == \core_course\customfield\course_handler::VISIBLETOALL;
|
||||
// Only visible fields to everybody supporting course grouping will be displayed.
|
||||
if (!$field->supports_course_grouping() || !$isvisible) {
|
||||
return []; // The field shouldn't have been selectable in the global settings, but just skip it now.
|
||||
}
|
||||
$values = $field->course_grouping_format_values($values);
|
||||
|
||||
@@ -54,7 +54,7 @@ $string['courseprogress'] = 'Course progress:';
|
||||
$string['completepercent'] = '{$a}% complete';
|
||||
$string['customfield'] = 'Custom field';
|
||||
$string['customfiltergrouping'] = 'Field to use';
|
||||
$string['customfiltergrouping_nofields'] = 'This option requires a course custom field to be set up.';
|
||||
$string['customfiltergrouping_nofields'] = 'This option requires a course custom field to be set up and visible to everyone.';
|
||||
$string['displaycategories'] = 'Display categories';
|
||||
$string['displaycategories_help'] = 'Display the course category on dashboard course items including cards, list items and summary items.';
|
||||
$string['favourites'] = 'Starred';
|
||||
|
||||
@@ -13,14 +13,16 @@ Feature: The my overview block allows users to group courses by custom fields
|
||||
| Checkbox field | Course fields | checkbox | checkboxfield | |
|
||||
| Date field | Course fields | date | datefield | {"mindate":0, "maxdate":0} |
|
||||
| Select field | Course fields | select | selectfield | {"options":"Option 1\nOption 2\nOption 3\nOption 4"} |
|
||||
| Text field | Course fields | text | textfield | |
|
||||
| Text field | Course fields | text | textfield | {"visibility":"2"} |
|
||||
| Text field 2 | Course fields | text | textfield2 | {"visibility":"2"} |
|
||||
| Hidden field | Course fields | text | hiddenfield | {"visibility":"0"} |
|
||||
And the following "courses" exist:
|
||||
| fullname | shortname | category | customfield_checkboxfield | customfield_datefield | customfield_selectfield | customfield_textfield |
|
||||
| Course 1 | C1 | 0 | 1 | 981028800 | 1 | fish |
|
||||
| Course 2 | C2 | 0 | 0 | 334324800 | | |
|
||||
| Course 3 | C3 | 0 | 0 | 981028800 | 2 | dog |
|
||||
| Course 4 | C4 | 0 | 1 | | 3 | cat |
|
||||
| Course 5 | C5 | 0 | | 334411200 | 2 | fish |
|
||||
| fullname | shortname | category | customfield_checkboxfield | customfield_datefield | customfield_selectfield | customfield_textfield | customfield_textfield2 |
|
||||
| Course 1 | C1 | 0 | 1 | 981028800 | 1 | fish | penguin |
|
||||
| Course 2 | C2 | 0 | 0 | 334324800 | | | |
|
||||
| Course 3 | C3 | 0 | 0 | 981028800 | 2 | dog | |
|
||||
| Course 4 | C4 | 0 | 1 | | 3 | cat | |
|
||||
| Course 5 | C5 | 0 | | 334411200 | 2 | fish | penguin |
|
||||
And the following "course enrolments" exist:
|
||||
| user | course | role |
|
||||
| student1 | C1 | student |
|
||||
@@ -172,3 +174,24 @@ Feature: The my overview block allows users to group courses by custom fields
|
||||
And I should not see "Course 3" in the "Course overview" "block"
|
||||
And I should not see "Course 4" in the "Course overview" "block"
|
||||
And I should not see "Course 5" in the "Course overview" "block"
|
||||
|
||||
Scenario: Hidden fields not displayed when configuring the custom field filters
|
||||
Given I log in as "admin"
|
||||
When I navigate to "Plugins > Blocks > Course overview" in site administration
|
||||
And I set the field "Custom field" to "1"
|
||||
Then the "Field to use" select box should not contain "Hidden field"
|
||||
|
||||
Scenario: Hidden fields not displayed in the filter
|
||||
Given the following config values are set as admin:
|
||||
| displaygroupingcustomfield | 1 | block_myoverview |
|
||||
| customfiltergrouping | textfield2 | block_myoverview |
|
||||
And I log in as "admin"
|
||||
And I navigate to "Courses > Course custom fields" in site administration
|
||||
And I click on "Edit" "link" in the "Text field 2" "table_row"
|
||||
And I set the field "Visible to" to "Nobody"
|
||||
And I press "Save changes"
|
||||
And I log out
|
||||
When I log in as "student1"
|
||||
And I click on "All (except removed from view)" "button" in the "Course overview" "block"
|
||||
Then I should not see "penguin" in the "Course overview" "block"
|
||||
Then I should not see "No text field" in the "Course overview" "block"
|
||||
|
||||
@@ -431,7 +431,9 @@ class api {
|
||||
$fields = $DB->get_records_sql($sql);
|
||||
foreach ($fields as $field) {
|
||||
$inst = field_controller::create(0, $field);
|
||||
if ($inst->supports_course_grouping()) {
|
||||
$isvisible = $inst->get_configdata_property('visibility') == \core_course\customfield\course_handler::VISIBLETOALL;
|
||||
// Only visible fields to everybody supporting course grouping will be displayed.
|
||||
if ($inst->supports_course_grouping() && $isvisible) {
|
||||
$ret[$inst->get('shortname')] = $inst->get('name');
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -35,7 +35,7 @@ $string['customfield_islocked'] = 'Locked';
|
||||
$string['customfield_islocked_help'] = 'If the field is locked, only users with the capability to change locked custom fields (by default users with the default role of manager only) will be able to change it in the course settings.';
|
||||
$string['customfield_notvisible'] = 'Nobody';
|
||||
$string['customfield_visibility'] = 'Visible to';
|
||||
$string['customfield_visibility_help'] = 'This setting determines who can view the custom field name and value in the list of courses.';
|
||||
$string['customfield_visibility_help'] = 'This setting determines who can view the custom field name and value in the list of courses or in the available custom field filter of the Dashboard.';
|
||||
$string['customfield_visibletoall'] = 'Everyone';
|
||||
$string['customfield_visibletoteachers'] = 'Teachers';
|
||||
$string['customfieldsettings'] = 'Common course custom fields settings';
|
||||
|
||||
Reference in New Issue
Block a user