3 * mods/scorm_packages/scorm-1.2/lib.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 require(AT_INCLUDE_PATH.'../mods/_core/file_manager/filemanager.inc.php');
26 class package_handler_scorm_1_2 {
28 function getManagerItemLinks ($id) {
29 $result = $this->getOrgs ($id);
31 while ($row = mysql_fetch_assoc($result)) {
33 '<div class="scormitem">'
34 . '<a href="mods/scorm_packages/scorm-1.2/view.php?org_id='
36 . ' title="ADL SCORM-1.2 Package"'
37 . ' onclick="show(\'scorm_1_2_throb_' . $row['org_id'] . '\')"'
41 <div class="scormfeedback" id="scorm_1_2_throb_'
43 . '" style="display:none;position:absolute;">'
45 . _AT(package_scorm_1_2_rte_loading)
47 . '<img src="images/transfer.gif" height="20" width="90" alt="">'
55 function getLearnerItemLinks ($id) {
56 $result = $this->getOrgs ($id);
58 while ($row = mysql_fetch_assoc($result)) {
60 . '<div class="scormitem">'
61 . '<a href="mods/scorm_packages/scorm-1.2/learner_view.php?org_id='
63 . ' title="ADL SCORM-1.2 Package"'
64 . ' onclick="show(\'scorm_1_2_throb_' . $row['org_id'] . '\')"'
70 . ' <div class="scormfeedback" id="scorm_1_2_throb_'
72 . '" style="display:none;position:absolute;">'
74 . _AT(package_scorm_1_2_rte_loading)
76 . '<img src="images/transfer.gif" height="20" width="90" alt="">'
84 function getCMILinks ($id) {
85 $result = $this->getOrgs ($id);
87 while ($row = mysql_fetch_assoc($result)) {
89 '<div class="scormitem">'
90 . '<a href="mods/scorm_packages/scorm-1.2/cmi.php?org_id='
92 . ' title="SCORM-1.2 CMI Data"'
101 function getSettingsLinks ($id) {
102 $result = $this->getOrgs ($id);
104 while ($row = mysql_fetch_assoc($result)) {
106 '<div class="scormitem">'
107 . '<a href="mods/scorm_packages/scorm-1.2/settings.php?org_id='
109 . ' title="ADL SCORM-1.2 Package"'
118 function getDeleteFormItems ($id, $i) {
119 $result = $this->getOrgs ($id);
121 while ($row = mysql_fetch_assoc($result)) {
123 . '<input type="checkbox" '
124 . 'id="goners['. $i . ']" '
125 . 'name="goners[' . $i . ']" '
126 . 'value="' . $row[org_id] . '" />'
127 . '<label class="scorminput" '
128 . 'for="goners['. $i .']">' . $row['title']
137 function getOrgs ($id) {
140 $sql = "SELECT o.org_id,
142 FROM ".TABLE_PREFIX."packages p,
143 ".TABLE_PREFIX."scorm_1_2_org o
144 WHERE p.package_id = $id
145 AND o.package_id = p.package_id
149 return mysql_query($sql, $db);
152 function deletePackages ($pids) {
157 * Dangerous deleting begins here
160 foreach ($pids as $id) {
161 $sql = "SELECT p.package_id
162 FROM ".TABLE_PREFIX."packages p,
163 ".TABLE_PREFIX."scorm_1_2_org o
165 AND o.package_id = p.package_id
166 AND p.ptype = 'scorm-1.2'
167 AND p.course_id = $_SESSION[course_id]
170 $result = mysql_query($sql, $db);
171 if (!$result) contunue;
173 $row = mysql_fetch_assoc($result);
174 $pkg = $row['package_id'];
176 $sql = "SELECT o.org_id
177 FROM ".TABLE_PREFIX."packages p,
178 ".TABLE_PREFIX."scorm_1_2_org o
179 WHERE p.package_id = $pkg
180 AND o.package_id = p.package_id
183 $result = mysql_query($sql, $db);
185 while ($row = mysql_fetch_assoc($result)) {
186 array_push ($orgs, $row['org_id']);
189 $sql = "SELECT item_id
190 FROM ".TABLE_PREFIX."scorm_1_2_item
193 $result = mysql_query($sql, $db);
194 $items = array('null');
195 while ($row = mysql_fetch_assoc($result)) {
196 array_push ($items, $row['item_id']);
200 * Delete cmi data of all items in organization for
203 $sql = "DELETE FROM ".TABLE_PREFIX."cmi
204 WHERE item_id in (" . implode (',', $items) . ")";
206 $result = mysql_query ($sql, $db);
210 * Delete all items belonging to this organization
213 $sql = "DELETE FROM ".TABLE_PREFIX."scorm_1_2_item
216 $result = mysql_query ($sql, $db);
219 * Delete the organization entry itself
222 $sql = "DELETE FROM ".TABLE_PREFIX."scorm_1_2_org
225 $result = mysql_query ($sql, $db);
227 if (sizeOf ($orgs) == 1) {
230 * There is no more organization left from
231 * this particular scorm-1.2 package, so
232 * we delete the package entry and all files
233 * which came with the package
236 $sql = "DELETE FROM ".TABLE_PREFIX."packages WHERE package_id = $pkg";
238 $result = mysql_query ($sql, $db);
240 $pdir = AT_INCLUDE_PATH
242 . $_SESSION['course_id']
251 $plug['scorm-1.2'] = new package_handler_scorm_1_2();