diff --git a/admin/tool/monitor/managerules.php b/admin/tool/monitor/managerules.php index 1889c3e2c46..caf42db95fa 100644 --- a/admin/tool/monitor/managerules.php +++ b/admin/tool/monitor/managerules.php @@ -113,8 +113,6 @@ if (!empty($action) && $ruleid) { echo $OUTPUT->header(); } -report_helper::save_selected_report($courseid, $manageurl); - // Print the selected dropdown. $managerules = get_string('managerules', 'tool_monitor'); report_helper::print_report_selector($managerules); diff --git a/lib/classes/report_helper.php b/lib/classes/report_helper.php index 1edd57b0ed6..10cdaeafefc 100644 --- a/lib/classes/report_helper.php +++ b/lib/classes/report_helper.php @@ -62,8 +62,7 @@ class report_helper { if (!empty($menu)) { $select = new url_select($menu, $activeurl, null, 'choosecoursereport'); $select->set_label(get_string('reporttype'), ['class' => 'accesshide']); - $select->attributes['style'] = "margin-bottom: 1.5rem"; - $select->class .= " mb-4"; + $select->class .= " mb-3"; echo $OUTPUT->render($select); } } @@ -72,6 +71,7 @@ class report_helper { /** * Save the last selected report in the session * + * @deprecated since Moodle 4.0 * @param int $id The course id * @param moodle_url $url The moodle url * @return void @@ -79,6 +79,9 @@ class report_helper { public static function save_selected_report(int $id, moodle_url $url):void { global $USER; + debugging('save_selected_report() has been deprecated because it is no longer used and will be '. + 'removed in future versions of Moodle', DEBUG_DEVELOPER); + // Last selected report. if (!isset($USER->course_last_report)) { $USER->course_last_report = []; diff --git a/lib/tests/report_helper_test.php b/lib/tests/report_helper_test.php index 4c2595ba331..9abe4d637c5 100644 --- a/lib/tests/report_helper_test.php +++ b/lib/tests/report_helper_test.php @@ -62,12 +62,16 @@ class report_helper_test extends \advanced_testcase { $url1 = new moodle_url($courseurlid[0]['url']); $courseid1 = $courseurlid[0]['id']; report_helper::save_selected_report($courseid1, $url1); + $this->assertDebuggingCalled('save_selected_report() has been deprecated because it is no ' . + 'longer used and will be removed in future versions of Moodle'); $this->assertEquals($USER->course_last_report[$courseid1], $url1); $url2 = new moodle_url($courseurlid[1]['url']); $courseid2 = $courseurlid[1]['id']; report_helper::save_selected_report($courseid2, $url2); + $this->assertDebuggingCalled('save_selected_report() has been deprecated because it is no ' . + 'longer used and will be removed in future versions of Moodle'); $this->assertEquals($USER->course_last_report[$courseid2], $url2); } diff --git a/report/competency/index.php b/report/competency/index.php index 18c599baddb..dd5eca16b82 100644 --- a/report/competency/index.php +++ b/report/competency/index.php @@ -73,8 +73,6 @@ $PAGE->set_title($title); $PAGE->set_heading($coursename); $PAGE->set_pagelayout('incourse'); -report_helper::save_selected_report($id, $navurl); - $output = $PAGE->get_renderer('report_competency'); echo $output->header(); diff --git a/report/completion/index.php b/report/completion/index.php index 5724550e96e..0a894af5eb4 100644 --- a/report/completion/index.php +++ b/report/completion/index.php @@ -115,8 +115,6 @@ foreach ($completion->get_criteria() as $criterion) { } } -report_helper::save_selected_report($courseid, $url); - // Can logged in user mark users as complete? // (if the logged in user has a role defined in the role criteria) $allow_marking = false; diff --git a/report/insights/insights.php b/report/insights/insights.php index 92623618a1a..17982ba2ca8 100644 --- a/report/insights/insights.php +++ b/report/insights/insights.php @@ -158,7 +158,6 @@ if ($model->get_analyser()::one_sample_per_analysable()) { echo $OUTPUT->header(); if ($course) { - report_helper::save_selected_report($course->id, $url); // Print selected drop down. $pluginname = get_string('pluginname', 'report_insights'); report_helper::print_report_selector($pluginname); diff --git a/report/log/classes/renderer.php b/report/log/classes/renderer.php index de28b081f39..4029e2e3899 100644 --- a/report/log/classes/renderer.php +++ b/report/log/classes/renderer.php @@ -100,13 +100,13 @@ class report_log_renderer extends plugin_renderer_base { $courses = $reportlog->get_course_list(); if (!empty($courses) && $reportlog->showcourses) { echo html_writer::label(get_string('selectacourse'), 'menuid', false, array('class' => 'accesshide')); - echo html_writer::select($courses, "id", $selectedcourseid, null); + echo html_writer::select($courses, "id", $selectedcourseid, null, ['class' => 'mr-2 mb-2']); } else { $courses = array(); $courses[$selectedcourseid] = get_course_display_name_for_list($reportlog->course) . (($selectedcourseid == SITEID) ? ' (' . get_string('site') . ') ' : ''); echo html_writer::label(get_string('selectacourse'), 'menuid', false, array('class' => 'accesshide')); - echo html_writer::select($courses, "id", $selectedcourseid, false); + echo html_writer::select($courses, "id", $selectedcourseid, false, ['class' => 'mr-2 mb-2']); // Check if user is admin and this came because of limitation on number of courses to show in dropdown. if (has_capability('report/log:view', $sitecontext)) { $a = new stdClass(); @@ -123,7 +123,8 @@ class report_log_renderer extends plugin_renderer_base { $groups = $reportlog->get_group_list(); if (!empty($groups)) { echo html_writer::label(get_string('selectagroup'), 'menugroup', false, array('class' => 'accesshide')); - echo html_writer::select($groups, "group", $reportlog->groupid, get_string("allgroups")); + echo html_writer::select($groups, "group", $reportlog->groupid, get_string("allgroups"), + ['class' => 'mr-2 mb-2']); } // Add user selector. @@ -131,7 +132,8 @@ class report_log_renderer extends plugin_renderer_base { if ($reportlog->showusers) { echo html_writer::label(get_string('selctauser'), 'menuuser', false, array('class' => 'accesshide')); - echo html_writer::select($users, "user", $reportlog->userid, get_string("allparticipants")); + echo html_writer::select($users, "user", $reportlog->userid, get_string("allparticipants"), + ['class' => 'mr-2 mb-2']); } else { $users = array(); if (!empty($reportlog->userid)) { @@ -140,7 +142,7 @@ class report_log_renderer extends plugin_renderer_base { $users[0] = get_string('allparticipants'); } echo html_writer::label(get_string('selctauser'), 'menuuser', false, array('class' => 'accesshide')); - echo html_writer::select($users, "user", $reportlog->userid, false); + echo html_writer::select($users, "user", $reportlog->userid, false, ['class' => 'mr-2 mb-2']); $a = new stdClass(); $a->url = new moodle_url('/report/log/index.php', array('chooselog' => 0, 'group' => $reportlog->get_selected_group(), 'user' => $reportlog->userid, @@ -155,26 +157,30 @@ class report_log_renderer extends plugin_renderer_base { // Add date selector. $dates = $reportlog->get_date_options(); echo html_writer::label(get_string('date'), 'menudate', false, array('class' => 'accesshide')); - echo html_writer::select($dates, "date", $reportlog->date, get_string("alldays")); + echo html_writer::select($dates, "date", $reportlog->date, get_string("alldays"), + ['class' => 'mr-2 mb-2']); // Add activity selector. $activities = $reportlog->get_activities_list(); echo html_writer::label(get_string('activities'), 'menumodid', false, array('class' => 'accesshide')); - echo html_writer::select($activities, "modid", $reportlog->modid, get_string("allactivities")); + echo html_writer::select($activities, "modid", $reportlog->modid, get_string("allactivities"), + ['class' => 'mr-2 mb-2']); // Add actions selector. echo html_writer::label(get_string('actions'), 'menumodaction', false, array('class' => 'accesshide')); - echo html_writer::select($reportlog->get_actions(), 'modaction', $reportlog->action, get_string("allactions")); + echo html_writer::select($reportlog->get_actions(), 'modaction', $reportlog->action, + get_string("allactions"), ['class' => 'mr-2 mb-2']); // Add origin. $origin = $reportlog->get_origin_options(); echo html_writer::label(get_string('origin', 'report_log'), 'menuorigin', false, array('class' => 'accesshide')); - echo html_writer::select($origin, 'origin', $reportlog->origin, false); + echo html_writer::select($origin, 'origin', $reportlog->origin, false, ['class' => 'mr-2 mb-2']); // Add edulevel. $edulevel = $reportlog->get_edulevel_options(); echo html_writer::label(get_string('edulevel'), 'menuedulevel', false, array('class' => 'accesshide')); - echo html_writer::select($edulevel, 'edulevel', $reportlog->edulevel, false).$this->help_icon('edulevel'); + echo html_writer::select($edulevel, 'edulevel', $reportlog->edulevel, false, + ['class' => 'mr-2 mb-2']) .$this->help_icon('edulevel'); // Add reader option. // If there is some reader available then only show submit button. @@ -186,10 +192,13 @@ class report_log_renderer extends plugin_renderer_base { } else { echo html_writer::label(get_string('selectlogreader', 'report_log'), 'menureader', false, array('class' => 'accesshide')); - echo html_writer::select($readers, 'logreader', $reportlog->selectedlogreader, false); + echo html_writer::select($readers, 'logreader', $reportlog->selectedlogreader, false, + ['class' => 'mr-2 mb-2']); } - echo html_writer::empty_tag('input', array('type' => 'submit', 'value' => get_string('gettheselogs'), - 'class' => 'btn btn-secondary')); + echo html_writer::start_div('mt-1'); + echo html_writer::empty_tag('input', array('type' => 'submit', + 'value' => get_string('gettheselogs'), 'class' => 'btn btn-primary')); + echo html_writer::end_div(); } echo html_writer::end_div(); echo html_writer::end_tag('form'); diff --git a/report/log/index.php b/report/log/index.php index 2b298884913..1e75bed5e9e 100644 --- a/report/log/index.php +++ b/report/log/index.php @@ -105,8 +105,6 @@ $url = new moodle_url("/report/log/index.php", $params); $PAGE->set_url('/report/log/index.php', array('id' => $id)); $PAGE->set_pagelayout('report'); -report_helper::save_selected_report($id, $url); - // Get course details. $course = null; if ($id) { diff --git a/report/log/tests/behat/course_report_log.feature b/report/log/tests/behat/course_report_log.feature index 74edcf0a01b..22d100e0f52 100644 --- a/report/log/tests/behat/course_report_log.feature +++ b/report/log/tests/behat/course_report_log.feature @@ -3,14 +3,11 @@ Feature: In a course administration page, navigate through report page, test for In order to navigate through report page As an admin Go to course administration -> reports - The reports page by default points to logs page Background: Given the following "courses" exist: | fullname | shortname | category | groupmode | | Course 1 | C1 | 0 | 1 | - | Course 2 | C2 | 0 | 1 | - | Course 3 | C3 | 0 | 1 | And the following "users" exist: | username | firstname | lastname | email | | student1 | Student | 1 | student1@example.com | @@ -18,36 +15,12 @@ Feature: In a course administration page, navigate through report page, test for | user | course | role | | admin | C1 | editingteacher | | student1 | C1 | student | - | admin | C2 | editingteacher | - | student1 | C2 | student | - | admin | C3 | editingteacher | - | student1 | C3 | student | @javascript - Scenario: Default page accessed for Report is log page + Scenario: Report selector should be available in the report log page Given I log in as "admin" And I am on "Course 1" course homepage - When I navigate to "Reports" in current page administration + When I navigate to "Reports > Logs" in current page administration Then "Report" "field" should exist And the "Report" select box should contain "Logs" And the field "Report" matches value "Logs" - - @javascript - Scenario: Verify the session setting is saved for different courses - Given I log in as "admin" - And I am on "Course 1" course homepage - And I navigate to "Reports" in current page administration - And "Report" "field" should exist - And the "Report" select box should contain "Logs" - And the field "Report" matches value "Logs" - # Now select the Live logs for Course 2 - And I am on "Course 2" course homepage - And I navigate to "Reports > Live logs" in current page administration - # now come back to course 1 and see if the default is logs page or not - And I am on "Course 1" course homepage - And I navigate to "Reports" in current page administration - And the "Report" select box should contain "Logs" - # Now come back again to Course 2 - And I am on "Course 2" course homepage - When I navigate to "Reports" in current page administration - Then the field "Report" matches value "Live logs" diff --git a/report/loglive/index.php b/report/loglive/index.php index d6964676204..bb2f8005827 100644 --- a/report/loglive/index.php +++ b/report/loglive/index.php @@ -61,8 +61,6 @@ $url = new moodle_url("/report/loglive/index.php", $params); $PAGE->set_url($url); $PAGE->set_pagelayout('report'); -report_helper::save_selected_report($id, $url); - $renderable = new report_loglive_renderable($logreader, $id, $url, 0, $page); $refresh = $renderable->get_refresh_rate(); $logreader = $renderable->selectedlogreader; diff --git a/report/outline/index.php b/report/outline/index.php index 85d9331b669..665f9899ffb 100644 --- a/report/outline/index.php +++ b/report/outline/index.php @@ -49,9 +49,6 @@ require_login($course); $context = context_course::instance($course->id); require_capability('report/outline:view', $context); -$url = new moodle_url('/report/outline/index.php', ['id' => $id]); -report_helper::save_selected_report($id, $url); - // Handle form to filter access logs by date. $filterform = new \report_outline\filter_form(); $filterform->set_data(['id' => $course->id, 'filterstartdate' => $startdate, 'filterenddate' => $enddate]); diff --git a/report/participation/index.php b/report/participation/index.php index e28f520ea03..e9e53c36455 100644 --- a/report/participation/index.php +++ b/report/participation/index.php @@ -68,8 +68,6 @@ require_login($course); $context = context_course::instance($course->id); require_capability('report/participation:view', $context); -report_helper::save_selected_report($id, $url); - $strparticipation = get_string('participationreport'); $strviews = get_string('views'); $strposts = get_string('posts'); diff --git a/report/progress/index.php b/report/progress/index.php index d2a0756dd46..6a8a12e1069 100644 --- a/report/progress/index.php +++ b/report/progress/index.php @@ -156,8 +156,6 @@ $grandtotal = $completion->get_num_tracked_users('', array(), $group); // Get user data $progress = array(); -report_helper::save_selected_report($id, $url); - if ($total) { $progress = $completion->get_progress_all( implode(' AND ', $where), diff --git a/report/stats/index.php b/report/stats/index.php index b94aa70b7e5..21591702e74 100644 --- a/report/stats/index.php +++ b/report/stats/index.php @@ -76,9 +76,6 @@ $event = \report_stats\event\report_viewed::create(array('context' => $context, $event->trigger(); stats_check_uptodate($course->id); -$url = new moodle_url('/report/stats/index.php', ['course' => $course->id]); -report_helper::save_selected_report($courseid, $url); - if ($course->id == SITEID) { admin_externalpage_setup('reportstats', '', null, '', array('pagelayout'=>'report')); echo $OUTPUT->header(); diff --git a/report/upgrade.txt b/report/upgrade.txt index 341fed59e5f..7cb53b41a19 100644 --- a/report/upgrade.txt +++ b/report/upgrade.txt @@ -1,6 +1,10 @@ This files describes API changes in /report/* - plugins, information provided here is intended especially for developers. +=== 4.0 === + +* The method report_helper::save_selected_report() has been been deprecated because it is no longer used. + === 3.11 === * The new report plugin's can have drop down, which can be included by calling static diff --git a/report/view.php b/report/view.php index bdaec23e9ed..cd72b82d111 100644 --- a/report/view.php +++ b/report/view.php @@ -36,11 +36,22 @@ if (!$course = $DB->get_record('course', array('id' => $courseid))) { } require_login($course); -// Get the last viewed Page. -if (!isset($USER->course_last_report[$courseid])) { - $lasturl = new moodle_url('/report/log/index.php', ['id' => $courseid]); -} else { - $lasturl = $USER->course_last_report[$courseid]; +// Get all course reports from the settings navigation. +if ($reportsnode = $PAGE->settingsnav->find('coursereports', \navigation_node::TYPE_CONTAINER)) { + // If there are available course reports to the user. + if ($reportsnode->children->count() > 0) { + // Redirect to the first course report from the list. + $firstreportnode = $reportsnode->children->getIterator()[0]; + redirect($firstreportnode->action()->out(false)); + } } +// Otherwise, output the page with a notification stating that there are no available course reports. +$PAGE->set_title(get_string('reports')); +$PAGE->set_pagelayout('incourse'); +$PAGE->set_heading($course->fullname); +$PAGE->set_pagetype('course-view-' . $course->format); -redirect($lasturl); +echo $OUTPUT->header(); +echo $OUTPUT->heading(get_string('reports')); +echo html_writer::div($OUTPUT->notification(get_string('noreports', 'debug'), 'error'), 'mt-3'); +echo $OUTPUT->footer();