Differences Between: [Versions 310 and 311] [Versions 310 and 400] [Versions 310 and 401] [Versions 310 and 402] [Versions 310 and 403]
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 * This page lets users to manage site wide competencies. 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 25 require_once(__DIR__ . '/../../config.php'); 26 27 $id = required_param('id', PARAM_INT); 28 29 $params = array('id' => $id); 30 $course = $DB->get_record('course', $params, '*', MUST_EXIST); 31 require_login($course); 32 $context = context_course::instance($course->id); 33 $currentuser = optional_param('user', null, PARAM_INT); 34 $currentmodule = optional_param('mod', null, PARAM_INT); 35 if ($currentmodule > 0) { 36 $cm = get_coursemodule_from_id('', $currentmodule, 0, false, MUST_EXIST); 37 $context = context_module::instance($cm->id); 38 } 39 40 // Fetch current active group. 41 $groupmode = groups_get_course_groupmode($course); 42 $currentgroup = groups_get_course_group($course, true); 43 if (empty($currentuser)) { 44 $gradable = get_enrolled_users($context, 'moodle/competency:coursecompetencygradable', $currentgroup, 'u.id', null, 0, 1); 45 if (empty($gradable)) { 46 $currentuser = 0; 47 } else { 48 $currentuser = array_pop($gradable)->id; 49 } 50 } else { 51 $gradable = get_enrolled_users($context, 'moodle/competency:coursecompetencygradable', $currentgroup, 'u.id'); 52 if (count($gradable) == 0) { 53 $currentuser = 0; 54 } else if (!in_array($currentuser, array_keys($gradable))) { 55 $currentuser = array_shift($gradable)->id; 56 } 57 } 58 59 $urlparams = array('id' => $id); 60 $navurl = new moodle_url('/report/competency/index.php', $urlparams); 61 $urlparams['user'] = $currentuser; 62 $urlparams['mod'] = $currentmodule; 63 $url = new moodle_url('/report/competency/index.php', $urlparams); 64 65 $title = get_string('pluginname', 'report_competency'); 66 $coursename = format_string($course->fullname, true, array('context' => $context)); 67 68 $PAGE->navigation->override_active_url($navurl); 69 $PAGE->set_url($url); 70 $PAGE->set_title($title); 71 $PAGE->set_heading($coursename); 72 $PAGE->set_pagelayout('incourse'); 73 74 $output = $PAGE->get_renderer('report_competency'); 75 76 echo $output->header(); 77 $baseurl = new moodle_url('/report/competency/index.php'); 78 $nav = new \report_competency\output\user_course_navigation($currentuser, $course->id, $baseurl, $currentmodule); 79 $top = $output->render($nav); 80 if ($currentuser > 0) { 81 $user = core_user::get_user($currentuser); 82 $usercontext = context_user::instance($currentuser); 83 $userheading = array( 84 'heading' => fullname($user, has_capability('moodle/site:viewfullnames', $context)), 85 'user' => $user, 86 'usercontext' => $usercontext 87 ); 88 if ($currentmodule > 0) { 89 $title = get_string('filtermodule', 'report_competency', format_string($cm->name)); 90 } 91 $top .= $output->context_header($userheading, 3); 92 } 93 echo $output->container($top, 'clearfix'); 94 echo $output->heading($title, 3); 95 96 if ($currentuser > 0) { 97 $page = new \report_competency\output\report($course->id, $currentuser, $currentmodule); 98 echo $output->render($page); 99 } else { 100 echo $output->container('', 'clearfix'); 101 echo $output->notify_problem(get_string('noparticipants', 'tool_lp')); 102 } 103 echo $output->footer();
title
Description
Body
title
Description
Body
title
Description
Body
title
Body