|
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 require_once("../../config.php"); 00018 require_once($CFG->dirroot.'/mod/scorm/locallib.php'); 00019 00020 $id = required_param('id', PARAM_INT); // course id 00021 00022 $PAGE->set_url('/mod/scorm/index.php', array('id'=>$id)); 00023 00024 if (!empty($id)) { 00025 if (!$course = $DB->get_record('course', array('id'=>$id))) { 00026 print_error('invalidcourseid'); 00027 } 00028 } else { 00029 print_error('missingparameter'); 00030 } 00031 00032 require_course_login($course); 00033 $PAGE->set_pagelayout('incourse'); 00034 00035 add_to_log($course->id, "scorm", "view all", "index.php?id=$course->id", ""); 00036 00037 $strscorm = get_string("modulename", "scorm"); 00038 $strscorms = get_string("modulenameplural", "scorm"); 00039 $strsectionname = get_string('sectionname', 'format_'.$course->format); 00040 $strname = get_string("name"); 00041 $strsummary = get_string("summary"); 00042 $strreport = get_string("report", 'scorm'); 00043 $strlastmodified = get_string("lastmodified"); 00044 00045 $PAGE->set_title($strscorms); 00046 $PAGE->set_heading($course->fullname); 00047 $PAGE->navbar->add($strscorms); 00048 echo $OUTPUT->header(); 00049 00050 $usesections = course_format_uses_sections($course->format); 00051 if ($usesections) { 00052 $sections = get_all_sections($course->id); 00053 } 00054 00055 if ($usesections) { 00056 $sortorder = "cw.section ASC"; 00057 } else { 00058 $sortorder = "m.timemodified DESC"; 00059 } 00060 00061 if (! $scorms = get_all_instances_in_course("scorm", $course)) { 00062 notice(get_string('thereareno', 'moodle', $strscorms), "../../course/view.php?id=$course->id"); 00063 exit; 00064 } 00065 00066 $table = new html_table(); 00067 00068 if ($usesections) { 00069 $table->head = array ($strsectionname, $strname, $strsummary, $strreport); 00070 $table->align = array ("center", "left", "left", "left"); 00071 } else { 00072 $table->head = array ($strlastmodified, $strname, $strsummary, $strreport); 00073 $table->align = array ("left", "left", "left", "left"); 00074 } 00075 00076 foreach ($scorms as $scorm) { 00077 $context = get_context_instance(CONTEXT_MODULE, $scorm->coursemodule); 00078 $tt = ""; 00079 if ($usesections) { 00080 if ($scorm->section) { 00081 $tt = get_section_name($course, $sections[$scorm->section]); 00082 } 00083 } else { 00084 $tt = userdate($scorm->timemodified); 00085 } 00086 $report = ' '; 00087 $reportshow = ' '; 00088 if (has_capability('mod/scorm:viewreport', $context)) { 00089 $trackedusers = scorm_get_count_users($scorm->id, $scorm->groupingid); 00090 if ($trackedusers > 0) { 00091 $reportshow = '<a href="report.php?id='.$scorm->coursemodule.'">'.get_string('viewallreports', 'scorm', $trackedusers).'</a></div>'; 00092 } else { 00093 $reportshow = get_string('noreports', 'scorm'); 00094 } 00095 } else if (has_capability('mod/scorm:viewscores', $context)) { 00096 require_once('locallib.php'); 00097 $report = scorm_grade_user($scorm, $USER->id); 00098 $reportshow = get_string('score', 'scorm').": ".$report; 00099 } 00100 $options = (object)array('noclean'=>true); 00101 if (!$scorm->visible) { 00102 //Show dimmed if the mod is hidden 00103 $table->data[] = array ($tt, "<a class=\"dimmed\" href=\"view.php?id=$scorm->coursemodule\">".format_string($scorm->name)."</a>", 00104 format_module_intro('scorm', $scorm, $scorm->coursemodule), $reportshow); 00105 } else { 00106 //Show normal if the mod is visible 00107 $table->data[] = array ($tt, "<a href=\"view.php?id=$scorm->coursemodule\">".format_string($scorm->name)."</a>", 00108 format_module_intro('scorm', $scorm, $scorm->coursemodule), $reportshow); 00109 } 00110 } 00111 00112 echo "<br />"; 00113 00114 echo html_writer::table($table); 00115 00116 echo $OUTPUT->footer();