MDL-74276 report: Render a new 'Reports Overview' page
This commit is contained in:
@@ -4665,6 +4665,10 @@ class settings_navigation extends navigation_node {
|
||||
foreach ($reports as $reportfunction) {
|
||||
$reportfunction($reportnav, $course, $coursecontext);
|
||||
}
|
||||
|
||||
if (!$reportnav->has_children()) {
|
||||
$reportnav->remove();
|
||||
}
|
||||
}
|
||||
|
||||
// Check if we can view the gradebook's setup page.
|
||||
@@ -5633,6 +5637,10 @@ class settings_navigation extends navigation_node {
|
||||
foreach ($reports as $reportfunction) {
|
||||
$reportfunction($frontpagenav, $course, $coursecontext);
|
||||
}
|
||||
|
||||
if (!$frontpagenav->has_children()) {
|
||||
$frontpagenav->remove();
|
||||
}
|
||||
}
|
||||
|
||||
// Backup this course
|
||||
|
||||
@@ -0,0 +1,51 @@
|
||||
{{!
|
||||
This file is part of Moodle - http://moodle.org/
|
||||
|
||||
Moodle is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Moodle is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
}}
|
||||
{{!
|
||||
@template core/report_link_page
|
||||
|
||||
Display the report page with a list of available reports.
|
||||
|
||||
Example context (json):
|
||||
{
|
||||
"node": {
|
||||
"text": "Root of menu",
|
||||
"key": "test0",
|
||||
"display": true,
|
||||
"children": [
|
||||
{
|
||||
"text": "Child of menu",
|
||||
"key": "test1",
|
||||
"display": true,
|
||||
"children": []
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}}
|
||||
{{#node}}
|
||||
<div class="container-fluid">
|
||||
<div class="row">
|
||||
<ul class="list-unstyled ml-0">
|
||||
{{#node.children}}
|
||||
{{#display}}
|
||||
<li><a href="{{{action}}}">{{text}}</a></li>
|
||||
{{/display}}
|
||||
{{/node.children}}
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
{{/node}}
|
||||
+18
-10
@@ -36,22 +36,30 @@ if (!$course = $DB->get_record('course', array('id' => $courseid))) {
|
||||
}
|
||||
require_login($course);
|
||||
|
||||
// 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);
|
||||
$PAGE->add_body_class('limitedwidth');
|
||||
|
||||
echo $OUTPUT->header();
|
||||
echo $OUTPUT->heading(get_string('reports'));
|
||||
echo html_writer::div($OUTPUT->notification(get_string('noreports', 'debug'), 'error'), 'mt-3');
|
||||
|
||||
// Check if there is at least one displayable report.
|
||||
$hasreports = false;
|
||||
if ($reportnode = $PAGE->settingsnav->find('coursereports', \navigation_node::TYPE_CONTAINER)) {
|
||||
foreach ($reportnode->children as $child) {
|
||||
if ($child->display) {
|
||||
$hasreports = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($hasreports) {
|
||||
echo $OUTPUT->render_from_template('core/report_link_page', ['node' => $reportnode]);
|
||||
} else {
|
||||
echo html_writer::div($OUTPUT->notification(get_string('noreports', 'debug'), 'error'), 'mt-3');
|
||||
}
|
||||
echo $OUTPUT->footer();
|
||||
|
||||
Reference in New Issue
Block a user