3 * mods/scorm_packages/scorm-1.2/view.inc.php
5 * This file is part of ATutor, see http://www.atutor.ca
7 * Copyright (C) 2005 Matthai Kurian
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License
11 * as published by the Free Software Foundation; either version 2
12 * of the License, or (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
24 function treeEl ($s) {
25 return '<img src="images/tree/tree_' . $s . '.gif" alt="">';
28 if (!$_GET['org_id']) {
29 header('Location: ../index.php');
34 $sql = "SELECT first_name, last_name
35 FROM ".TABLE_PREFIX."members
36 WHERE member_id = ".$_SESSION['member_id'];
38 $result = mysql_query($sql, $db);
39 $q_row = mysql_fetch_assoc($result);
40 $student_name = $q_row['last_name'] . ', ' . $q_row['first_name'];
42 //if ($student_name == ', ') $msg->addWarning('packages_no_student_name');
44 $sql = "SELECT package_id
45 FROM ".TABLE_PREFIX."scorm_1_2_org
46 WHERE org_id = $_GET[org_id]";
47 $result = mysql_query($sql, $db);
48 $q_row = mysql_fetch_assoc($result);
49 $pkg = $q_row['package_id'];
51 $sql = "SELECT item_id, scormtype, idx, title, href
52 FROM ".TABLE_PREFIX."scorm_1_2_item
53 WHERE org_id = $_GET[org_id]
56 $result = mysql_query($sql, $db);
63 while ($row = mysql_fetch_assoc($result)) {
64 $org[$i]['id'] = $row['item_id'];
65 $org[$i]['idx'] = $row['idx'];
66 $org[$i]['type'] = $row['scormtype'];
67 $org[$i]['title'] = $row['title'];
68 $org[$i]['href'] = $row['href'];
69 $iid[$row['item_id']] = $i;
70 $ist[$i] = 'not attempted';
75 $sql = "SELECT c.item_id,
77 FROM ".TABLE_PREFIX."cmi c,
78 ".TABLE_PREFIX."scorm_1_2_item i,
79 ".TABLE_PREFIX."scorm_1_2_org o
80 WHERE o.org_id = $_GET[org_id]
81 AND i.org_id = o.org_id
82 AND i.item_id = c.item_id
83 AND c.member_id = $_SESSION[member_id]
84 AND c.lvalue = 'cmi.core.lesson_status'
86 $result = mysql_query($sql, $db);
87 while ($row = mysql_fetch_assoc($result)) {
88 $ist[$iid[$row['item_id']]] = $row['rvalue'];
94 $tidx = explode ('.', $org[$c-1]['idx']);
98 for ($l=0; $l<$lvl; $l++) array_push ($fil, treeEl ('space'));
99 array_push ($fil, treeEl('end'));
101 for ($i=$c-1; $i>=0; $i--) {
102 $tidx = explode ('.', $org[$i]['idx']);
103 $lvl = sizeOf($tidx);
105 switch ($org[$i]['type']) {
107 $_pages[$me]['title'] =$org[$i]['title'];
112 array_push ($fil, treeEl('disabled'));
117 if ($org[$i]['idx'].'.1' == $org[$i+1]['idx']) {
118 // cluster with resource
121 array_push ($fil, treeEl('disabled'));
126 if ($lvl < $llvl) array_push ($fil, treeEl('end'));
127 if ($lvl == $llvl) array_push ($fil, treeEl ('split'));
129 array_push ($fil, treeEl ('vertline'));
130 array_push ($fil, treeEl ('end'));
135 if ($org[$i]['href']) {
136 if ($org[$i]['type'] == 'sco') {
142 . str_replace (' ', '-', $ist[$i])
143 . '.png" alt="' . $ist[$i]
144 . '" title="' . $ist[$i] . '">'
145 . '<a href="javascript:void(0)" '
146 . 'onclick="Launch(' . $i .');'
148 . $org[$i]['title'] . '</a>'
156 . 'asset.png" alt="">'
157 . '<a href="javascript:void(0)" '
158 . 'onclick="Launch(' . $i .');'
160 . $org[$i]['title'] . '</a>'
166 . '<b>' . $org[$i]['title'] . '</b>'
173 require(AT_INCLUDE_PATH.'header.inc.php');
178 <applet code="ATutorApiAdapterApplet"
179 id="RTE" name="RTE" mayscript="true"
180 codebase="<?php echo AT_BASE_HREF?>mods/scorm_packages/scorm-1.2/"
181 archive="<?php echo AT_BASE_HREF?>mods/scorm_packages/scorm-1.2/java/ATutorApiAdapterApplet.jar,<?php echo AT_BASE_HREF?>mods/scorm_packages/scorm-1.2/java/PfPLMS-API-adapter-core.jar,<?php echo AT_BASE_HREF?>mods/scorm_packages/scorm-1.2/java/gnu.jar"
182 width="0" height="0" >
183 <param name="student_id" value="<?php echo $_SESSION['member_id']?>" />
184 <param name="student_name" value="<?php echo $student_name?>" />
185 <?php if ($prefs['show_rte_communication'] == 1) {
186 echo '<param name="verbose" value="1" />' . "\n";
189 echo ($prefs['show_rte_communication'] == 1?'true':'false');
193 <script language="Javascript">
195 function getObj (o) {
196 if(document.getElementById) return document.getElementById(o);
197 if(document.all) return document.all[o];
201 scHREF = new Array();
203 scType = new Array();
207 for ($i=0; $i<=$c; $i++) {
208 echo 'scHREF[' . $i ."] = '";
209 if ($org[$i]['href'] != '') {
210 echo AT_PACKAGE_URL_BASE
211 . $_SESSION['course_id'] .'/' . $pkg .'/'
216 . 'scID[' . $i ."] = '" . $org[$i]['id'] . "';\n"
217 . 'scType[' . $i ."] = '" . $org[$i]['type'] . "';\n"
226 var scowindow = null;
227 var isRunning = false;
228 var isLaunching = false;
234 var auto_advance = <?php
235 echo ($prefs['auto_advance'] == 1 ?'true':'false');
237 var show_comm = <?php
238 echo ($prefs['show_rte_communication'] == 1?'true':'false');
241 function LMSInitialize (s) {
249 var o = getObj ('im'+scoidx);
250 o.src = '<?php echo $im;?>busy.png';
251 o.alt = '<?php echo _AT('scorm_sco_is_running')?>';
252 o.title = '<?php echo _AT('scorm_sco_is_running')?>';
253 rv = window.document.RTE.LMSInitialize (s);
254 initstat = window.document.RTE.ATutorGetValue (
255 'cmi.core.lesson_status'
260 function LMSFinish (s) {
264 var stat = window.document.RTE.ATutorGetValue ('cmi.core.lesson_status');
266 var o = getObj ('im'+scoidx);
269 if (stat == 'not attempted') stat = 'not-attempted';
270 o.src = '<?php echo $im;?>'+stat+'.png';
271 if (!autonext && auto_advance && !initstat.equals(stat)) {
272 if (stat == 'completed' ||
275 for (i=scoidx+1; i<scHREF.length; i++) {
276 if (scHREF[i].length) {
286 rv = window.document.RTE.LMSFinish (s);
292 if (autonext) setTimeout ('Launch (autonext)', 500);
297 function LMSSetValue (l, r) {
298 return window.document.RTE.LMSSetValue (l, r);
301 function LMSGetValue (l) {
302 return window.document.RTE.LMSGetValue (l);
305 function LMSGetLastError () {
306 return window.document.RTE.LMSGetLastError ();
309 function LMSGetErrorString (s) {
310 return window.document.RTE.LMSGetErrorString (s);
313 function LMSGetDiagnostic (s) {
314 return window.document.RTE.LMSGetDiagnostic (s);
317 function LMSCommit (s) {
318 return window.document.RTE.LMSCommit (s);
322 function Launch (i) {
323 if (autonext && autonext != i) return;
325 if (i == scoidx) return;
327 if (scowindow && scowindow.closed) {
332 window.document.RTE.ATutorReset(scID[scoidx]);
337 if (isLaunching) return;
339 if (scowindow != null) {
340 if (!isRunning) return;
345 if (scType[i] == 'sco') {
347 window.document.RTE.ATutorPrepare(scID[i]);
348 } catch (Exception) {
349 alert ('Sorry, LiveConnect does not work');
359 scowindow = window.open (
362 'width='+scoWidth+',height='+scoHeight+','+
363 'toolbar=no,menubar=no,status=no,scrollbars=yes'
365 if (scType[i] == 'sco') {
367 if (scowindow) scowindow.API = this;
372 function cleanup () {
373 if (scowindow) scowindow.close();
376 function checkResize () {
378 w = scowindow.innerWidth;
379 h = scowindow.innerHeight;
380 if (w >= 640 && h >= 480) {
384 } catch (Exception) {};
387 this.onunload=cleanup;
391 $p = "\n" . '<div id="scorm_1_2_toc" style="display:block; border:thin solid #cccccc;width:95%;padding:1em;margin:auto;">' . "\n";
392 for ($i=$c-1; $i>=0; $i--) {
393 $p .= $tree[$i] . '<br />' . "\n";
395 $p .= '</div>' . "\n";
396 echo utf8_decode($p);