ILIAS  eassessment Revision 61809
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilSCORM2004Objective.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 
35 require_once("./Modules/Scorm2004/classes/seq_editor/class.ilSCORM2004Item.php");
36 require_once("./Modules/Scorm2004/classes/seq_editor/class.ilSCORM2004MapInfo.php");
37 
38 
40 {
41 
42  //db fields
43 
44  private $node = null;
45  private $id = null; //userd as ID
46  private $objectiveID = null; //used as title
47 
48  //not supported in GUI yet
49  private $minNormalizedMeasure = 1.0;
50  private $primary = true;
51  private $satisfiedByMeasure = false;
52 
53  //mappings
54  private $mappings =array();
55 
60  function ilSCORM2004Objective($a_treeid = null, $a_obj_id = null)
61  {
62  parent::ilSCORM2004Item($a_treeid);
63 
64  if ($a_obj_id !=null && $a_treeid != null) {
65  $xpath_obj = new DOMXPath($this->dom);
66  $obj_node_list = $xpath_obj->query('//objective[@objectiveID = "'.$a_obj_id.'"] | '.
67  '//primaryObjective[@objectiveID = "'.$a_obj_id.'"]');
68  $this->setNode($obj_node_list->item(0));
69  } else {
70  if ($a_obj_id ==null && $a_treeid != null) {
71  $obj_con = $this->dom->createElement("objectives");
72  $obj = $this->dom->createElement("primaryObjective");
73  $root = $this->dom->getElementsByTagName("sequencing")->item(0);
74  $obj_con->appendChild($obj);
75  $root->appendChild($obj_con);
76  $this->node =$this->dom->getElementsByTagName("primaryObjective")->item(0);
77  }
78  }
79  }
80 
81 
82 
83  // **********************
84  // GETTER METHODS
85  // **********************
86 
87  public function getId()
88  {
89  return $this->node->getAttribute("objectiveID");
90  }
91 
92  public function getMinNormalizedMeasure()
93  {
94  return $this->node->getAttribute("minNormalizedMeasure");
95  }
96 
97  public function getObjectiveID()
98  {
99  return $this->node->getAttribute("title");
100  }
101 
102  public function getPrimary()
103  {
104  return $this->primary;
105  }
106 
107  public function getSatisfiedByMeasure()
108  {
109  return $this->node->getAttribute("satisfiedByMeasure");
110  }
111 
112  public function getMappings()
113  {
114  return $this->mappings;
115  }
116 
117  // **********************
118  // Setter METHODS
119  // **********************
120 
121  public function setSeqNodeId($a_seqnodeid)
122  {
123  $this->seqNodeId = $a_seqnodeid;
124  }
125 
126  public function setId($a_id)
127  {
128  $this->node->setAttribute("objectiveID",$a_id);
129  }
130 
131 
132  public function setMinNormalizedMeasure($a_minmeasure)
133  {
134  $this->node->setAttribute("minNormalizedMeasure",$a_minmeasure);
135  }
136 
137  public function setObjectiveID($a_objectiveid)
138  {
139  $this->node->setAttribute("title",$a_objectiveid);
140  }
141 
142  public function setPrimary($a_primary)
143  {
144  $this->primary = $a_primary;
145  }
146 
147  public function setSatisfiedByMeasure($a_satisfied)
148  {
149  $this->node->setAttribute("satisfiedByMeasure",$a_satisfied);
150  }
151 
152  public function setMappings($a_mappings)
153  {
154  $this->mappings = $a_mappings;
155  }
156 
157  public function setNode($a_node)
158  {
159  $this->node = $a_node;
160  }
161 
162  public function setDom($a_dom)
163  {
164  $this->dom = $a_dom;
165  }
166 
167  // **********************
168  // Standard Operations for Object
169  // **********************
170 
171 
172  public function updateObjective() {
173  parent::update();
174  }
175 
176  static function fetchAllObjectives($a_slm_object,$a_tree_node_id)
177  {
178  global $ilDB;
179 
180  $objectives = array();
181  $seq_item = new ilSCORM2004Item($a_tree_node_id);
182  $xpath_obj = new DOMXPath($seq_item->dom);
183  $obj_node_list = $xpath_obj->query('//objective | //primaryObjective');
184  for ($i=0;$i<$obj_node_list->length;$i++) {
185  $obj = new ilSCORM2004Objective();
186  $obj->setNode($obj_node_list->item($i));
187  $mapping_node_list = $xpath_obj->query('//objective | //primaryObjective');
188  //check for mapping
189  array_push($objectives,$obj);
190  }
191  return $objectives;
192 
193  }
194 
195 }
196 ?>