MDL-74716 course: Add Request a course link to My courses
This commit is contained in:
@@ -29,6 +29,7 @@
|
||||
|
||||
require_once(__DIR__ . '/../config.php');
|
||||
require_once($CFG->dirroot . '/my/lib.php');
|
||||
require_once($CFG->dirroot . '/course/lib.php');
|
||||
|
||||
redirect_if_major_upgrade_required();
|
||||
|
||||
@@ -78,6 +79,13 @@ if ($coursecat && ($category = core_course_category::get_nearest_editable_subcat
|
||||
// The user has the capability to manage the course category.
|
||||
$coursemanagemenu['manageurl'] = new moodle_url('/course/management.php', ['categoryid' => $category->id]);
|
||||
}
|
||||
if ($coursecat) {
|
||||
$category = core_course_category::get_nearest_editable_subcategory($coursecat, ['moodle/course:request']);
|
||||
if ($category && $category->can_request_course()) {
|
||||
$coursemanagemenu['courserequesturl'] = new moodle_url('/course/request.php', ['categoryid' => $category->id]);
|
||||
|
||||
}
|
||||
}
|
||||
if (!empty($coursemanagemenu)) {
|
||||
// Render the course management menu.
|
||||
$PAGE->add_header_action($OUTPUT->render_from_template('my/dropdown', $coursemanagemenu));
|
||||
|
||||
@@ -22,7 +22,8 @@
|
||||
Example context (json):
|
||||
{
|
||||
"newcourseurl": "https://moodle.test/course/edit.php?category=1",
|
||||
"manageurl": "https://moodle.test/course/management.php?categoryid=1"
|
||||
"manageurl": "https://moodle.test/course/management.php?categoryid=1",
|
||||
"courserequesturl": "https://moodle.test/course/request.php?categoryid=1"
|
||||
}
|
||||
}}
|
||||
<div class="btn-group">
|
||||
@@ -37,5 +38,8 @@
|
||||
{{#manageurl}}
|
||||
<a class="dropdown-item" href="{{manageurl}}">{{#str}}managecourses, core{{/str}}</a>
|
||||
{{/manageurl}}
|
||||
{{#courserequesturl}}
|
||||
<a class="dropdown-item" href="{{courserequesturl}}">{{#str}}requestcourse, core{{/str}}</a>
|
||||
{{/courserequesturl}}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -111,3 +111,31 @@ Feature: Run tests over my courses.
|
||||
And "Move Course overview block" "button" should not exist in the "Course overview" "block"
|
||||
And I click on "Actions menu" "icon" in the "Course overview" "block"
|
||||
And I should not see "Delete Course overview block"
|
||||
|
||||
@javascript
|
||||
Scenario: User with creating a course permission can't see the Request course link
|
||||
Given the following "permission overrides" exist:
|
||||
| capability | permission | role | contextlevel | reference |
|
||||
| moodle/course:request | Allow | user | System | |
|
||||
When I am on the "My courses" page logged in as "admin"
|
||||
And I click on "Course management options" "link"
|
||||
And I should see "New course"
|
||||
Then I should not see "Request a course"
|
||||
|
||||
@javascript
|
||||
Scenario: User without creating a course but with course request permission could see the Request course link
|
||||
Given the following "permission overrides" exist:
|
||||
| capability | permission | role | contextlevel | reference |
|
||||
| moodle/course:request | Allow | user | System | |
|
||||
When I am on the "My courses" page logged in as "user1"
|
||||
And I click on "Course management options" "link"
|
||||
And I should not see "New course"
|
||||
Then I should see "Request a course"
|
||||
And the following config values are set as admin:
|
||||
| enablecourserequests | 0 |
|
||||
And I am on the "My courses" page logged in as "user1"
|
||||
And "Course management options" "link" should not exist
|
||||
|
||||
Scenario: User without creating nor course request permission shouldn't see any Request course link
|
||||
Given I am on the "My courses" page logged in as "user1"
|
||||
Then "Course management options" "link" should not exist
|
||||
|
||||
Reference in New Issue
Block a user