-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathview.php
63 lines (45 loc) · 1.74 KB
/
view.php
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
<?php
/**
* Prints an instance of mod_nosferatu.
*
* @package mod_nosferatu
* @copyright 2021 Ferran Recio <[email protected]>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
use mod_nosferatu\manager;
require(__DIR__ . '/../../config.php');
require_once(__DIR__ . '/lib.php');
$id = required_param('id', PARAM_INT);
$section = optional_param('section', 'starter', PARAM_ALPHA);
list($course, $cm) = get_course_and_cm_from_cmid($id, 'nosferatu');
require_login($course, true, $cm);
$manager = manager::create_from_coursemodule($cm);
$instance = $manager->get_instance();
$context = $manager->get_context();
// Trigger module viewed event and completion.
$manager->set_module_viewed($course);
$url = new moodle_url('/mod/nosferatu/view.php', ['id' => $cm->id, 'section' => $section]);
$PAGE->set_url($url);
$shortname = format_string($course->shortname, true, ['context' => $context]);
$pagetitle = strip_tags($shortname . ': ' . format_string($instance->name));
$PAGE->set_title(format_string($pagetitle));
$PAGE->set_heading(format_string($course->fullname));
$PAGE->set_context($context);
echo $OUTPUT->header();
echo $OUTPUT->heading(format_string($instance->name));
$instance = $manager->get_instance();
if (!empty($instance->intro)) {
echo $OUTPUT->box(format_module_intro('nosferatu', $instance, $cm->id), 'generalbox', 'intro');
}
$navigation = new mod_nosferatu\output\action_bar($manager, $url);
echo $navigation->get_view_bar();
switch ($section) {
case 'beginner':
$widget = new mod_nosferatu\output\beginner($manager, $section);
break;
default:
$widget = new mod_nosferatu\output\starter($manager, $section);
break;
}
echo $OUTPUT->render($widget);
echo $OUTPUT->footer();