Search moodle.org's
Developer Documentation

See Release Notes
Long Term Support Release

  • Bug fixes for general core bugs in 4.1.x will end 13 November 2023 (12 months).
  • Bug fixes for security issues in 4.1.x will end 10 November 2025 (36 months).
  • PHP version: minimum PHP 7.4.0 Note: minimum PHP version has increased since Moodle 4.0. PHP 8.0.x is supported too.
   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 file contains functions used by the progress report
  19   *
  20   * @package    report
  21   * @subpackage progress
  22   * @copyright  2009 Sam Hemelryk
  23   * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  24   */
  25  
  26  defined('MOODLE_INTERNAL') || die;
  27  
  28  /**
  29   * This function extends the navigation with the report items
  30   *
  31   * @param navigation_node $navigation The navigation node to extend
  32   * @param stdClass $course The course to object for the report
  33   * @param stdClass $context The context of the course
  34   */
  35  function report_progress_extend_navigation_course($navigation, $course, $context) {
  36      global $CFG, $OUTPUT;
  37  
  38      require_once($CFG->libdir.'/completionlib.php');
  39  
  40      $showonnavigation = has_capability('report/progress:view', $context);
  41      $group = groups_get_course_group($course,true); // Supposed to verify group
  42      if($group===0 && $course->groupmode==SEPARATEGROUPS) {
  43          $showonnavigation = ($showonnavigation && has_capability('moodle/site:accessallgroups', $context));
  44      }
  45  
  46      $completion = new completion_info($course);
  47      $showonnavigation = ($showonnavigation && $completion->is_enabled() && $completion->has_activities());
  48      if ($showonnavigation) {
  49          $url = new moodle_url('/report/progress/index.php', array('course'=>$course->id));
  50          $navigation->add(get_string('pluginname','report_progress'), $url, navigation_node::TYPE_SETTING, null, null, new pix_icon('i/report', ''));
  51      }
  52  }
  53  
  54  /**
  55   * Return a list of page types
  56   * @param string $pagetype current page type
  57   * @param stdClass $parentcontext Block's parent context
  58   * @param stdClass $currentcontext Current context of block
  59   * @return array
  60   */
  61  function report_progress_page_type_list($pagetype, $parentcontext, $currentcontext) {
  62      $array = array(
  63          '*'                     => get_string('page-x', 'pagetype'),
  64          'report-*'              => get_string('page-report-x', 'pagetype'),
  65          'report-progress-*'     => get_string('page-report-progress-x',  'report_progress'),
  66          'report-progress-index' => get_string('page-report-progress-index',  'report_progress'),
  67      );
  68      return $array;
  69  }