[ Index ]

PHP Cross Reference of moodle-2.8

title

Body

[close]

/mod/imscp/ -> view.php (source)

   1  <?php
   2  
   3  // This file is part of Moodle - http://moodle.org/
   4  //
   5  // Moodle is free software: you can redistribute it and/or modify
   6  // it under the terms of the GNU General Public License as published by
   7  // the Free Software Foundation, either version 3 of the License, or
   8  // (at your option) any later version.
   9  //
  10  // Moodle is distributed in the hope that it will be useful,
  11  // but WITHOUT ANY WARRANTY; without even the implied warranty of
  12  // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  13  // GNU General Public License for more details.
  14  //
  15  // You should have received a copy of the GNU General Public License
  16  // along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
  17  
  18  /**
  19   * IMS CP module main user interface
  20   *
  21   * @package mod_imscp
  22   * @copyright  2009 Petr Skoda  {@link http://skodak.org}
  23   * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  24   */
  25  
  26  require('../../config.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  $params = array(
  49      'context' => $context,
  50      'objectid' => $imscp->id
  51  );
  52  $event = \mod_imscp\event\course_module_viewed::create($params);
  53  $event->add_record_snapshot('imscp', $imscp);
  54  $event->trigger();
  55  
  56  // Update 'viewed' state if required by completion system
  57  $completion = new completion_info($course);
  58  $completion->set_module_viewed($cm);
  59  
  60  $PAGE->set_url('/mod/imscp/view.php', array('id' => $cm->id));
  61  $PAGE->requires->js('/mod/imscp/dummyapi.js', true);
  62  
  63  $PAGE->requires->string_for_js('navigation', 'imscp');
  64  $PAGE->requires->string_for_js('toc', 'imscp');
  65  $PAGE->requires->string_for_js('hide', 'moodle');
  66  $PAGE->requires->string_for_js('show', 'moodle');
  67  
  68  //TODO: find some better way to disable blocks and minimise footer - pagetype just for this does not seem like a good solution
  69  //$PAGE->set_pagelayout('maxcontent');
  70  
  71  $PAGE->set_title($course->shortname.': '.$imscp->name);
  72  $PAGE->set_heading($course->fullname);
  73  $PAGE->set_activity_record($imscp);
  74  echo $OUTPUT->header();
  75  echo $OUTPUT->heading(format_string($imscp->name));
  76  
  77  // verify imsmanifest was parsed properly
  78  if (!$imscp->structure) {
  79      echo $OUTPUT->notification(get_string('deploymenterror', 'imscp'), 'notifyproblem');
  80      echo $OUTPUT->footer();
  81      die;
  82  }
  83  
  84  imscp_print_content($imscp, $cm, $course);
  85  
  86  echo $OUTPUT->footer();


Generated: Fri Nov 28 20:29:05 2014 Cross-referenced by PHPXref 0.7.1