ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
class.ilSCORMTrackingItemsTableGUI.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 1998-2013 ILIAS open source, Extended GPL, see docs/LICENSE */
3 
4 include_once './Services/Table/classes/class.ilTable2GUI.php';
5 include_once './Modules/ScormAicc/classes/class.ilSCORMTrackingItems.php';
6 
14 {
15  private $obj_id = 0;
16  private $user_id = 0;
17  private $bySCO = false;
18  private $scosSelected = array();
19  private $userSelected = array();
20  private $allowExportPrivacy = false;
21  private $lmTitle = "";
22 
26  public function __construct($a_obj_id, $a_parent_obj, $a_parent_cmd, $a_userSelected, $a_scosSelected, $a_report)
27  {
28  global $DIC;
29  $ilCtrl = $DIC['ilCtrl'];
30  $lng = $DIC['lng'];
31  $ilAccess = $DIC['ilAccess'];
32  $lng = $DIC['lng'];
33  $rbacsystem = $DIC['rbacsystem'];
34  $lng->loadLanguageModule("scormtrac");
35 
36  $this->obj_id = $a_obj_id;
37  $this->report = $a_report;
38  $this->scosSelected = $a_scosSelected;
39  $this->userSelected = $a_userSelected;
40  if ($a_parent_cmd == "showTrackingItemsBySco") {
41  $this->bySCO = true;
42  }
43  $this->lmTitle = $a_parent_obj->object->getTitle();
44 
45  $this->setId('AICC' . $this->report);
46  parent::__construct($a_parent_obj, $a_parent_cmd);
47  // $this->setLimit(9999); //#23582
48 
49  include_once('./Services/PrivacySecurity/classes/class.ilPrivacySettings.php');
51  $this->allowExportPrivacy = $privacy->enabledExportSCORM();
52 
53 
54  // if($a_print_view)
55  // {
56  // $this->setPrintMode(true);
57  // }
58 
59 
60  foreach ($this->getSelectedColumns() as $c) {
61  $l = $c;
62  if (in_array($l, array("status", "time", "score"))) {
63  $l = "cont_" . $l;
64  // } else {
65  // $l =
66  }
67  $s = $this->lng->txt($l);
68  if (substr($l, 0, 14) == "interaction_id") {
69  $s = $this->lng->txt(substr($l, 0, 14)) . ' ' . substr($l, 14);
70  }
71  if (substr($l, 0, 17) == "interaction_value") {
72  $s = sprintf($this->lng->txt(substr($l, 0, 17)), substr($l, 17, (strpos($l, ' ') - 17))) . substr($l, strpos($l, ' '));
73  }
74  if (substr($l, 0, 23) == "interaction_description") {
75  $s = $this->lng->txt(substr($l, 0, 23)) . ' ' . substr($l, 23);
76  }
77  $this->addColumn($s, $c);
78  }
79 
80  $this->setRowTemplate('tpl.scorm_tracking_items.html', 'Modules/ScormAicc');
81  $this->setFormAction($ilCtrl->getFormAction($this->getParentObject()));
82 
83  $this->setExternalSorting(true);
84  // $this->setExternalSegmentation(true);
85  $this->setEnableHeader(true);
86  $this->setEnableTitle(true);
87  // $this->setDefaultOrderField("cp_node_id, user_id");
88  $this->setDefaultOrderField("");
89  $this->setDefaultOrderDirection("asc");
90  $this->setShowTemplates(true);
91 
92  $this->setExportFormats(array(self::EXPORT_CSV, self::EXPORT_EXCEL));
93  // $this->initFilter();
94  $this->getItems();
95  }
102  public function getSelectableColumns()
103  {
104  // default fields
105  $cols = array();
106 
107  switch ($this->report) {
108  case "exportSelectedCore":
109  $cols = ilSCORMTrackingItems::exportSelectedCoreColumns($this->bySCO, $this->allowExportPrivacy);
110  break;
111  case "exportSelectedRaw":
113  break;
114  case "exportSelectedInteractions":
116  break;
117  case "exportSelectedObjectives":
119  break;
120  case "tracInteractionItem":
121  $cols = ilSCORMTrackingItems::tracInteractionItemColumns($this->bySCO, $this->allowExportPrivacy);
122  break;
123  case "tracInteractionUser":
124  $cols = ilSCORMTrackingItems::tracInteractionUserColumns($this->bySCO, $this->allowExportPrivacy);
125  break;
126  case "tracInteractionUserAnswers":
127  $cols = ilSCORMTrackingItems::tracInteractionUserAnswersColumns($this->userSelected, $this->scosSelected, $this->bySCO, $this->allowExportPrivacy);
128  break;
129  case "exportSelectedSuccess":
131  break;
132  }
133 
134  return $cols;
135  }
136 
141  public function getObjId()
142  {
143  return $this->obj_id;
144  }
145 
146 
147  public function getItems()
148  {
149  global $DIC;
150  $lng = $DIC['lng'];
151 
152  $this->determineOffsetAndOrder(true);
153  $this->determineLimit();
154 
155  $ilSCORMTrackingItems = new ilSCORMTrackingItems();
156  switch ($this->report) {
157  case "exportSelectedCore":
158  $tr_data = $ilSCORMTrackingItems->exportSelectedCore($this->userSelected, $this->scosSelected, $this->bySCO, $this->allowExportPrivacy, $this->getObjId(), $this->lmTitle);
159  break;
160  case "exportSelectedRaw":
161  $tr_data = $ilSCORMTrackingItems->exportSelectedRaw($this->userSelected, $this->scosSelected, $this->bySCO, $this->allowExportPrivacy, $this->getObjId(), $this->lmTitle);
162  break;
163  case "exportSelectedInteractions":
164  $tr_data = $ilSCORMTrackingItems->exportSelectedInteractions($this->userSelected, $this->scosSelected, $this->bySCO, $this->allowExportPrivacy, $this->getObjId(), $this->lmTitle);
165  break;
166  case "exportSelectedObjectives":
167  $tr_data = $ilSCORMTrackingItems->exportSelectedObjectives($this->userSelected, $this->scosSelected, $this->bySCO, $this->allowExportPrivacy, $this->getObjId(), $this->lmTitle);
168  break;
169  case "tracInteractionItem":
170  $tr_data = $ilSCORMTrackingItems->tracInteractionItem($this->userSelected, $this->scosSelected, $this->bySCO, $this->allowExportPrivacy, $this->getObjId(), $this->lmTitle);
171  break;
172  case "tracInteractionUser":
173  $tr_data = $ilSCORMTrackingItems->tracInteractionUser($this->userSelected, $this->scosSelected, $this->bySCO, $this->allowExportPrivacy, $this->getObjId(), $this->lmTitle);
174  break;
175  case "tracInteractionUserAnswers":
176  $tr_data = $ilSCORMTrackingItems->tracInteractionUserAnswers($this->userSelected, $this->scosSelected, $this->bySCO, $this->allowExportPrivacy, $this->getObjId(), $this->lmTitle);
177  break;
178  case "exportSelectedSuccess":
179  $tr_data = $ilSCORMTrackingItems->exportSelectedSuccess($this->userSelected, $this->allowExportPrivacy, $this->getObjId(), $this->lmTitle);
180  break;
181  }
182 // $this->setMaxCount($tr_data["cnt"]);
183  if (ilUtil::stripSlashes($this->getOrderField()) != "") {
184  include_once "Services/Utilities/classes/class.ilStr.php";
186  }
187 
188  $this->setData($tr_data);
189  }
190  protected function parseValue($id, $value, $type)
191  {
192  global $DIC;
193  $lng = $DIC['lng'];
194  $lng->loadLanguageModule("trac");
195  switch ($id) {
196  case "status":
197  include_once("./Services/Tracking/classes/class.ilLearningProgressBaseGUI.php");
200  $value = ilUtil::img($path, $text);
201  break;
202  }
203  //BLUM round
204  if ($id == "launch_data" || $id == "suspend_data") {
205  return $value;
206  }
207  if (is_numeric($value)) {
208  return round($value, 2);
209  }
210  return $value;
211  }
215  protected function fillRow($data)
216  {
217  global $DIC;
218  $ilCtrl = $DIC['ilCtrl'];
219  $lng = $DIC['lng'];
220  foreach ($this->getSelectedColumns() as $c) {
221  $this->tpl->setCurrentBlock("user_field");
222  $val = $this->parseValue($c, $data[$c], "scormtrac");
223  $this->tpl->setVariable("VAL_UF", $val);
224  $this->tpl->parseCurrentBlock();
225  }
226  }
227 
228  protected function fillHeaderExcel(ilExcel $worksheet, &$a_row)
229  {
230  $labels = $this->getSelectableColumns();
231  $cnt = 0;
232  foreach ($this->getSelectedColumns() as $c) {
233  $worksheet->setCell($a_row, $cnt, $labels[$c]["txt"]);
234  $cnt++;
235  }
236  }
237 
238  protected function fillRowExcel(ilExcel $worksheet, &$a_row, $a_set)
239  {
240  global $DIC;
241  $lng = $DIC['lng'];
242  $lng->loadLanguageModule("trac");
243  include_once("./Services/Tracking/classes/class.ilLearningProgressBaseGUI.php");
244  $cnt = 0;
245  foreach ($this->getSelectedColumns() as $c) {
246  if ($c != 'status') {
247  $val = $this->parseValue($c, $a_set[$c], "user");
248  } else {
249  $val = ilLearningProgressBaseGUI::_getStatusText((int) $a_set[$c]);
250  }
251  $worksheet->setCell($a_row, $cnt, $val);
252  $cnt++;
253  }
254  }
255 
256  protected function fillHeaderCSV($a_csv)
257  {
258  $labels = $this->getSelectableColumns();
259  foreach ($this->getSelectedColumns() as $c) {
260  $a_csv->addColumn($labels[$c]["txt"]);
261  }
262 
263  $a_csv->addRow();
264  }
265 
266  protected function fillRowCSV($a_csv, $a_set)
267  {
268  global $DIC;
269  $lng = $DIC['lng'];
270  $lng->loadLanguageModule("trac");
271  include_once("./Services/Tracking/classes/class.ilLearningProgressBaseGUI.php");
272  foreach ($this->getSelectedColumns() as $c) {
273  if ($c != 'status') {
274  $val = $this->parseValue($c, $a_set[$c], "user");
275  } else {
276  $val = ilLearningProgressBaseGUI::_getStatusText((int) $a_set[$c]);
277  }
278  $a_csv->addColumn($val);
279  }
280 
281  $a_csv->addRow();
282  }
283 }
Class ilSCORMTrackingItemsTableGUI.
$path
Definition: aliased.php:25
setExternalSorting($a_val)
Set external sorting.
setDefaultOrderField($a_defaultorderfield)
Set Default order field.
setExportFormats(array $formats)
Set available export formats.
static _getImagePathForStatus($a_status)
Get image path for status.
$type
global $DIC
Definition: saml.php:7
setShowTemplates($a_value)
Toggle templates.
static _getStatusText($a_status, $a_lng=null)
Get status alt text.
if(!array_key_exists('StateId', $_REQUEST)) $id
$s
Definition: pwgen.php:45
determineLimit()
Determine the limit.
getOrderDirection()
Get order direction.
setId($a_val)
Set id.
static exportSelectedCoreColumns($b_orderBySCO, $b_allowExportPrivacy)
global $ilCtrl
Definition: ilias.php:18
setDefaultOrderDirection($a_defaultorderdirection)
Set Default order direction.
Class ilTable2GUI.
static stableSortArray($array, $a_array_sortby, $a_array_sortorder=0, $a_numeric=false)
Sort an aray using a stable sort algorithm, which preveserves the sequence of array elements which ha...
fillRowExcel(ilExcel $worksheet, &$a_row, $a_set)
$text
Definition: errorreport.php:18
getSelectedColumns()
Get selected columns.
setCell($a_row, $a_col, $a_value, $a_datatype=null)
Set cell value.
static stripSlashes($a_str, $a_strip_html=true, $a_allow="")
strip slashes if magic qoutes is enabled
static img($a_src, $a_alt=null, $a_width="", $a_height="", $a_border=0, $a_id="", $a_class="")
Build img tag.
setRowTemplate($a_template, $a_template_dir="")
Set row template.
determineOffsetAndOrder($a_omit_offset=false)
Determine offset and order.
setFormAction($a_form_action, $a_multipart=false)
Set Form action parameter.
global $l
Definition: afr.php:30
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.
setEnableHeader($a_enableheader)
Set Enable Header.
static _getInstance()
Get instance of ilPrivacySettings.
setEnableTitle($a_enabletitle)
Set Enable Title.
Class ilSCORMTrackingItems.
$cols
Definition: xhr_table.php:11
__construct($a_obj_id, $a_parent_obj, $a_parent_cmd, $a_userSelected, $a_scosSelected, $a_report)
Constructor.