3 /// This page prints a particular instance of scorm
4 /// (Replace scorm with the name of your module)
6 require_once("../../config.php");
7 require_once("lib.php");
9 optional_variable($id); // Course Module ID, or
10 optional_variable($a); // scorm ID
11 optional_variable($frameset, "");
14 if (! $cm = get_record("course_modules", "id", $id)) {
15 error("Course Module ID was incorrect");
18 if (! $course = get_record("course", "id", $cm->course)) {
19 error("Course is misconfigured");
22 if (! $scorm = get_record("scorm", "id", $cm->instance)) {
23 error("Course module is incorrect");
27 if (! $scorm = get_record("scorm", "id", $a)) {
28 error("Course module is incorrect");
30 if (! $course = get_record("course", "id", $scorm->course)) {
31 error("Course is misconfigured");
33 if (! $cm = get_coursemodule_from_instance("scorm", $scorm->id, $course->id)) {
34 error("Course Module ID was incorrect");
38 require_login($course->id);
41 $strscorms = get_string("modulenameplural", "scorm");
42 $strscorm = get_string("modulename", "scorm");
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> ->";
48 $navigation = "<a target=\"{$CFG->framename}\" href=\"index.php?id=$course->id\">$strscorms</a> ->";
51 $pagetitle = strip_tags("$course->shortname: $scorm->name");
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"));
59 if (!empty($_POST["scoid"]))
60 $scoid = "&scoid=".$_POST["scoid"];
61 if (($scorm->popup != "") && (!empty($_POST["mode"])))
62 $mode = $_POST["mode"];
63 if (($scorm->popup == "") && (!empty($_GET["mode"])))
64 $mode = $_GET["mode"];
66 if (($frameset == "top") || ($scorm->popup != "")) {
67 add_to_log($course->id, "scorm", "view", "playscorm.php?id=$cm->id", "$scorm->id");
69 // Print the page header
71 print_header($pagetitle, "$course->fullname",
72 "$navigation <a target=\"{$CFG->framename}\" href=\"view.php?id=$cm->id\" title=\"$scorm->summary\">$scorm->name</a>",
73 "", "", true, update_module_button($cm->id, $course->id, $strscorm), navmenu($course, $cm, '_top'));
75 echo "<table width=\"100%\">\n <tr><td align=\"center\">".text_to_html($scorm->summary, true, false)."</td>\n";
76 if ($mode == "browse")
77 echo "<td align=\"right\" width=\"10%\" nowrap>".get_string("browsemode","scorm")."</td>\n";
78 echo " </tr>\n</table>\n";
80 if ($scorm->popup != "") {
81 echo "<script id=\"scormAPI\" language=\"JavaScript\" type=\"text/javascript\" src=\"scormAPI.php?id=$cm->id&mode=".$mode.$scoid."\"></script>\n";
83 if (!empty($_POST['scoid']))
84 $currentSCO = $_POST['scoid'];
87 <script language="Javascript">
89 function playSCO(scoid) {
90 document.navform.scoid.value=scoid;
91 document.navform.submit();
94 function expandCollide(which,list) {
95 var nn=document.ids?true:false
96 var w3c=document.getElementById?true:false
97 var beg=nn?"document.ids.":w3c?"document.getElementById(":"document.all.";
98 var mid=w3c?").style":".style";
100 if (eval(beg+list+mid+".display") != "none") {
101 which.src = "pix/plus.gif";
102 eval(beg+list+mid+".display='none';");
104 which.src = "pix/minus.gif";
105 eval(beg+list+mid+".display='block';");
111 <style type="text/css">
112 .scormlist { list-style-type:none; }
115 print_simple_box_start("CENTER");
117 echo " <tr><th>".get_string("coursestruct","scorm")."</th></tr>\n";
118 echo " <tr><td nowrap>\n<ul class=\"scormlist\"'>\n";
120 if ($scoes = get_records_select("scorm_scoes","scorm='$scorm->id' order by id ASC")){
123 $parents[$level]="/";
124 foreach ($scoes as $sco) {
125 if ($parents[$level]!=$sco->parent) {
126 if ($level>0 && $parents[$level-1]==$sco->parent) {
127 echo " </ul></li>\n";
130 echo " <li><ul id='".$sublist."' class=\"scormlist\"'>\n";
132 $parents[$level]=$sco->parent;
136 $nextsco = next($scoes);
137 if (($nextsco !== false) && ($sco->parent != $nextsco->parent) && (($level==0) || (($level>0) && ($nextsco->parent != $parents[$level-1])))) {
139 echo " <img src=\"pix/minus.gif\" onClick='expandCollide(this,".$sublist.");'/>\n";
141 echo " <img src=\"pix/spacer.gif\" />\n";
147 if ($sco->id == $currentSCO) {
148 $startbold = '-> <b>';
149 $endbold = '</b> <-';
151 if (($currentSCO == "") && ($mode != "normal")) {
152 $currentSCO = $sco->id;
153 $startbold = '-> <b>';
154 $endbold = '</b> <-';
156 if ($sco_user=get_record("scorm_sco_users","scoid",$sco->id,"userid",$USER->id)) {
157 if ( $sco_user->cmi_core_lesson_status == "")
158 $sco_user->cmi_core_lesson_status = "not attempted";
159 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")."\" />\n";
160 if (($sco_user->cmi_core_lesson_status == "not attempted") || ($sco_user->cmi_core_lesson_status == "incomplete")) {
161 if ($currentSCO == "") {
163 $currentSCO = $sco->id;
164 $startbold = '-> <b>';
165 $endbold = '</b> <-';
169 echo " <img src=\"pix/notattempted.gif\" alt=\"".get_string("notattempted","scorm")."\" />";
173 if (($sco_user->cmi_core_lesson_status == "passed") || ($sco_user->cmi_core_lesson_status == "failed"))
174 $score = "(".get_string("score","scorm").": ".$sco_user->cmi_core_score_raw.")";
175 echo " $startbold<a href=\"javascript:playSCO(".$sco->id.");\">$sco->title</a> $score$endbold\n </li>\n";
177 echo " $sco->title\n </li>\n";
180 for ($i=0;$i<$level;$i++){
181 echo " </ul></li>\n";
184 echo "</ul></td></tr>\n";
186 print_simple_box_end();
190 echo "<table width=\"100%\">\n <tr>\n";
191 echo " <td align=\"center\" nowrap>
192 <iframe name=\"cmi\" width=\"1\" height=\"1\" src=\"cmi.php?id=$cm->id\" style=\"visibility: hidden;\"></iframe>
193 <form name=\"navform\" method=\"POST\" action=\"playscorm.php?id=$cm->id\" target=\"_top\">
194 <input name=\"scoid\" type=\"hidden\" />
195 <input name=\"mode\" type=\"hidden\" value=\"".$mode."\" />
196 <input name=\"prev\" type=\"button\" value=\"".get_string("prev","scorm")."\" onClick=\"top.changeSco('prev');\" /> \n";
198 if ($scorm->popup == "") {
199 if ($scoes = get_records_select("scorm_scoes","scorm='$scorm->id' order by id ASC")){
201 $parents[$level]="/";
202 foreach ($scoes as $sco) {
203 if ($parents[$level]!=$sco->parent) {
204 if ($level>0 && $parents[$level-1]==$sco->parent) {
208 $parents[$level]=$sco->parent;
212 for ($i=0;$i<$level;$i++) {
215 $options[$sco->id] = $indenting."> ".$sco->title;
218 choose_from_menu($options, "courseStructure", "", "", "document.navform.scoid.value=document.navform.courseStructure.options[document.navform.courseStructure.selectedIndex].value;document.navform.submit();");
220 echo " <input name=\"next\" type=\"button\" value=\"".get_string("next","scorm")."\" onClick=\"top.changeSco('next')\" />\n";
224 echo "</tr>\n</table>\n";
226 if ($scorm->popup != "") {
228 <script language="Javascript">
234 echo "</body>\n</html>\n";
236 if ($scorm->popup == "") {
241 echo "<head><title>$course->shortname: $scorm->name</title></head>\n";
242 echo "<script id=\"scormAPI\" language=\"JavaScript\" type=\"text/javascript\" src=\"scormAPI.php?id=$cm->id&mode=".$mode.$scoid."\"></script>\n";
243 echo "<frameset rows=\"$CFG->scorm_framesize,*\" onLoad=\"SCOInitialize();\">\n";
244 echo "\t <frame name=\"nav\" src=\"playscorm.php?id=$cm->id&mode=".$mode."&frameset=top\">\n";
245 echo "\t <frame name=\"main\" src=\"\">\n";
246 echo "</frameset>\n";