ILIAS  release_4-3 Revision
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilLPCollectionSettingsTableGUI.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 1998-2009 ILIAS open source, Extended GPL, see docs/LICENSE */
3 
4 include_once './Services/Table/classes/class.ilTable2GUI.php';
5 include_once './Services/Tracking/classes/class.ilLPCollections.php';
6 include_once './Services/Tracking/classes/class.ilLPObjSettings.php';
7 
15 {
16 
17  private $mode;
18  private $node_id;
19  private $collections;
20 
26  public function __construct($node_id,$a_parent_obj, $a_parent_cmd = "")
27  {
28  $this->node_id = $node_id;
29  parent::__construct($a_parent_obj, $a_parent_cmd);
30  $this->setId('lpobjs_'.$this->getNode());
31  }
32 
38  public function setMode($a_mode)
39  {
40  $this->mode = $a_mode;
41  }
42 
47  public function getMode()
48  {
49  return $this->mode;
50  }
51 
56  public function getNode()
57  {
58  return $this->node_id;
59  }
60 
65  protected function getCollection()
66  {
67  return $this->collections;
68  }
69 
73  public function parse()
74  {
75  switch($this->getMode())
76  {
77  case LP_MODE_COLLECTION:
79  $this->parseCollection();
80  break;
81 
82  case LP_MODE_SCORM:
83  $this->parseScormCollection();
84  break;
85  }
86  $this->initTable();
87  }
88 
93  protected function fillRow($a_set)
94  {
95  global $objDefinition;
96 
97  include_once './Services/Link/classes/class.ilLink.php';
98 
99  $this->tpl->setCurrentBlock('item_row');
100  $this->tpl->setVariable('ITEM_ID', $a_set['id']);
101  $this->tpl->setVariable('COLL_TITLE', $a_set['title']);
102  $this->tpl->setVariable('COLL_DESC',$a_set['description']);
103 
104  if($this->getMode() == LP_MODE_SCORM)
105  {
106  $this->tpl->setVariable('TYPE_IMG', ilUtil::getImagePath('icon_sco_s.png'));
107  $this->tpl->setVariable('ALT_IMG', $this->lng->txt('obj_sco'));
108  }
109  else
110  {
111  if($objDefinition->isPluginTypeName($a_set["type"]))
112  {
113  $alt = ilPlugin::lookupTxt("rep_robj", $a_set['type'], "obj_".$a_set['type']);
114  }
115  else
116  {
117  $alt = $this->lng->txt('obj_' . $a_set['type']);
118  }
119  $this->tpl->setVariable('ALT_IMG', $alt);
120  $this->tpl->setVariable('TYPE_IMG', ilObject::_getIcon("", "tiny", $a_set['type']));
121  $this->tpl->setVariable('COLL_LINK', ilLink::_getLink($a_set['ref_id'], $a_set['type']));
122  $this->tpl->setVariable('COLL_FRAME', ilFrameTargetInfo::_getFrame('MainContent', $a_set['type']));
123 
124  include_once './Services/Tree/classes/class.ilPathGUI.php';
125  $path = new ilPathGUI();
126  $this->tpl->setVariable('COLL_PATH', $this->lng->txt('path').': '.$path->getPath($this->getNode(),$a_set['ref_id']));
127 
128  $mode = $a_set['mode_id'];
130  {
131  $this->tpl->setVariable("COLL_MODE", $a_set['mode']);
132  }
133  else
134  {
135  $this->tpl->setVariable("COLL_MODE", "");
136  $this->tpl->setVariable("COLL_MODE_DEACTIVATED", $a_set['mode']);
137  }
138  if($this->isAnonymized($a_set))
139  {
140  $this->tpl->setVariable("ANONYMIZED", $this->lng->txt('trac_anonymized_info_short'));
141  }
142  }
143 
144  // Assigned ?
145  $this->tpl->setVariable("ASSIGNED_IMG_OK", $a_set['status']
146  ? ilUtil::getImagePath('icon_ok.png')
147  : ilUtil::getImagePath('icon_not_ok.png')
148  );
149  $this->tpl->setVariable("ASSIGNED_STATUS", $a_set['status']
150  ? $this->lng->txt('trac_assigned')
151  : $this->lng->txt('trac_not_assigned')
152  );
153  $this->tpl->parseCurrentBlock();
154 
155 
156  // Parse grouped items
157  foreach((array) $a_set['grouped'] as $item)
158  {
159  $this->fillRow($item);
160  }
161 
162  // show num obligatory info
163  if(count($a_set['grouped']))
164  {
165  $this->tpl->setCurrentBlock('num_passed_items');
166  $this->tpl->setVariable('MIN_PASSED_TXT', $this->lng->txt('trac_min_passed'));
167  $this->tpl->setVariable('NUM_OBLIGATORY', $a_set['num_obligatory']);
168  $this->tpl->setVariable('GRP_ID', $a_set['grouping_id']);
169  $this->tpl->parseCurrentBlock();
170  }
171  }
172 
177  protected function parseCollection()
178  {
179  $hasGroupedItems = false;
180 
181  $this->collections = new ilLPCollections(ilObject::_lookupObjId($this->getNode()));
182 
183  $items = ilLPCollections::_getPossibleItems($this->getNode(), $this->getCollection());
184 
185  $data = array();
186  $done = array();
187  foreach($items as $item)
188  {
189  if(in_array($item, $done))
190  continue;
191 
192  $tmp = $this->parseCollectionItem($item);
193  $tmp['grouped'] = array();
194 
195  if($this->getMode() == LP_MODE_COLLECTION)
196  {
197  $grouped_items = ilLPCollections::lookupGroupedItems(ilObject::_lookupObjId($this->getNode()), $item);
198  if(count((array) $grouped_items['items']) > 1)
199  {
200  foreach($grouped_items['items'] as $gr)
201  {
202  if($gr == $item)
203  {
204  continue;
205  }
206  $tmp['grouped'][] = $this->parseCollectionItem($gr);
207  $tmp['num_obligatory'] = $grouped_items['num_obligatory'];
208  $tmp['grouping_id'] = $grouped_items['grouping_id'];
209  $hasGroupedItems = true;
210  $done[] = $gr;
211  }
212  }
213  }
214  $data[] = $tmp;
215  }
216 
217  if($hasGroupedItems)
218  {
219  $this->addCommandButton('saveObligatoryMaterials', $this->lng->txt('trac_group_materials_save'));
220  }
221 
222  $this->setData((array) $data);
223  }
224 
228  protected function parseScormCollection()
229  {
230  $this->collections = new ilLPCollections(ilObject::_lookupObjId($this->getNode()));
231 
233 
234  $data = array();
235  foreach($items as $obj_id => $item)
236  {
237  $tmp['id'] = $obj_id;
238  $tmp['ref_id'] = 0;
239  $tmp['title'] = $item['title'];
240 
241  // status (sorting)
242  $tmp["status"] = $this->getCollection()->isAssigned($obj_id);
243 
244  $data[] = $tmp;
245  }
246  $this->setData($data);
247  return;
248  }
249 
254  protected function parseCollectionItem($item)
255  {
256  $tmp['ref_id'] = $item;
257  $tmp['id'] = $item;
258  $tmp['obj_id'] = ilObject::_lookupObjId($item);
259  $tmp['type'] = ilObject::_lookupType($tmp['obj_id']);
260  $tmp['title'] = ilObject::_lookupTitle($tmp['obj_id']);
261  $tmp['description'] = ilObject::_lookupDescription($tmp['obj_id']);
262 
263  // mode to text (sorting)
264  $tmp["mode_id"] = ilLPObjSettings::_lookupMode($tmp['obj_id']);
265  $tmp["mode"] = ilLPObjSettings::_mode2Text($tmp["mode_id"]);
266 
267  // status (sorting)
268  $tmp["status"] = $this->getCollection()->isAssigned($item);
269 
270  return $tmp;
271  }
272 
276  protected function initTable()
277  {
278  global $ilCtrl;
279 
280  $this->setFormAction($ilCtrl->getFormAction($this->getParentObject()));
281  switch($this->getMode())
282  {
283  case LP_MODE_COLLECTION:
284  $this->setRowTemplate('tpl.lp_collection_row.html', 'Services/Tracking');
285  $this->setTitle($this->lng->txt('trac_lp_determination'));
286  $this->setDescription($this->lng->txt('trac_lp_determination_info_crs'));
287  break;
288 
290  $this->setRowTemplate('tpl.lp_collection_row.html', 'Services/Tracking');
291  $this->setTitle($this->lng->txt('trac_lp_determination_tutor'));
292  $this->setDescription($this->lng->txt('trac_lp_determination_info_crs_tutor'));
293  break;
294 
295  case LP_MODE_SCORM:
296  $this->setRowTemplate('tpl.lp_collection_scorm_row.html', 'Services/Tracking');
297  $this->setTitle($this->lng->txt('trac_lp_determination'));
298  $this->setDescription($this->lng->txt('trac_lp_determination_info_sco'));
299  break;
300  }
301 
302  $this->addColumn('','','1px');
303  $this->addColumn($this->lng->txt('item'), 'title', '50%');
304 
305  if($this->getMode() != LP_MODE_SCORM)
306  {
307  $this->addColumn($this->lng->txt('trac_mode'), 'mode');
308  }
309 
310  if($this->getMode() != LP_MODE_MANUAL_BY_TUTOR)
311  {
312  $this->addMultiCommand('assign', $this->lng->txt('trac_collection_assign'));
313  $this->addMultiCommand('deassign', $this->lng->txt('trac_collection_deassign'));
314  $this->addColumn($this->lng->txt('trac_determines_learning_progress'), 'status');
315  }
316  else
317  {
318  $this->addMultiCommand('assign', $this->lng->txt('trac_manual_display'));
319  $this->addMultiCommand('deassign', $this->lng->txt('trac_manual_no_display'));
320  $this->addColumn($this->lng->txt('trac_manual_is_displayed'), 'status');
321  }
322 
323  $this->enable('select_all');
324  $this->setSelectAllCheckbox('item_ids');
325 
326  if($this->getMode() == LP_MODE_COLLECTION)
327  {
328  $this->addMultiCommand('groupMaterials', $this->lng->txt('trac_group_materials'));
330  {
331  $this->addMultiCommand('releaseMaterials', $this->lng->txt('trac_release_materials'));
332  }
333  }
334  }
335 
341  protected function isAnonymized($a_item)
342  {
343  switch($a_item['type'])
344  {
345  case 'tst':
346  include_once './Modules/Test/classes/class.ilObjTest.php';
347 
348  if(ilObjTest::_lookupAnonymity($a_item['obj_id']))
349  {
350  return true;
351  }
352  return false;
353 
354  default:
355  return false;
356  }
357  }
358 
359 }
360 ?>