-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathcoursesettings.php
61 lines (42 loc) · 1.74 KB
/
coursesettings.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
<?php
/**
* Configure course coursesettingss.
*
* @package mod_evokeportfolio
* @copyright 2021 World Bank Group <https://worldbank.org>
* @author Willian Mano <[email protected]>
*/
require(__DIR__.'/../../config.php');
// Course module id.
$id = required_param('id', PARAM_INT);
$course = $DB->get_record('course', ['id' => $id], '*', MUST_EXIST);
require_course_login($course, true);
$context = context_course::instance($course->id);
if (!has_capability('moodle/course:update', $context)) {
redirect(new moodle_url('/course/view.php', ['id' => $id]), \core\notification::error('Illegal access!'));
}
$url = new moodle_url('/local/evokegame/coursesettings.php', ['id' => $course->id]);
$PAGE->set_url($url);
$PAGE->set_title(format_string($course->fullname));
$PAGE->set_heading(format_string($course->fullname));
$PAGE->set_context($context);
$formdata = [
'courseid' => $id
];
$form = new \local_evokegame\forms\coursesettings($url, $formdata);
if ($form->is_cancelled()) {
redirect(new moodle_url('/course/view.php', ['id' => $id]));
} else if ($formdata = $form->get_data()) {
$data = clone $formdata;
unset($data->submitbutton);
$coursesettingsutil = new \local_evokegame\util\coursesettings();
$coursesettingsutil->process_form($data, $context);
$url = new moodle_url('/course/view.php', ['id' => $id]);
redirect($url, get_string('coursesettings_success', 'local_evokegame'), null, \core\output\notification::NOTIFY_SUCCESS);
} else {
echo $OUTPUT->header();
$renderer = $PAGE->get_renderer('local_evokegame');
$contentrenderable = new \local_evokegame\output\coursesettings($course, $context, $form);
echo $renderer->render($contentrenderable);
echo $OUTPUT->footer();
}