ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
class.ilSCORMTrackingItemsTableGUI.php
Go to the documentation of this file.
1 <?php
2 
3 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 
42  public function __construct(int $a_obj_id, ?object $a_parent_obj, string $a_parent_cmd, array $a_userSelected, array $a_scosSelected, string $a_report)
43  {
44  global $DIC;
45  $ilCtrl = $DIC->ctrl();
46  $lng = $DIC->language();
47  $ilAccess = $DIC->access();
48  $lng = $DIC->language();
49  $rbacsystem = $DIC->rbac();
50  $lng->loadLanguageModule("scormtrac");
51 
52  $this->obj_id = $a_obj_id;
53  $this->report = $a_report;
54  $this->scosSelected = $a_scosSelected;
55  $this->userSelected = $a_userSelected;
56  if ($a_parent_cmd === "showTrackingItemsBySco") {
57  $this->bySCO = true;
58  }
59  if ($a_parent_obj !== null) {
60  $this->lmTitle = $a_parent_obj->getObject()->getTitle();
61  }
62 
63  $this->setId('AICC' . $this->report);
64  parent::__construct($a_parent_obj, $a_parent_cmd);
65  $privacy = ilPrivacySettings::getInstance();
66  $this->allowExportPrivacy = $privacy->enabledExportSCORM();
67 
68 
69  // if($a_print_view)
70  // {
71  // $this->setPrintMode(true);
72  // }
73 
74 
75  foreach ($this->getSelectedColumns() as $c) {
76  $l = $c;
77  if (in_array($l, array("status", "time", "score"))) {
78  $l = "cont_" . $l;
79  // } else {
80  // $l =
81  }
82  $s = $this->lng->txt($l);
83  if (substr($l, 0, 14) === "interaction_id") {
84  $s = $this->lng->txt(substr($l, 0, 14)) . ' ' . substr($l, 14);
85  }
86  if (substr($l, 0, 17) === "interaction_value") {
87  $s = sprintf($this->lng->txt(substr($l, 0, 17)), substr($l, 17, (strpos($l, ' ') - 17))) . substr($l, strpos($l, ' '));
88  }
89  if (substr($l, 0, 23) === "interaction_description") {
90  $s = $this->lng->txt(substr($l, 0, 23)) . ' ' . substr($l, 23);
91  }
92  $this->addColumn($s, $c);
93  }
94 
95  $this->setRowTemplate('tpl.scorm_tracking_items.html', 'Modules/ScormAicc');
96  $this->setFormAction($ilCtrl->getFormAction($this->getParentObject()));
97 
98  $this->setExternalSorting(true);
99  // $this->setExternalSegmentation(true);
100  $this->setEnableHeader(true);
101  $this->setEnableTitle(true);
102  // $this->setDefaultOrderField("cp_node_id, user_id");
103  $this->setDefaultOrderField("");
104  $this->setDefaultOrderDirection("asc");
105  $this->setShowTemplates(true);
106 
107  $this->setExportFormats(array(self::EXPORT_CSV, self::EXPORT_EXCEL));
108  // $this->initFilter();
109  $this->getItems();
110  }
111 
115  public function getSelectableColumns(): array
116  {
117  // default fields
118  $cols = array();
119 
120  switch ($this->report) {
121  case "exportSelectedCore":
122  $cols = ilSCORMTrackingItems::exportSelectedCoreColumns($this->bySCO, $this->allowExportPrivacy);
123  break;
124  case "exportSelectedRaw":
126  break;
127  case "exportSelectedInteractions":
129  break;
130  case "exportSelectedObjectives":
132  break;
133  // case "tracInteractionItem":
134  // $cols = ilSCORMTrackingItems::tracInteractionItemColumns($this->bySCO, $this->allowExportPrivacy);
135  // break;
136  // case "tracInteractionUser":
137  // $cols = ilSCORMTrackingItems::tracInteractionUserColumns($this->bySCO, $this->allowExportPrivacy);
138  // break;
139  // case "tracInteractionUserAnswers":
140  // $cols = ilSCORMTrackingItems::tracInteractionUserAnswersColumns($this->userSelected, $this->scosSelected, $this->bySCO, $this->allowExportPrivacy);
141  // break;
142  case "exportSelectedSuccess":
144  break;
145  }
146 
147  return $cols;
148  }
149 
150  public function getObjId(): int
151  {
152  return $this->obj_id;
153  }
154 
155  public function getItems(): void
156  {
157  global $DIC;
158  $lng = $DIC->language();
159 
160  $this->determineOffsetAndOrder(true);
161  $this->determineLimit();
162 
163  $ilSCORMTrackingItems = new ilSCORMTrackingItems();
164  switch ($this->report) {
165  case "exportSelectedCore":
166  $tr_data = $ilSCORMTrackingItems->exportSelectedCore($this->userSelected, $this->scosSelected, $this->bySCO, $this->allowExportPrivacy, $this->getObjId(), $this->lmTitle);
167  break;
168  case "exportSelectedRaw":
169  $tr_data = $ilSCORMTrackingItems->exportSelectedRaw($this->userSelected, $this->scosSelected, $this->bySCO, $this->allowExportPrivacy, $this->getObjId(), $this->lmTitle);
170  break;
171  case "exportSelectedInteractions":
172  $tr_data = $ilSCORMTrackingItems->exportSelectedInteractions($this->userSelected, $this->scosSelected, $this->bySCO, $this->allowExportPrivacy, $this->getObjId(), $this->lmTitle);
173  break;
174  case "exportSelectedObjectives":
175  $tr_data = $ilSCORMTrackingItems->exportSelectedObjectives($this->userSelected, $this->scosSelected, $this->bySCO, $this->allowExportPrivacy, $this->getObjId(), $this->lmTitle);
176  break;
177  case "tracInteractionItem":
178  $tr_data = $ilSCORMTrackingItems->tracInteractionItem($this->userSelected, $this->scosSelected, $this->bySCO, $this->allowExportPrivacy, $this->getObjId(), $this->lmTitle);
179  break;
180  case "tracInteractionUser":
181  $tr_data = $ilSCORMTrackingItems->tracInteractionUser($this->userSelected, $this->scosSelected, $this->bySCO, $this->allowExportPrivacy, $this->getObjId(), $this->lmTitle);
182  break;
183  case "tracInteractionUserAnswers":
184  $tr_data = $ilSCORMTrackingItems->tracInteractionUserAnswers($this->userSelected, $this->scosSelected, $this->bySCO, $this->allowExportPrivacy, $this->getObjId(), $this->lmTitle);
185  break;
186  case "exportSelectedSuccess":
187  $tr_data = $ilSCORMTrackingItems->exportSelectedSuccess($this->userSelected, $this->allowExportPrivacy, $this->getObjId(), $this->lmTitle);
188  break;
189  }
190  // $this->setMaxCount($tr_data["cnt"]);
191  if (ilUtil::stripSlashes($this->getOrderField()) != "") {
192  $tr_data = ilArrayUtil::stableSortArray(
193  $tr_data,
196  );
197  }
198 
199  $this->setData($tr_data);
200  }
201 
206  protected function parseValue(string $id, $value, string $type)
207  {
208  global $DIC;
209  $lng = $DIC->language();
210  $lng->loadLanguageModule("trac");
211  if ($id === "status") {
213  $path = $icons->getImagePathForStatus((int) $value);
214  $text = ilLearningProgressBaseGUI::_getStatusText((int) $value);
215  $value = ilUtil::img($path, $text);
216  }
217  //BLUM round
218  if ($id === "launch_data" || $id === "suspend_data") {
219  return $value;
220  }
221  if (is_numeric($value)) {
222  return round((float)$value, 2);
223  }
224  return $value;
225  }
226 
231  protected function fillRow(array $a_set): void
232  {
233  global $DIC;
234  $ilCtrl = $DIC->ctrl();
235  $lng = $DIC->language();
236  foreach ($this->getSelectedColumns() as $c) {
237  $this->tpl->setCurrentBlock("user_field");
238  $val = $this->parseValue($c, $a_set[$c], "scormtrac");
239  $this->tpl->setVariable("VAL_UF", $val);
240  $this->tpl->parseCurrentBlock();
241  }
242  }
243 
244  protected function fillHeaderExcel(ilExcel $a_excel, int &$a_row): void
245  {
246  $labels = $this->getSelectableColumns();
247  $cnt = 0;
248  foreach ($this->getSelectedColumns() as $c) {
249  $a_excel->setCell($a_row, $cnt, $labels[$c]["txt"]);
250  $cnt++;
251  }
252  }
253 
254  protected function fillRowExcel(ilExcel $a_excel, int &$a_row, array $a_set): void
255  {
256  global $DIC;
257  $lng = $DIC->language();
258  $lng->loadLanguageModule("trac");
259  $cnt = 0;
260  foreach ($this->getSelectedColumns() as $c) {
261  if ($c !== 'status') {
262  $val = $this->parseValue($c, $a_set[$c], "user");
263  } else {
264  $val = ilLearningProgressBaseGUI::_getStatusText((int) $a_set[$c]);
265  }
266  $a_excel->setCell($a_row, $cnt, $val);
267  $cnt++;
268  }
269  }
270 
271  protected function fillHeaderCSV(ilCSVWriter $a_csv): void
272  {
273  $labels = $this->getSelectableColumns();
274  foreach ($this->getSelectedColumns() as $c) {
275  $a_csv->addColumn($labels[$c]["txt"]);
276  }
277 
278  $a_csv->addRow();
279  }
280 
281  protected function fillRowCSV(ilCSVWriter $a_csv, array $a_set): void
282  {
283  global $DIC;
284  $lng = $DIC->language();
285  $lng->loadLanguageModule("trac");
286  foreach ($this->getSelectedColumns() as $c) {
287  if ($c !== 'status') {
288  $val = $this->parseValue($c, $a_set[$c], "user");
289  } else {
290  $val = ilLearningProgressBaseGUI::_getStatusText((int) $a_set[$c]);
291  }
292  $a_csv->addColumn($val);
293  }
294 
295  $a_csv->addRow();
296  }
297 }
parseValue(string $id, $value, string $type)
setData(array $a_data)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
fillHeaderExcel(ilExcel $a_excel, int &$a_row)
addColumn(string $a_col)
setExportFormats(array $formats)
Set available export formats.
$c
Definition: cli.php:38
setFormAction(string $a_form_action, bool $a_multipart=false)
$type
setEnableTitle(bool $a_enabletitle)
fillRowCSV(ilCSVWriter $a_csv, array $a_set)
static stripSlashes(string $a_str, bool $a_strip_html=true, string $a_allow="")
setShowTemplates(bool $a_value)
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.
setCell(int $a_row, int $a_col, $a_value, ?string $a_datatype=null)
Set cell value.
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:32
global $DIC
Definition: feed.php:28
setExternalSorting(bool $a_val)
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.
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)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
$cols
Definition: xhr_table.php:11
determineOffsetAndOrder(bool $a_omit_offset=false)
setEnableHeader(bool $a_enableheader)