ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
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 $lmTitle = "";
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 $this->setId('2004' . $this->report);
61 parent::__construct($a_parent_obj, $a_parent_cmd);
62 // $this->setLimit(9999); //#23582
63
64 include_once('./Services/PrivacySecurity/classes/class.ilPrivacySettings.php');
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.scorm2004_tracking_items.html', 'Modules/Scorm2004');
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 }
117 public function getSelectableColumns()
118 {
119 // default fields
120 $cols = array();
121
122 switch ($this->report) {
123 case "exportSelectedCore":
124 $cols = ilSCORM2004TrackingItems::exportSelectedCoreColumns($this->bySCO, $this->allowExportPrivacy);
125 break;
126 case "exportSelectedInteractions":
128 break;
129 case "exportSelectedObjectives":
131 break;
132 case "exportObjGlobalToSystem":
134 break;
135 case "tracInteractionItem":
136 $cols = ilSCORM2004TrackingItems::tracInteractionItemColumns($this->bySCO, $this->allowExportPrivacy);
137 break;
138 case "tracInteractionUser":
139 $cols = ilSCORM2004TrackingItems::tracInteractionUserColumns($this->bySCO, $this->allowExportPrivacy);
140 break;
141 case "tracInteractionUserAnswers":
142 $cols = ilSCORM2004TrackingItems::tracInteractionUserAnswersColumns($this->userSelected, $this->scosSelected, $this->bySCO, $this->allowExportPrivacy);
143 break;
144 case "exportSelectedSuccess":
146 break;
147 }
148
149 return $cols;
150 }
151
156 public function getObjId()
157 {
158 return $this->obj_id;
159 }
160
161
162 public function getItems()
163 {
165
166 $this->determineOffsetAndOrder(true);
167 $this->determineLimit();
168
169 $ilSCORM2004TrackingItems = new ilSCORM2004TrackingItems();
170 switch ($this->report) {
171 case "exportSelectedCore":
172 $tr_data = $ilSCORM2004TrackingItems->exportSelectedCore($this->userSelected, $this->scosSelected, $this->bySCO, $this->allowExportPrivacy, $this->getObjId(), $this->lmTitle);
173 break;
174 case "exportSelectedInteractions":
175 $tr_data = $ilSCORM2004TrackingItems->exportSelectedInteractions($this->userSelected, $this->scosSelected, $this->bySCO, $this->allowExportPrivacy, $this->getObjId(), $this->lmTitle);
176 break;
177 case "exportSelectedObjectives":
178 $tr_data = $ilSCORM2004TrackingItems->exportSelectedObjectives($this->userSelected, $this->scosSelected, $this->bySCO, $this->allowExportPrivacy, $this->getObjId(), $this->lmTitle);
179 break;
180 case "exportObjGlobalToSystem":
181 $tr_data = $ilSCORM2004TrackingItems->exportObjGlobalToSystem($this->userSelected, $this->allowExportPrivacy, $this->getObjId(), $this->lmTitle);
182 break;
183 case "tracInteractionItem":
184 $tr_data = $ilSCORM2004TrackingItems->tracInteractionItem($this->userSelected, $this->scosSelected, $this->bySCO, $this->allowExportPrivacy, $this->getObjId(), $this->lmTitle);
185 break;
186 case "tracInteractionUser":
187 $tr_data = $ilSCORM2004TrackingItems->tracInteractionUser($this->userSelected, $this->scosSelected, $this->bySCO, $this->allowExportPrivacy, $this->getObjId(), $this->lmTitle);
188 break;
189 case "tracInteractionUserAnswers":
190 $tr_data = $ilSCORM2004TrackingItems->tracInteractionUserAnswers($this->userSelected, $this->scosSelected, $this->bySCO, $this->allowExportPrivacy, $this->getObjId(), $this->lmTitle);
191 break;
192 case "exportSelectedSuccess":
193 $tr_data = $ilSCORM2004TrackingItems->exportSelectedSuccess($this->userSelected, $this->allowExportPrivacy, $this->getObjId(), $this->lmTitle);
194 break;
195 }
196 // $this->setMaxCount($tr_data["cnt"]);
197 if (ilUtil::stripSlashes($this->getOrderField()) != "") {
198 include_once "Services/Utilities/classes/class.ilStr.php";
200 }
201
202 $this->setData($tr_data);
203 }
204 protected function parseValue($id, $value, $type)
205 {
207 $lng->loadLanguageModule("trac");
208 switch ($id) {
209 case "status":
210 include_once("./Services/Tracking/classes/class.ilLearningProgressBaseGUI.php");
213 $value = ilUtil::img($path, $text);
214 break;
215 }
216 //BLUM round
217 if ($id == "launch_data" || $id == "suspend_data") {
218 return $value;
219 }
220 if (is_numeric($value)) {
221 return round($value, 2);
222 }
223 return $value;
224 }
228 protected function fillRow($data)
229 {
232 foreach ($this->getSelectedColumns() as $c) {
233 $this->tpl->setCurrentBlock("user_field");
234 $val = $this->parseValue($c, $data[$c], "scormtrac");
235 $this->tpl->setVariable("VAL_UF", $val);
236 $this->tpl->parseCurrentBlock();
237 }
238 }
239
240 protected function fillHeaderExcel(ilExcel $worksheet, &$a_row)
241 {
242 $labels = $this->getSelectableColumns();
243 $cnt = 0;
244 foreach ($this->getSelectedColumns() as $c) {
245 $worksheet->setCell($a_row, $cnt, $labels[$c]["txt"]);
246 $cnt++;
247 }
248 }
249
250 protected function fillRowExcel(ilExcel $worksheet, &$a_row, $a_set)
251 {
253 $lng->loadLanguageModule("trac");
254 include_once("./Services/Tracking/classes/class.ilLearningProgressBaseGUI.php");
255 $cnt = 0;
256 foreach ($this->getSelectedColumns() as $c) {
257 if ($c != 'status') {
258 $val = $this->parseValue($c, $a_set[$c], "user");
259 } else {
260 $val = ilLearningProgressBaseGUI::_getStatusText((int) $a_set[$c]);
261 }
262 $worksheet->setCell($a_row, $cnt, $val);
263 $cnt++;
264 }
265 }
266
267 protected function fillHeaderCSV($a_csv)
268 {
269 $labels = $this->getSelectableColumns();
270 foreach ($this->getSelectedColumns() as $c) {
271 $a_csv->addColumn($labels[$c]["txt"]);
272 }
273
274 $a_csv->addRow();
275 }
276
277 protected function fillRowCSV($a_csv, $a_set)
278 {
280 $lng->loadLanguageModule("trac");
281 include_once("./Services/Tracking/classes/class.ilLearningProgressBaseGUI.php");
282 foreach ($this->getSelectedColumns() as $c) {
283 if ($c != 'status') {
284 $val = $this->parseValue($c, $a_set[$c], "user");
285 } else {
286 $val = ilLearningProgressBaseGUI::_getStatusText((int) $a_set[$c]);
287 }
288 $a_csv->addColumn($val);
289 }
290
291 $a_csv->addRow();
292 }
293}
An exception for terminatinating execution or to throw for unit testing.
setCell($a_row, $a_col, $a_value, $a_datatype=null)
Set cell value.
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.
determineLimit()
Determine the limit.
setDefaultOrderDirection($a_defaultorderdirection)
Set Default order direction.
setShowTemplates($a_value)
Toggle templates.
getOrderDirection()
Get order direction.
static img($a_src, $a_alt=null, $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...
global $ilCtrl
Definition: ilias.php:18
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
$type
$DIC
Definition: xapitoken.php:46
$cols
Definition: xhr_table.php:11