[ Index ]

PHP Cross Reference of Unnamed Project

title

Body

[close]

/report/competency/ -> index.php (source)

   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  
  35  // Fetch current active group.
  36  $groupmode = groups_get_course_groupmode($course);
  37  $currentgroup = groups_get_course_group($course, true);
  38  if (empty($currentuser)) {
  39      $gradable = get_enrolled_users($context, 'moodle/competency:coursecompetencygradable', $currentgroup, 'u.id', null, 0, 1);
  40      if (empty($gradable)) {
  41          $currentuser = 0;
  42      } else {
  43          $currentuser = array_pop($gradable)->id;
  44      }
  45  } else {
  46      $gradable = get_enrolled_users($context, 'moodle/competency:coursecompetencygradable', $currentgroup, 'u.id');
  47      if (count($gradable) == 0) {
  48          $currentuser = 0;
  49      } else if (!in_array($currentuser, array_keys($gradable))) {
  50          $currentuser = array_shift($gradable)->id;
  51      }
  52  }
  53  
  54  $urlparams = array('id' => $id, 'user' => $currentuser);
  55  
  56  $url = new moodle_url('/report/competency/index.php', $urlparams);
  57  $title = get_string('pluginname', 'report_competency');
  58  $PAGE->set_url($url);
  59  $PAGE->set_title($title);
  60  $coursename = format_text($course->fullname, false, array('context' => $context));
  61  $PAGE->set_heading($coursename);
  62  $PAGE->set_pagelayout('incourse');
  63  
  64  $output = $PAGE->get_renderer('report_competency');
  65  
  66  echo $output->header();
  67  $baseurl = new moodle_url('/report/competency/index.php');
  68  $nav = new \report_competency\output\user_course_navigation($currentuser, $course->id, $baseurl);
  69  echo $output->render($nav);
  70  if ($currentuser > 0) {
  71      $user = core_user::get_user($currentuser);
  72      $usercontext = context_user::instance($currentuser);
  73      $userheading = array(
  74          'heading' => fullname($user),
  75          'user' => $user,
  76          'usercontext' => $usercontext
  77      );
  78      echo $output->context_header($userheading, 3);
  79  }
  80  echo $output->heading($title, 3);
  81  
  82  if ($currentuser > 0) {
  83      $page = new \report_competency\output\report($course->id, $currentuser);
  84      echo $output->render($page);
  85  } else {
  86      echo $output->container('', 'clearfix');
  87      echo $output->notify_problem(get_string('noparticipants', 'tool_lp'));
  88  }
  89  echo $output->footer();


Generated: Thu Aug 11 10:00:09 2016 Cross-referenced by PHPXref 0.7.1