MDL-40922 mod_folder: replaced the 'view' and 'view all' add_to_log calls with events
[moodle.git] / mod / scorm / index.php
blob0b99c4da19e98f1ad89f0943542def8998bd5547
1 <?php
2 // This file is part of Moodle - http://moodle.org/
3 //
4 // Moodle is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU General Public License as published by
6 // the Free Software Foundation, either version 3 of the License, or
7 // (at your option) any later version.
8 //
9 // Moodle is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
14 // You should have received a copy of the GNU General Public License
15 // along with Moodle. If not, see <http://www.gnu.org/licenses/>.
17 require_once("../../config.php");
18 require_once($CFG->dirroot.'/mod/scorm/locallib.php');
20 $id = required_param('id', PARAM_INT); // course id
22 $PAGE->set_url('/mod/scorm/index.php', array('id'=>$id));
24 if (!empty($id)) {
25 if (!$course = $DB->get_record('course', array('id'=>$id))) {
26 print_error('invalidcourseid');
28 } else {
29 print_error('missingparameter');
32 require_course_login($course);
33 $PAGE->set_pagelayout('incourse');
35 add_to_log($course->id, "scorm", "view all", "index.php?id=$course->id", "");
37 $strscorm = get_string("modulename", "scorm");
38 $strscorms = get_string("modulenameplural", "scorm");
39 $strname = get_string("name");
40 $strsummary = get_string("summary");
41 $strreport = get_string("report", 'scorm');
42 $strlastmodified = get_string("lastmodified");
44 $PAGE->set_title($strscorms);
45 $PAGE->set_heading($course->fullname);
46 $PAGE->navbar->add($strscorms);
47 echo $OUTPUT->header();
48 echo $OUTPUT->heading($strscorms);
50 $usesections = course_format_uses_sections($course->format);
52 if ($usesections) {
53 $sortorder = "cw.section ASC";
54 } else {
55 $sortorder = "m.timemodified DESC";
58 if (! $scorms = get_all_instances_in_course("scorm", $course)) {
59 notice(get_string('thereareno', 'moodle', $strscorms), "../../course/view.php?id=$course->id");
60 exit;
63 $table = new html_table();
65 if ($usesections) {
66 $strsectionname = get_string('sectionname', 'format_'.$course->format);
67 $table->head = array ($strsectionname, $strname, $strsummary, $strreport);
68 $table->align = array ("center", "left", "left", "left");
69 } else {
70 $table->head = array ($strlastmodified, $strname, $strsummary, $strreport);
71 $table->align = array ("left", "left", "left", "left");
74 foreach ($scorms as $scorm) {
75 $context = context_module::instance($scorm->coursemodule);
76 $tt = "";
77 if ($usesections) {
78 if ($scorm->section) {
79 $tt = get_section_name($course, $scorm->section);
81 } else {
82 $tt = userdate($scorm->timemodified);
84 $report = '&nbsp;';
85 $reportshow = '&nbsp;';
86 if (has_capability('mod/scorm:viewreport', $context)) {
87 $trackedusers = scorm_get_count_users($scorm->id, $scorm->groupingid);
88 if ($trackedusers > 0) {
89 $reportshow = '<a href="report.php?id='.$scorm->coursemodule.'">'.get_string('viewallreports', 'scorm', $trackedusers).'</a></div>';
90 } else {
91 $reportshow = get_string('noreports', 'scorm');
93 } else if (has_capability('mod/scorm:viewscores', $context)) {
94 require_once('locallib.php');
95 $report = scorm_grade_user($scorm, $USER->id);
96 $reportshow = get_string('score', 'scorm').": ".$report;
98 $options = (object)array('noclean'=>true);
99 if (!$scorm->visible) {
100 //Show dimmed if the mod is hidden
101 $table->data[] = array ($tt, "<a class=\"dimmed\" href=\"view.php?id=$scorm->coursemodule\">".format_string($scorm->name)."</a>",
102 format_module_intro('scorm', $scorm, $scorm->coursemodule), $reportshow);
103 } else {
104 //Show normal if the mod is visible
105 $table->data[] = array ($tt, "<a href=\"view.php?id=$scorm->coursemodule\">".format_string($scorm->name)."</a>",
106 format_module_intro('scorm', $scorm, $scorm->coursemodule), $reportshow);
110 echo "<br />";
112 echo html_writer::table($table);
114 echo $OUTPUT->footer();