MDL-57216 navigation: Added missing grade overview link.
authorAdrian Greeve <adrian@moodle.com>
Wed, 7 Dec 2016 08:38:27 +0000 (16:38 +0800)
committerAdrian Greeve <adrian@moodle.com>
Fri, 9 Dec 2016 02:19:32 +0000 (10:19 +0800)
For theme_boost the grade overview link has been added
to the user profile page.

grade/report/overview/lang/en/gradereport_overview.php
grade/report/overview/lib.php
grade/report/user/lib.php

index 2f0b4a4..54c178f 100644 (file)
@@ -23,5 +23,6 @@
  */
 
 $string['eventgradereportviewed'] = 'Grade overview report viewed';
+$string['gradesoverview'] = 'Grades overview';
 $string['pluginname'] = 'Overview report';
 $string['overview:view'] = 'View the overview report';
index d8bf895..6ab529e 100644 (file)
@@ -451,4 +451,26 @@ function grade_report_overview_settings_definition(&$mform) {
     $mform->addHelpButton('report_overview_showtotalsifcontainhidden', 'hidetotalifhiddenitems', 'grades');
 }
 
-
+/**
+ * Add nodes to myprofile page.
+ *
+ * @param \core_user\output\myprofile\tree $tree Tree object
+ * @param stdClass $user user object
+ * @param bool $iscurrentuser
+ * @param stdClass $course Course object
+ */
+function gradereport_overview_myprofile_navigation(core_user\output\myprofile\tree $tree, $user, $iscurrentuser, $course) {
+    if (empty($course)) {
+        // We want to display these reports under the site context.
+        $course = get_fast_modinfo(SITEID)->get_course();
+    }
+    $systemcontext = context_system::instance();
+    $usercontext = context_user::instance($user->id);
+    $coursecontext = context_course::instance($course->id);
+    if (grade_report_overview::check_access($systemcontext, $coursecontext, $usercontext, $course, $user->id)) {
+        $url = new moodle_url('/grade/report/overview/index.php', array('userid' => $user->id));
+        $node = new core_user\output\myprofile\node('reports', 'grades', get_string('gradesoverview', 'gradereport_overview'),
+                null, $url);
+        $tree->add_node($node);
+    }
+}
index e582b7a..9f751fa 100644 (file)
@@ -1250,7 +1250,7 @@ function gradereport_user_myprofile_navigation(core_user\output\myprofile\tree $
     $anyreport = has_capability('moodle/user:viewuseractivitiesreport', $usercontext);
 
     // Start capability checks.
-    if ($anyreport || ($course->showreports && $user->id == $USER->id)) {
+    if ($anyreport || $iscurrentuser) {
         // Add grade hardcoded grade report if necessary.
         $gradeaccess = false;
         $coursecontext = context_course::instance($course->id);