mirror of
https://github.com/moodle/moodle.git
synced 2025-03-21 08:00:37 +01:00
Merge branch 'MDL-65958-master-v3' of git://github.com/lameze/moodle
This commit is contained in:
commit
3eb551e809
@ -98,7 +98,7 @@ trait eventtype {
|
||||
$mform->hideIf('categoryid', 'eventtype', 'noteq', 'category');
|
||||
}
|
||||
|
||||
$showall = $CFG->calendar_adminseesall && !has_capability('moodle/calendar:manageentries', \context_system::instance());
|
||||
$showall = is_siteadmin() && !empty($CFG->calendar_adminseesall);
|
||||
if (!empty($eventtypes['course'])) {
|
||||
$mform->addElement('course', 'courseid', get_string('course'), ['limittoenrolled' => !$showall]);
|
||||
$mform->hideIf('courseid', 'eventtype', 'noteq', 'course');
|
||||
|
@ -3691,7 +3691,7 @@ function calendar_get_allowed_event_types(int $courseid = null) {
|
||||
|
||||
$types['user'] = has_capability('moodle/calendar:manageownentries', $context);
|
||||
|
||||
if (has_capability('moodle/calendar:manageentries', $context) || !empty($CFG->calendar_adminseesall)) {
|
||||
if (has_capability('moodle/calendar:manageentries', $context)) {
|
||||
$types['course'] = true;
|
||||
|
||||
$types['group'] = (!empty($groups) && has_capability('moodle/site:accessallgroups', $context))
|
||||
|
@ -14,6 +14,8 @@ Feature: Perform basic calendar functionality
|
||||
And the following "courses" exist:
|
||||
| fullname | shortname | format |
|
||||
| Course 1 | C1 | topics |
|
||||
| Course 2 | C2 | topics |
|
||||
| Course 3 | C3 | topics |
|
||||
And the following "course enrolments" exist:
|
||||
| user | course | role |
|
||||
| student1 | C1 | student |
|
||||
@ -188,3 +190,51 @@ Feature: Perform basic calendar functionality
|
||||
And I follow "This month"
|
||||
When I click on "New event" "button"
|
||||
Then the field "Type of event" matches value "Course"
|
||||
|
||||
@javascript
|
||||
Scenario: Admin can only see all courses if calendar_adminseesall setting is enabled.
|
||||
Given I log in as "admin"
|
||||
And I am on "Course 1" course homepage
|
||||
And I enrol "admin" user as "Teacher"
|
||||
And I am viewing site calendar
|
||||
And I click on "New event" "button"
|
||||
And I set the field "Type of event" to "Course"
|
||||
When I open the autocomplete suggestions list
|
||||
Then I should see "Course 1" in the ".form-autocomplete-suggestions" "css_element"
|
||||
And I should not see "Course 2" in the ".form-autocomplete-suggestions" "css_element"
|
||||
And I should not see "Course 3" in the ".form-autocomplete-suggestions" "css_element"
|
||||
And I click on "Close" "button"
|
||||
And I am on site homepage
|
||||
And I navigate to "Appearance > Calendar" in site administration
|
||||
And I set the field "Admins see all" to "1"
|
||||
And I press "Save changes"
|
||||
And I am viewing site calendar
|
||||
And I click on "New event" "button"
|
||||
And I set the field "Type of event" to "Course"
|
||||
When I open the autocomplete suggestions list
|
||||
Then I should see "Course 1" in the ".form-autocomplete-suggestions" "css_element"
|
||||
And I should see "Course 2" in the ".form-autocomplete-suggestions" "css_element"
|
||||
And I should see "Course 3" in the ".form-autocomplete-suggestions" "css_element"
|
||||
|
||||
@javascript
|
||||
Scenario: Students can only see user event type by default.
|
||||
Given I log in as "student1"
|
||||
And I am viewing site calendar
|
||||
When I click on "New event" "button"
|
||||
Then I should see "User" in the "div#fitem_id_staticeventtype" "css_element"
|
||||
And I am on "Course 1" course homepage
|
||||
And I follow "This month"
|
||||
When I click on "New event" "button"
|
||||
Then I should see "User" in the "div#fitem_id_staticeventtype" "css_element"
|
||||
And I click on "Close" "button"
|
||||
And I log out
|
||||
Given I log in as "admin"
|
||||
And I navigate to "Appearance > Calendar" in site administration
|
||||
And I set the field "Admins see all" to "1"
|
||||
And I press "Save changes"
|
||||
And I log out
|
||||
Given I log in as "student1"
|
||||
And I am on "Course 1" course homepage
|
||||
And I follow "This month"
|
||||
When I click on "New event" "button"
|
||||
Then I should see "User" in the "div#fitem_id_staticeventtype" "css_element"
|
||||
|
Loading…
x
Reference in New Issue
Block a user