2 // This file is part of Moodle - http://moodle.org/
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.
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));
25 if (!$course = $DB->get_record('course', array('id' => $id))) {
26 throw new \
moodle_exception('invalidcourseid');
29 throw new \
moodle_exception('missingparameter');
32 require_course_login($course);
33 $PAGE->set_pagelayout('incourse');
35 // Trigger instances list viewed event.
36 $event = \mod_scorm\event\course_module_instance_list_viewed
::create(array('context' => context_course
::instance($course->id
)));
37 $event->add_record_snapshot('course', $course);
40 $strscorm = get_string("modulename", "scorm");
41 $strscorms = get_string("modulenameplural", "scorm");
42 $strname = get_string("name");
43 $strsummary = get_string("summary");
44 $strreport = get_string("report", 'scorm');
45 $strlastmodified = get_string("lastmodified");
47 $PAGE->set_title($strscorms);
48 $PAGE->set_heading($course->fullname
);
49 $PAGE->navbar
->add($strscorms);
50 echo $OUTPUT->header();
52 $usesections = course_format_uses_sections($course->format
);
55 $sortorder = "cw.section ASC";
57 $sortorder = "m.timemodified DESC";
60 if (! $scorms = get_all_instances_in_course("scorm", $course)) {
61 notice(get_string('thereareno', 'moodle', $strscorms), "../../course/view.php?id=$course->id");
65 $table = new html_table();
68 $strsectionname = get_string('sectionname', 'format_'.$course->format
);
69 $table->head
= array ($strsectionname, $strname, $strsummary, $strreport);
70 $table->align
= array ("center", "left", "left", "left");
72 $table->head
= array ($strlastmodified, $strname, $strsummary, $strreport);
73 $table->align
= array ("left", "left", "left", "left");
76 foreach ($scorms as $scorm) {
77 $context = context_module
::instance($scorm->coursemodule
);
80 if ($scorm->section
) {
81 $tt = get_section_name($course, $scorm->section
);
84 $tt = userdate($scorm->timemodified
);
87 $reportshow = ' ';
88 if (has_capability('mod/scorm:viewreport', $context)) {
89 $trackedusers = scorm_get_count_users($scorm->id
, $scorm->groupingid
);
90 if ($trackedusers > 0) {
91 $reportshow = html_writer
::link('report.php?id='.$scorm->coursemodule
,
92 get_string('viewallreports', 'scorm', $trackedusers));
94 $reportshow = get_string('noreports', 'scorm');
96 } else if (has_capability('mod/scorm:viewscores', $context)) {
97 require_once('locallib.php');
98 $report = scorm_grade_user($scorm, $USER->id
);
99 $reportshow = get_string('score', 'scorm').": ".$report;
101 $options = (object)array('noclean' => true);
102 if (!$scorm->visible
) {
103 // Show dimmed if the mod is hidden.
104 $table->data
[] = array ($tt, html_writer
::link('view.php?id='.$scorm->coursemodule
,
105 format_string($scorm->name
),
106 array('class' => 'dimmed')),
107 format_module_intro('scorm', $scorm, $scorm->coursemodule
), $reportshow);
109 // Show normal if the mod is visible.
110 $table->data
[] = array ($tt, html_writer
::link('view.php?id='.$scorm->coursemodule
, format_string($scorm->name
)),
111 format_module_intro('scorm', $scorm, $scorm->coursemodule
), $reportshow);
115 echo html_writer
::empty_tag('br');
117 echo html_writer
::table($table);
119 echo $OUTPUT->footer();