Commit | Line | Data |
---|---|---|
5c508e3f | 1 | <?php |
f7b5c6aa DM |
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. | |
13 | // | |
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/>. | |
16 | ||
17 | require_once("../../config.php"); | |
18 | require_once($CFG->dirroot.'/mod/scorm/locallib.php'); | |
19 | ||
4cb25b36 | 20 | $id = required_param('id', PARAM_INT); // Course id. |
f7b5c6aa | 21 | |
27b8872c | 22 | $PAGE->set_url('/mod/scorm/index.php', array('id' => $id)); |
f7b5c6aa DM |
23 | |
24 | if (!empty($id)) { | |
27b8872c | 25 | if (!$course = $DB->get_record('course', array('id' => $id))) { |
f7b5c6aa | 26 | print_error('invalidcourseid'); |
7487c856 | 27 | } |
f7b5c6aa DM |
28 | } else { |
29 | print_error('missingparameter'); | |
30 | } | |
31 | ||
32 | require_course_login($course); | |
33 | $PAGE->set_pagelayout('incourse'); | |
34 | ||
0a616190 AA |
35 | // Trigger instances list viewed event. |
36 | $event = \mod_scorm\event\course_module_instance_list_viewed::create(array('context' => context_course::instance($course->id))); | |
1e242b41 | 37 | $event->add_record_snapshot('course', $course); |
0a616190 | 38 | $event->trigger(); |
f7b5c6aa DM |
39 | |
40 | $strscorm = get_string("modulename", "scorm"); | |
41 | $strscorms = get_string("modulenameplural", "scorm"); | |
f7b5c6aa DM |
42 | $strname = get_string("name"); |
43 | $strsummary = get_string("summary"); | |
44 | $strreport = get_string("report", 'scorm'); | |
45 | $strlastmodified = get_string("lastmodified"); | |
46 | ||
47 | $PAGE->set_title($strscorms); | |
48 | $PAGE->set_heading($course->fullname); | |
49 | $PAGE->navbar->add($strscorms); | |
50 | echo $OUTPUT->header(); | |
b2970f96 | 51 | echo $OUTPUT->heading($strscorms); |
f7b5c6aa DM |
52 | |
53 | $usesections = course_format_uses_sections($course->format); | |
f7b5c6aa DM |
54 | |
55 | if ($usesections) { | |
56 | $sortorder = "cw.section ASC"; | |
57 | } else { | |
58 | $sortorder = "m.timemodified DESC"; | |
59 | } | |
60 | ||
61 | if (! $scorms = get_all_instances_in_course("scorm", $course)) { | |
62 | notice(get_string('thereareno', 'moodle', $strscorms), "../../course/view.php?id=$course->id"); | |
63 | exit; | |
64 | } | |
65 | ||
66 | $table = new html_table(); | |
67 | ||
68 | if ($usesections) { | |
09af1e28 | 69 | $strsectionname = get_string('sectionname', 'format_'.$course->format); |
f7b5c6aa DM |
70 | $table->head = array ($strsectionname, $strname, $strsummary, $strreport); |
71 | $table->align = array ("center", "left", "left", "left"); | |
72 | } else { | |
73 | $table->head = array ($strlastmodified, $strname, $strsummary, $strreport); | |
74 | $table->align = array ("left", "left", "left", "left"); | |
75 | } | |
76 | ||
77 | foreach ($scorms as $scorm) { | |
a3fc4b3a | 78 | $context = context_module::instance($scorm->coursemodule); |
f7b5c6aa | 79 | $tt = ""; |
7487c856 | 80 | if ($usesections) { |
f7b5c6aa | 81 | if ($scorm->section) { |
71a56e08 | 82 | $tt = get_section_name($course, $scorm->section); |
f7b5c6aa | 83 | } |
03f5a0f8 | 84 | } else { |
f7b5c6aa | 85 | $tt = userdate($scorm->timemodified); |
03f5a0f8 | 86 | } |
f7b5c6aa DM |
87 | $report = ' '; |
88 | $reportshow = ' '; | |
89 | if (has_capability('mod/scorm:viewreport', $context)) { | |
90 | $trackedusers = scorm_get_count_users($scorm->id, $scorm->groupingid); | |
91 | if ($trackedusers > 0) { | |
4cb25b36 | 92 | $reportshow = html_writer::link('report.php?id='.$scorm->coursemodule, |
0025296f | 93 | get_string('viewallreports', 'scorm', $trackedusers)); |
03f5a0f8 | 94 | } else { |
f7b5c6aa | 95 | $reportshow = get_string('noreports', 'scorm'); |
1f106b3f | 96 | } |
f7b5c6aa DM |
97 | } else if (has_capability('mod/scorm:viewscores', $context)) { |
98 | require_once('locallib.php'); | |
99 | $report = scorm_grade_user($scorm, $USER->id); | |
100 | $reportshow = get_string('score', 'scorm').": ".$report; | |
03f5a0f8 | 101 | } |
27b8872c | 102 | $options = (object)array('noclean' => true); |
f7b5c6aa | 103 | if (!$scorm->visible) { |
4cb25b36 | 104 | // Show dimmed if the mod is hidden. |
105 | $table->data[] = array ($tt, html_writer::link('view.php?id='.$scorm->coursemodule, | |
106 | format_string($scorm->name), | |
107 | array('class' => 'dimmed')), | |
f7b5c6aa DM |
108 | format_module_intro('scorm', $scorm, $scorm->coursemodule), $reportshow); |
109 | } else { | |
4cb25b36 | 110 | // Show normal if the mod is visible. |
27b8872c | 111 | $table->data[] = array ($tt, html_writer::link('view.php?id='.$scorm->coursemodule, format_string($scorm->name)), |
f7b5c6aa DM |
112 | format_module_intro('scorm', $scorm, $scorm->coursemodule), $reportshow); |
113 | } | |
114 | } | |
03f5a0f8 | 115 | |
27b8872c | 116 | echo html_writer::empty_tag('br'); |
03f5a0f8 | 117 | |
f7b5c6aa | 118 | echo html_writer::table($table); |
e5dd8e3b | 119 | |
f7b5c6aa | 120 | echo $OUTPUT->footer(); |