Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 4.3.x will end 7 October 2024 (12 months).
  • Bug fixes for security issues in 4.3.x will end 21 April 2025 (18 months).
  • PHP version: minimum PHP 8.0.0 Note: minimum PHP version has increased since Moodle 4.1. PHP 8.2.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   * Shows a tabulated view of all the available LTI tools in a given course.
  19   *
  20   * @package    mod_lti
  21   * @copyright  2023 Jake Dallimore <jrhdallimore@gmail.com>
  22   * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  23   */
  24  
  25  use mod_lti\output\course_tools_page;
  26  
  27  require_once("../../config.php");
  28  require_once($CFG->dirroot . '/mod/lti/lib.php');
  29  require_once($CFG->dirroot . '/mod/lti/locallib.php');
  30  
  31  $id = required_param('id', PARAM_INT); // Course Id.
  32  
  33  // Access + permissions.
  34  $course = get_course($id);
  35  require_course_login($course, false);
  36  
  37  $context = context_course::instance($course->id);
  38  if (!has_capability('mod/lti:addpreconfiguredinstance', $context)) {
  39      throw new \moodle_exception('nopermissions', 'error', '', get_string('courseexternaltoolsnoviewpermissions', 'mod_lti'));
  40  }
  41  
  42  // Page setup.
  43  global $PAGE, $OUTPUT;
  44  $pagetitle = get_string('courseexternaltools', 'mod_lti');
  45  $pageurl = new moodle_url('/mod/lti/coursetools.php', ['id' => $course->id]);
  46  $PAGE->set_pagelayout('incourse');
  47  $PAGE->set_context($context);
  48  $PAGE->set_url($pageurl);
  49  $PAGE->set_title($pagetitle);
  50  $PAGE->set_heading(format_string($course->fullname, true, ['context' => $context]));
  51  $PAGE->add_body_class('limitedwidth');
  52  
  53  // Display.
  54  echo $OUTPUT->header();
  55  echo $OUTPUT->heading($pagetitle);
  56  
  57  $renderer = $PAGE->get_renderer('mod_lti');
  58  $coursetoolspage = new course_tools_page($course->id);
  59  echo $renderer->render($coursetoolspage);
  60  $PAGE->requires->js_call_amd('mod_lti/course_tools_list', 'init');
  61  
  62  echo $OUTPUT->footer();