Skip to content

Commit

Permalink
Merge branch 'MDL-74716-master' of https://github.com/aanabit/moodle
Browse files Browse the repository at this point in the history
  • Loading branch information
junpataleta committed Jun 20, 2022
2 parents 70fb867 + 31b4535 commit 9182cb1
Show file tree
Hide file tree
Showing 7 changed files with 55 additions and 7 deletions.
2 changes: 1 addition & 1 deletion admin/tool/usertours/classes/manager.php
Expand Up @@ -867,7 +867,7 @@ public static function update_shipped_tours() {
// be increased if the tour has been updated.
$shippedtours = [
'40_tour_navigation_dashboard.json' => 4,
'40_tour_navigation_mycourse.json' => 4,
'40_tour_navigation_mycourse.json' => 5,
'40_tour_navigation_course_teacher.json' => 3,
'40_tour_navigation_course_student.json' => 3,
];
Expand Down
8 changes: 8 additions & 0 deletions admin/tool/usertours/db/upgrade.php
Expand Up @@ -129,6 +129,14 @@ function xmldb_tool_usertours_upgrade($oldversion) {
upgrade_plugin_savepoint(true, 2022040602, 'tool', 'usertours');
}

if ($oldversion < 2022061600) {
// Update shipped tours.
// Normally, we just bump the version numbers because we need to call update_shipped_tours only once.
manager::update_shipped_tours();

upgrade_plugin_savepoint(true, 2022061600, 'tool', 'usertours');
}

// Automatically generated Moodle v4.0.0 release upgrade line.
// Put any upgrade step following this.

Expand Down
6 changes: 3 additions & 3 deletions admin/tool/usertours/tours/40_tour_navigation_mycourse.json
Expand Up @@ -5,16 +5,16 @@
"enabled": "1",
"sortorder": "1",
"endtourlabel": "tour_navigation_mycourses_endtourlabel,tool_usertours",
"configdata": "{\"placement\":\"bottom\",\"orphan\":\"0\",\"backdrop\":\"1\",\"reflex\":\"0\",\"filtervalues\":{\"accessdate\":{\"filter_accessdate\":\"tool_usertours_accountcreation\",\"filter_accessdate_range\":0,\"filter_accessdate_enabled\":\"0\"},\"category\":[],\"course\":[],\"courseformat\":[],\"role\":[],\"theme\":[\"boost\"],\"cssselector\":[]},\"majorupdatetime\":1641972468,\"shipped_tour\":true,\"shipped_filename\":\"40_tour_navigation_mycourse.json\",\"shipped_version\":1}",
"configdata": "{\"placement\":\"bottom\",\"orphan\":\"0\",\"backdrop\":\"1\",\"reflex\":\"0\",\"filtervalues\":{\"accessdate\":{\"filter_accessdate\":\"tool_usertours_accountcreation\",\"filter_accessdate_range\":0,\"filter_accessdate_enabled\":\"0\"},\"category\":[],\"course\":[],\"courseformat\":[],\"role\":[],\"theme\":[\"boost\"],\"cssselector\":[]},\"majorupdatetime\":1641972468,\"shipped_tour\":true,\"shipped_filename\":\"40_tour_navigation_mycourse.json\",\"shipped_version\":5}",
"displaystepnumbers": true,
"version": "2021101301",
"version": "2022061600",
"steps": [
{
"title": "tour_navigation_mycourses_title,tool_usertours",
"content": "tour_navigation_mycourses_content,tool_usertours",
"contentformat": "1",
"targettype": "0",
"targetvalue": ".header-actions-container .btn-group",
"targetvalue": ".header-actions-container .btn-group.course-manage",
"sortorder": "0",
"configdata": "{}"
}
Expand Down
2 changes: 1 addition & 1 deletion admin/tool/usertours/version.php
Expand Up @@ -24,6 +24,6 @@

defined('MOODLE_INTERNAL') || die();

$plugin->version = 2022041900; // The current module version (Date: YYYYMMDDXX).
$plugin->version = 2022061600; // The current module version (Date: YYYYMMDDXX).
$plugin->requires = 2022041200; // Requires this Moodle version.
$plugin->component = 'tool_usertours'; // Full name of the plugin (used for diagnostics).
8 changes: 8 additions & 0 deletions my/courses.php
Expand Up @@ -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();

Expand Down Expand Up @@ -78,6 +79,13 @@
// 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));
Expand Down
8 changes: 6 additions & 2 deletions my/templates/dropdown.mustache
Expand Up @@ -22,10 +22,11 @@
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">
<div class="btn-group{{#manageurl}} course-manage{{/manageurl}}{{#courserequesturl}} course-request{{/courserequesturl}}">
<!-- Set as a link to appease Goutte behat. -->
<a href="#" class="btn btn-link btn-icon icon-size-3 rounded-circle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" title="{{#str}}coursemanagementoptions, my{{/str}}">
<i class="fa fa-ellipsis-v text-dark py-2" aria-hidden="true"></i>
Expand All @@ -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>
28 changes: 28 additions & 0 deletions my/tests/behat/my_courses.feature
Expand Up @@ -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

0 comments on commit 9182cb1

Please sign in to comment.