forked from richardjonesnz/moodle-mod_simplelesson
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmanage_attempts.php
More file actions
executable file
·64 lines (52 loc) · 2.44 KB
/
Copy pathmanage_attempts.php
File metadata and controls
executable file
·64 lines (52 loc) · 2.44 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
<?php
// This file is part of Moodle - http://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 <http://www.gnu.org/licenses/>.
/**
* Manage the attempt records.
*
* @package mod_simplelesson
* @copyright 2018 Richard Jones <richardnz@outlook.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
use mod_simplelesson\local\reporting;
use mod_simplelesson\local\attempts;
use mod_simplelesson\forms\manage_attempts_select;
require_once('../../config.php');
$courseid = required_param('courseid', PARAM_INT);
$action = optional_param('action', 'none', PARAM_ALPHA);
$attemptid = optional_param('attemptid', 0, PARAM_INT);
$course = $DB->get_record('course', ['id' => $courseid], '*', MUST_EXIST);
// Set up the page.
$PAGE->set_url('/mod/simplelesson/manage_attempts.php', ['courseid' => $courseid, 'action' => $action]);
require_login($course, true);
$coursecontext = context_course::instance($courseid);
require_capability('mod/simplelesson:manageattempts', $coursecontext);
$PAGE->set_heading(format_string($course->fullname));
$PAGE->activityheader->set_description('');
$simplelesson = $PAGE->cm;
$returnmanage = new moodle_url('/mod/simplelesson/manage_attempts.php', ['courseid' => $courseid,
'action' => $action]);
if ( ($action == 'delete') && ($attempt != 0) ) {
$message = attempts::delete_attempt($attemptid) ? get_string('attempt_deleted', 'mod_simplelesson')
: get_string('attempt_not_deleted', 'mod_simplelesson');
redirect($returnmanage, $message, 2);
}
$mform = new manage_attempts_select(null, ['courseid' => $courseid, 'action' => $action]);
$sortby = ($data = $mform->get_data()) ? $data->sortby : 'id';
$records = reporting::fetch_course_attempt_data($courseid, $sortby);
echo $OUTPUT->header();
$mform->display();
echo reporting::show_course_attempt_report($records, $courseid);
echo $OUTPUT->footer();