3 require_once("../../config.php");
5 $id = required_param('id', PARAM_INT
); // Course module ID
7 if (! $cm = get_coursemodule_from_id('quiz', $id)) {
8 error('Course Module ID was incorrect');
11 if (! $quiz = get_record('quiz', 'id', $cm->instance
)) {
12 error('quiz ID was incorrect');
15 if (! $course = get_record('course', 'id', $quiz->course
)) {
16 error('Course is misconfigured');
19 require_login($course->id
, false, $cm);
21 if (has_capability('mod/quiz:viewreports', get_context_instance(CONTEXT_MODULE
, $cm->id
))) {
22 redirect('report.php?id='.$cm->id
);
24 redirect('view.php?id='.$cm->id
);