ILIAS  eassessment Revision 61809
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilSCORM2004Utilities.php
Go to the documentation of this file.
1 <?php
2 /*
3  +-----------------------------------------------------------------------------+
4  | ILIAS open source |
5  +-----------------------------------------------------------------------------+
6  | Copyright (c) 1998-2008 ILIAS open source, University of Cologne |
7  | |
8  | This program is free software; you can redistribute it and/or |
9  | modify it under the terms of the GNU General Public License |
10  | as published by the Free Software Foundation; either version 2 |
11  | of the License, or (at your option) any later version. |
12  | |
13  | This program is distributed in the hope that it will be useful, |
14  | but WITHOUT ANY WARRANTY; without even the implied warranty of |
15  | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16  | GNU General Public License for more details. |
17  | |
18  | You should have received a copy of the GNU General Public License |
19  | along with this program; if not, write to the Free Software |
20  | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
21  +-----------------------------------------------------------------------------+
22 */
23 
24 
37 {
38 
39 
40  private $id = null;
41 
42  /*
43  * Constructor
44  * @access public
45  */
46  function ilSCORM2004Utilities($a_id)
47  {
48  $this->id = $a_id;
49  }
50 
51  public function parentHasSeqTemplate($a_slm_id)
52  {
53  require_once("./Modules/Scorm2004/classes/seq_editor/class.ilSCORM2004Template.php");
54 
55  global $ilDB,$ilLog;
56  $has_template = false;
57 
58  $mtree = new ilTree($a_slm_id);
59  $mtree->setTableNames('sahs_sc13_tree','sahs_sc13_tree_node');
60  $mtree->setTreeTablePK("slm_id");
61  //get all parents for current node
62  $parents = $this -> getParentsForNode($a_parents=array(),$this->id);
63  for ($i=0;$i<count($parents);$i++)
64  {
65  $template = ilSCORM2004SeqTemplate::templateForChapter($parents[$i]);
66  if ($template) {
67  $has_template = true;
68  break;
69  }
70  }
71 
72  return $has_template;
73  }
74 
75  private function getParentsForNode($a_parents,$a_id){
76  $parent_id = $tree->getParentId($id);
77  if ($parent_id != 0) {
78  array_push($a_parents,$parent_id);
79  $this->getParentsForNode($a_parents,$parent_id);
80  } else {
81  return $a_parents;
82  }
83  }
84 
85 
86  public function getLeftRightInfo()
87  {
88  global $ilDB,$ilLog;
89  $ilLog->write("SCORM: getLeftRightInfo");
90  $query = "SELECT * FROM sahs_sc13_seq_tree WHERE (child = ".
91  $ilDB->quote($this->getSeqNodeId(), "integer").
92  " AND importid=".$ilDB->quote($this->getImportIdent(), "text").")";
93  $obj_set = $ilDB->query($query);
94  $ilLog->write("SCORM: getLeftRightInfo executed".$query);
95  $obj_rec = $ilDB->fetchAssoc($obj_set);
96  return array("left"=> $obj_rec["lft"], "right" => $obj_rec["rgt"]);
97  }
98 
99 
100  protected function getSeqNodeId()
101  {
102  global $ilDB,$ilLog;
103  $all_props = $this->getAllSequencingProperties();
104  $ilLog->write("SCORM: getSeqNodeId: ".$all_props["seqnodeid"]);
105  return $all_props["seqnodeid"];
106  }
107 
108  private function getSequencingId()
109  {
110  global $ilDB,$ilLog;
111  $ilLog->write("SCORM: getSequencingId for".$this->getId());
112  $query = "SELECT * FROM sahs_sc13_seq_item WHERE sahs_sc13_tree_node_id = ".
113  $ilDB->quote($this->getId(), "integer");
114  $obj_set = $ilDB->query($query);
115  $obj_rec = $obj_set->fetchRow(DB_FETCHMODE_ASSOC);
116  return $obj_rec['sequencingid'];
117  }
118 
119  private function getItemId()
120  {
121  global $ilDB,$ilLog;
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(DB_FETCHMODE_ASSOC);
127  return $obj_rec['seqnodeid'];
128  }
129 
130  public function getImportIdent()
131  {
132  global $ilDB,$ilLog;
133  $ilLog->write("SCORM: getImportIdent for".$this->getId);
134  $query = "SELECT * FROM sahs_sc13_seq_item WHERE sahs_sc13_tree_node_id = ".
135  $ilDB->quote($this->getId(), "integer");
136  $obj_set = $ilDB->query($query);
137  $obj_rec = $obj_set->fetchRow(DB_FETCHMODE_ASSOC);
138  return $obj_rec['importid'];
139  }
140 
141 
142 
143  private function getId()
144  {
145  return $this->id;
146  }
147 
148  public function getAllowedActions()
149  {
150  global $ilDB,$ilLog;
151  $ilLog->write("SCORM: getAllowedActions for".$this->tree_node_id);
152  $query = "SELECT * FROM sahs_sc13_seq_item WHERE sahs_sc13_tree_node_id = ".
153  $ilDB->quote($this->getId(), "integer");
154  $obj_set = $ilDB->query($query);
155  $obj_rec = $obj_set->fetchRow(DB_FETCHMODE_ASSOC);
156  return array("copy"=>!$obj_rec['nocopy'],"move"=>!$obj_rec['nomove'],"delete"=>!$obj_rec['nodelete']);
157  }
158 
159  public function getControlModeProperties()
160  {
161  global $ilDB;
162  $query = "SELECT * FROM sahs_sc13_seq_seq WHERE id = ".
163  $ilDB->quote($this->getSequencingId(), "text");
164  $obj_set = $ilDB->query($query);
165  $obj_rec = $obj_set->fetchRow(DB_FETCHMODE_ASSOC);
166  $c_properties = array(
167  'flow' => $obj_rec['flow'],
168  'forwardOnly' => $obj_rec['forwardonly'],
169  'choice' => $obj_rec['choice'],
170  'choiceExit' => $obj_rec['choiceexit'] );
171  return $c_properties;
172  }
173 
174  public function getAllSequencingProperties()
175  {
176  global $ilDB,$ilLog;
177  $query = "SELECT * FROM sahs_sc13_seq_seq WHERE (id = ".
178  $ilDB->quote($this->getSequencingId(), "text").
179  " AND importid=".$ilDB->quote($this->getImportIdent(), "text").")";
180  $obj_set = $ilDB->query($query);
181  $ilLog->write("SCORM: getAllSequencingProperties for".$this->getSequencingId());
182  $obj_rec = $obj_set->fetchRow(DB_FETCHMODE_ASSOC);
183  $sprop = array(
184  'importId' => $obj_rec['importid'],
185  'activityAbsoluteDurationLimit' => $obj_rec['activityabsolutedurationlimit'],
186  'activityExperiencedDurationLimit' => $obj_rec['activityexperienceddurlimit'],
187  'attemptAbsoluteDurationLimit' => $obj_rec['attemptabsolutedurationlimit'],
188  'attemptExperiencedDurationLimit' => $obj_rec['attemptexperienceddurlimit'],
189  'attemptLimit' => $obj_rec['attemptlimit'],
190  'beginTimeLimit' => $obj_rec['begintimelimit'],
191  'completionSetByContent' => $obj_rec['completionsetbycontent'],
192  'constrainChoice' => $obj_rec['constrainchoice'],
193  'seqNodeId' => $obj_rec['seqnodeid'],
194  'endTimeLimit' => $obj_rec['endtimelimit'],
195  'id' => $obj_rec['id'],
196  'measureSatisfactionIfActive' => $obj_rec['measuresatisfactionifactive'],
197  'objectiveMeasureWeight' => $obj_rec['objectivemeasureweight'],
198  'objectiveSetByContent' => $obj_rec['objectivesetbycontent'],
199  'preventActivation' => $obj_rec['preventactivation'],
200  'randomizationTiming' => $obj_rec['randomizationtiming'],
201  'reorderChildren' => $obj_rec['reorderchildren'],
202  'requiredForCompleted' => $obj_rec['requiredforcompleted'],
203  'requiredForIncomplete' => $obj_rec['requiredforincomplete'],
204  'requiredForNotSatisfied' => $obj_rec['requiredfornotsatisfied'],
205  'requiredForSatisfied' => $obj_rec['requiredforsatisfied'],
206  'rollupObjectiveSatisfied' => $obj_rec['rollupobjectivesatisfied'],
207  'rollupProgressCompletion' => $obj_rec['rollupprogresscompletion'],
208  'selectCount' => $obj_rec['selectcount'],
209  'selectionTiming' => $obj_rec['selectiontiming'],
210  'sequencingId' => $obj_rec['sequencingid'],
211  'tracked' => $obj_rec['tracked'],
212  'useCurrentAttemptObjectiveInfo' => $obj_rec['usecurrentattemptobjectiveinfo'],
213  'useCurrentAttemptProgressInfo' => $obj_rec['usecurrentattemptprogressinfo'],
214  'flow' => $obj_rec['flow'],
215  'forwardOnly' => $obj_rec['forwardonly'],
216  'choice' => $obj_rec['choice'],
217  'choiceExit' => $obj_rec['choiceexit'] );
218  return $sprop;
219  }
220 
221 
222 
223 }
224 ?>