|
Moodle
2.2.1
http://www.collinsharper.com
|
00001 <?php 00002 // This file is part of Moodle - http://moodle.org/ 00003 // 00004 // Moodle is free software: you can redistribute it and/or modify 00005 // it under the terms of the GNU General Public License as published by 00006 // the Free Software Foundation, either version 3 of the License, or 00007 // (at your option) any later version. 00008 // 00009 // Moodle is distributed in the hope that it will be useful, 00010 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00012 // GNU General Public License for more details. 00013 // 00014 // You should have received a copy of the GNU General Public License 00015 // along with Moodle. If not, see <http://www.gnu.org/licenses/>. 00016 00017 // This script uses installed report plugins to print scorm reports 00018 00019 require_once("../../config.php"); 00020 require_once($CFG->libdir.'/tablelib.php'); 00021 require_once($CFG->dirroot.'/mod/scorm/locallib.php'); 00022 require_once($CFG->dirroot.'/mod/scorm/reportsettings_form.php'); 00023 require_once($CFG->dirroot.'/mod/scorm/report/reportlib.php'); 00024 require_once($CFG->libdir.'/formslib.php'); 00025 require_once($CFG->dirroot.'/mod/scorm/report/default.php'); // Parent class 00026 define('SCORM_REPORT_DEFAULT_PAGE_SIZE', 20); 00027 define('SCORM_REPORT_ATTEMPTS_ALL_STUDENTS', 0); 00028 define('SCORM_REPORT_ATTEMPTS_STUDENTS_WITH', 1); 00029 define('SCORM_REPORT_ATTEMPTS_STUDENTS_WITH_NO', 2); 00030 00031 $id = required_param('id', PARAM_INT);// Course Module ID, or 00032 $download = optional_param('download', '', PARAM_RAW); 00033 $mode = optional_param('mode', '', PARAM_ALPHA); // Report mode 00034 00035 $cm = get_coursemodule_from_id('scorm', $id, 0, false, MUST_EXIST); 00036 $course = $DB->get_record('course', array('id'=>$cm->course), '*', MUST_EXIST); 00037 $scorm = $DB->get_record('scorm', array('id'=>$cm->instance), '*', MUST_EXIST); 00038 00039 $contextmodule = get_context_instance(CONTEXT_MODULE, $cm->id); 00040 $reportlist = scorm_report_list($contextmodule); 00041 00042 $url = new moodle_url('/mod/scorm/report.php'); 00043 00044 $url->param('id', $id); 00045 if (empty($mode)) { 00046 $mode = reset($reportlist); 00047 } else if (!in_array($mode, $reportlist)) { 00048 print_error('erroraccessingreport', 'scorm'); 00049 } 00050 $url->param('mode', $mode); 00051 00052 $PAGE->set_url($url); 00053 00054 require_login($course->id, false, $cm); 00055 00056 require_capability('mod/scorm:viewreport', $contextmodule); 00057 00058 if (count($reportlist) < 1) { 00059 print_error('erroraccessingreport', 'scorm'); 00060 } 00061 00062 add_to_log($course->id, 'scorm', 'report', 'report.php?id='.$cm->id, $scorm->id, $cm->id); 00063 $userdata = null; 00064 if (!empty($download)) { 00065 $noheader = true; 00066 } 00068 if (empty($noheader)) { 00069 $strreport = get_string('report', 'scorm'); 00070 $strattempt = get_string('attempt', 'scorm'); 00071 00072 $PAGE->set_title("$course->shortname: ".format_string($scorm->name)); 00073 $PAGE->set_heading($course->fullname); 00074 $PAGE->navbar->add($strreport, new moodle_url('/mod/scorm/report.php', array('id'=>$cm->id))); 00075 00076 echo $OUTPUT->header(); 00077 $currenttab = 'reports'; 00078 require($CFG->dirroot . '/mod/scorm/tabs.php'); 00079 echo $OUTPUT->heading(format_string($scorm->name)); 00080 } 00081 00082 // Open the selected Scorm report and display it 00083 $reportclassname = "scorm_{$mode}_report"; 00084 $report = new $reportclassname(); 00085 $report->display($scorm, $cm, $course, $download); // Run the report! 00086 00087 // Print footer 00088 00089 if (empty($noheader)) { 00090 echo $OUTPUT->footer(); 00091 }