PS. Should anyone require it, on the question of enabling Moodle 4.0.* "My courses" page to show the "Request a course" link to the permitted users, the workaround is luckily easy (if you have server access).
We must simply copy these two files from Moodle the 4.1.* release and replace the Moodle 4.0.* originals (after renaming them somehow for backup's sake):
- /my/courses.php
- /my/templates/dropdown.mustache
The differences between Moodle 4.0 and Moodle 4.1 in both files were rather brief, altogether about ten lines of code affected. Here's the listing if anyone is interested:
In the courses.php file these two were added:
L. 32:
require_once($CFG->dirroot . '/course/lib.php');
require_once($CFG->dirroot . '/course/lib.php');
after the line: require_once($CFG->dirroot . '/my/lib.php');
Ll. 82-88:
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]);
}
}
BEFORE the line :
if (!empty($coursemanagemenu)) {
in dropdown.mustache there were 3 changes:
ll. 25-26:
"manageurl": "https://moodle.test/course/management.php?categoryid=1",
"courserequesturl": "https://moodle.test/course/request.php?categoryid=1"
replaced this l. 25:
"manageurl": "https://moodle.test/course/management.php?categoryid=1"
l.29
<div class="btn-group{{#manageurl}} course-manage{{/manageurl}}{{#courserequesturl}} course-request{{/courserequesturl}}">
instead of this line 28:
<div class="btn-group">
ll. 41-43:
{{#courserequesturl}}
<a class="dropdown-item" href="{{courserequesturl}}">{{#str}}requestcourse, core{{/str}}</a>
{{/courserequesturl}}
were added before the last two </div>'s
"manageurl": "https://moodle.test/course/management.php?categoryid=1",
"courserequesturl": "https://moodle.test/course/request.php?categoryid=1"
replaced this l. 25:
"manageurl": "https://moodle.test/course/management.php?categoryid=1"
l.29
<div class="btn-group{{#manageurl}} course-manage{{/manageurl}}{{#courserequesturl}} course-request{{/courserequesturl}}">
instead of this line 28:
<div class="btn-group">
ll. 41-43:
{{#courserequesturl}}
<a class="dropdown-item" href="{{courserequesturl}}">{{#str}}requestcourse, core{{/str}}</a>
{{/courserequesturl}}
were added before the last two </div>'s
I'm happy to be able to use these "hacks" already, before the planned upgrade to Moodle 4.2 or 4.3 next year.
Maybe this will also help someone who, like me, is stuck with version 4.0 for some time.
Kind regards,
Przemek