ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
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  $users = $this->getParentObject()->object->getTrackedUsers($this->filter['lastname']);
45  $attempts = $this->getParentObject()->object->getAttemptsForUsers();
46  $versions = $this->getParentObject()->object->getModuleVersionForUsers();
47 
48  $data = array();
49  foreach ($users as $user) {
50  $tmp = array();
51  $tmp['user'] = $user['user_id'];
52  $tmp['name'] = $user['lastname'] . ', ' . $user['firstname'];
53  $dt = new ilDateTime($user['last_access'], IL_CAL_DATETIME);
54  $tmp['last_access'] = $dt->get(IL_CAL_UNIX);
55  $tmp['attempts'] = (int) $attempts[$user['user_id']];
56  $tmp['version'] = (int) $versions[$user['user_id']];
57 
58  $data[] = $tmp;
59  }
60  $this->determineOffsetAndOrder();
61  $orderField = $this->getOrderField();
62  $orderDirection = $this->getOrderDirection();
63  if ( in_array(ilUtil::stripSlashes($orderField), ['user', 'attempts', 'version']) ) {
64  $this->setExternalSorting(true);
66  $data,
67  $orderField,
68  $orderDirection,
69  true
70  );
71  }
72  $this->setData($data);
73  }
74 
75  public function initFilter()
76  {
77  $item = $this->addFilterItemByMetaType("lastname", ilTable2GUI::FILTER_TEXT);
78  $this->filter["lastname"] = $item->getValue();
79  }
80 
85  protected function fillRow($a_set)
86  {
87  global $DIC;
88  $ilCtrl = $DIC['ilCtrl'];
89 
90  $this->tpl->setVariable('CHECKBOX_ID', $a_set['user']);
91  $this->tpl->setVariable('VAL_USERNAME', $a_set['name']);
92 
93  // $ilCtrl->setParameter($this->getParentObject(),'user_id',$a_set['user']);
94  // $this->tpl->setVariable('LINK_ITEM', $ilCtrl->getLinkTarget($this->getParentObject(),'showTrackingItem'));
95 
96  $this->tpl->setVariable('VAL_LAST', ilDatePresentation::formatDate(new ilDateTime($a_set['last_access'], IL_CAL_UNIX)));
97  $this->tpl->setVariable('VAL_ATTEMPT', (int) $a_set['attempts']);
98  $this->tpl->setVariable('VAL_VERSION', (string) $a_set['version']);
99  }
100 
104  protected function initTable()
105  {
106  global $DIC;
107  $ilCtrl = $DIC['ilCtrl'];
108 
109  $this->setFilterCommand('applyUserTableFilter');
110  $this->setResetCommand('resetUserTableFilter');
111 
112  $this->setDisableFilterHiding(false);
113 
114  $this->setFormAction($ilCtrl->getFormAction($this->getParentObject()));
115  $this->setRowTemplate('tpl.scorm_track_items.html', 'Modules/ScormAicc');
116  $this->setTitle($this->lng->txt('cont_tracking_items'));
117 
118  $this->addColumn('', '', '1px');
119  $this->addColumn($this->lng->txt('user'), 'name', '35%');
120  $this->addColumn($this->lng->txt('last_access'), 'last_access', '25%');
121  $this->addColumn($this->lng->txt('attempts'), 'attempts', '20%');
122  $this->addColumn($this->lng->txt('version'), 'version', '20%');
123 
124  $this->enable('select_all');
125  $this->setSelectAllCheckbox('user');
126 
127  $this->addMultiCommand('deleteTrackingForUser', $this->lng->txt('delete'));
128  $this->addMultiCommand('decreaseAttempts', $this->lng->txt('decrease_attempts'));
129  $this->addMultiCommand('exportSelectionUsers', $this->lng->txt('export'));
130  }
131 }
static sortArray( $array, $a_array_sortby, $a_array_sortorder=0, $a_numeric=false, $a_keep_keys=false)
sortArray
setExternalSorting($a_val)
Set external sorting.
const IL_CAL_DATETIME
global $DIC
Definition: saml.php:7
addFilterItemByMetaType($id, $type=self::FILTER_TEXT, $a_optional=false, $caption=null)
Add filter by standard type.
const IL_CAL_UNIX
getOrderDirection()
Get order direction.
static formatDate(ilDateTime $date, $a_skip_day=false, $a_include_wd=false, $include_seconds=false)
Format a date public.
getParentObject()
Get parent object.
setId($a_val)
Set id.
global $ilCtrl
Definition: ilias.php:18
setTitle($a_title, $a_icon=0, $a_icon_alt=0)
Set title and title icon.
Class ilTable2GUI.
setResetCommand($a_val, $a_caption=null)
Set reset filter command.
setSelectAllCheckbox($a_select_all_checkbox, $a_select_all_on_top=false)
Set the name of the checkbox that should be toggled with a select all button.
setDisableFilterHiding($a_val=true)
Set disable filter hiding.
__construct($a_obj_id, $a_parent_obj, $a_parent_cmd)
Constructor.
addMultiCommand($a_cmd, $a_text)
Add Command button.
enable($a_module_name)
enables particular modules of table
Date and time handling
static stripSlashes($a_str, $a_strip_html=true, $a_allow="")
strip slashes if magic qoutes is enabled
$user
Definition: migrateto20.php:57
setRowTemplate($a_template, $a_template_dir="")
Set row template.
$users
Definition: authpage.php:44
determineOffsetAndOrder($a_omit_offset=false)
Determine offset and order.
setFormAction($a_form_action, $a_multipart=false)
Set Form action parameter.
addColumn( $a_text, $a_sort_field="", $a_width="", $a_is_checkbox_action_column=false, $a_class="", $a_tooltip="", $a_tooltip_with_html=false)
Add a column to the header.
setFilterCommand($a_val, $a_caption=null)
Set filter command.