changed all the POST with option/required_param functions
[moodle.git] / mod / scorm / index.php
1 <?php // $Id$
3     require_once("../../config.php");
5     $id = required_param('id', '', PARAM_INT);   // course id
7     if (!empty($id)) {
8         if (! $course = get_record("course", "id", $id)) {
9             error("Course ID is incorrect");
10         }
11     } else {
12         error('A required parameter is missing');
13     }
15     require_course_login($course);
17     add_to_log($course->id, "scorm", "view all", "index.php?id=$course->id", "");
19     $strscorm = get_string("modulename", "scorm");
20     $strscorms = get_string("modulenameplural", "scorm");
21     $strweek = get_string("week");
22     $strtopic = get_string("topic");
23     $strname = get_string("name");
24     $strsummary = get_string("summary");
25     $strlastmodified = get_string("lastmodified");
27     print_header_simple("$strscorms", "", "$strscorms",
28                  "", "", true, "", navmenu($course));
30     if ($course->format == "weeks" or $course->format == "topics") {
31         $sortorder = "cw.section ASC";
32     } else {
33         $sortorder = "m.timemodified DESC";
34     }
36     if (! $scorms = get_all_instances_in_course("scorm", $course)) {
37         notice("There are no scorms", "../../course/view.php?id=$course->id");
38         exit;
39     }
41     if ($course->format == "weeks") {
42         $table->head  = array ($strweek, $strname, $strsummary);
43         $table->align = array ("center", "left", "left");
44     } else if ($course->format == "topics") {
45         $table->head  = array ($strtopic, $strname, $strsummary);
46         $table->align = array ("center", "left", "left");
47     } else {
48         $table->head  = array ($strlastmodified, $strname, $strsummary);
49         $table->align = array ("left", "left", "left");
50     }
52     foreach ($scorms as $scorm) {
54         $tt = "";
55         if ($course->format == "weeks" or $course->format == "topics") {
56             if ($scorm->section) {
57                 $tt = "$scorm->section";
58             }
59         } else {
60             $tt = "<font size=\"1\">".userdate($scorm->timemodified);
61         }
62         if (!$scorm->visible) {
63            //Show dimmed if the mod is hidden
64            $table->data[] = array ($tt, "<a class=\"dimmed\" href=\"view.php?id=$scorm->coursemodule\">".format_string($scorm->name,true)."</a>",
65                                    format_text($scorm->summary));
66         } else {
67            //Show normal if the mod is visible
68            $table->data[] = array ($tt, "<a href=\"view.php?id=$scorm->coursemodule\">".format_string($scorm->name,true)."</a>",
69                                    format_text($scorm->summary));
70         }
71     }
73     echo "<br />";
75     print_table($table);
77     print_footer($course);
80 ?>