ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
class.ilSCORMTrackingUsersTableGUI.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=1);
27 {
28  private int $obj_id;
29  private array $filter;
30 
31  public function __construct(int $a_obj_id, ?object $a_parent_obj, string $a_parent_cmd)
32  {
33  $this->obj_id = $a_obj_id;
34 
35  $this->setId('sco_tr_usrs_' . $this->obj_id);
36  parent::__construct($a_parent_obj, $a_parent_cmd);
37  $this->initFilter();
38  }
39 
40  public function getObjId(): int
41  {
42  return $this->obj_id;
43  }
44 
49  public function parse(): void
50  {
51  $this->initTable();
52 
53  $users = $this->getParentObject()->getObject()->getTrackedUsers((string) $this->filter['lastname']);
54  $attempts = $this->getParentObject()->getObject()->getAttemptsForUsers();
55  $versions = $this->getParentObject()->getObject()->getModuleVersionForUsers();
56 
57  $data = array();
58  foreach ($users as $user) {
59  $tmp = array();
60  $tmp['user'] = $user['user_id'];
61  $tmp['name'] = $user['lastname'] . ', ' . $user['firstname'];
62  $dt = new ilDateTime($user['last_access'], IL_CAL_DATETIME);
63  $tmp['last_access'] = $dt->get(IL_CAL_UNIX);
64  $tmp['attempts'] = (int) $attempts[$user['user_id']];
65  $tmp['version'] = (int) $versions[$user['user_id']];
66 
67  $data[] = $tmp;
68  }
69  $this->determineOffsetAndOrder();
70  $orderField = $this->getOrderField();
71  $orderDirection = $this->getOrderDirection();
72  if (in_array(ilUtil::stripSlashes($orderField), ['user', 'attempts', 'version'])) {
73  $this->setExternalSorting(true);
75  $data,
76  $orderField,
77  $orderDirection,
78  true
79  );
80  }
81  $this->setData($data);
82  }
83 
87  public function initFilter(): void
88  {
89  $item = $this->addFilterItemByMetaType("lastname", ilTable2GUI::FILTER_TEXT);
90  if ($item !== null) {
91  $this->filter["lastname"] = $item->getValue();
92  }
93  }
94 
98  protected function fillRow(array $a_set): void
99  {
100  global $DIC;
101  $ilCtrl = $DIC->ctrl();
102 
103  $this->tpl->setVariable('CHECKBOX_ID', $a_set['user']);
104  $this->tpl->setVariable('VAL_USERNAME', $a_set['name']);
105 
106  // $ilCtrl->setParameter($this->getParentObject(),'user_id',$a_set['user']);
107  // $this->tpl->setVariable('LINK_ITEM', $ilCtrl->getLinkTarget($this->getParentObject(),'showTrackingItem'));
108 
109  $this->tpl->setVariable('VAL_LAST', ilDatePresentation::formatDate(new ilDateTime($a_set['last_access'], IL_CAL_UNIX)));
110  $this->tpl->setVariable('VAL_ATTEMPT', (int) $a_set['attempts']);
111  $this->tpl->setVariable('VAL_VERSION', (string) $a_set['version']);
112  }
113 
114  protected function initTable(): void
115  {
116  global $DIC;
117  $ilCtrl = $DIC->ctrl();
118 
119  $this->setFilterCommand('applyUserTableFilter');
120  $this->setResetCommand('resetUserTableFilter');
121 
122  $this->setDisableFilterHiding(false);
123 
124  $this->setFormAction($ilCtrl->getFormAction($this->getParentObject()));
125  $this->setRowTemplate('tpl.scorm_track_items.html', 'Modules/ScormAicc');
126  $this->setTitle($this->lng->txt('cont_tracking_items'));
127 
128  $this->addColumn('', '', '1px');
129  $this->addColumn($this->lng->txt('user'), 'name', '35%');
130  $this->addColumn($this->lng->txt('last_access'), 'last_access', '25%');
131  $this->addColumn($this->lng->txt('attempts'), 'attempts', '20%');
132  $this->addColumn($this->lng->txt('version'), 'version', '20%');
133 
134  $this->enable('select_all');
135  $this->setSelectAllCheckbox('user');
136 
137  $this->addMultiCommand('deleteTrackingForUser', $this->lng->txt('delete'));
138  $this->addMultiCommand('exportSelectionUsers', $this->lng->txt('export'));
139  }
140 }
setData(array $a_data)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
enable(string $a_module_name)
const IL_CAL_DATETIME
setFormAction(string $a_form_action, bool $a_multipart=false)
setResetCommand(string $a_val, string $a_caption="")
static stripSlashes(string $a_str, bool $a_strip_html=true, string $a_allow="")
setSelectAllCheckbox(string $a_select_all_checkbox, bool $a_select_all_on_top=false)
static formatDate(ilDateTime $date, bool $a_skip_day=false, bool $a_include_wd=false, bool $include_seconds=false)
setDisableFilterHiding(bool $a_val=true)
const IL_CAL_UNIX
setId(string $a_val)
global $DIC
Definition: feed.php:28
setExternalSorting(bool $a_val)
__construct(int $a_obj_id, ?object $a_parent_obj, string $a_parent_cmd)
addFilterItemByMetaType(string $id, int $type=self::FILTER_TEXT, bool $a_optional=false, string $caption="")
Add filter by standard type.
setRowTemplate(string $a_template, string $a_template_dir="")
Set row template.
setFilterCommand(string $a_val, string $a_caption="")
setTitle(string $a_title, string $a_icon="", string $a_icon_alt="")
__construct(Container $dic, ilPlugin $plugin)
addColumn(string $a_text, string $a_sort_field="", string $a_width="", bool $a_is_checkbox_action_column=false, string $a_class="", string $a_tooltip="", bool $a_tooltip_with_html=false)
addMultiCommand(string $a_cmd, string $a_text)
determineOffsetAndOrder(bool $a_omit_offset=false)
fillRow(array $a_set)
Fill row template.
static sortArray(array $array, string $a_array_sortby_key, string $a_array_sortorder="asc", bool $a_numeric=false, bool $a_keep_keys=false)