Skip to content

Commit

Permalink
Merge branch 'MDL-76061-master' of https://github.com/PhMemmel/moodle
Browse files Browse the repository at this point in the history
  • Loading branch information
junpataleta committed Jan 10, 2023
2 parents 025985f + b84005e commit 1a7a646
Show file tree
Hide file tree
Showing 2 changed files with 95 additions and 1 deletion.
3 changes: 2 additions & 1 deletion calendar/lib.php
Expand Up @@ -2360,7 +2360,8 @@ function calendar_edit_event_allowed($event, $manualedit = false) {
return has_capability('moodle/calendar:manageentries', $event->context);
} else if (!empty($event->userid) && $event->userid == $USER->id) {
// If course is not set, but userid id set, it's a user event.
return (has_capability('moodle/calendar:manageownentries', $event->context));
return (has_capability('moodle/calendar:manageownentries',
context_user::instance($event->userid)));
} else if (!empty($event->userid)) {
return calendar_can_manage_user_event($event);
}
Expand Down
93 changes: 93 additions & 0 deletions calendar/tests/behat/calendar.feature
Expand Up @@ -354,3 +354,96 @@ Feature: Perform basic calendar functionality
And I press "Save"
And I click on "Category event" "link"
And I should see "Category event"

@javascript
Scenario: Changing the event type from user to anything else should work
Given I log in as "teacher1"
# We need this so we can see the groups.
And the following "course enrolments" exist:
| user | course | role |
| teacher1 | C1 | editingteacher |
# We need this so we can make a category event.
And the following "categories" exist:
| name | category | idnumber |
| CatA | 0 | cata |
And the following "role assigns" exist:
| user | role | contextlevel | reference |
| teacher1 | manager | Category | cata |
And I am on "Course 1" course homepage
And I follow "Full calendar"
And I set the field "course" to "C1"
And I press "New event"
And I set the following fields to these values:
| Event title | type change test event |
| Type of event | User |
And I press "Save"
And I am on "Course 1" course homepage
And I follow "Full calendar"
And I click on "type change test event" "link"
And I should see "User event"
When I click on "Edit" "button"
And I set the following fields to these values:
| Event title | type change test event |
| Type of event | Course |
And I expand the "Course" autocomplete
And I click on "Course 1" item in the autocomplete list
And I press "Save"
And I click on "type change test event" "link"
Then I should see "Course event"
# Reset to user event
And I click on "Edit" "button"
And I set the following fields to these values:
| Event title | type change test event |
| Type of event | User |
And I press "Save"
And I click on "type change test event" "link"
And I should see "User event"
# Now test changing from user to group event.
And I am on "Course 1" course homepage
And I follow "Full calendar"
And I click on "type change test event" "link"
And I click on "Edit" "button"
And I set the following fields to these values:
| Event title | type change test event |
| Type of event | Group |
And I click on "#fitem_id_groupcourseid .form-autocomplete-downarrow" "css_element"
And I click on "Course 1" item in the autocomplete list
And I set the following fields to these values:
| Group | Group 1 |
And I press "Save"
And I click on "type change test event" "link"
And I should see "Group event"
# Reset to user event
And I click on "Edit" "button"
And I set the following fields to these values:
| Event title | type change test event |
| Type of event | User |
And I press "Save"
And I click on "type change test event" "link"
And I should see "User event"
# Now test changing from user to course event.
And I click on "Edit" "button"
And I set the following fields to these values:
| Event title | Course 1 event |
| Type of event | Course |
And I expand the "Course" autocomplete
And I click on "Course 1" item in the autocomplete list
And I press "Save"
And I click on "Course 1 event" "link"
And I should see "Course event"
# Reset to user event
And I click on "Edit" "button"
And I set the following fields to these values:
| Event title | type change test event |
| Type of event | User |
And I press "Save"
And I click on "type change test event" "link"
And I should see "User event"
# Now test changing from user to category event.
And I click on "Edit" "button"
And I set the following fields to these values:
| Event title | type change test event |
| Type of event | Category |
And I press "Save"
And I click on "type change test event" "link"
And I should see "Category event"

0 comments on commit 1a7a646

Please sign in to comment.