ILIAS  trunk Revision v11.0_alpha-1689-g66c127b4ae8
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
class.ilSCORMTrackingItemsTableGUI.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
27 {
28  private int $obj_id;
29  private int $user_id = 0;
30  private bool $bySCO = false;
31  private array $scosSelected;
32  private array $userSelected;
33  private bool $allowExportPrivacy = false;
34  private string $lmTitle = "";
35  private string $report;
36 
40  public function __construct(int $a_obj_id, ?object $a_parent_obj, string $a_parent_cmd, array $a_userSelected, array $a_scosSelected, string $a_report)
41  {
42  global $DIC;
43  $ilCtrl = $DIC->ctrl();
44  $lng = $DIC->language();
45  $ilAccess = $DIC->access();
46  $lng = $DIC->language();
47  $rbacsystem = $DIC->rbac();
48  $lng->loadLanguageModule("scormtrac");
49 
50  $this->obj_id = $a_obj_id;
51  $this->report = $a_report;
52  $this->scosSelected = $a_scosSelected;
53  $this->userSelected = $a_userSelected;
54  if ($a_parent_cmd === "showTrackingItemsBySco") {
55  $this->bySCO = true;
56  }
57  if ($a_parent_obj !== null) {
58  $this->lmTitle = $a_parent_obj->getObject()->getTitle();
59  }
60 
61  $this->setId('AICC' . $this->report);
62  parent::__construct($a_parent_obj, $a_parent_cmd);
63  $privacy = ilPrivacySettings::getInstance();
64  $this->allowExportPrivacy = $privacy->enabledExportSCORM();
65 
66 
67  // if($a_print_view)
68  // {
69  // $this->setPrintMode(true);
70  // }
71 
72 
73  foreach ($this->getSelectedColumns() as $c) {
74  $l = $c;
75  if (in_array($l, array("status", "time", "score"))) {
76  $l = "cont_" . $l;
77  // } else {
78  // $l =
79  }
80  $s = $this->lng->txt($l);
81  if (substr($l, 0, 14) === "interaction_id") {
82  $s = $this->lng->txt(substr($l, 0, 14)) . ' ' . substr($l, 14);
83  }
84  if (substr($l, 0, 17) === "interaction_value") {
85  $s = sprintf($this->lng->txt(substr($l, 0, 17)), substr($l, 17, (strpos($l, ' ') - 17))) . substr($l, strpos($l, ' '));
86  }
87  if (substr($l, 0, 23) === "interaction_description") {
88  $s = $this->lng->txt(substr($l, 0, 23)) . ' ' . substr($l, 23);
89  }
90  $this->addColumn($s, $c);
91  }
92 
93  $this->setRowTemplate('tpl.scorm_tracking_items.html', 'components/ILIAS/ScormAicc');
94  $this->setFormAction($ilCtrl->getFormAction($this->getParentObject()));
95 
96  $this->setExternalSorting(true);
97  // $this->setExternalSegmentation(true);
98  $this->setEnableHeader(true);
99  $this->setEnableTitle(true);
100  // $this->setDefaultOrderField("cp_node_id, user_id");
101  $this->setDefaultOrderField("");
102  $this->setDefaultOrderDirection("asc");
103 
104  $this->setExportFormats(array(self::EXPORT_CSV, self::EXPORT_EXCEL));
105  // $this->initFilter();
106  $this->getItems();
107  }
108 
112  public function getSelectableColumns(): array
113  {
114  // default fields
115  $cols = array();
116 
117  switch ($this->report) {
118  case "exportSelectedCore":
119  $cols = ilSCORMTrackingItems::exportSelectedCoreColumns($this->bySCO, $this->allowExportPrivacy);
120  break;
121  case "exportSelectedRaw":
123  break;
124  case "exportSelectedInteractions":
126  break;
127  case "exportSelectedObjectives":
129  break;
130  // case "tracInteractionItem":
131  // $cols = ilSCORMTrackingItems::tracInteractionItemColumns($this->bySCO, $this->allowExportPrivacy);
132  // break;
133  // case "tracInteractionUser":
134  // $cols = ilSCORMTrackingItems::tracInteractionUserColumns($this->bySCO, $this->allowExportPrivacy);
135  // break;
136  // case "tracInteractionUserAnswers":
137  // $cols = ilSCORMTrackingItems::tracInteractionUserAnswersColumns($this->userSelected, $this->scosSelected, $this->bySCO, $this->allowExportPrivacy);
138  // break;
139  case "exportSelectedSuccess":
141  break;
142  }
143 
144  return $cols;
145  }
146 
147  public function getObjId(): int
148  {
149  return $this->obj_id;
150  }
151 
152  public function getItems(): void
153  {
154  global $DIC;
155  $lng = $DIC->language();
156 
157  $this->determineOffsetAndOrder(true);
158  $this->determineLimit();
159 
160  $ilSCORMTrackingItems = new ilSCORMTrackingItems();
161  switch ($this->report) {
162  case "exportSelectedCore":
163  $tr_data = $ilSCORMTrackingItems->exportSelectedCore($this->userSelected, $this->scosSelected, $this->bySCO, $this->allowExportPrivacy, $this->getObjId(), $this->lmTitle);
164  break;
165  case "exportSelectedRaw":
166  $tr_data = $ilSCORMTrackingItems->exportSelectedRaw($this->userSelected, $this->scosSelected, $this->bySCO, $this->allowExportPrivacy, $this->getObjId(), $this->lmTitle);
167  break;
168  case "exportSelectedInteractions":
169  $tr_data = $ilSCORMTrackingItems->exportSelectedInteractions($this->userSelected, $this->scosSelected, $this->bySCO, $this->allowExportPrivacy, $this->getObjId(), $this->lmTitle);
170  break;
171  case "exportSelectedObjectives":
172  $tr_data = $ilSCORMTrackingItems->exportSelectedObjectives($this->userSelected, $this->scosSelected, $this->bySCO, $this->allowExportPrivacy, $this->getObjId(), $this->lmTitle);
173  break;
174  case "tracInteractionItem":
175  $tr_data = $ilSCORMTrackingItems->tracInteractionItem($this->userSelected, $this->scosSelected, $this->bySCO, $this->allowExportPrivacy, $this->getObjId(), $this->lmTitle);
176  break;
177  case "tracInteractionUser":
178  $tr_data = $ilSCORMTrackingItems->tracInteractionUser($this->userSelected, $this->scosSelected, $this->bySCO, $this->allowExportPrivacy, $this->getObjId(), $this->lmTitle);
179  break;
180  case "tracInteractionUserAnswers":
181  $tr_data = $ilSCORMTrackingItems->tracInteractionUserAnswers($this->userSelected, $this->scosSelected, $this->bySCO, $this->allowExportPrivacy, $this->getObjId(), $this->lmTitle);
182  break;
183  case "exportSelectedSuccess":
184  $tr_data = $ilSCORMTrackingItems->exportSelectedSuccess($this->userSelected, $this->allowExportPrivacy, $this->getObjId(), $this->lmTitle);
185  break;
186  }
187  // $this->setMaxCount($tr_data["cnt"]);
188  if (ilUtil::stripSlashes($this->getOrderField()) != "") {
189  $tr_data = ilArrayUtil::stableSortArray(
190  $tr_data,
193  );
194  }
195 
196  $this->setData($tr_data);
197  }
198 
199  protected function parseValue(string $id, string|float|int|null $value, string $type): string|float|int|null
200  {
201  global $DIC;
202  $lng = $DIC->language();
203  $lng->loadLanguageModule("trac");
204  if ($id === "status") {
206  $path = $icons->getImagePathForStatus((int) $value);
207  $text = ilLearningProgressBaseGUI::_getStatusText((int) $value);
208  $value = ilUtil::img($path, $text);
209  }
210  //BLUM round
211  if ($id === "launch_data" || $id === "suspend_data") {
212  return $value;
213  }
214  if (is_numeric($value)) {
215  return round((float)$value, 2);
216  }
217  return $value;
218  }
219 
224  protected function fillRow(array $a_set): void
225  {
226  global $DIC;
227  $ilCtrl = $DIC->ctrl();
228  $lng = $DIC->language();
229  foreach ($this->getSelectedColumns() as $c) {
230  $this->tpl->setCurrentBlock("user_field");
231  $val = $this->parseValue($c, $a_set[$c], "scormtrac");
232  $this->tpl->setVariable("VAL_UF", $val);
233  $this->tpl->parseCurrentBlock();
234  }
235  }
236 
237  protected function fillHeaderExcel(ilExcel $a_excel, int &$a_row): void
238  {
239  $labels = $this->getSelectableColumns();
240  $cnt = 0;
241  foreach ($this->getSelectedColumns() as $c) {
242  $a_excel->setCell($a_row, $cnt, $labels[$c]["txt"]);
243  $cnt++;
244  }
245  }
246 
247  protected function fillRowExcel(ilExcel $a_excel, int &$a_row, array $a_set): void
248  {
249  global $DIC;
250  $lng = $DIC->language();
251  $lng->loadLanguageModule("trac");
252  $cnt = 0;
253  foreach ($this->getSelectedColumns() as $c) {
254  if ($c !== 'status') {
255  $val = $this->parseValue($c, $a_set[$c], "user");
256  } else {
257  $val = ilLearningProgressBaseGUI::_getStatusText((int) $a_set[$c]);
258  }
259  $a_excel->setCell($a_row, $cnt, $val);
260  $cnt++;
261  }
262  }
263 
264  protected function fillHeaderCSV(ilCSVWriter $a_csv): void
265  {
266  $labels = $this->getSelectableColumns();
267  foreach ($this->getSelectedColumns() as $c) {
268  $a_csv->addColumn($labels[$c]["txt"]);
269  }
270 
271  $a_csv->addRow();
272  }
273 
274  protected function fillRowCSV(ilCSVWriter $a_csv, array $a_set): void
275  {
276  global $DIC;
277  $lng = $DIC->language();
278  $lng->loadLanguageModule("trac");
279  foreach ($this->getSelectedColumns() as $c) {
280  if ($c !== 'status') {
281  $val = $this->parseValue($c, $a_set[$c], "user");
282  } else {
283  $val = ilLearningProgressBaseGUI::_getStatusText((int) $a_set[$c]);
284  }
285  $a_csv->addColumn($val);
286  }
287 
288  $a_csv->addRow();
289  }
290 }
setData(array $a_data)
Class ilSCORMTrackingItemsTableGUI.
fillHeaderExcel(ilExcel $a_excel, int &$a_row)
addColumn(string $a_col)
setExportFormats(array $formats)
Set available export formats.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
setFormAction(string $a_form_action, bool $a_multipart=false)
setEnableTitle(bool $a_enabletitle)
fillRowCSV(ilCSVWriter $a_csv, array $a_set)
static stripSlashes(string $a_str, bool $a_strip_html=true, string $a_allow="")
static getInstance(int $variant=ilLPStatusIcons::ICON_VARIANT_DEFAULT, ?\ILIAS\UI\Renderer $renderer=null, ?\ILIAS\UI\Factory $factory=null)
static exportSelectedCoreColumns(bool $b_orderBySCO, bool $b_allowExportPrivacy)
loadLanguageModule(string $a_module)
Load language module.
$c
Definition: deliver.php:25
static img(string $a_src, ?string $a_alt=null, $a_width="", $a_height="", $a_border=0, $a_id="", $a_class="")
Build img tag.
ilLanguage $lng
setId(string $a_val)
$path
Definition: ltiservices.php:29
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
setExternalSorting(bool $a_val)
setCell(int $a_row, int $col, $value, ?string $datatype=null, bool $disable_strip_tags_for_strings=false)
Set cell value.
setDefaultOrderField(string $a_defaultorderfield)
__construct(int $a_obj_id, ?object $a_parent_obj, string $a_parent_cmd, array $a_userSelected, array $a_scosSelected, string $a_report)
setRowTemplate(string $a_template, string $a_template_dir="")
Set row template.
global $DIC
Definition: shib_login.php:22
setDefaultOrderDirection(string $a_defaultorderdirection)
static _getStatusText(int $a_status, ?ilLanguage $a_lng=null)
Get status alt text.
static stableSortArray(array $array, string $a_array_sortby, string $a_array_sortorder="asc", bool $a_numeric=false)
Sort an aray using a stable sort algorithm, which preveserves the sequence of array elements which ha...
fillRowExcel(ilExcel $a_excel, int &$a_row, array $a_set)
__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)
Class ilSCORMTrackingItems.
parseValue(string $id, string|float|int|null $value, string $type)
determineOffsetAndOrder(bool $a_omit_offset=false)
setEnableHeader(bool $a_enableheader)