MDL-31983 navigation: Move reports from Navigation to Settings
This commit is contained in:
+78
-72
@@ -2169,38 +2169,6 @@ class global_navigation extends navigation_node {
|
||||
$usernode->add(get_string('notes', 'notes'), $url);
|
||||
}
|
||||
|
||||
// Add reports node
|
||||
$reporttab = $usernode->add(get_string('activityreports'));
|
||||
$reports = get_plugin_list_with_function('report', 'extend_navigation_user', 'lib.php');
|
||||
foreach ($reports as $reportfunction) {
|
||||
$reportfunction($reporttab, $user, $course);
|
||||
}
|
||||
$anyreport = has_capability('moodle/user:viewuseractivitiesreport', $usercontext);
|
||||
if ($anyreport || ($course->showreports && $iscurrentuser && $forceforcontext)) {
|
||||
// Add grade hardcoded grade report if necessary
|
||||
$gradeaccess = false;
|
||||
if (has_capability('moodle/grade:viewall', $coursecontext)) {
|
||||
//ok - can view all course grades
|
||||
$gradeaccess = true;
|
||||
} else if ($course->showgrades) {
|
||||
if ($iscurrentuser && has_capability('moodle/grade:view', $coursecontext)) {
|
||||
//ok - can view own grades
|
||||
$gradeaccess = true;
|
||||
} else if (has_capability('moodle/grade:viewall', $usercontext)) {
|
||||
// ok - can view grades of this user - parent most probably
|
||||
$gradeaccess = true;
|
||||
} else if ($anyreport) {
|
||||
// ok - can view grades of this user - parent most probably
|
||||
$gradeaccess = true;
|
||||
}
|
||||
}
|
||||
if ($gradeaccess) {
|
||||
$reporttab->add(get_string('grade'), new moodle_url('/course/user.php', array('mode'=>'grade', 'id'=>$course->id, 'user'=>$usercontext->instanceid)));
|
||||
}
|
||||
}
|
||||
// Check the number of nodes in the report node... if there are none remove the node
|
||||
$reporttab->trim_if_empty();
|
||||
|
||||
// If the user is the current user add the repositories for the current user
|
||||
$hiddenfields = array_flip(explode(',', $CFG->hiddenuserfields));
|
||||
if ($iscurrentuser) {
|
||||
@@ -2439,26 +2407,6 @@ class global_navigation extends navigation_node {
|
||||
$participants = $coursenode->add(get_string('participants'), null, self::TYPE_CONTAINER, get_string('participants'), 'participants');
|
||||
}
|
||||
|
||||
// View course reports
|
||||
if (has_capability('moodle/site:viewreports', $this->page->context)) { // basic capability for listing of reports
|
||||
$reportnav = $coursenode->add(get_string('reports'), null, self::TYPE_CONTAINER, null, null, new pix_icon('i/stats', ''));
|
||||
$coursereports = get_plugin_list('coursereport'); // deprecated
|
||||
foreach ($coursereports as $report=>$dir) {
|
||||
$libfile = $CFG->dirroot.'/course/report/'.$report.'/lib.php';
|
||||
if (file_exists($libfile)) {
|
||||
require_once($libfile);
|
||||
$reportfunction = $report.'_report_extend_navigation';
|
||||
if (function_exists($report.'_report_extend_navigation')) {
|
||||
$reportfunction($reportnav, $course, $this->page->context);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$reports = get_plugin_list_with_function('report', 'extend_navigation_course', 'lib.php');
|
||||
foreach ($reports as $reportfunction) {
|
||||
$reportfunction($reportnav, $course, $this->page->context);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
/**
|
||||
@@ -2514,26 +2462,6 @@ class global_navigation extends navigation_node {
|
||||
$coursenode->add(get_string('calendar', 'calendar'), $calendarurl, self::TYPE_CUSTOM, null, 'calendar');
|
||||
}
|
||||
|
||||
// View course reports
|
||||
if (has_capability('moodle/site:viewreports', $this->page->context)) { // basic capability for listing of reports
|
||||
$reportnav = $coursenode->add(get_string('reports'), null, self::TYPE_CONTAINER, null, null, new pix_icon('i/stats', ''));
|
||||
$coursereports = get_plugin_list('coursereport'); // deprecated
|
||||
foreach ($coursereports as $report=>$dir) {
|
||||
$libfile = $CFG->dirroot.'/course/report/'.$report.'/lib.php';
|
||||
if (file_exists($libfile)) {
|
||||
require_once($libfile);
|
||||
$reportfunction = $report.'_report_extend_navigation';
|
||||
if (function_exists($report.'_report_extend_navigation')) {
|
||||
$reportfunction($reportnav, $course, $this->page->context);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$reports = get_plugin_list_with_function('report', 'extend_navigation_course', 'lib.php');
|
||||
foreach ($reports as $reportfunction) {
|
||||
$reportfunction($reportnav, $course, $this->page->context);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -3470,6 +3398,28 @@ class settings_navigation extends navigation_node {
|
||||
$coursenode->add(get_string('filters', 'admin'), $url, self::TYPE_SETTING, null, null, new pix_icon('i/filter', ''));
|
||||
}
|
||||
|
||||
// View course reports.
|
||||
if (has_capability('moodle/site:viewreports', $coursecontext)) { // Basic capability for listing of reports.
|
||||
$reportnav = $coursenode->add(get_string('reports'), null, self::TYPE_CONTAINER, null, null,
|
||||
new pix_icon('i/stats', ''));
|
||||
$coursereports = get_plugin_list('coursereport');
|
||||
foreach ($coursereports as $report => $dir) {
|
||||
$libfile = $CFG->dirroot.'/course/report/'.$report.'/lib.php';
|
||||
if (file_exists($libfile)) {
|
||||
require_once($libfile);
|
||||
$reportfunction = $report.'_report_extend_navigation';
|
||||
if (function_exists($report.'_report_extend_navigation')) {
|
||||
$reportfunction($reportnav, $course, $coursecontext);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$reports = get_plugin_list_with_function('report', 'extend_navigation_course', 'lib.php');
|
||||
foreach ($reports as $reportfunction) {
|
||||
$reportfunction($reportnav, $course, $coursecontext);
|
||||
}
|
||||
}
|
||||
|
||||
// Add view grade report is permitted
|
||||
$reportavailable = false;
|
||||
if (has_capability('moodle/grade:viewall', $coursecontext)) {
|
||||
@@ -3976,6 +3926,40 @@ class settings_navigation extends navigation_node {
|
||||
}
|
||||
}
|
||||
|
||||
// Add reports node.
|
||||
$reporttab = $usersetting->add(get_string('activityreports'));
|
||||
$reports = get_plugin_list_with_function('report', 'extend_navigation_user', 'lib.php');
|
||||
foreach ($reports as $reportfunction) {
|
||||
$reportfunction($reporttab, $user, $course);
|
||||
}
|
||||
$anyreport = has_capability('moodle/user:viewuseractivitiesreport', $usercontext);
|
||||
if ($anyreport || ($course->showreports && $iscurrentuser && $forceforcontext)) {
|
||||
// Add grade hardcoded grade report if necessary.
|
||||
$gradeaccess = false;
|
||||
if (has_capability('moodle/grade:viewall', $coursecontext)) {
|
||||
// Can view all course grades.
|
||||
$gradeaccess = true;
|
||||
} else if ($course->showgrades) {
|
||||
if ($iscurrentuser && has_capability('moodle/grade:view', $coursecontext)) {
|
||||
// Can view own grades.
|
||||
$gradeaccess = true;
|
||||
} else if (has_capability('moodle/grade:viewall', $usercontext)) {
|
||||
// Can view grades of this user - parent most probably.
|
||||
$gradeaccess = true;
|
||||
} else if ($anyreport) {
|
||||
// Can view grades of this user - parent most probably.
|
||||
$gradeaccess = true;
|
||||
}
|
||||
}
|
||||
if ($gradeaccess) {
|
||||
$reporttab->add(get_string('grade'), new moodle_url('/course/user.php', array('mode'=>'grade', 'id'=>$course->id,
|
||||
'user'=>$usercontext->instanceid)));
|
||||
}
|
||||
}
|
||||
// Check the number of nodes in the report node... if there are none remove the node
|
||||
$reporttab->trim_if_empty();
|
||||
|
||||
|
||||
// Login as ...
|
||||
if (!$user->deleted and !$currentuser && !session_is_loggedinas() && has_capability('moodle/user:loginas', $coursecontext) && !is_siteadmin($user->id)) {
|
||||
$url = new moodle_url('/course/loginas.php', array('id'=>$course->id, 'user'=>$user->id, 'sesskey'=>sesskey()));
|
||||
@@ -4141,6 +4125,28 @@ class settings_navigation extends navigation_node {
|
||||
$frontpage->add(get_string('filters', 'admin'), $url, self::TYPE_SETTING, null, null, new pix_icon('i/filter', ''));
|
||||
}
|
||||
|
||||
// View course reports.
|
||||
if (has_capability('moodle/site:viewreports', $coursecontext)) { // Basic capability for listing of reports.
|
||||
$frontpagenav = $frontpage->add(get_string('reports'), null, self::TYPE_CONTAINER, null, null,
|
||||
new pix_icon('i/stats', ''));
|
||||
$coursereports = get_plugin_list('coursereport');
|
||||
foreach ($coursereports as $report=>$dir) {
|
||||
$libfile = $CFG->dirroot.'/course/report/'.$report.'/lib.php';
|
||||
if (file_exists($libfile)) {
|
||||
require_once($libfile);
|
||||
$reportfunction = $report.'_report_extend_navigation';
|
||||
if (function_exists($report.'_report_extend_navigation')) {
|
||||
$reportfunction($frontpagenav, $course, $coursecontext);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$reports = get_plugin_list_with_function('report', 'extend_navigation_course', 'lib.php');
|
||||
foreach ($reports as $reportfunction) {
|
||||
$reportfunction($frontpagenav, $course, $coursecontext);
|
||||
}
|
||||
}
|
||||
|
||||
// Backup this course
|
||||
if (has_capability('moodle/backup:backupcourse', $coursecontext)) {
|
||||
$url = new moodle_url('/backup/backup.php', array('id'=>$course->id));
|
||||
|
||||
+20
-42
@@ -1553,48 +1553,6 @@ function quiz_get_extra_capabilities() {
|
||||
return $caps;
|
||||
}
|
||||
|
||||
/**
|
||||
* This fucntion extends the global navigation for the site.
|
||||
* It is important to note that you should not rely on PAGE objects within this
|
||||
* body of code as there is no guarantee that during an AJAX request they are
|
||||
* available
|
||||
*
|
||||
* @param navigation_node $quiznode The quiz node within the global navigation
|
||||
* @param object $course The course object returned from the DB
|
||||
* @param object $module The module object returned from the DB
|
||||
* @param object $cm The course module instance returned from the DB
|
||||
*/
|
||||
function quiz_extend_navigation($quiznode, $course, $module, $cm) {
|
||||
global $CFG;
|
||||
|
||||
$context = context_module::instance($cm->id);
|
||||
|
||||
if (has_capability('mod/quiz:view', $context)) {
|
||||
$url = new moodle_url('/mod/quiz/view.php', array('id'=>$cm->id));
|
||||
$quiznode->add(get_string('info', 'quiz'), $url, navigation_node::TYPE_SETTING,
|
||||
null, null, new pix_icon('i/info', ''));
|
||||
}
|
||||
|
||||
if (has_any_capability(array('mod/quiz:viewreports', 'mod/quiz:grade'), $context)) {
|
||||
require_once($CFG->dirroot . '/mod/quiz/report/reportlib.php');
|
||||
$reportlist = quiz_report_list($context);
|
||||
|
||||
$url = new moodle_url('/mod/quiz/report.php',
|
||||
array('id' => $cm->id, 'mode' => reset($reportlist)));
|
||||
$reportnode = $quiznode->add(get_string('results', 'quiz'), $url,
|
||||
navigation_node::TYPE_SETTING,
|
||||
null, null, new pix_icon('i/report', ''));
|
||||
|
||||
foreach ($reportlist as $report) {
|
||||
$url = new moodle_url('/mod/quiz/report.php',
|
||||
array('id' => $cm->id, 'mode' => $report));
|
||||
$reportnode->add(get_string($report, 'quiz_'.$report), $url,
|
||||
navigation_node::TYPE_SETTING,
|
||||
null, 'quiz_report_' . $report, new pix_icon('i/item', ''));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This function extends the settings navigation block for the site.
|
||||
*
|
||||
@@ -1603,6 +1561,7 @@ function quiz_extend_navigation($quiznode, $course, $module, $cm) {
|
||||
*
|
||||
* @param settings_navigation $settings
|
||||
* @param navigation_node $quiznode
|
||||
* @return void
|
||||
*/
|
||||
function quiz_extend_settings_navigation($settings, $quiznode) {
|
||||
global $PAGE, $CFG;
|
||||
@@ -1652,6 +1611,25 @@ function quiz_extend_settings_navigation($settings, $quiznode) {
|
||||
$quiznode->add_node($node, $beforekey);
|
||||
}
|
||||
|
||||
if (has_any_capability(array('mod/quiz:viewreports', 'mod/quiz:grade'), $PAGE->cm->context)) {
|
||||
require_once($CFG->dirroot . '/mod/quiz/report/reportlib.php');
|
||||
$reportlist = quiz_report_list($PAGE->cm->context);
|
||||
|
||||
$url = new moodle_url('/mod/quiz/report.php',
|
||||
array('id' => $PAGE->cm->id, 'mode' => reset($reportlist)));
|
||||
$reportnode = $quiznode->add_node(navigation_node::create(get_string('results', 'quiz'), $url,
|
||||
navigation_node::TYPE_SETTING,
|
||||
null, null, new pix_icon('i/report', '')), $beforekey);
|
||||
|
||||
foreach ($reportlist as $report) {
|
||||
$url = new moodle_url('/mod/quiz/report.php',
|
||||
array('id' => $PAGE->cm->id, 'mode' => $report));
|
||||
$reportnode->add_node(navigation_node::create(get_string($report, 'quiz_'.$report), $url,
|
||||
navigation_node::TYPE_SETTING,
|
||||
null, 'quiz_report_' . $report, new pix_icon('i/item', '')));
|
||||
}
|
||||
}
|
||||
|
||||
question_extend_settings_navigation($quiznode, $PAGE->cm->context)->trim_if_empty();
|
||||
}
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
$module->version = 2012112900; // The current module version (Date: YYYYMMDDXX).
|
||||
$module->version = 2013310100; // The current module version (Date: YYYYMMDDXX).
|
||||
$module->requires = 2012112900; // Requires this Moodle version.
|
||||
$module->component = 'mod_quiz'; // Full name of the plugin (used for diagnostics).
|
||||
$module->cron = 60;
|
||||
|
||||
Reference in New Issue
Block a user