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   * Competencies to review renderable.
  19   *
  20   * @package    block_lp
  21   * @copyright  2016 Frédéric Massart - FMCorz.net
  22   * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  23   */
  24  namespace block_lp\output;
  25  defined('MOODLE_INTERNAL') || die();
  26  
  27  use renderable;
  28  use templatable;
  29  use renderer_base;
  30  use stdClass;
  31  use moodle_url;
  32  use core_competency\api;
  33  use core_competency\external\competency_exporter;
  34  use core_competency\external\user_competency_exporter;
  35  use core_user\external\user_summary_exporter;
  36  
  37  /**
  38   * Competencies to review renderable class.
  39   *
  40   * @package    block_lp
  41   * @copyright  2016 Frédéric Massart - FMCorz.net
  42   * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  43   */
  44  class competencies_to_review_page implements renderable, templatable {
  45  
  46      /** @var array Competencies to review. */
  47      protected $compstoreview;
  48  
  49      /**
  50       * Constructor.
  51       */
  52      public function __construct() {
  53          $this->compstoreview = api::list_user_competencies_to_review(0, 1000);
  54      }
  55  
  56      /**
  57       * Export the data.
  58       *
  59       * @param renderer_base $output
  60       * @return stdClass
  61       */
  62      public function export_for_template(renderer_base $output) {
  63          $data = new stdClass();
  64  
  65          $compstoreview = array();
  66          foreach ($this->compstoreview['competencies'] as $compdata) {
  67              $ucexporter = new user_competency_exporter($compdata->usercompetency,
  68                  array('scale' => $compdata->competency->get_scale()));
  69              $compexporter = new competency_exporter($compdata->competency,
  70                  array('context' => $compdata->competency->get_context()));
  71              $userexporter = new user_summary_exporter($compdata->user);
  72              $compstoreview[] = array(
  73                  'usercompetency' => $ucexporter->export($output),
  74                  'competency' => $compexporter->export($output),
  75                  'user' => $userexporter->export($output),
  76              );
  77          }
  78  
  79          $data = array(
  80              'competencies' => $compstoreview,
  81              'pluginbaseurl' => (new moodle_url('/blocks/lp'))->out(false),
  82          );
  83  
  84          return $data;
  85      }
  86  
  87  }