Merge commit 'catalyst/MOODLE_19_STABLE' into mdl19-linuxchix
[moodle-linuxchix.git] / mod / scorm / index.php
blob5e4fc4ffc136f6c8ce30477a6b79d5d8547a5f63
1 <?php // $Id$
3 require_once("../../config.php");
4 require_once("locallib.php");
6 $id = required_param('id', PARAM_INT); // course id
8 if (!empty($id)) {
9 if (! $course = get_record("course", "id", $id)) {
10 error("Course ID is incorrect");
12 } else {
13 error('A required parameter is missing');
16 require_course_login($course);
18 add_to_log($course->id, "scorm", "view all", "index.php?id=$course->id", "");
20 $strscorm = get_string("modulename", "scorm");
21 $strscorms = get_string("modulenameplural", "scorm");
22 $strweek = get_string("week");
23 $strtopic = get_string("topic");
24 $strname = get_string("name");
25 $strsummary = get_string("summary");
26 $strreport = get_string("report",'scorm');
27 $strlastmodified = get_string("lastmodified");
29 $navlinks = array();
30 $navlinks[] = array('name' => $strscorms, 'link' => '', 'type' => 'activity');
31 $navigation = build_navigation($navlinks);
33 print_header_simple("$strscorms", "", $navigation,
34 "", "", true, "", navmenu($course));
36 if ($course->format == "weeks" or $course->format == "topics") {
37 $sortorder = "cw.section ASC";
38 } else {
39 $sortorder = "m.timemodified DESC";
42 if (! $scorms = get_all_instances_in_course("scorm", $course)) {
43 notice(get_string('thereareno', 'moodle', $strscorms), "../../course/view.php?id=$course->id");
44 exit;
47 if ($course->format == "weeks") {
48 $table->head = array ($strweek, $strname, $strsummary, $strreport);
49 $table->align = array ("center", "left", "left", "left");
50 } else if ($course->format == "topics") {
51 $table->head = array ($strtopic, $strname, $strsummary, $strreport);
52 $table->align = array ("center", "left", "left", "left");
53 } else {
54 $table->head = array ($strlastmodified, $strname, $strsummary, $strreport);
55 $table->align = array ("left", "left", "left", "left");
58 foreach ($scorms as $scorm) {
60 $context = get_context_instance(CONTEXT_MODULE,$scorm->coursemodule);
61 $tt = "";
62 if ($course->format == "weeks" or $course->format == "topics") {
63 if ($scorm->section) {
64 $tt = "$scorm->section";
66 } else {
67 $tt = userdate($scorm->timemodified);
69 $report = '&nbsp;';
70 $reportshow = '&nbsp;';
71 if (has_capability('mod/scorm:viewreport', $context)) {
72 $trackedusers = scorm_get_count_users($scorm->id, $scorm->groupingid);
73 if ($trackedusers > 0) {
74 $reportshow = '<a href="report.php?id='.$scorm->coursemodule.'">'.get_string('viewallreports','scorm',$trackedusers).'</a></div>';
75 } else {
76 $reportshow = get_string('noreports','scorm');
78 } else if (has_capability('mod/scorm:viewscores', $context)) {
79 require_once('locallib.php');
80 $report = scorm_grade_user($scorm, $USER->id);
81 $reportshow = get_string('score','scorm').": ".$report;
83 if (!$scorm->visible) {
84 //Show dimmed if the mod is hidden
85 $table->data[] = array ($tt, "<a class=\"dimmed\" href=\"view.php?id=$scorm->coursemodule\">".format_string($scorm->name)."</a>",
86 format_text($scorm->summary), $reportshow);
87 } else {
88 //Show normal if the mod is visible
89 $table->data[] = array ($tt, "<a href=\"view.php?id=$scorm->coursemodule\">".format_string($scorm->name)."</a>",
90 format_text($scorm->summary), $reportshow);
94 echo "<br />";
96 print_table($table);
98 print_footer($course);