SCORM Grades MDL-22332 redirect to report page correctly from gradebook - thanks...
[moodle.git] / mod / scorm / grade.php
CommitLineData
e0ad0e73
DM
1<?php
2
3 require_once("../../config.php");
4
5 $id = required_param('id', PARAM_INT); // Course module ID
6
7 if (! $cm = get_coursemodule_from_id('scorm', $id)) {
8 print_error('invalidcoursemodule');
9 }
10
20f88deb 11 if (! $scorm = $DB->get_record('scorm', array('id'=>$cm->instance))) {
e0ad0e73
DM
12 print_error('invalidcoursemodule');
13 }
14
20f88deb 15 if (! $course = $DB->get_record('course', array('id'=> $scorm->course))) {
e0ad0e73
DM
16 print_error('coursemisconf');
17 }
18
19 require_login($course->id, false, $cm);
20
21 if (has_capability('mod/scorm:viewreport', get_context_instance(CONTEXT_MODULE, $cm->id))) {
22 redirect('report.php?id='.$cm->id);
23 } else {
24 redirect('view.php?id='.$cm->id);
25 }