ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
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{
19
20
21 private $id = null;
22
23 /*
24 * Constructor
25 * @access public
26 */
27 function ilSCORM2004Utilities($a_id)
28 {
29 $this->id = $a_id;
30 }
31
32 public function parentHasSeqTemplate($a_slm_id)
33 {
34 require_once("./Modules/Scorm2004/classes/seq_editor/class.ilSCORM2004SeqTemplate.php");
35
36 global $ilDB,$ilLog;
37 $has_template = false;
38
39 $mtree = new ilTree($a_slm_id);
40 $mtree->setTableNames('sahs_sc13_tree','sahs_sc13_tree_node');
41 $mtree->setTreeTablePK("slm_id");
42 //get all parents for current node
43 $parents = $this -> getParentsForNode($a_parents=array(),$this->id);
44 for ($i=0;$i<count($parents);$i++)
45 {
46 $template = ilSCORM2004SeqTemplate::templateForChapter($parents[$i]);
47 if ($template) {
48 $has_template = true;
49 break;
50 }
51 }
52
53 return $has_template;
54 }
55
56 private function getParentsForNode($a_parents,$a_id){
57 $parent_id = $tree->getParentId($id);
58 if ($parent_id != 0) {
59 array_push($a_parents,$parent_id);
60 $this->getParentsForNode($a_parents,$parent_id);
61 } else {
62 return $a_parents;
63 }
64 }
65
66
67 public function getLeftRightInfo()
68 {
69 global $ilDB,$ilLog;
70 $ilLog->write("SCORM: getLeftRightInfo");
71 $query = "SELECT * FROM sahs_sc13_seq_tree WHERE (child = ".
72 $ilDB->quote($this->getSeqNodeId(), "integer").
73 " AND importid=".$ilDB->quote($this->getImportIdent(), "text").")";
74 $obj_set = $ilDB->query($query);
75 $ilLog->write("SCORM: getLeftRightInfo executed".$query);
76 $obj_rec = $ilDB->fetchAssoc($obj_set);
77 return array("left"=> $obj_rec["lft"], "right" => $obj_rec["rgt"]);
78 }
79
80
81 protected function getSeqNodeId()
82 {
83 global $ilDB,$ilLog;
84 $all_props = $this->getAllSequencingProperties();
85 $ilLog->write("SCORM: getSeqNodeId: ".$all_props["seqnodeid"]);
86 return $all_props["seqnodeid"];
87 }
88
89 private function getSequencingId()
90 {
91 global $ilDB,$ilLog;
92 $ilLog->write("SCORM: getSequencingId for".$this->getId());
93 $query = "SELECT * FROM sahs_sc13_seq_item WHERE sahs_sc13_tree_node_id = ".
94 $ilDB->quote($this->getId(), "integer");
95 $obj_set = $ilDB->query($query);
96 $obj_rec = $obj_set->fetchRow(DB_FETCHMODE_ASSOC);
97 return $obj_rec['sequencingid'];
98 }
99
100 private function getItemId()
101 {
102 global $ilDB,$ilLog;
103 $ilLog->write("SCORM: getSequencingId for".$this->getId);
104 $query = "SELECT * FROM sahs_sc13_seq_item WHERE sahs_sc13_tree_node_id = ".
105 $ilDB->quote($this->getId(), "integer");
106 $obj_set = $ilDB->query($query);
107 $obj_rec = $obj_set->fetchRow(DB_FETCHMODE_ASSOC);
108 return $obj_rec['seqnodeid'];
109 }
110
111 public function getImportIdent()
112 {
113 global $ilDB,$ilLog;
114 $ilLog->write("SCORM: getImportIdent for".$this->getId);
115 $query = "SELECT * FROM sahs_sc13_seq_item WHERE sahs_sc13_tree_node_id = ".
116 $ilDB->quote($this->getId(), "integer");
117 $obj_set = $ilDB->query($query);
118 $obj_rec = $obj_set->fetchRow(DB_FETCHMODE_ASSOC);
119 return $obj_rec['importid'];
120 }
121
122
123
124 private function getId()
125 {
126 return $this->id;
127 }
128
129 public function getAllowedActions()
130 {
131 global $ilDB,$ilLog;
132 $ilLog->write("SCORM: getAllowedActions for".$this->tree_node_id);
133 $query = "SELECT * FROM sahs_sc13_seq_item WHERE sahs_sc13_tree_node_id = ".
134 $ilDB->quote($this->getId(), "integer");
135 $obj_set = $ilDB->query($query);
136 $obj_rec = $obj_set->fetchRow(DB_FETCHMODE_ASSOC);
137 return array("copy"=>!$obj_rec['nocopy'],"move"=>!$obj_rec['nomove'],"delete"=>!$obj_rec['nodelete']);
138 }
139
140 public function getControlModeProperties()
141 {
142 global $ilDB;
143 $query = "SELECT * FROM sahs_sc13_seq_seq WHERE id = ".
144 $ilDB->quote($this->getSequencingId(), "text");
145 $obj_set = $ilDB->query($query);
146 $obj_rec = $obj_set->fetchRow(DB_FETCHMODE_ASSOC);
147 $c_properties = array(
148 'flow' => $obj_rec['flow'],
149 'forwardOnly' => $obj_rec['forwardonly'],
150 'choice' => $obj_rec['choice'],
151 'choiceExit' => $obj_rec['choiceexit'] );
152 return $c_properties;
153 }
154
156 {
157 global $ilDB,$ilLog;
158 $query = "SELECT * FROM sahs_sc13_seq_seq WHERE (id = ".
159 $ilDB->quote($this->getSequencingId(), "text").
160 " AND importid=".$ilDB->quote($this->getImportIdent(), "text").")";
161 $obj_set = $ilDB->query($query);
162 $ilLog->write("SCORM: getAllSequencingProperties for".$this->getSequencingId());
163 $obj_rec = $obj_set->fetchRow(DB_FETCHMODE_ASSOC);
164 $sprop = array(
165 'importId' => $obj_rec['importid'],
166 'activityAbsoluteDurationLimit' => $obj_rec['activityabsolutedurationlimit'],
167 'activityExperiencedDurationLimit' => $obj_rec['activityexperienceddurlimit'],
168 'attemptAbsoluteDurationLimit' => $obj_rec['attemptabsolutedurationlimit'],
169 'attemptExperiencedDurationLimit' => $obj_rec['attemptexperienceddurlimit'],
170 'attemptLimit' => $obj_rec['attemptlimit'],
171 'beginTimeLimit' => $obj_rec['begintimelimit'],
172 'completionSetByContent' => $obj_rec['completionsetbycontent'],
173 'constrainChoice' => $obj_rec['constrainchoice'],
174 'seqNodeId' => $obj_rec['seqnodeid'],
175 'endTimeLimit' => $obj_rec['endtimelimit'],
176 'id' => $obj_rec['id'],
177 'measureSatisfactionIfActive' => $obj_rec['measuresatisfactionifactive'],
178 'objectiveMeasureWeight' => $obj_rec['objectivemeasureweight'],
179 'objectiveSetByContent' => $obj_rec['objectivesetbycontent'],
180 'preventActivation' => $obj_rec['preventactivation'],
181 'randomizationTiming' => $obj_rec['randomizationtiming'],
182 'reorderChildren' => $obj_rec['reorderchildren'],
183 'requiredForCompleted' => $obj_rec['requiredforcompleted'],
184 'requiredForIncomplete' => $obj_rec['requiredforincomplete'],
185 'requiredForNotSatisfied' => $obj_rec['requiredfornotsatisfied'],
186 'requiredForSatisfied' => $obj_rec['requiredforsatisfied'],
187 'rollupObjectiveSatisfied' => $obj_rec['rollupobjectivesatisfied'],
188 'rollupProgressCompletion' => $obj_rec['rollupprogresscompletion'],
189 'selectCount' => $obj_rec['selectcount'],
190 'selectionTiming' => $obj_rec['selectiontiming'],
191 'sequencingId' => $obj_rec['sequencingid'],
192 'tracked' => $obj_rec['tracked'],
193 'useCurrentAttemptObjectiveInfo' => $obj_rec['usecurrentattemptobjectiveinfo'],
194 'useCurrentAttemptProgressInfo' => $obj_rec['usecurrentattemptprogressinfo'],
195 'flow' => $obj_rec['flow'],
196 'forwardOnly' => $obj_rec['forwardonly'],
197 'choice' => $obj_rec['choice'],
198 'choiceExit' => $obj_rec['choiceexit'] );
199 return $sprop;
200 }
201
202
203
204}
205?>
const DB_FETCHMODE_ASSOC
Definition: class.ilDB.php:10
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...
global $ilDB