From 2cd5c61049cc12b1e476e7c9d0959ecc320df367 Mon Sep 17 00:00:00 2001 From: Amaia Anabitarte Date: Wed, 22 Dec 2021 16:05:38 +0100 Subject: [PATCH] MDL-73310 course: Add course index to all non-site course pages --- .../tests/behat/course_courseindex.feature | 27 ++++++++++++++++--- course/lib.php | 22 +++++++++------ lib/tests/behat/behat_navigation.php | 10 ++++++- .../activity_completion_report_filter.feature | 20 +++++++------- theme/boost/scss/moodle/grade.scss | 4 +++ theme/boost/style/moodle.css | 3 +++ theme/classic/style/moodle.css | 3 +++ 7 files changed, 67 insertions(+), 22 deletions(-) diff --git a/course/format/tests/behat/course_courseindex.feature b/course/format/tests/behat/course_courseindex.feature index 4dda2f929e5..b305236ce11 100644 --- a/course/format/tests/behat/course_courseindex.feature +++ b/course/format/tests/behat/course_courseindex.feature @@ -28,14 +28,35 @@ Feature: Course index depending on role And I change window size to "large" @javascript - Scenario: Course index is present on course and activities. + Scenario: Course index is present on course pages. Given I am on the "C1" "Course" page logged in as "teacher1" - Given the "multilang" filter is "on" + And the "multilang" filter is "on" And the "multilang" filter applies to "content and headings" +# Course index is visible on Course main page When I am on the "C1" "Course" page logged in as "teacher1" - Then I am on the "Activity sample 1" "assign activity editing" page + And "courseindex-content" "region" should be visible +# Course index is visible on Settings page + And I am on the "C1" "course editing" page + And "courseindex-content" "region" should be visible +# Course index is visible on Participants page + And I am on the "C1" "enrolled users" page + And "courseindex-content" "region" should be visible +# Course index is visible on Enrolment methods page + And I am on the "C1" "enrolment methods" page + And "courseindex-content" "region" should be visible +# Course index is visible on Groups page + And I am on the "C1" "groups" page + And "courseindex-content" "region" should be visible +# Course index is visible on Permissions page + And I am on the "C1" "permissions" page + And "courseindex-content" "region" should be visible +# Course index is visible on Activity edition page + And I am on the "Activity sample 1" "assign activity editing" page + And "courseindex-content" "region" should be visible And I set the field "Assignment name" in the "General" "fieldset" to "ActivityAktivität sample 1" And I press "Save and display" +# Course index is visible on Activity page + And "courseindex-content" "region" should be visible And I should see "Activity sample 1" in the "courseindex-content" "region" @javascript diff --git a/course/lib.php b/course/lib.php index 190eaeace07..23dcdd87e8e 100644 --- a/course/lib.php +++ b/course/lib.php @@ -3868,15 +3868,21 @@ function core_course_core_calendar_get_valid_event_timestart_range(\calendar_eve */ function core_course_drawer(): string { global $PAGE; - $format = course_get_format($PAGE->course); - // Only course and modules are able to render course index. - $ismod = strpos($PAGE->pagetype, 'mod-') === 0; - if ($ismod || $PAGE->pagetype == 'course-view-' . $format->get_format()) { - $renderer = $format->get_renderer($PAGE); - if (method_exists($renderer, 'course_index_drawer')) { - return $renderer->course_index_drawer($format); - } + // Only add course index on non-site course pages. + if (!$PAGE->course || $PAGE->course->id == SITEID) { + return ''; + } + + // Show course index to users can access the course only. + if (!can_access_course($PAGE->course)) { + return ''; + } + + $format = course_get_format($PAGE->course); + $renderer = $format->get_renderer($PAGE); + if (method_exists($renderer, 'course_index_drawer')) { + return $renderer->course_index_drawer($format); } return ''; diff --git a/lib/tests/behat/behat_navigation.php b/lib/tests/behat/behat_navigation.php index f66492b1d08..d028c9ab99e 100644 --- a/lib/tests/behat/behat_navigation.php +++ b/lib/tests/behat/behat_navigation.php @@ -773,12 +773,20 @@ class behat_navigation extends behat_base { } return new moodle_url('/course/index.php', ['categoryid' => $categoryid]); - case 'course': + case 'course editing': $courseid = $this->get_course_id($identifier); if (!$courseid) { throw new Exception('The specified course with shortname, fullname, or idnumber "' . $identifier . '" does not exist'); } + return new moodle_url('/course/edit.php', ['id' => $courseid]); + + case 'course': + $courseid = $this->get_course_id($identifier); + if (!$courseid) { + throw new Exception('The specified course with shortname, fullname, or idnumber "' . + $identifier . '" does not exist'); + } return new moodle_url('/course/view.php', ['id' => $courseid]); case 'activity': diff --git a/report/progress/tests/behat/activity_completion_report_filter.feature b/report/progress/tests/behat/activity_completion_report_filter.feature index f6260825b44..8fed1c558af 100644 --- a/report/progress/tests/behat/activity_completion_report_filter.feature +++ b/report/progress/tests/behat/activity_completion_report_filter.feature @@ -38,16 +38,16 @@ Feature: Teacher can view and filter activity completion data by group and activ And I am on "Course 1" course homepage And I navigate to "Reports" in current page administration And I select "Activity completion" from the "Report type" singleselect - Then "My quiz B" "link" should appear before "My quiz A" "link" - And I should see "My assignment" - And I should see "My page" - And I should see "Student One" - And I should see "Student Two" + Then "My quiz B" "link" should appear before "My quiz A" "link" in the "completion-progress" "table" + And I should see "My assignment" in the "completion-progress" "table" + And I should see "My page" in the "completion-progress" "table" + And I should see "Student One" in the "completion-progress" "table" + And I should see "Student Two" in the "completion-progress" "table" And I set the field "Separate groups" to "Group 1" And I set the field "Include" to "Quizzes" And I set the field "Activity order" to "Alphabetical" - And "My quiz A" "link" should appear before "My quiz B" "link" - And I should not see "My assignment" - And I should not see "My page" - And I should see "Student One" - And I should not see "Student Two" + And "My quiz A" "link" should appear before "My quiz B" "link" in the "completion-progress" "table" + And I should not see "My assignment" in the "completion-progress" "table" + And I should not see "My page" in the "completion-progress" "table" + And I should see "Student One" in the "completion-progress" "table" + And I should not see "Student Two" in the "completion-progress" "table" diff --git a/theme/boost/scss/moodle/grade.scss b/theme/boost/scss/moodle/grade.scss index 5702b3b9dca..e0137ef2af3 100644 --- a/theme/boost/scss/moodle/grade.scss +++ b/theme/boost/scss/moodle/grade.scss @@ -451,6 +451,10 @@ border-right: transparent; } } + + .show-drawer-left .gradeparent th.header { + left: -1rem; + } } /** diff --git a/theme/boost/style/moodle.css b/theme/boost/style/moodle.css index 5175bf2766c..1c94d792923 100644 --- a/theme/boost/style/moodle.css +++ b/theme/boost/style/moodle.css @@ -19542,6 +19542,9 @@ p.arrow_button { .path-grade-report-grader .gradeparent td.noborder { border-right: transparent; } +.path-grade-report-grader .show-drawer-left .gradeparent th.header { + left: -1rem; } + /** * User report. */ diff --git a/theme/classic/style/moodle.css b/theme/classic/style/moodle.css index 4e88f2c7a38..b6fdf042ce4 100644 --- a/theme/classic/style/moodle.css +++ b/theme/classic/style/moodle.css @@ -19542,6 +19542,9 @@ p.arrow_button { .path-grade-report-grader .gradeparent td.noborder { border-right: transparent; } +.path-grade-report-grader .show-drawer-left .gradeparent th.header { + left: -1rem; } + /** * User report. */