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 define('AT_INCLUDE_PATH', '../../../include/');
29 require(AT_INCLUDE_PATH.'vitals.inc.php');
30 authenticate(AT_PRIV_PACKAGES);
31 $me = 'mods/scorm_packages/scorm-1.2/view.php';
32 $im = 'mods/scorm_packages/scorm-1.2/images/';
34 if (!$_GET['org_id']) {
35 header('Location: ../index.php');
39 $sql = "SELECT first_name, last_name
40 FROM ".TABLE_PREFIX."members
41 WHERE member_id = ".$_SESSION['member_id'];
43 $result = mysql_query($sql, $db);
44 $q_row = mysql_fetch_assoc($result);
45 $student_name = $q_row['last_name'] . ', ' . $q_row['first_name'];
47 //if ($student_name == ', ') $msg->addWarning ('packages_no_student_name');
49 $sql = "SELECT package_id
50 FROM ".TABLE_PREFIX."scorm_1_2_org
51 WHERE org_id = $_GET[org_id]";
52 $result = mysql_query($sql, $db);
53 $q_row = mysql_fetch_assoc($result);
54 $pkg = $q_row['package_id'];
56 // check if the org_id belongs to current course
57 $sql = "SELECT course_id FROM ".TABLE_PREFIX."packages WHERE package_id = '".$pkg."'";
58 $result = mysql_query($sql, $db);
59 $row = mysql_fetch_assoc($result);
60 if ($row["course_id"] <> $_SESSION['course_id'])
62 $msg->addError('ACCESS_DENIED');
64 $_pages['mods/scorm_packages/scorm-1.2/view.php']['title_var'] = 'scorm_packages';
65 require (AT_INCLUDE_PATH.'header.inc.php');
67 require(AT_INCLUDE_PATH.'footer.inc.php');
71 $sql = "SELECT item_id, scormtype, idx, title, href
72 FROM ".TABLE_PREFIX."scorm_1_2_item
73 WHERE org_id = $_GET[org_id]
76 $result = mysql_query($sql, $db);
83 while ($row = mysql_fetch_assoc($result)) {
84 $org[$i]['id'] = $row['item_id'];
85 $org[$i]['idx'] = $row['idx'];
86 $org[$i]['type'] = $row['scormtype'];
87 $org[$i]['title'] = $row['title'];
88 $org[$i]['href'] = $row['href'];
89 $iid[$row['item_id']] = $i;
90 $ist[$i] = 'not attempted';
95 $sql = "SELECT c.item_id,
97 FROM ".TABLE_PREFIX."cmi c,
98 ".TABLE_PREFIX."scorm_1_2_item i,
99 ".TABLE_PREFIX."scorm_1_2_org o
100 WHERE o.org_id = $_GET[org_id]
101 AND i.org_id = o.org_id
102 AND i.item_id = c.item_id
103 AND c.member_id = $_SESSION[member_id]
104 AND c.lvalue = 'cmi.core.lesson_status'
106 $result = mysql_query($sql, $db);
107 while ($row = mysql_fetch_assoc($result)) {
108 $ist[$iid[$row['item_id']]] = $row['rvalue'];
114 $tidx = explode ('.', $org[$c-1]['idx']);
115 $lvl = sizeOf($tidx);
118 for ($l=0; $l<$lvl; $l++) array_push ($fil, treeEl ('space'));
119 array_push ($fil, treeEl('end'));
121 for ($i=$c-1; $i>=0; $i--) {
122 $tidx = explode ('.', $org[$i]['idx']);
123 $lvl = sizeOf($tidx);
125 switch ($org[$i]['type']) {
127 $_pages[$me]['title'] =$org[$i]['title'];
132 array_push ($fil, treeEl('disabled'));
137 if ($org[$i]['idx'].'.1' == $org[$i+1]['idx']) {
138 // cluster with resource
141 array_push ($fil, treeEl('disabled'));
146 if ($lvl < $llvl) array_push ($fil, treeEl('end'));
147 if ($lvl == $llvl) array_push ($fil, treeEl ('split'));
149 array_push ($fil, treeEl ('vertline'));
150 array_push ($fil, treeEl ('end'));
155 if ($org[$i]['href']) {
156 if ($org[$i]['type'] == 'sco') {
162 . str_replace (' ', '-', $ist[$i])
163 . '.png" alt="' . $ist[$i]
164 . '" title="' . $ist[$i] . '">'
165 . '<a href="javascript:void(0)" '
166 . 'onclick="Launch(' . $i .');'
168 . $org[$i]['title'] . '</a>'
176 . 'asset.png" alt="">'
177 . '<a href="javascript:void(0)" '
178 . 'onclick="Launch(' . $i .');'
180 . $org[$i]['title'] . '</a>'
186 . '<b>' . $org[$i]['title'] . '</b>'
193 require(AT_INCLUDE_PATH.'header.inc.php');
198 <applet code="ATutorApiAdapterApplet"
199 id="RTE" name="RTE" mayscript="true"
200 codebase="<?php echo AT_BASE_HREF?>mods/scorm_packages/scorm-1.2/"
201 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"
202 width="0" height="0" >
203 <param name="student_id" value="<?php echo $_SESSION['member_id']?>" />
204 <param name="student_name" value="<?php echo $student_name?>" />
205 <?php if ($prefs['show_rte_communication'] == 1) {
206 echo '<param name="verbose" value="1" />' . "\n";
212 <script language="Javascript">
214 function getObj (o) {
215 if(document.getElementById) return document.getElementById(o);
216 if(document.all) return document.all[o];
220 scHREF = new Array();
222 scType = new Array();
226 for ($i=0; $i<=$c; $i++) {
227 echo 'scHREF[' . $i ."] = '";
228 if ($org[$i]['href'] != '') {
229 echo AT_PACKAGE_URL_BASE
230 . $_SESSION['course_id'] .'/' . $pkg .'/'
235 . 'scID[' . $i ."] = '" . $org[$i]['id'] . "';\n"
236 . 'scType[' . $i ."] = '" . $org[$i]['type'] . "';\n"
245 var scowindow = null;
246 var isRunning = false;
247 var isLaunching = false;
253 var auto_advance = <?php
254 echo ($prefs['auto_advance'] == 1 ?'true':'false');
256 var show_comm = <?php
257 echo ($prefs['show_rte_communication'] == 1?'true':'false');
260 function LMSInitialize (s) {
261 rv = window.document.RTE.LMSInitialize (s);
262 if (rv != 'true') return rv;
271 var o = getObj ('im'+scoidx);
272 o.src = '<?php echo $im;?>busy.png';
273 o.alt = '<?php echo _AT('scorm_sco_is_running')?>';
274 o.title = '<?php echo _AT('scorm_sco_is_running')?>';
275 initstat = window.document.RTE.ATutorGetValue (
276 'cmi.core.lesson_status'
281 function LMSFinish (s) {
285 var stat = window.document.RTE.ATutorGetValue ('cmi.core.lesson_status');
287 var o = getObj ('im'+scoidx);
290 if (stat == 'not attempted') stat = 'not-attempted';
291 o.src = '<?php echo $im;?>'+stat+'.png';
293 if (!autonext && auto_advance && initstat != stat) {
294 if (stat == 'completed' ||
297 for (i=scoidx+1; i<scHREF.length; i++) {
298 if (scHREF[i].length) {
308 rv = window.document.RTE.LMSFinish (s);
314 if (autonext) setTimeout ('Launch (autonext)', 500);
319 function LMSSetValue (l, r) {
320 return window.document.RTE.LMSSetValue (l, r);
323 function LMSGetValue (l) {
324 return window.document.RTE.LMSGetValue (l);
327 function LMSGetLastError () {
328 return window.document.RTE.LMSGetLastError ();
331 function LMSGetErrorString (s) {
332 return window.document.RTE.LMSGetErrorString (s);
335 function LMSGetDiagnostic (s) {
336 return window.document.RTE.LMSGetDiagnostic (s);
339 function LMSCommit (s) {
340 return window.document.RTE.LMSCommit (s);
344 function Launch (i) {
345 if (autonext && autonext != i) return;
347 if (i == scoidx) return;
349 if (scowindow && scowindow.closed) {
354 window.document.RTE.ATutorReset(scID[scoidx]);
359 if (isLaunching) return;
361 if (scowindow != null) {
362 if (!isRunning) return;
367 if (scType[i] == 'sco') {
369 window.document.RTE.ATutorPrepare(scID[i]);
370 } catch (Exception) {
371 alert ('Sorry, LiveConnect does not work');
381 scowindow = window.open (
384 'width='+scoWidth+',height='+scoHeight+','+
385 'toolbar=no,menubar=no,status=no,scrollbars=yes'
387 if (scType[i] == 'sco') {
389 if (scowindow) scowindow.API = this;
394 function cleanup () {
395 if (scowindow) scowindow.close();
398 function checkResize () {
400 w = scowindow.innerWidth;
401 h = scowindow.innerHeight;
402 if (w >= 640 && h >= 480) {
406 } catch (Exception) {};
409 this.onunload=cleanup;
413 $p = "\n" . '<div id="scorm_1_2_toc" style="display:block; border:thin solid #cccccc;width:95%;padding:1em;margin:auto;">' . "\n";
414 for ($i=$c-1; $i>=0; $i--) {
415 $p .= $tree[$i] . '<br />' . "\n";
417 $p .= '</div>' . "\n";
418 echo utf8_decode($p);
424 require(AT_INCLUDE_PATH.'footer.inc.php');