This repository was archived by the owner on Apr 12, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathview.php
More file actions
71 lines (58 loc) · 2.47 KB
/
Copy pathview.php
File metadata and controls
71 lines (58 loc) · 2.47 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
<?php
// This file is part of Moodle - https://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <https://www.gnu.org/licenses/>.
/**
* Prints an instance of mod_dmelearn.
*
* @package mod_dmelearn
* @author Kien Vu, AJ Dunn
* @copyright 2015 - 2022 WCHN Digital Learning & Design, 2015 BrightCookie (http://www.brightcookie.com.au)
* @since 1.0.0
* @license https://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
require_once(dirname(dirname(dirname(__FILE__))) . '/config.php');
require_once('lib.php');
$id = required_param('id', PARAM_INT); // Course Module ID.
if (!$coursemodule = get_coursemodule_from_id('dmelearn', $id)) {
print_error('Course Module ID was incorrect');
}
if (!$course = $DB->get_record('course', array('id' => $coursemodule->course))) {
print_error('Course is misconfigured');
}
$context = context_module::instance($coursemodule->id);
require_login($course->id, true, $coursemodule);
$canview = has_capability('mod/dmelearn:view', $context);
if (!$canview) {
print_error('accessdenied', 'dmelearn');
}
if (!$elmo = $DB->get_record('dmelearn', array('id' => $coursemodule->instance))) {
print_error('Course module is incorrect, instance');
}
if (!$cw = $DB->get_record('course_sections', array('id' => $coursemodule->section))) {
print_error('Course module is incorrect, section');
}
// Use the new Moodle 2.7+ $event->trigger() for logging.
if ($CFG->version >= 2014051200) {
$event = \mod_dmelearn\event\course_module_viewed::create(array(
'objectid' => $PAGE->cm->instance,
'context' => $PAGE->context,
));
$event->add_record_snapshot('course', $PAGE->course);
// In the next line you can use $PAGE->activityrecord if it is set, or skip this line if you don't have a record
// $event->add_record_snapshot($PAGE->cm->modname, $activityrecord);
$event->trigger();
}
header("location: {$CFG->wwwroot}/mod/dmelearn/content/?id={$elmo->id}");
die();