ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
class.ilSCORM2004Utilities.php
Go to the documentation of this file.
1<?php
2
3/* Copyright (c) 1998-2011 ILIAS open source, Extended GPL, see docs/LICENSE */
4
5
18{
22 protected $db;
23
27 protected $log;
28
29
30
31 private $id = null;
32
33 /*
34 * Constructor
35 * @access public
36 */
37 public function __construct($a_id)
38 {
39 global $DIC;
40
41 $this->db = $DIC->database();
42 $this->log = $DIC["ilLog"];
43 $this->id = $a_id;
44 }
45
46 public function parentHasSeqTemplate($a_slm_id)
47 {
48 require_once("./Modules/Scorm2004/classes/seq_editor/class.ilSCORM2004SeqTemplate.php");
49
52 $has_template = false;
53
54 $mtree = new ilTree($a_slm_id);
55 $mtree->setTableNames('sahs_sc13_tree', 'sahs_sc13_tree_node');
56 $mtree->setTreeTablePK("slm_id");
57 //get all parents for current node
58 $parents = $this -> getParentsForNode($a_parents=array(), $this->id);
59 for ($i=0;$i<count($parents);$i++) {
61 if ($template) {
62 $has_template = true;
63 break;
64 }
65 }
66
67 return $has_template;
68 }
69
70 private function getParentsForNode($a_parents, $a_id)
71 {
72 $parent_id = $tree->getParentId($id);
73 if ($parent_id != 0) {
74 array_push($a_parents, $parent_id);
75 $this->getParentsForNode($a_parents, $parent_id);
76 } else {
77 return $a_parents;
78 }
79 }
80
81
82 public function getLeftRightInfo()
83 {
86 $ilLog->write("SCORM: getLeftRightInfo");
87 $query = "SELECT * FROM sahs_sc13_seq_tree WHERE (child = " .
88 $ilDB->quote($this->getSeqNodeId(), "integer") .
89 " AND importid=" . $ilDB->quote($this->getImportIdent(), "text") . ")";
90 $obj_set = $ilDB->query($query);
91 $ilLog->write("SCORM: getLeftRightInfo executed" . $query);
92 $obj_rec = $ilDB->fetchAssoc($obj_set);
93 return array("left"=> $obj_rec["lft"], "right" => $obj_rec["rgt"]);
94 }
95
96
97 protected function getSeqNodeId()
98 {
101 $all_props = $this->getAllSequencingProperties();
102 $ilLog->write("SCORM: getSeqNodeId: " . $all_props["seqnodeid"]);
103 return $all_props["seqnodeid"];
104 }
105
106 private function getSequencingId()
107 {
110 $ilLog->write("SCORM: getSequencingId for" . $this->getId());
111 $query = "SELECT * FROM sahs_sc13_seq_item WHERE sahs_sc13_tree_node_id = " .
112 $ilDB->quote($this->getId(), "integer");
113 $obj_set = $ilDB->query($query);
114 $obj_rec = $obj_set->fetchRow(ilDBConstants::FETCHMODE_ASSOC);
115 return $obj_rec['sequencingid'];
116 }
117
118 private function getItemId()
119 {
122 $ilLog->write("SCORM: getSequencingId for" . $this->getId);
123 $query = "SELECT * FROM sahs_sc13_seq_item WHERE sahs_sc13_tree_node_id = " .
124 $ilDB->quote($this->getId(), "integer");
125 $obj_set = $ilDB->query($query);
126 $obj_rec = $obj_set->fetchRow(ilDBConstants::FETCHMODE_ASSOC);
127 return $obj_rec['seqnodeid'];
128 }
129
130 public function getImportIdent()
131 {
134 $ilLog->write("SCORM: getImportIdent for" . $this->getId);
135 $query = "SELECT * FROM sahs_sc13_seq_item WHERE sahs_sc13_tree_node_id = " .
136 $ilDB->quote($this->getId(), "integer");
137 $obj_set = $ilDB->query($query);
138 $obj_rec = $obj_set->fetchRow(ilDBConstants::FETCHMODE_ASSOC);
139 return $obj_rec['importid'];
140 }
141
142
143
144 private function getId()
145 {
146 return $this->id;
147 }
148
149 public function getAllowedActions()
150 {
153 $ilLog->write("SCORM: getAllowedActions for" . $this->tree_node_id);
154 $query = "SELECT * FROM sahs_sc13_seq_item WHERE sahs_sc13_tree_node_id = " .
155 $ilDB->quote($this->getId(), "integer");
156 $obj_set = $ilDB->query($query);
157 $obj_rec = $obj_set->fetchRow(ilDBConstants::FETCHMODE_ASSOC);
158 return array("copy"=>!$obj_rec['nocopy'],"move"=>!$obj_rec['nomove'],"delete"=>!$obj_rec['nodelete']);
159 }
160
161 public function getControlModeProperties()
162 {
164 $query = "SELECT * FROM sahs_sc13_seq_seq WHERE id = " .
165 $ilDB->quote($this->getSequencingId(), "text");
166 $obj_set = $ilDB->query($query);
167 $obj_rec = $obj_set->fetchRow(ilDBConstants::FETCHMODE_ASSOC);
168 $c_properties = array(
169 'flow' => $obj_rec['flow'],
170 'forwardOnly' => $obj_rec['forwardonly'],
171 'choice' => $obj_rec['choice'],
172 'choiceExit' => $obj_rec['choiceexit'] );
173 return $c_properties;
174 }
175
177 {
180 $query = "SELECT * FROM sahs_sc13_seq_seq WHERE (id = " .
181 $ilDB->quote($this->getSequencingId(), "text") .
182 " AND importid=" . $ilDB->quote($this->getImportIdent(), "text") . ")";
183 $obj_set = $ilDB->query($query);
184 $ilLog->write("SCORM: getAllSequencingProperties for" . $this->getSequencingId());
185 $obj_rec = $obj_set->fetchRow(ilDBConstants::FETCHMODE_ASSOC);
186 $sprop = array(
187 'importId' => $obj_rec['importid'],
188 'activityAbsoluteDurationLimit' => $obj_rec['activityabsolutedurationlimit'],
189 'activityExperiencedDurationLimit' => $obj_rec['activityexperienceddurlimit'],
190 'attemptAbsoluteDurationLimit' => $obj_rec['attemptabsolutedurationlimit'],
191 'attemptExperiencedDurationLimit' => $obj_rec['attemptexperienceddurlimit'],
192 'attemptLimit' => $obj_rec['attemptlimit'],
193 'beginTimeLimit' => $obj_rec['begintimelimit'],
194 'completionSetByContent' => $obj_rec['completionsetbycontent'],
195 'constrainChoice' => $obj_rec['constrainchoice'],
196 'seqNodeId' => $obj_rec['seqnodeid'],
197 'endTimeLimit' => $obj_rec['endtimelimit'],
198 'id' => $obj_rec['id'],
199 'measureSatisfactionIfActive' => $obj_rec['measuresatisfactionifactive'],
200 'objectiveMeasureWeight' => $obj_rec['objectivemeasureweight'],
201 'objectiveSetByContent' => $obj_rec['objectivesetbycontent'],
202 'preventActivation' => $obj_rec['preventactivation'],
203 'randomizationTiming' => $obj_rec['randomizationtiming'],
204 'reorderChildren' => $obj_rec['reorderchildren'],
205 'requiredForCompleted' => $obj_rec['requiredforcompleted'],
206 'requiredForIncomplete' => $obj_rec['requiredforincomplete'],
207 'requiredForNotSatisfied' => $obj_rec['requiredfornotsatisfied'],
208 'requiredForSatisfied' => $obj_rec['requiredforsatisfied'],
209 'rollupObjectiveSatisfied' => $obj_rec['rollupobjectivesatisfied'],
210 'rollupProgressCompletion' => $obj_rec['rollupprogresscompletion'],
211 'selectCount' => $obj_rec['selectcount'],
212 'selectionTiming' => $obj_rec['selectiontiming'],
213 'sequencingId' => $obj_rec['sequencingid'],
214 'tracked' => $obj_rec['tracked'],
215 'useCurrentAttemptObjectiveInfo' => $obj_rec['usecurrentattemptobjectiveinfo'],
216 'useCurrentAttemptProgressInfo' => $obj_rec['usecurrentattemptprogressinfo'],
217 'flow' => $obj_rec['flow'],
218 'forwardOnly' => $obj_rec['forwardonly'],
219 'choice' => $obj_rec['choice'],
220 'choiceExit' => $obj_rec['choiceexit'] );
221 return $sprop;
222 }
223}
An exception for terminatinating execution or to throw for unit testing.
static templateForChapter($a_chapter_id)
Class ilSCORM2004Utilities.
getParentsForNode($a_parents, $a_id)
Tree class data representation in hierachical trees using the Nested Set Model with Gaps by Joe Celco...
$template
$i
Definition: disco.tpl.php:19
$query
global $DIC
Definition: saml.php:7
global $ilDB