MDL-50015 mod_imscp: New WS mod_imscp_view_imscp
[moodle.git] / mod / imscp / view.php
CommitLineData
2ff648fb 1<?php
2ff648fb 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 *
35501c37 20 * @package mod_imscp
3b43615f
PS
21 * @copyright 2009 Petr Skoda {@link http://skodak.org}
22 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
2ff648fb 23 */
24
25require('../../config.php');
947b0214 26require_once($CFG->dirroot . '/mod/imscp/lib.php');
2ff648fb 27require_once("$CFG->dirroot/mod/imscp/locallib.php");
aac4cb97 28require_once($CFG->libdir . '/completionlib.php');
2ff648fb 29
218ab060
DB
30$id = optional_param('id', 0, PARAM_INT); // Course module id.
31$i = optional_param('i', 0, PARAM_INT); // IMS CP instance id.
2ff648fb 32
218ab060
DB
33if ($i) { // Two ways to specify the module.
34 $imscp = $DB->get_record('imscp', array('id' => $i), '*', MUST_EXIST);
2ff648fb 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);
218ab060 39 $imscp = $DB->get_record('imscp', array('id' => $cm->instance), '*', MUST_EXIST);
2ff648fb 40}
41
218ab060 42$course = $DB->get_record('course', array('id' => $cm->course), '*', MUST_EXIST);
2ff648fb 43
44require_course_login($course, true, $cm);
b631c408 45$context = context_module::instance($cm->id);
e0334eca 46require_capability('mod/imscp:view', $context);
2ff648fb 47
947b0214
JL
48// Completion and trigger events.
49imscp_view($imscp, $course, $cm, $context);
c15a60e6 50
a6855934 51$PAGE->set_url('/mod/imscp/view.php', array('id' => $cm->id));
57d9e586 52$PAGE->requires->js('/mod/imscp/dummyapi.js', true);
2ff648fb 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
218ab060
DB
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'); ?
2ff648fb 61
62$PAGE->set_title($course->shortname.': '.$imscp->name);
63$PAGE->set_heading($course->fullname);
64$PAGE->set_activity_record($imscp);
44391f9f 65echo $OUTPUT->header();
43601cdf 66echo $OUTPUT->heading(format_string($imscp->name));
2ff648fb 67
218ab060 68// Verify imsmanifest was parsed properly.
2ff648fb 69if (!$imscp->structure) {
70 echo $OUTPUT->notification(get_string('deploymenterror', 'imscp'), 'notifyproblem');
47ecb374 71 echo $OUTPUT->continue_button(course_get_url($course->id, $cm->section));
2ff648fb 72 echo $OUTPUT->footer();
73 die;
74}
75
76imscp_print_content($imscp, $cm, $course);
77
78echo $OUTPUT->footer();