ILIAS  release_4-3 Revision
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilSCORMTrackingUsersTableGUI.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 
13 {
14  private $obj_id = 0;
15 
19  public function __construct($a_obj_id,$a_parent_obj,$a_parent_cmd)
20  {
21  $this->obj_id = $a_obj_id;
22 
23  $this->setId('sco_tr_usrs_'.$this->obj_id);
24  parent::__construct($a_parent_obj, $a_parent_cmd);
25  $this->initFilter();
26  }
27 
32  public function getObjId()
33  {
34  return $this->obj_id;
35  }
36 
40  public function parse()
41  {
42  $this->initTable();
43 
44  // @TODO add filter
45  $users = $this->getParentObject()->object->getTrackedUsers($this->filter['lastname']);
46  $attempts = $this->getParentObject()->object->getAttemptsForUsers();
47  $versions = $this->getParentObject()->object->getModuleVersionForUsers();
48 
49  $data = array();
50  foreach($users as $user)
51  {
52  $tmp = array();
53  $tmp['user'] = $user['user_id'];
54  $tmp['firstname'] = $user['firstname'];
55  $tmp['lastname'] = $user['lastname'];
56  $dt = new ilDateTime($user['last_access'],IL_CAL_DATETIME);
57  $tmp['last_access'] = $dt->get(IL_CAL_UNIX);
58  $tmp['attempts'] = (int) $attempts[$user['user_id']];
59  $tmp['version'] = (int) $versions[$user['user_id']];
60 
61  $data[] = $tmp;
62  }
63  $this->setData($data);
64  }
65 
66  public function initFilter()
67  {
68  $item = $this->addFilterItemByMetaType("lastname", ilTable2GUI::FILTER_TEXT);
69  $this->filter["lastname"] = $item->getValue();
70  }
71 
76  protected function fillRow($a_set)
77  {
78  global $ilCtrl;
79 
80  $this->tpl->setVariable('CHECKBOX_ID', $a_set['user']);
81  $this->tpl->setVariable('VAL_USERNAME', $a_set['lastname'].', '.$a_set['firstname']);
82 
83  $ilCtrl->setParameter($this->getParentObject(),'user_id',$a_set['user']);
84  $this->tpl->setVariable('LINK_ITEM', $ilCtrl->getLinkTarget($this->getParentObject(),'showTrackingItem'));
85 
86  $this->tpl->setVariable('VAL_LAST', ilDatePresentation::formatDate(new ilDateTime($a_set['last_access'],IL_CAL_UNIX)));
87  $this->tpl->setVariable('VAL_ATTEMPT', (int) $a_set['attempts']);
88  $this->tpl->setVariable('VAL_VERSION', (string) $a_set['version']);
89 
90  }
91 
95  protected function initTable()
96  {
97  global $ilCtrl;
98 
99  $this->setFilterCommand('applyUserTableFilter');
100  $this->setResetCommand('resetUserTableFilter');
101 
102  $this->setDisableFilterHiding(false);
103 
104  $this->setFormAction($ilCtrl->getFormAction($this->getParentObject()));
105  $this->setRowTemplate('tpl.scorm_track_items.html', 'Modules/ScormAicc');
106  $this->setTitle($this->lng->txt('cont_tracking_items'));
107 
108  $this->addColumn('','','1px');
109  $this->addColumn($this->lng->txt('name'), 'lastname','35%');
110  $this->addColumn($this->lng->txt('last_access'), 'last_access', '25%');
111  $this->addColumn($this->lng->txt('attempts'), 'attempts', '20%');
112  $this->addColumn($this->lng->txt('version'), 'version','20%');
113 
114  $this->enable('select_all');
115  $this->setSelectAllCheckbox('user');
116 
117  $this->addMultiCommand('deleteTrackingForUser', $this->lng->txt('delete'));
118  $this->addMultiCommand('decreaseAttempts', $this->lng->txt('decrease_attempts'));
119  $this->addMultiCommand('exportSelectionUsers', $this->lng->txt('export'));
120  }
121 }
122 ?>