[ Index ] |
PHP Cross Reference of Unnamed Project |
[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 * User navigation class. 19 * 20 * @package report_competency 21 * @copyright 2015 Damyon Wiese 22 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 23 */ 24 namespace report_competency\output; 25 26 use renderable; 27 use renderer_base; 28 use templatable; 29 use context_course; 30 use core_competency\external\user_summary_exporter; 31 use stdClass; 32 33 /** 34 * User course navigation class. 35 * 36 * @package report_competency 37 * @copyright 2015 Damyon Wiese 38 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 39 */ 40 class user_course_navigation implements renderable, templatable { 41 42 /** @var userid */ 43 protected $userid; 44 45 /** @var courseid */ 46 protected $courseid; 47 48 /** @var baseurl */ 49 protected $baseurl; 50 51 /** 52 * Construct. 53 * 54 * @param int $userid 55 * @param int $courseid 56 * @param string $baseurl 57 */ 58 public function __construct($userid, $courseid, $baseurl) { 59 $this->userid = $userid; 60 $this->courseid = $courseid; 61 $this->baseurl = $baseurl; 62 } 63 64 /** 65 * Export the data. 66 * 67 * @param renderer_base $output 68 * @return stdClass 69 */ 70 public function export_for_template(renderer_base $output) { 71 global $CFG, $DB, $SESSION, $PAGE; 72 73 $context = context_course::instance($this->courseid); 74 75 $data = new stdClass(); 76 $data->userid = $this->userid; 77 $data->courseid = $this->courseid; 78 $data->baseurl = $this->baseurl; 79 $data->groupselector = ''; 80 81 if (has_any_capability(array('moodle/competency:usercompetencyview', 'moodle/competency:coursecompetencymanage'), 82 $context)) { 83 $course = $DB->get_record('course', array('id' => $this->courseid)); 84 $currentgroup = groups_get_course_group($course, true); 85 if ($currentgroup !== false) { 86 $select = groups_allgroups_course_menu($course, $PAGE->url, true, $currentgroup); 87 $data->groupselector = $select; 88 } 89 // Fetch showactive. 90 $defaultgradeshowactiveenrol = !empty($CFG->grade_report_showonlyactiveenrol); 91 $showonlyactiveenrol = get_user_preferences('grade_report_showonlyactiveenrol', $defaultgradeshowactiveenrol); 92 $showonlyactiveenrol = $showonlyactiveenrol || !has_capability('moodle/course:viewsuspendedusers', $context); 93 94 // Fetch current active group. 95 $groupmode = groups_get_course_groupmode($course); 96 97 $users = get_enrolled_users($context, 'moodle/competency:coursecompetencygradable', $currentgroup, 98 'u.*', null, 0, 0, $showonlyactiveenrol); 99 100 $data->users = array(); 101 foreach ($users as $user) { 102 $exporter = new user_summary_exporter($user); 103 $user = $exporter->export($output); 104 if ($user->id == $this->userid) { 105 $user->selected = true; 106 } 107 $data->users[] = $user; 108 } 109 $data->hasusers = true; 110 } else { 111 $data->users = array(); 112 $data->hasusers = false; 113 } 114 115 return $data; 116 } 117 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Thu Aug 11 10:00:09 2016 | Cross-referenced by PHPXref 0.7.1 |