Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 3.11.x will end 14 Nov 2022 (12 months plus 6 months extension).
  • Bug fixes for security issues in 3.11.x will end 13 Nov 2023 (18 months plus 12 months extension).
  • PHP version: minimum PHP 7.3.0 Note: minimum PHP version has increased since Moodle 3.10. PHP 7.4.x is supported too.
/mod/imscp/ -> view.php (source)

Differences Between: [Versions 310 and 311] [Versions 311 and 400] [Versions 311 and 401] [Versions 311 and 402] [Versions 311 and 403] [Versions 39 and 311]

   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   * IMS CP module main user interface
  19   *
  20   * @package mod_imscp
  21   * @copyright  2009 Petr Skoda  {@link http://skodak.org}
  22   * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  23   */
  24  
  25  require('../../config.php');
  26  require_once($CFG->dirroot . '/mod/imscp/lib.php');
  27  require_once("$CFG->dirroot/mod/imscp/locallib.php");
  28  require_once($CFG->libdir . '/completionlib.php');
  29  
  30  $id = optional_param('id', 0, PARAM_INT);  // Course module id.
  31  $i  = optional_param('i', 0, PARAM_INT);   // IMS CP instance id.
  32  
  33  if ($i) {  // Two ways to specify the module.
  34      $imscp = $DB->get_record('imscp', array('id' => $i), '*', MUST_EXIST);
  35      $cm = get_coursemodule_from_instance('imscp', $imscp->id, $imscp->course, false, MUST_EXIST);
  36  
  37  } else {
  38      $cm = get_coursemodule_from_id('imscp', $id, 0, false, MUST_EXIST);
  39      $imscp = $DB->get_record('imscp', array('id' => $cm->instance), '*', MUST_EXIST);
  40  }
  41  
  42  $course = $DB->get_record('course', array('id' => $cm->course), '*', MUST_EXIST);
  43  
  44  require_course_login($course, true, $cm);
  45  $context = context_module::instance($cm->id);
  46  require_capability('mod/imscp:view', $context);
  47  
  48  // Completion and trigger events.
  49  imscp_view($imscp, $course, $cm, $context);
  50  
  51  $PAGE->set_url('/mod/imscp/view.php', array('id' => $cm->id));
  52  $PAGE->requires->js('/mod/imscp/dummyapi.js', true);
  53  
  54  $PAGE->requires->string_for_js('navigation', 'imscp');
  55  $PAGE->requires->string_for_js('toc', 'imscp');
  56  $PAGE->requires->string_for_js('hide', 'moodle');
  57  $PAGE->requires->string_for_js('show', 'moodle');
  58  
  59  // TODO: find some better way to disable blocks and minimise footer - pagetype just for this does not seem like a good solution.
  60  // $PAGE->set_pagelayout('maxcontent'); ?
  61  
  62  $PAGE->set_title($course->shortname.': '.$imscp->name);
  63  $PAGE->set_heading($course->fullname);
  64  $PAGE->set_activity_record($imscp);
  65  
  66  // Verify imsmanifest was parsed properly.
  67  if (!$imscp->structure) {
  68      redirect(course_get_url($course->id, $cm->section), get_string('deploymenterror', 'imscp'));
  69  }
  70  
  71  echo $OUTPUT->header();
  72  echo $OUTPUT->heading(format_string($imscp->name));
  73  
  74  // Render the activity information.
  75  $cminfo = cm_info::create($cm);
  76  $completiondetails = \core_completion\cm_completion_details::get_instance($cminfo, $USER->id);
  77  $activitydates = \core\activity_dates::get_dates_for_module($cminfo, $USER->id);
  78  echo $OUTPUT->activity_information($cminfo, $completiondetails, $activitydates);
  79  
  80  // Info box.
  81  if ($imscp->intro) {
  82      echo $OUTPUT->box(format_module_intro('imscp', $imscp, $cm->id), 'generalbox', 'intro');
  83  }
  84  
  85  imscp_print_content($imscp, $cm, $course);
  86  
  87  echo $OUTPUT->footer();