New string from Bobo
[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
11
12 if ($id) {
13 if (! $cm = get_record("course_modules", "id", $id)) {
14 error("Course Module ID was incorrect");
15 }
16
17 if (! $course = get_record("course", "id", $cm->course)) {
18 error("Course is misconfigured");
19 }
20
21 if (! $scorm = get_record("scorm", "id", $cm->instance)) {
22 error("Course module is incorrect");
23 }
24
25 } else {
26 if (! $scorm = get_record("scorm", "id", $a)) {
27 error("Course module is incorrect");
28 }
29 if (! $course = get_record("course", "id", $scorm->course)) {
30 error("Course is misconfigured");
31 }
32 if (! $cm = get_coursemodule_from_instance("scorm", $scorm->id, $course->id)) {
33 error("Course Module ID was incorrect");
34 }
35 }
36
37 require_login($course->id);
38
39
40 $strscorms = get_string("modulenameplural", "scorm");
41 $strscorm = get_string("modulename", "scorm");
42
43 if ($course->category) {
44 $navigation = "<a target=\"{$CFG->framename}\" href=\"../../course/view.php?id=$course->id\">$course->shortname</a> ->
45 <a target=\"{$CFG->framename}\" href=\"index.php?id=$course->id\">$strscorms</a> ->";
46 } else {
47 $navigation = "<a target=\"{$CFG->framename}\" href=\"index.php?id=$course->id\">$strscorms</a> ->";
48 }
49
50 $pagetitle = strip_tags("$course->shortname: $scorm->name");
51
52 if (!$cm->visible and !isteacher($course->id)) {
53 print_header($pagetitle, "$course->fullname", "$navigation $scorm->name", "", "", true,
54 update_module_button($cm->id, $course->id, $strscorm), navmenu($course, $cm));
55 notice(get_string("activityiscurrentlyhidden"));
56 }
57 switch ($frameset) {
58 case "top":
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",
64 "$navigation <a target=\"{$CFG->framename}\" href=\"view.php?id=$cm->id\" title=\"$scorm->summary\">$scorm->name</a>",
65 "", "", true, update_module_button($cm->id, $course->id, $strscorm), navmenu($course, $cm));
66
67 echo "<table width=\"100%\"><tr><td align=\"center\">".text_to_html($scorm->summary, true, false)."</td></tr></table>\n";
68 echo "</body>\n</html>\n";
69 break;
70 case "left":
71 //
72 // Print SCORM Nav button
73 //
74 if (file_exists("$CFG->dirroot/theme/$CFG->theme/styles.php")) {
75 $styles = $CFG->stylesheet;
76 require_once("$CFG->dirroot/theme/$CFG->theme/config.php");
77 } else {
78 $styles = "$CFG->wwwroot/theme/standard/styles.php";
79 require_once("$CFG->dirroot/theme/standard/config.php");
80 }
81 if ( get_string("thisdirection") == "rtl" ) {
82 $direction = " dir=\"rtl\"";
83 } else {
84 $direction = " dir=\"ltr\"";
85 }
86 $meta = "<meta http-equiv=\"content-type\" content=\"text/html; charset=$encoding\" />\n$meta\n";
87 echo "<html $direction>\n<head>\n";
88 echo $meta;
89 echo "<title>Navigator</title>\n";
90 echo "<link rel=\"stylesheet\" type=\"text/css\" href=\"".$styles."\" />\n";
91 //echo "<script language=\"JavaScript\" type=\"text/javascript\" src=\"scormAPI.php?id=$cm->id&mode=".$_GET["mode"].$scoid."\"></script>\n";
92 echo "</head>\n<body bgcolor=\"".$THEME->body."\" leftmargin=\"0\">\n";
93 echo "<table width=\"100%\">\n";
94 if ($_GET["mode"] == "browse")
95 echo " <tr><td align=\"center\"><b>".get_string("browsemode","scorm")."</b></td></tr>";
96 echo " <tr><td align=\"center\" width=\"20%\" nowrap>
97 <iframe name=\"cmi\" width=\"1\" height=\"1\" src=\"cmi.php?id=$cm->id\" style=\"visibility: hidden;\"></iframe>
98 <form name=\"navform\" method=\"POST\" action=\"playscorm.php?id=$cm->id\" target=\"_top\">
99 <input name=\"scoid\" type=\"hidden\" />
100 <input name=\"mode\" type=\"hidden\" value=\"".$_GET["mode"]."\" />
101 <input name=\"prev\" type=\"button\" value=\"".get_string("prev","scorm")."\" onClick=\"top.changeSco('prev');\" />&nbsp;
102 <input name=\"next\" type=\"button\" value=\"".get_string("next","scorm")."\" onClick=\"top.changeSco('next')\" />
103 </form>
104 </td></tr>\n";
105 echo "</table>\n";
106 echo "<style type=\"text/css\">.scormlist { list-style-type:none;font-size:small; }</style>\n";
107 echo "<ul class=\"scormlist\">\n";
108 if ($scoes = get_records_select("scorm_scoes","scorm='$scorm->id' order by id ASC")){
109 $level=0;
110 $sublist=0;
111 $parents[$level]="/";
112 $incomplete=false;
113 foreach ($scoes as $sco) {
114 if ($parents[$level]!=$sco->parent) {
115 if ($level>0 && $parents[$level-1]==$sco->parent) {
116 echo " </ul>\n";
117 $level--;
118 } else {
119 echo " <ul id='".$sublist."' class=\"scormlist\">\n";
120 $level++;
121 $parents[$level]=$sco->parent;
122 }
123 }
124 echo " <li>";
125 $nextsco = next($scoes);
126 if (($nextsco !== false) && ($sco->parent != $nextsco->parent) && ($nextsco->parent != $parents[$level-1])) {
127 $sublist++;
128 echo "<img src=\"pix/minus.gif\" onClick='expandCollide(this,".$sublist.");'/>";
129 } else
130 echo "<img src=\"pix/spacer.gif\" />";
131 if ($sco->launch) {
132 if ($sco_user=get_record("scorm_sco_users","scoid",$sco->id,"userid",$USER->id)) {
133 if ( $sco_user->cmi_core_lesson_status == "")
134 $sco_user->cmi_core_lesson_status = "not attempted";
135 echo "<img src=\"pix/".scorm_remove_spaces($sco_user->cmi_core_lesson_status).".gif\" alt=\"".get_string(scorm_remove_spaces($sco_user->cmi_core_lesson_status),"scorm")."\" title=\"".get_string(scorm_remove_spaces($sco_user->cmi_core_lesson_status),"scorm")."\" />";
136 switch ($sco_user->cmi_core_lesson_status) {
137 case "not attempted":
138 case "incomplete":
139 case "browsed":
140 $incomplete = true;
141 }
142 } else {
143 echo "<img src=\"pix/notattempted.gif\" alt=\"".get_string("notattempted","scorm")."\" />";
144 $incomplete = true;
145 }
146 echo "&nbsp;<a href=\"javascript:playSCO(".$sco->id.")\">$sco->title</a></li>\n";
147 } else {
148 echo "&nbsp;$sco->title</li>\n";
149 }
150 }
151
152 for ($i=0;$i<$level;$i++){
153 echo " </ul>\n";
154 }
155 }
156 echo "</ul></p>\n";
157 echo "<script language=\"javascript\">
158<!--
159 function playSCO(scoid,status) {
160 document.navform.scoid.value = scoid;
161 document.navform.submit();
162 }
163
164 function expandCollide(which,list) {
165 var nn=document.ids?true:false
166 var w3c=document.getElementById?true:false
167 var beg=nn?\"document.ids.\":w3c?\"document.getElementById(\":\"document.all.\";
168 var mid=w3c?\").style\":\".style\";
169
170 if (eval(beg+list+mid+\".display\") != \"none\") {
171 which.src = \"pix/plus.gif\";
172 eval(beg+list+mid+\".display='none';\");
173 } else {
174 which.src = \"pix/minus.gif\";
175 eval(beg+list+mid+\".display='block';\");
176 }
177
178 }
179
180-->
181</script>\n";
182 echo "</body>\n</html>\n";
183 break;
184 default:
185 //
186 // Frameset
187 //
188 if ($_POST["scoid"])
189 $scoid = "&scoid=".$_POST["scoid"];
190 echo "<html>\n";
191 echo "<head><title>$course->shortname: $scorm->name</title></head>\n";
192 echo "<script id=\"scormAPI\" language=\"JavaScript\" type=\"text/javascript\" src=\"scormAPI.php?id=$cm->id&mode=".$_GET["mode"].$scoid."\"></script>\n";
193 echo "<frameset rows=\"$SCORM_TOP_FRAME_SIZE,*\">\n";
194 echo " <frame name=\"upper\" src=\"playscorm.php?id=$cm->id&mode=".$_POST["mode"]."&frameset=top\">\n";
195 echo " <frameset cols=\"$SCORM_LEFT_FRAME_SIZE,*\" onload=\"SCOInitialize();\">\n";
196 echo " <frame name=\"nav\" src=\"playscorm.php?id=$cm->id&mode=".$_POST["mode"]."&frameset=left\">\n";
197 echo " <frame name=\"main\" src=\"\">\n";
198 echo " </frameset>\n";
199 echo "</frameset>\n";
200 echo "</html>\n";
201 break;
202 }
203?>