mirror of
https://github.com/moodle/moodle.git
synced 2025-04-13 12:32:08 +02:00
MDL-74080 block_myoverview: Fix create course link based on permissions
This commit is contained in:
parent
967d9b2546
commit
89849347e5
@ -412,8 +412,8 @@ class main implements renderable, templatable {
|
||||
|
||||
$newcourseurl = '';
|
||||
$coursecat = \core_course_category::user_top();
|
||||
if ($coursecat->can_create_course()) {
|
||||
$newcourseurl = new \moodle_url('/course/edit.php', ['category' => $coursecat->id]);
|
||||
if ($category = \core_course_category::get_nearest_editable_subcategory($coursecat, ['create'])) {
|
||||
$newcourseurl = new \moodle_url('/course/edit.php', ['category' => $category->id]);
|
||||
}
|
||||
|
||||
$customfieldvalues = $this->get_customfield_values_for_export();
|
||||
|
@ -26,3 +26,19 @@ Feature: If there is no course yet, users with capabilities have a link to creat
|
||||
Given I am on the "My courses" page logged in as "teacher1"
|
||||
When I should see "No courses"
|
||||
Then I should not see "Create new course"
|
||||
|
||||
Scenario: Course creators on a subcategory can see a link to new course form from my overview block
|
||||
Given the following "categories" exist:
|
||||
| name | category | idnumber |
|
||||
| Cat 1 | 0 | CAT1 |
|
||||
| Cat 2 | CAT1 | CAT2 |
|
||||
And the following "role assigns" exist:
|
||||
| user | role | contextlevel | reference |
|
||||
| teacher1 | coursecreator | Category | CAT2 |
|
||||
And I am on the "My courses" page logged in as "teacher1"
|
||||
And I should see "No courses"
|
||||
And I should see "Create new course" in the "region-main" "region"
|
||||
And I should not see "Add a new course"
|
||||
When I click on "Create new course" "link" in the "region-main" "region"
|
||||
Then I should see "Add a new course"
|
||||
And I should see "Cat 2" in the "page-header" "region"
|
||||
|
Loading…
x
Reference in New Issue
Block a user