update for moodle 1.3.1
[moodle.git] / mod / scorm / playscorm.php
CommitLineData
98ca59f6 1<?PHP // $Id$
2
3/// This page prints a particular instance of scorm
4/// (Replace scorm with the name of your module)
5
6 require_once("../../config.php");
7 require_once("lib.php");
8
9 optional_variable($id); // Course Module ID, or
10 optional_variable($a); // scorm ID
fc1b2663 11 optional_variable($frameset, "");
98ca59f6 12
13 if ($id) {
14 if (! $cm = get_record("course_modules", "id", $id)) {
15 error("Course Module ID was incorrect");
16 }
17
18 if (! $course = get_record("course", "id", $cm->course)) {
19 error("Course is misconfigured");
20 }
21
22 if (! $scorm = get_record("scorm", "id", $cm->instance)) {
23 error("Course module is incorrect");
24 }
25
26 } else {
27 if (! $scorm = get_record("scorm", "id", $a)) {
28 error("Course module is incorrect");
29 }
30 if (! $course = get_record("course", "id", $scorm->course)) {
31 error("Course is misconfigured");
32 }
33 if (! $cm = get_coursemodule_from_instance("scorm", $scorm->id, $course->id)) {
34 error("Course Module ID was incorrect");
35 }
36 }
37
38 require_login($course->id);
39
40
41 $strscorms = get_string("modulenameplural", "scorm");
42 $strscorm = get_string("modulename", "scorm");
43
44 if ($course->category) {
45 $navigation = "<a target=\"{$CFG->framename}\" href=\"../../course/view.php?id=$course->id\">$course->shortname</a> ->
46 <a target=\"{$CFG->framename}\" href=\"index.php?id=$course->id\">$strscorms</a> ->";
47 } else {
48 $navigation = "<a target=\"{$CFG->framename}\" href=\"index.php?id=$course->id\">$strscorms</a> ->";
49 }
50
51 $pagetitle = strip_tags("$course->shortname: $scorm->name");
52
53 if (!$cm->visible and !isteacher($course->id)) {
54 print_header($pagetitle, "$course->fullname", "$navigation $scorm->name", "", "", true,
55 update_module_button($cm->id, $course->id, $strscorm), navmenu($course, $cm));
56 notice(get_string("activityiscurrentlyhidden"));
57 }
fc1b2663 58 if ($frameset == "top") {
c5163bfd 59 add_to_log($course->id, "scorm", "view", "playscorm.php?id=$cm->id", "$scorm->id");
60 //
61 // Print the page header
62 //
63 print_header($pagetitle, "$course->fullname",
98ca59f6 64 "$navigation <a target=\"{$CFG->framename}\" href=\"view.php?id=$cm->id\" title=\"$scorm->summary\">$scorm->name</a>",
c5163bfd 65 "", "", true, update_module_button($cm->id, $course->id, $strscorm), navmenu($course, $cm, '_top'));
98ca59f6 66
c5163bfd 67 echo "<table width=\"100%\">\n <tr><td align=\"center\">".text_to_html($scorm->summary, true, false)."</td></tr></table>\n";
68
69 if ($scoes = get_records_select("scorm_scoes","scorm='$scorm->id' order by id ASC")){
70 $level=0;
71 $parents[$level]="/";
72 foreach ($scoes as $sco) {
73 if ($parents[$level]!=$sco->parent) {
74 if ($level>0 && $parents[$level-1]==$sco->parent) {
75 $level--;
76 } else {
77 $level++;
78 $parents[$level]=$sco->parent;
79 }
80 }
81 $indenting = "";
82 for ($i=0;$i<$level;$i++) {
83 $indenting .= "-";
84 }
85 $options[$sco->id] = $indenting."&gt; ".$sco->title;
86 }
87 }
88
89 echo "<table width=\"100%\">\n <tr>\n";
90 echo " <td nowrap>
98ca59f6 91 <iframe name=\"cmi\" width=\"1\" height=\"1\" src=\"cmi.php?id=$cm->id\" style=\"visibility: hidden;\"></iframe>
92 <form name=\"navform\" method=\"POST\" action=\"playscorm.php?id=$cm->id\" target=\"_top\">
93 <input name=\"scoid\" type=\"hidden\" />
94 <input name=\"mode\" type=\"hidden\" value=\"".$_GET["mode"]."\" />
c5163bfd 95 <input name=\"prev\" type=\"button\" value=\"".get_string("prev","scorm")."\" onClick=\"top.changeSco('prev');\" />&nbsp;\n";
96 choose_from_menu($options, "courseStructure", "", "", "document.navform.scoid.value=document.navform.courseStructure.options[document.navform.courseStructure.selectedIndex].value;document.navform.submit();");
97 echo " &nbsp;<input name=\"next\" type=\"button\" value=\"".get_string("next","scorm")."\" onClick=\"top.changeSco('next')\" />
98ca59f6 98 </form>
c5163bfd 99 </td>\n";
100 if ($_GET["mode"] == "browse")
101 echo "<td align=\"right\">".get_string("browsemode","scorm")."</td>\n";
102 echo "</tr>\n</table>\n";
103 echo "</body>\n</html>\n";
104 } else {
105 //
106 // Frameset
107 //
108 if ($_POST["scoid"])
109 $scoid = "&scoid=".$_POST["scoid"];
110 echo "<html>\n";
111 echo "<head><title>$course->shortname: $scorm->name</title></head>\n";
112 echo "<script id=\"scormAPI\" language=\"JavaScript\" type=\"text/javascript\" src=\"scormAPI.php?id=$cm->id&mode=".$_POST["mode"].$scoid."\"></script>\n";
113 echo "<frameset rows=\"$SCORM_FRAME_SIZE,*\" onLoad=\"SCOInitialize();\">\n";
114 echo " <frame name=\"nav\" src=\"playscorm.php?id=$cm->id&mode=".$_POST["mode"]."&frameset=top\">\n";
115 echo " <frame name=\"main\" src=\"\">\n";
116 echo "</frameset>\n";
117 echo "</html>\n";
98ca59f6 118 }
119?>