ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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 $scoTite = "";
22 
26  public function __construct($a_obj_id, $a_parent_obj, $a_parent_cmd, $a_userSelected, $a_scosSelected, $a_report)
27  {
28  global $ilCtrl, $lng, $ilAccess, $lng, $rbacsystem;
29  $lng->loadLanguageModule("scormtrac");
30 
31  $this->obj_id = $a_obj_id;
32  $this->report = $a_report;
33  $this->scosSelected=$a_scosSelected;
34  $this->userSelected=$a_userSelected;
35  if ($a_parent_cmd == "showTrackingItemsBySco") {
36  $this->bySCO = true;
37  }
38  $this->lmTitle = $a_parent_obj->object->getTitle();
39 
40  $this->setId('AICC' . $this->report);
41  parent::__construct($a_parent_obj, $a_parent_cmd);
42  // $this->setLimit(9999); //#23582
43 
44  include_once('./Services/PrivacySecurity/classes/class.ilPrivacySettings.php');
46  $this->allowExportPrivacy = $privacy->enabledExportSCORM();
47 
48 
49  // if($a_print_view)
50  // {
51  // $this->setPrintMode(true);
52  // }
53 
54 
55  foreach ($this->getSelectedColumns() as $c) {
56  $l = $c;
57  if (in_array($l, array("status", "time", "score"))) {
58  $l = "cont_" . $l;
59  // } else {
60  // $l =
61  }
62  $s = $this->lng->txt($l);
63  if (substr($l, 0, 14) == "interaction_id") {
64  $s = $this->lng->txt(substr($l, 0, 14)) . ' ' . substr($l, 14);
65  }
66  if (substr($l, 0, 17) == "interaction_value") {
67  $s = sprintf($this->lng->txt(substr($l, 0, 17)), substr($l, 17, (strpos($l, ' ')-17))) . substr($l, strpos($l, ' '));
68  }
69  if (substr($l, 0, 23) == "interaction_description") {
70  $s = $this->lng->txt(substr($l, 0, 23)) . ' ' . substr($l, 23);
71  }
72  $this->addColumn($s, $c);
73  }
74 
75  $this->setRowTemplate('tpl.scorm_tracking_items.html', 'Modules/ScormAicc');
76  $this->setFormAction($ilCtrl->getFormAction($this->getParentObject()));
77 
78  $this->setExternalSorting(true);
79  // $this->setExternalSegmentation(true);
80  $this->setEnableHeader(true);
81  $this->setEnableTitle(true);
82  // $this->setDefaultOrderField("cp_node_id, user_id");
83  $this->setDefaultOrderField("");
84  $this->setDefaultOrderDirection("asc");
85  $this->setShowTemplates(true);
86 
87  $this->setExportFormats(array(self::EXPORT_CSV, self::EXPORT_EXCEL));
88  // $this->initFilter();
89  $this->getItems();
90  }
97  public function getSelectableColumns()
98  {
99  // default fields
100  $cols = array();
101 
102  switch ($this->report) {
103  case "exportSelectedCore":
104  $cols=ilSCORMTrackingItems::exportSelectedCoreColumns($this->bySCO, $this->allowExportPrivacy);
105  break;
106  case "exportSelectedRaw":
108  break;
109  case "exportSelectedInteractions":
111  break;
112  case "exportSelectedObjectives":
114  break;
115  case "tracInteractionItem":
116  $cols=ilSCORMTrackingItems::tracInteractionItemColumns($this->bySCO, $this->allowExportPrivacy);
117  break;
118  case "tracInteractionUser":
119  $cols=ilSCORMTrackingItems::tracInteractionUserColumns($this->bySCO, $this->allowExportPrivacy);
120  break;
121  case "tracInteractionUserAnswers":
122  $cols=ilSCORMTrackingItems::tracInteractionUserAnswersColumns($this->userSelected, $this->scosSelected, $this->bySCO, $this->allowExportPrivacy);
123  break;
124  case "exportSelectedSuccess":
126  break;
127  }
128 
129  return $cols;
130  }
131 
136  public function getObjId()
137  {
138  return $this->obj_id;
139  }
140 
141 
142  public function getItems()
143  {
144  global $lng;
145 
146  $this->determineOffsetAndOrder();
147  $ilSCORMTrackingItems = new ilSCORMTrackingItems();
148  switch ($this->report) {
149  case "exportSelectedCore":
150  $tr_data = $ilSCORMTrackingItems->exportSelectedCore($this->userSelected, $this->scosSelected, $this->bySCO, $this->allowExportPrivacy, $this->getObjId());
151  break;
152  case "exportSelectedRaw":
153  $tr_data = $ilSCORMTrackingItems->exportSelectedRaw($this->userSelected, $this->scosSelected, $this->bySCO, $this->allowExportPrivacy, $this->getObjId());
154  break;
155  case "exportSelectedInteractions":
156  $tr_data = $ilSCORMTrackingItems->exportSelectedInteractions($this->userSelected, $this->scosSelected, $this->bySCO, $this->allowExportPrivacy, $this->getObjId());
157  break;
158  case "exportSelectedObjectives":
159  $tr_data = $ilSCORMTrackingItems->exportSelectedObjectives($this->userSelected, $this->scosSelected, $this->bySCO, $this->allowExportPrivacy, $this->getObjId());
160  break;
161  case "tracInteractionItem":
162  $tr_data = $ilSCORMTrackingItems->tracInteractionItem($this->userSelected, $this->scosSelected, $this->bySCO, $this->allowExportPrivacy, $this->getObjId());
163  break;
164  case "tracInteractionUser":
165  $tr_data = $ilSCORMTrackingItems->tracInteractionUser($this->userSelected, $this->scosSelected, $this->bySCO, $this->allowExportPrivacy, $this->getObjId());
166  break;
167  case "tracInteractionUserAnswers":
168  $tr_data = $ilSCORMTrackingItems->tracInteractionUserAnswers($this->userSelected, $this->scosSelected, $this->bySCO, $this->allowExportPrivacy, $this->getObjId());
169  break;
170  case "exportSelectedSuccess":
171  $tr_data = $ilSCORMTrackingItems->exportSelectedSuccess($this->userSelected, $this->allowExportPrivacy, $this->getObjId());
172  break;
173  }
174  $this->setMaxCount($tr_data["cnt"]);
175  if (ilUtil::stripSlashes($this->getOrderField()) !="") {
176  include_once "Services/Utilities/classes/class.ilStr.php";
178  }
179 
180  $this->setData($tr_data);
181  }
182  protected function parseValue($id, $value, $type)
183  {
184  global $lng;
185  $lng->loadLanguageModule("trac");
186  switch ($id) {
187  case "status":
188  include_once("./Services/Tracking/classes/class.ilLearningProgressBaseGUI.php");
191  $value = ilUtil::img($path, $text);
192  break;
193  }
194  //BLUM round
195  if ($id=="launch_data" || $id=="suspend_data") {
196  return $value;
197  }
198  if (is_numeric($value)) {
199  return round($value, 2);
200  }
201  return $value;
202  }
206  protected function fillRow($data)
207  {
208  global $ilCtrl, $lng;
209  foreach ($this->getSelectedColumns() as $c) {
210  $this->tpl->setCurrentBlock("user_field");
211  $val = $this->parseValue($c, $data[$c], "scormtrac");
212  $this->tpl->setVariable("VAL_UF", $val);
213  $this->tpl->parseCurrentBlock();
214  }
215  }
216 
217  protected function fillHeaderExcel(ilExcel $worksheet, &$a_row)
218  {
219  $labels = $this->getSelectableColumns();
220  $cnt = 0;
221  foreach ($this->getSelectedColumns() as $c) {
222  $worksheet->setCell($a_row, $cnt, $labels[$c]["txt"]);
223  $cnt++;
224  }
225  }
226 
227  protected function fillRowExcel(ilExcel $worksheet, &$a_row, $a_set)
228  {
229  global $lng;
230  $lng->loadLanguageModule("trac");
231  include_once("./Services/Tracking/classes/class.ilLearningProgressBaseGUI.php");
232  $cnt = 0;
233  foreach ($this->getSelectedColumns() as $c) {
234  if ($c != 'status') {
235  $val = $this->parseValue($c, $a_set[$c], "user");
236  } else {
237  $val = ilLearningProgressBaseGUI::_getStatusText((int) $a_set[$c]);
238  }
239  $worksheet->setCell($a_row, $cnt, $val);
240  $cnt++;
241  }
242  }
243 
244  protected function fillHeaderCSV($a_csv)
245  {
246  $labels = $this->getSelectableColumns();
247  foreach ($this->getSelectedColumns() as $c) {
248  $a_csv->addColumn($labels[$c]["txt"]);
249  }
250 
251  $a_csv->addRow();
252  }
253 
254  protected function fillRowCSV($a_csv, $a_set)
255  {
256  global $lng;
257  $lng->loadLanguageModule("trac");
258  include_once("./Services/Tracking/classes/class.ilLearningProgressBaseGUI.php");
259  foreach ($this->getSelectedColumns() as $c) {
260  if ($c != 'status') {
261  $val = $this->parseValue($c, $a_set[$c], "user");
262  } else {
263  $val = ilLearningProgressBaseGUI::_getStatusText((int) $a_set[$c]);
264  }
265  $a_csv->addColumn($val);
266  }
267 
268  $a_csv->addRow();
269  }
270 }
Class ilSCORMTrackingItemsTableGUI.
setExternalSorting($a_val)
Set external sorting.
$worksheet
setDefaultOrderField($a_defaultorderfield)
Set Default order field.
setExportFormats(array $formats)
Set available export formats.
static _getImagePathForStatus($a_status)
Get image path for status.
$type
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
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
setRowTemplate($a_template, $a_template_dir="")
Set row template.
Create styles array
The data for the language used.
determineOffsetAndOrder($a_omit_offset=false)
Determine offset and order.
setFormAction($a_form_action, $a_multipart=false)
Set Form action parameter.
static img($a_src, $a_alt="", $a_width="", $a_height="", $a_border=0, $a_id="", $a_class="")
Build img tag.
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.
setMaxCount($a_max_count)
set max.
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.