MDL-11082 Improved groups upgrade performance 1.8x -> 1.9; thanks Eloy for telling...
[moodle-pu.git] / mod / scorm / index.php
blob92c9ee8a0cf73b9e3584b34e67a154ef553fd79f
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("There are no scorms", "../../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 if (has_capability('mod/scorm:viewreport', $context)) {
71 $trackedusers = scorm_get_count_users($scorm->id, $scorm->groupingid);
72 if ($trackedusers > 0) {
73 $reportshow = '<a href="report.php?id='.$scorm->coursemodule.'">'.get_string('viewallreports','scorm',$trackedusers).'</a></div>';
74 } else {
75 $reportshow = get_string('noreports','scorm');
77 } else if (has_capability('mod/scorm:viewscores', $context)) {
78 require_once('locallib.php');
79 $report = scorm_grade_user($scorm, $USER->id);
80 $reportshow = get_string('score','scorm').": ".$report;
82 if (!$scorm->visible) {
83 //Show dimmed if the mod is hidden
84 $table->data[] = array ($tt, "<a class=\"dimmed\" href=\"view.php?id=$scorm->coursemodule\">".format_string($scorm->name,true)."</a>",
85 format_text($scorm->summary), $reportshow);
86 } else {
87 //Show normal if the mod is visible
88 $table->data[] = array ($tt, "<a href=\"view.php?id=$scorm->coursemodule\">".format_string($scorm->name,true)."</a>",
89 format_text($scorm->summary), $reportshow);
93 echo "<br />";
95 print_table($table);
97 print_footer($course);