/** * Returns an array of plugin reports as grade_plugin_info objects * * @param int $courseid * @return array */ public static function get_plugins_reports($courseid) { global $SITE; if (self::$gradereports !== null) { return self::$gradereports; } $context = context_course::instance($courseid); $gradereports = array(); $gradepreferences = array(); foreach (core_component::get_plugin_list('gradereport') as $plugin => $plugindir) { //some reports make no sense if we're not within a course if ($courseid == $SITE->id && ($plugin == 'grader' || $plugin == 'user')) { continue; } // Remove ones we can't see if (!has_capability('gradereport/' . $plugin . ':view', $context)) { continue; } $pluginstr = get_string('pluginname', 'gradereport_' . $plugin); $url = new moodle_url('/grade/report/' . $plugin . '/index.php', array('id' => $courseid)); $gradereports[$plugin] = new grade_plugin_info($plugin, $url, $pluginstr); // Add link to preferences tab if such a page exists if (file_exists($plugindir . '/preferences.php')) { $url = new moodle_url('/grade/report/' . $plugin . '/preferences.php', array('id' => $courseid)); $gradepreferences[$plugin] = new grade_plugin_info($plugin, $url, $pluginstr); } } if (count($gradereports) == 0) { $gradereports = false; $gradepreferences = false; } else { if (count($gradepreferences) == 0) { $gradepreferences = false; asort($gradereports); } else { asort($gradereports); asort($gradepreferences); } } self::$gradereports = $gradereports; self::$gradereportpreferences = $gradepreferences; return self::$gradereports; }
/** * Returns an array of plugin reports as grade_plugin_info objects * * @param int $courseid * @return array */ public static function get_plugins_reports($courseid) { global $SITE; if (self::$gradereports !== null) { return self::$gradereports; } $context = context_course::instance($courseid); $gradereports = array(); $gradepreferences = array(); foreach (core_component::get_plugin_list('gradereport') as $plugin => $plugindir) { //some reports make no sense if we're not within a course if ($courseid == $SITE->id && ($plugin == 'grader' || $plugin == 'user')) { continue; } // Remove ones we can't see if (!has_capability('gradereport/' . $plugin . ':view', $context)) { continue; } $pluginstr = get_string('pluginname', 'gradereport_' . $plugin); //@Harsha Added userid to the links if they changed from one to another $itemid = optional_param('itemid', 0, PARAM_INT); $userid = optional_param('userid', 0, PARAM_INT); if ($itemid > 0) { $userid = $itemid; } if ($plugin === 'user' and $userid > 0) { $url = new moodle_url('/grade/report/' . $plugin . '/index.php', array('id' => $courseid, 'userid' => $userid)); $gradereports[$plugin] = new grade_plugin_info($plugin, $url, $pluginstr); } else { if ($plugin === 'singleview' and $userid > 0) { $url = new moodle_url('/grade/report/' . $plugin . '/index.php', array('id' => $courseid, 'userid' => $userid)); $gradereports[$plugin] = new grade_plugin_info($plugin, $url, $pluginstr); } else { $url = new moodle_url('/grade/report/' . $plugin . '/index.php', array('id' => $courseid)); $gradereports[$plugin] = new grade_plugin_info($plugin, $url, $pluginstr); } } //End of code @Harsha //Default code starts //$url = new moodle_url('/grade/report/'.$plugin.'/index.php', array('id'=>$courseid)); //$gradereports[$plugin] = new grade_plugin_info($plugin, $url, $pluginstr); //Default code ends // Add link to preferences tab if such a page exists if (file_exists($plugindir . '/preferences.php')) { $url = new moodle_url('/grade/report/' . $plugin . '/preferences.php', array('id' => $courseid)); $gradepreferences[$plugin] = new grade_plugin_info($plugin, $url, get_string('preferences', 'grades') . ': ' . $pluginstr); } } if (count($gradereports) == 0) { $gradereports = false; $gradepreferences = false; } else { if (count($gradepreferences) == 0) { $gradepreferences = false; asort($gradereports); } else { asort($gradereports); asort($gradepreferences); } } self::$gradereports = $gradereports; self::$gradereportpreferences = $gradepreferences; return self::$gradereports; }