ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
class.ilSCORM2004TrackingItemsTableGUI.php
Go to the documentation of this file.
1<?php
2/* Copyright (c) 1998-2013 ILIAS open source, Extended GPL, see docs/LICENSE */
3
4include_once './Services/Table/classes/class.ilTable2GUI.php';
5include_once './Modules/Scorm2004/classes/class.ilSCORM2004TrackingItems.php';
6
14{
18 protected $access;
19
23 protected $rbacsystem;
24
25 private $obj_id = 0;
26 private $user_id = 0;
27 private $bySCO = false;
28 private $scosSelected = array();
29 private $userSelected = array();
30 private $allowExportPrivacy = false;
31 private $scoTite = "";
32
36 public function __construct($a_obj_id, $a_parent_obj, $a_parent_cmd, $a_userSelected, $a_scosSelected, $a_report)
37 {
38 global $DIC;
39
40 $this->ctrl = $DIC->ctrl();
41 $this->lng = $DIC->language();
42 $this->access = $DIC->access();
43 $this->rbacsystem = $DIC->rbac()->system();
44
45 $ilCtrl = $DIC->ctrl();
46 $lng = $DIC->language();
47 $ilAccess = $DIC->access();
48 $lng = $DIC->language();
49 $rbacsystem = $DIC->rbac()->system();
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 $this->lmTitle = $a_parent_obj->object->getTitle();
60
61 $this->setId('2004' . $this->report);
62 parent::__construct($a_parent_obj, $a_parent_cmd);
63 // $this->setLimit(9999); //#23582
64
65 include_once('./Services/PrivacySecurity/classes/class.ilPrivacySettings.php');
67 $this->allowExportPrivacy = $privacy->enabledExportSCORM();
68
69
70 // if($a_print_view)
71 // {
72 // $this->setPrintMode(true);
73 // }
74
75
76 foreach ($this->getSelectedColumns() as $c) {
77 $l = $c;
78 if (in_array($l, array("status", "time", "score"))) {
79 $l = "cont_" . $l;
80 // } else {
81 // $l =
82 }
83 $s = $this->lng->txt($l);
84 if (substr($l, 0, 14) == "interaction_id") {
85 $s = $this->lng->txt(substr($l, 0, 14)) . ' ' . substr($l, 14);
86 }
87 if (substr($l, 0, 17) == "interaction_value") {
88 $s = sprintf($this->lng->txt(substr($l, 0, 17)), substr($l, 17, (strpos($l, ' ')-17))) . substr($l, strpos($l, ' '));
89 }
90 if (substr($l, 0, 23) == "interaction_description") {
91 $s = $this->lng->txt(substr($l, 0, 23)) . ' ' . substr($l, 23);
92 }
93 $this->addColumn($s, $c);
94 }
95
96 $this->setRowTemplate('tpl.scorm2004_tracking_items.html', 'Modules/Scorm2004');
97 $this->setFormAction($ilCtrl->getFormAction($this->getParentObject()));
98
99 $this->setExternalSorting(true);
100 // $this->setExternalSegmentation(true);
101 $this->setEnableHeader(true);
102 $this->setEnableTitle(true);
103 // $this->setDefaultOrderField("cp_node_id, user_id");
104 $this->setDefaultOrderField("");
105 $this->setDefaultOrderDirection("asc");
106 $this->setShowTemplates(true);
107
108 $this->setExportFormats(array(self::EXPORT_CSV, self::EXPORT_EXCEL));
109 // $this->initFilter();
110 $this->getItems();
111 }
118 public function getSelectableColumns()
119 {
120 // default fields
121 $cols = array();
122
123 switch ($this->report) {
124 case "exportSelectedCore":
125 $cols=ilSCORM2004TrackingItems::exportSelectedCoreColumns($this->bySCO, $this->allowExportPrivacy);
126 break;
127 case "exportSelectedInteractions":
129 break;
130 case "exportSelectedObjectives":
132 break;
133 case "exportObjGlobalToSystem":
135 break;
136 case "tracInteractionItem":
137 $cols=ilSCORM2004TrackingItems::tracInteractionItemColumns($this->bySCO, $this->allowExportPrivacy);
138 break;
139 case "tracInteractionUser":
140 $cols=ilSCORM2004TrackingItems::tracInteractionUserColumns($this->bySCO, $this->allowExportPrivacy);
141 break;
142 case "tracInteractionUserAnswers":
143 $cols=ilSCORM2004TrackingItems::tracInteractionUserAnswersColumns($this->userSelected, $this->scosSelected, $this->bySCO, $this->allowExportPrivacy);
144 break;
145 case "exportSelectedSuccess":
147 break;
148 }
149
150 return $cols;
151 }
152
157 public function getObjId()
158 {
159 return $this->obj_id;
160 }
161
162
163 public function getItems()
164 {
166
168 $ilSCORM2004TrackingItems = new ilSCORM2004TrackingItems();
169 switch ($this->report) {
170 case "exportSelectedCore":
171 $tr_data = $ilSCORM2004TrackingItems->exportSelectedCore($this->userSelected, $this->scosSelected, $this->bySCO, $this->allowExportPrivacy, $this->getObjId());
172 break;
173 case "exportSelectedInteractions":
174 $tr_data = $ilSCORM2004TrackingItems->exportSelectedInteractions($this->userSelected, $this->scosSelected, $this->bySCO, $this->allowExportPrivacy, $this->getObjId());
175 break;
176 case "exportSelectedObjectives":
177 $tr_data = $ilSCORM2004TrackingItems->exportSelectedObjectives($this->userSelected, $this->scosSelected, $this->bySCO, $this->allowExportPrivacy, $this->getObjId());
178 break;
179 case "exportObjGlobalToSystem":
180 $tr_data = $ilSCORM2004TrackingItems->exportObjGlobalToSystem($this->userSelected, $this->allowExportPrivacy, $this->getObjId());
181 break;
182 case "tracInteractionItem":
183 $tr_data = $ilSCORM2004TrackingItems->tracInteractionItem($this->userSelected, $this->scosSelected, $this->bySCO, $this->allowExportPrivacy, $this->getObjId());
184 break;
185 case "tracInteractionUser":
186 $tr_data = $ilSCORM2004TrackingItems->tracInteractionUser($this->userSelected, $this->scosSelected, $this->bySCO, $this->allowExportPrivacy, $this->getObjId());
187 break;
188 case "tracInteractionUserAnswers":
189 $tr_data = $ilSCORM2004TrackingItems->tracInteractionUserAnswers($this->userSelected, $this->scosSelected, $this->bySCO, $this->allowExportPrivacy, $this->getObjId());
190 break;
191 case "exportSelectedSuccess":
192 $tr_data = $ilSCORM2004TrackingItems->exportSelectedSuccess($this->userSelected, $this->allowExportPrivacy, $this->getObjId());
193 break;
194 }
195 $this->setMaxCount($tr_data["cnt"]);
196 if (ilUtil::stripSlashes($this->getOrderField()) !="") {
197 include_once "Services/Utilities/classes/class.ilStr.php";
199 }
200
201 $this->setData($tr_data);
202 }
203 protected function parseValue($id, $value, $type)
204 {
206 $lng->loadLanguageModule("trac");
207 switch ($id) {
208 case "status":
209 include_once("./Services/Tracking/classes/class.ilLearningProgressBaseGUI.php");
212 $value = ilUtil::img($path, $text);
213 break;
214 }
215 //BLUM round
216 if ($id=="launch_data" || $id=="suspend_data") {
217 return $value;
218 }
219 if (is_numeric($value)) {
220 return round($value, 2);
221 }
222 return $value;
223 }
227 protected function fillRow($data)
228 {
231 foreach ($this->getSelectedColumns() as $c) {
232 $this->tpl->setCurrentBlock("user_field");
233 $val = $this->parseValue($c, $data[$c], "scormtrac");
234 $this->tpl->setVariable("VAL_UF", $val);
235 $this->tpl->parseCurrentBlock();
236 }
237 }
238
239 protected function fillHeaderExcel(ilExcel $worksheet, &$a_row)
240 {
241 $labels = $this->getSelectableColumns();
242 $cnt = 0;
243 foreach ($this->getSelectedColumns() as $c) {
244 $worksheet->setCell($a_row, $cnt, $labels[$c]["txt"]);
245 $cnt++;
246 }
247 }
248
249 protected function fillRowExcel(ilExcel $worksheet, &$a_row, $a_set)
250 {
252 $lng->loadLanguageModule("trac");
253 include_once("./Services/Tracking/classes/class.ilLearningProgressBaseGUI.php");
254 $cnt = 0;
255 foreach ($this->getSelectedColumns() as $c) {
256 if ($c != 'status') {
257 $val = $this->parseValue($c, $a_set[$c], "user");
258 } else {
259 $val = ilLearningProgressBaseGUI::_getStatusText((int) $a_set[$c]);
260 }
261 $worksheet->setCell($a_row, $cnt, $val);
262 $cnt++;
263 }
264 }
265
266 protected function fillHeaderCSV($a_csv)
267 {
268 $labels = $this->getSelectableColumns();
269 foreach ($this->getSelectedColumns() as $c) {
270 $a_csv->addColumn($labels[$c]["txt"]);
271 }
272
273 $a_csv->addRow();
274 }
275
276 protected function fillRowCSV($a_csv, $a_set)
277 {
279 $lng->loadLanguageModule("trac");
280 include_once("./Services/Tracking/classes/class.ilLearningProgressBaseGUI.php");
281 foreach ($this->getSelectedColumns() as $c) {
282 if ($c != 'status') {
283 $val = $this->parseValue($c, $a_set[$c], "user");
284 } else {
285 $val = ilLearningProgressBaseGUI::_getStatusText((int) $a_set[$c]);
286 }
287 $a_csv->addColumn($val);
288 }
289
290 $a_csv->addRow();
291 }
292}
sprintf('%.4f', $callTime)
$worksheet
global $l
Definition: afr.php:30
An exception for terminatinating execution or to throw for unit testing.
static _getStatusText($a_status, $a_lng=null)
Get status alt text.
static _getImagePathForStatus($a_status)
Get image path for status.
static _getInstance()
Get instance of ilPrivacySettings.
__construct($a_obj_id, $a_parent_obj, $a_parent_cmd, $a_userSelected, $a_scosSelected, $a_report)
Constructor.
fillRowCSV($a_csv, $a_set)
CSV Version of Fill Row.
fillHeaderExcel(ilExcel $worksheet, &$a_row)
Excel Version of Fill Header.
fillRowExcel(ilExcel $worksheet, &$a_row, $a_set)
Excel Version of Fill Row.
Class ilSCORM2004TrackingItems.
static tracInteractionItemColumns($b_orderBySCO, $b_allowExportPrivacy)
static tracInteractionUserColumns($b_orderBySCO, $b_allowExportPrivacy)
static exportSelectedCoreColumns($b_orderBySCO, $b_allowExportPrivacy)
static tracInteractionUserAnswersColumns($a_user=array(), $a_sco=array(), $b_orderBySCO, $b_allowExportPrivacy)
Class ilTable2GUI.
getSelectedColumns()
Get selected columns.
setEnableHeader($a_enableheader)
Set Enable Header.
setExternalSorting($a_val)
Set external sorting.
setExportFormats(array $formats)
Set available export formats.
determineOffsetAndOrder($a_omit_offset=false)
Determine offset and order.
setData($a_data)
set table data @access public
setEnableTitle($a_enabletitle)
Set Enable Title.
setRowTemplate($a_template, $a_template_dir="")
Set row template.
setDefaultOrderField($a_defaultorderfield)
Set Default order field.
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.
setId($a_val)
Set id.
setFormAction($a_form_action, $a_multipart=false)
Set Form action parameter.
setDefaultOrderDirection($a_defaultorderdirection)
Set Default order direction.
setShowTemplates($a_value)
Toggle templates.
getOrderDirection()
Get order direction.
setMaxCount($a_max_count)
set max.
static img($a_src, $a_alt="", $a_width="", $a_height="", $a_border=0, $a_id="", $a_class="")
Build img tag.
static stripSlashes($a_str, $a_strip_html=true, $a_allow="")
strip slashes if magic qoutes is enabled
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...
if(!array_key_exists('StateId', $_REQUEST)) $id
global $ilCtrl
Definition: ilias.php:18
$type
$s
Definition: pwgen.php:45
global $DIC
Definition: saml.php:7
$text
Definition: errorreport.php:18
$cols
Definition: xhr_table.php:11