ILIAS  Release_4_2_x_branch Revision 61807
 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  include_once './classes/class.ilLink.php';
96 
97  $this->tpl->setCurrentBlock('item_row');
98  $this->tpl->setVariable('ITEM_ID', $a_set['id']);
99  $this->tpl->setVariable('COLL_TITLE', $a_set['title']);
100  $this->tpl->setVariable('COLL_DESC',$a_set['description']);
101 
102  if($this->getMode() == LP_MODE_SCORM)
103  {
104  $this->tpl->setVariable('TYPE_IMG', ilUtil::getImagePath('icon_sco_s.gif'));
105  $this->tpl->setVariable('ALT_IMG', $this->lng->txt('obj_sco'));
106  }
107  else
108  {
109  include_once './Services/Tree/classes/class.ilPathGUI.php';
110  $path = new ilPathGUI();
111 
112  $this->tpl->setVariable('TYPE_IMG', ilUtil::getImagePath('icon_' . $a_set['type'] . '_s.gif'));
113  $this->tpl->setVariable('ALT_IMG', $this->lng->txt('obj_' . $a_set['type']));
114  $this->tpl->setVariable('COLL_LINK', ilLink::_getLink($a_set['ref_id'], $a_set['type']));
115  $this->tpl->setVariable('COLL_FRAME', ilFrameTargetInfo::_getFrame('MainContent', $a_set['type']));
116  $this->tpl->setVariable('COLL_PATH', $this->lng->txt('path').': '.$path->getPath($this->getNode(),$a_set['ref_id']));
117 
118  $mode = $a_set['mode_id'];
120  {
121  $this->tpl->setVariable("COLL_MODE", $a_set['mode']);
122  }
123  else
124  {
125  $this->tpl->setVariable("COLL_MODE", "");
126  $this->tpl->setVariable("COLL_MODE_DEACTIVATED", $a_set['mode']);
127  }
128  if($this->isAnonymized($a_set))
129  {
130  $this->tpl->setVariable("ANONYMIZED", $this->lng->txt('trac_anonymized_info_short'));
131  }
132  }
133 
134  // Assigned ?
135  $this->tpl->setVariable("ASSIGNED_IMG_OK", $a_set['status']
136  ? ilUtil::getImagePath('icon_ok.gif')
137  : ilUtil::getImagePath('icon_not_ok.gif')
138  );
139  $this->tpl->setVariable("ASSIGNED_STATUS", $a_set['status']
140  ? $this->lng->txt('trac_assigned')
141  : $this->lng->txt('trac_not_assigned')
142  );
143  $this->tpl->parseCurrentBlock();
144 
145 
146  // Parse grouped items
147  foreach((array) $a_set['grouped'] as $item)
148  {
149  $this->fillRow($item);
150  }
151 
152  // show num obligatory info
153  if(count($a_set['grouped']))
154  {
155  $this->tpl->setCurrentBlock('num_passed_items');
156  $this->tpl->setVariable('MIN_PASSED_TXT', $this->lng->txt('trac_min_passed'));
157  $this->tpl->setVariable('NUM_OBLIGATORY', $a_set['num_obligatory']);
158  $this->tpl->setVariable('GRP_ID', $a_set['grouping_id']);
159  $this->tpl->parseCurrentBlock();
160  }
161  }
162 
167  protected function parseCollection()
168  {
169  $hasGroupedItems = false;
170 
171  $this->collections = new ilLPCollections(ilObject::_lookupObjId($this->getNode()));
172 
173  $items = ilLPCollections::_getPossibleItems($this->getNode());
174 
175  $data = array();
176  $done = array();
177  foreach($items as $item)
178  {
179  if(in_array($item, $done))
180  continue;
181 
182  $tmp = $this->parseCollectionItem($item);
183  $tmp['grouped'] = array();
184 
185  if($this->getMode() == LP_MODE_COLLECTION)
186  {
187  $grouped_items = ilLPCollections::lookupGroupedItems(ilObject::_lookupObjId($this->getNode()), $item);
188  if(count((array) $grouped_items['items']) > 1)
189  {
190  foreach($grouped_items['items'] as $gr)
191  {
192  if($gr == $item)
193  {
194  continue;
195  }
196  $tmp['grouped'][] = $this->parseCollectionItem($gr);
197  $tmp['num_obligatory'] = $grouped_items['num_obligatory'];
198  $tmp['grouping_id'] = $grouped_items['grouping_id'];
199  $hasGroupedItems = true;
200  $done[] = $gr;
201  }
202  }
203  }
204  $data[] = $tmp;
205  }
206 
207  if($hasGroupedItems)
208  {
209  $this->addCommandButton('saveObligatoryMaterials', $this->lng->txt('trac_group_materials_save'));
210  }
211 
212  $this->setData((array) $data);
213  }
214 
218  protected function parseScormCollection()
219  {
220  $this->collections = new ilLPCollections(ilObject::_lookupObjId($this->getNode()));
221 
223 
224  $data = array();
225  foreach($items as $obj_id => $item)
226  {
227  $tmp['id'] = $obj_id;
228  $tmp['ref_id'] = 0;
229  $tmp['title'] = $item['title'];
230 
231  // status (sorting)
232  $tmp["status"] = $this->getCollection()->isAssigned($obj_id);
233 
234  $data[] = $tmp;
235  }
236  $this->setData($data);
237  return;
238  }
239 
244  protected function parseCollectionItem($item)
245  {
246  $tmp['ref_id'] = $item;
247  $tmp['id'] = $item;
248  $tmp['obj_id'] = ilObject::_lookupObjId($item);
249  $tmp['type'] = ilObject::_lookupType($tmp['obj_id']);
250  $tmp['title'] = ilObject::_lookupTitle($tmp['obj_id']);
251  $tmp['description'] = ilObject::_lookupDescription($tmp['obj_id']);
252 
253  // mode to text (sorting)
254  $tmp["mode_id"] = ilLPObjSettings::_lookupMode($tmp['obj_id']);
255  $tmp["mode"] = ilLPObjSettings::_mode2Text($tmp["mode_id"]);
256 
257  // status (sorting)
258  $tmp["status"] = $this->getCollection()->isAssigned($item);
259 
260  return $tmp;
261  }
262 
266  protected function initTable()
267  {
268  global $ilCtrl;
269 
270  $this->setFormAction($ilCtrl->getFormAction($this->getParentObject()));
271  switch($this->getMode())
272  {
273  case LP_MODE_COLLECTION:
274  $this->setRowTemplate('tpl.lp_collection_row.html', 'Services/Tracking');
275  $this->setTitle($this->lng->txt('trac_lp_determination'));
276  $this->setDescription($this->lng->txt('trac_lp_determination_info_crs'));
277  break;
278 
280  $this->setRowTemplate('tpl.lp_collection_row.html', 'Services/Tracking');
281  $this->setTitle($this->lng->txt('trac_lp_determination_tutor'));
282  $this->setDescription($this->lng->txt('trac_lp_determination_info_crs_tutor'));
283  break;
284 
285  case LP_MODE_SCORM:
286  $this->setRowTemplate('tpl.lp_collection_scorm_row.html', 'Services/Tracking');
287  $this->setTitle($this->lng->txt('trac_lp_determination'));
288  $this->setDescription($this->lng->txt('trac_lp_determination_info_sco'));
289  break;
290  }
291 
292  $this->addColumn('','','1px');
293  $this->addColumn($this->lng->txt('item'), 'title', '50%');
294 
295  if($this->getMode() != LP_MODE_SCORM)
296  {
297  $this->addColumn($this->lng->txt('trac_mode'), 'mode');
298  }
299 
300  if($this->getMode() != LP_MODE_MANUAL_BY_TUTOR)
301  {
302  $this->addMultiCommand('assign', $this->lng->txt('trac_collection_assign'));
303  $this->addMultiCommand('deassign', $this->lng->txt('trac_collection_deassign'));
304  $this->addColumn($this->lng->txt('trac_determines_learning_progress'), 'status');
305  }
306  else
307  {
308  $this->addMultiCommand('assign', $this->lng->txt('trac_manual_display'));
309  $this->addMultiCommand('deassign', $this->lng->txt('trac_manual_no_display'));
310  $this->addColumn($this->lng->txt('trac_manual_is_displayed'), 'status');
311  }
312 
313  $this->enable('select_all');
314  $this->setSelectAllCheckbox('item_ids');
315 
316  if($this->getMode() == LP_MODE_COLLECTION)
317  {
318  $this->addMultiCommand('groupMaterials', $this->lng->txt('trac_group_materials'));
320  {
321  $this->addMultiCommand('releaseMaterials', $this->lng->txt('trac_release_materials'));
322  }
323  }
324  }
325 
331  protected function isAnonymized($a_item)
332  {
333  switch($a_item['type'])
334  {
335  case 'tst':
336  include_once './Modules/Test/classes/class.ilObjTest.php';
337 
338  if(ilObjTest::_lookupAnonymity($a_item['obj_id']))
339  {
340  return true;
341  }
342  return false;
343 
344  default:
345  return false;
346  }
347  }
348 
349 }
350 ?>