[ Index ] |
PHP Cross Reference of moodle-2.8 |
[Summary view] [Print] [Text view]
1 <?php 2 // This file is part of Moodle - http://moodle.org/ 3 // 4 // Moodle is free software: you can redistribute it and/or modify 5 // it under the terms of the GNU General Public License as published by 6 // the Free Software Foundation, either version 3 of the License, or 7 // (at your option) any later version. 8 // 9 // Moodle is distributed in the hope that it will be useful, 10 // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 // GNU General Public License for more details. 13 // 14 // You should have received a copy of the GNU General Public License 15 // along with Moodle. If not, see <http://www.gnu.org/licenses/>. 16 17 /** 18 * Display user activity reports for a course (totals) 19 * 20 * @package report 21 * @subpackage outline 22 * @copyright 1999 onwards Martin Dougiamas http://dougiamas.com 23 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 24 */ 25 26 require('../../config.php'); 27 require_once($CFG->dirroot.'/report/outline/locallib.php'); 28 require_once($CFG->dirroot.'/report/outline/lib.php'); 29 30 $userid = required_param('id', PARAM_INT); 31 $courseid = required_param('course', PARAM_INT); 32 $mode = optional_param('mode', 'outline', PARAM_ALPHA); 33 34 if ($mode !== 'complete' and $mode !== 'outline') { 35 $mode = 'outline'; 36 } 37 38 $user = $DB->get_record('user', array('id'=>$userid, 'deleted'=>0), '*', MUST_EXIST); 39 $course = $DB->get_record('course', array('id'=>$courseid), '*', MUST_EXIST); 40 41 $coursecontext = context_course::instance($course->id); 42 $personalcontext = context_user::instance($user->id); 43 44 if ($USER->id != $user->id and has_capability('moodle/user:viewuseractivitiesreport', $personalcontext) 45 and !is_enrolled($coursecontext, $USER) and is_enrolled($coursecontext, $user)) { 46 //TODO: do not require parents to be enrolled in courses - this is a hack! 47 require_login(); 48 $PAGE->set_course($course); 49 } else { 50 require_login($course); 51 } 52 $PAGE->set_url('/report/outline/user.php', array('id'=>$userid, 'course'=>$courseid, 'mode'=>$mode)); 53 54 if (!report_outline_can_access_user_report($user, $course, true)) { 55 require_capability('report/outline:view', $coursecontext); 56 } 57 58 $stractivityreport = get_string('activityreport'); 59 60 $PAGE->set_pagelayout('report'); 61 $PAGE->set_url('/report/outline/user.php', array('id'=>$user->id, 'course'=>$course->id, 'mode'=>$mode)); 62 $PAGE->navigation->extend_for_user($user); 63 $PAGE->navigation->set_userid_for_parent_checks($user->id); // see MDL-25805 for reasons and for full commit reference for reversal when fixed. 64 $PAGE->set_title("$course->shortname: $stractivityreport"); 65 $PAGE->set_heading($course->fullname); 66 67 // Trigger a report viewed event. 68 $event = \report_outline\event\report_viewed::create(array('context' => context_course::instance($course->id), 69 'relateduserid' => $userid, 'other' => array('mode' => $mode))); 70 $event->trigger(); 71 72 echo $OUTPUT->header(); 73 74 $modinfo = get_fast_modinfo($course); 75 $sections = $modinfo->get_section_info_all(); 76 $itemsprinted = false; 77 78 foreach ($sections as $i => $section) { 79 80 if ($section->uservisible) { // prevent hidden sections in user activity. Thanks to Geoff Wilbert! 81 // Check the section has modules/resources, if not there is nothing to display. 82 if (!empty($modinfo->sections[$i])) { 83 $itemsprinted = true; 84 echo '<div class="section">'; 85 echo '<h2>'; 86 echo get_section_name($course, $section); 87 echo "</h2>"; 88 89 echo '<div class="content">'; 90 91 if ($mode == "outline") { 92 echo "<table cellpadding=\"4\" cellspacing=\"0\">"; 93 } 94 95 foreach ($modinfo->sections[$i] as $cmid) { 96 $mod = $modinfo->cms[$cmid]; 97 98 if (empty($mod->uservisible)) { 99 continue; 100 } 101 102 $instance = $DB->get_record("$mod->modname", array("id"=>$mod->instance)); 103 $libfile = "$CFG->dirroot/mod/$mod->modname/lib.php"; 104 105 if (file_exists($libfile)) { 106 require_once($libfile); 107 108 switch ($mode) { 109 case "outline": 110 $user_outline = $mod->modname."_user_outline"; 111 if (function_exists($user_outline)) { 112 $output = $user_outline($course, $user, $mod, $instance); 113 } else { 114 $output = report_outline_user_outline($user->id, $cmid, $mod->modname, $instance->id); 115 } 116 report_outline_print_row($mod, $instance, $output); 117 break; 118 case "complete": 119 $user_complete = $mod->modname."_user_complete"; 120 $image = $OUTPUT->pix_icon('icon', $mod->modfullname, 'mod_'.$mod->modname, array('class'=>'icon')); 121 echo "<h4>$image $mod->modfullname: ". 122 "<a href=\"$CFG->wwwroot/mod/$mod->modname/view.php?id=$mod->id\">". 123 format_string($instance->name,true)."</a></h4>"; 124 125 ob_start(); 126 127 echo "<ul>"; 128 if (function_exists($user_complete)) { 129 $user_complete($course, $user, $mod, $instance); 130 } else { 131 echo report_outline_user_complete($user->id, $cmid, $mod->modname, $instance->id); 132 } 133 echo "</ul>"; 134 135 $output = ob_get_contents(); 136 ob_end_clean(); 137 138 if (str_replace(' ', '', $output) != '<ul></ul>') { 139 echo $output; 140 } 141 break; 142 } 143 } 144 } 145 146 if ($mode == "outline") { 147 echo "</table>"; 148 } 149 echo '</div>'; // content 150 echo '</div>'; // section 151 } 152 } 153 } 154 155 if (!$itemsprinted) { 156 echo $OUTPUT->notification(get_string('nothingtodisplay')); 157 } 158 159 echo $OUTPUT->footer();
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Fri Nov 28 20:29:05 2014 | Cross-referenced by PHPXref 0.7.1 |