ILIAS  trunk Revision v12.0_alpha-377-g3641b37b9db
ilCmiXapiStatementsGUI Class Reference
+ Collaboration diagram for ilCmiXapiStatementsGUI:

Public Member Functions

 __construct (ilObjCmiXapi $object)
 
 executeCommand ()
 
 asyncUserAutocompleteCmd ()
 
 getVerbs ()
 
 getVerbsPipline ()
 

Protected Member Functions

 resetFilterCmd ()
 
 applyFilterCmd ()
 
 showCmd ()
 
 initLimitingAndOrdering (ilCmiXapiStatementsReportFilter $filter, ilCmiXapiStatementsTableGUI $table)
 
 initActorFilter (ilCmiXapiStatementsReportFilter $filter, ilCmiXapiStatementsTableGUI $table)
 
 initVerbFilter (ilCmiXapiStatementsReportFilter $filter, ilCmiXapiStatementsTableGUI $table)
 
 initPeriodFilter (ilCmiXapiStatementsReportFilter $filter, ilCmiXapiStatementsTableGUI $table)
 
 initTableData (ilCmiXapiStatementsTableGUI $table, ilCmiXapiStatementsReportFilter $filter)
 
 buildTableGUI ()
 

Protected Attributes

ilObjCmiXapi $object
 
ilCmiXapiAccess $access
 

Private Attributes

ilGlobalTemplateInterface $main_tpl
 
ILIAS DI Container $dic
 

Detailed Description

Definition at line 30 of file class.ilCmiXapiStatementsGUI.php.

Constructor & Destructor Documentation

◆ __construct()

ilCmiXapiStatementsGUI::__construct ( ilObjCmiXapi  $object)

Definition at line 37 of file class.ilCmiXapiStatementsGUI.php.

38 {
39 global $DIC;
40 $this->dic = $DIC;
41 $this->main_tpl = $DIC->ui()->mainTemplate();
42 $this->object = $object;
43
44 $this->access = ilCmiXapiAccess::getInstance($this->object);
45 }
static getInstance(ilObjCmiXapi $object)
global $DIC
Definition: shib_login.php:26

References $DIC, $object, ILIAS\Repository\access(), and ilCmiXapiAccess\getInstance().

+ Here is the call graph for this function:

Member Function Documentation

◆ applyFilterCmd()

ilCmiXapiStatementsGUI::applyFilterCmd ( )
protected

Definition at line 73 of file class.ilCmiXapiStatementsGUI.php.

73 : void
74 {
75 $table = $this->buildTableGUI();
76 $table->writeFilterToSession();
77 $table->resetOffset();
78 $this->showCmd();
79 }

References buildTableGUI(), and showCmd().

+ Here is the call graph for this function:

◆ asyncUserAutocompleteCmd()

ilCmiXapiStatementsGUI::asyncUserAutocompleteCmd ( )

Definition at line 166 of file class.ilCmiXapiStatementsGUI.php.

166 : void
167 {
168 $auto = new ilCmiXapiUserAutocomplete($this->object->getId());
169 $auto->setSearchFields(array('login','firstname','lastname','email'));
170 $auto->setResultField('login');
171 $auto->enableFieldSearchableCheck(true);
172 $auto->setMoreLinkAvailable(true);
173
174 //$auto->setLimit(ilUserAutoComplete::MAX_ENTRIES);
175 $term = '';
176 if ($this->dic->http()->wrapper()->query()->has('term')) {
177 $term = $this->dic->http()->wrapper()->query()->retrieve('term', $this->dic->refinery()->kindlyTo()->string());
178 } elseif ($this->dic->http()->wrapper()->post()->has('term')) {
179 $term = $this->dic->http()->wrapper()->post()->retrieve('term', $this->dic->refinery()->kindlyTo()->string());
180 }
181 if ($term != '') {
182 $result = json_decode($auto->getList(ilUtil::stripSlashes($term)), true);
183 echo json_encode($result);
184 }
185 exit();
186 }
static stripSlashes(string $a_str, bool $a_strip_html=true, string $a_allow="")
exit

References exit, ILIAS\Repository\object(), and ilUtil\stripSlashes().

+ Here is the call graph for this function:

◆ buildTableGUI()

ilCmiXapiStatementsGUI::buildTableGUI ( )
protected

Definition at line 226 of file class.ilCmiXapiStatementsGUI.php.

227 {
228 $isMultiActorReport = $this->access->hasOutcomesAccess();
229 $table = new ilCmiXapiStatementsTableGUI($this, 'show', $isMultiActorReport);
230 $table->setFilterCommand('applyFilter');
231 $table->setResetCommand('resetFilter');
232
233 return $table;
234 }

References ILIAS\Repository\access(), ilTable2GUI\setFilterCommand(), and ilTable2GUI\setResetCommand().

Referenced by applyFilterCmd(), resetFilterCmd(), and showCmd().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ executeCommand()

ilCmiXapiStatementsGUI::executeCommand ( )
Exceptions
ilCmiXapiException

Definition at line 50 of file class.ilCmiXapiStatementsGUI.php.

50 : void
51 {
52 global $DIC; /* @var \ILIAS\DI\Container $DIC */
53
54 if (!$this->access->hasStatementsAccess()) {
55 throw new ilCmiXapiException('access denied!');
56 }
57
58 switch ($DIC->ctrl()->getNextClass($this)) {
59 default:
60 $cmd = $DIC->ctrl()->getCmd('show') . 'Cmd';
61 $this->{$cmd}();
62 }
63 }

References $DIC, and ILIAS\Repository\access().

+ Here is the call graph for this function:

◆ getVerbs()

ilCmiXapiStatementsGUI::getVerbs ( )

Definition at line 236 of file class.ilCmiXapiStatementsGUI.php.

236 : ?array
237 {
239
240 $lrsType = $this->object->getLrsType();
241 $defaultLrs = $lrsType->getLrsEndpointStatementsAggregationLink();
242 $defaultBasicAuth = $lrsType->getBasicAuth();
243
244 $defaultHeaders = [
245 'X-Experience-API-Version: 1.0.3',
246 'Authorization: ' . $defaultBasicAuth,
247 'Cache-Control: no-cache, no-store, must-revalidate'
248 ];
249
250 // Pipeline zusammenbauen
251 $pipeline = json_encode($this->getVerbsPipline());
252 $defaultVerbsUrl = $defaultLrs . "?pipeline=" . urlencode($pipeline);
253
254 // cURL-Setup
255 $ch = curl_init($defaultVerbsUrl);
256 curl_setopt_array($ch, [
257 CURLOPT_RETURNTRANSFER => true,
258 CURLOPT_HTTPHEADER => $defaultHeaders,
259 CURLOPT_CONNECTTIMEOUT => 10,
260 CURLOPT_TIMEOUT => 30,
261 CURLOPT_SSL_VERIFYPEER => true,
262 CURLOPT_FOLLOWLOCATION => true
263 ]);
264
265 // Request ausführen
266 $body = curl_exec($ch);
267 $error = curl_error($ch);
268 $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
269 curl_close($ch);
270
271 // Fehlerbehandlung
272 if ($error) {
273 $log->error('cURL error in getVerbs(): ' . $error);
274 return null;
275 }
276
277 if ($httpCode < 200 || $httpCode >= 300) {
278 $log->error("Unexpected HTTP code in getVerbs(): {$httpCode}");
279 return null;
280 }
281
282 if (!$body) {
283 $log->error('Empty response in getVerbs()');
284 return null;
285 }
286
287 // Antwort dekodieren
288 $decoded = json_decode($body, true);
289 if (json_last_error() !== JSON_ERROR_NONE) {
290 $log->error('JSON decode error in getVerbs(): ' . json_last_error_msg());
291 return null;
292 }
293
294 return $decoded;
295 }
static getLogger(string $a_component_id)
Get component logger.
$log
Definition: ltiresult.php:34

References $log, and ilLoggerFactory\getLogger().

+ Here is the call graph for this function:

◆ getVerbsPipline()

ilCmiXapiStatementsGUI::getVerbsPipline ( )

Definition at line 297 of file class.ilCmiXapiStatementsGUI.php.

297 : array
298 {
299 $pipeline = array();
300
301 // filter activityId
302 $match = array();
303 $match['statement.object.objectType'] = 'Activity';
304 $match['statement.actor.objectType'] = 'Agent';
305
306 $activityId = array();
307
308 if ($this->object->getContentType() == ilObjCmiXapi::CONT_TYPE_CMI5 && !$this->object->isMixedContentType()) {
309 // https://github.com/AICC/CMI-5_Spec_Current/blob/quartz/cmi5_spec.md#963-extensions
310 $activityId['statement.context.extensions.https://ilias&46;de/cmi5/activityid'] = $this->object->getActivityId();
311 } else {
312 $activityQuery = [
313 '$regex' => '^' . preg_quote($this->object->getActivityId()) . ''
314 ];
315 $activityId['$or'] = [];
316 $activityId['$or'][] = ['statement.object.id' => $activityQuery];
317 $activityId['$or'][] = ['statement.context.contextActivities.parent.id' => $activityQuery];
318 }
319 $match['$and'] = [];
320 $match['$and'][] = $activityId;
321
322 $sort = array();
323 $sort['statement.verb.id'] = 1;
324
325 // project distinct verbs
326 $group = array('_id' => '$statement.verb.id');
327 // $project = array('statement.verb.id' => 1);
328 // project distinct verbs
329
330 $pipeline[] = array('$match' => $match);
331 $pipeline[] = array('$group' => $group);
332 $pipeline[] = array('$sort' => $sort);
333 //$pipeline[] = array('$project' => $project);
334
335 return $pipeline;
336 }

References ilObjCmiXapi\CONT_TYPE_CMI5, and ILIAS\Repository\object().

+ Here is the call graph for this function:

◆ initActorFilter()

ilCmiXapiStatementsGUI::initActorFilter ( ilCmiXapiStatementsReportFilter  $filter,
ilCmiXapiStatementsTableGUI  $table 
)
protected

Definition at line 115 of file class.ilCmiXapiStatementsGUI.php.

118 : void {
119 if ($this->access->hasOutcomesAccess()) {
120 $actor = $table->getFilterItemByPostVar('actor')->getValue();
121 if ($actor && strlen($actor)) {
122 $usrId = ilObjUser::getUserIdByLogin($actor);
123 if ($usrId) {
124 $filter->setActor(new ilCmiXapiUser($this->object->getId(), $usrId, $this->object->getPrivacyIdent()));
125 } else {
127 "given actor ({$actor}) is not a valid actor for object ({$this->object->getId()})"
128 );
129 }
130 }
131 } else {
132 $filter->setActor(new ilCmiXapiUser($this->object->getId(), $this->dic->user()->getId(), $this->object->getPrivacyIdent()));
133 }
134 }
static getUserIdByLogin(string $a_login)
getFilterItemByPostVar(string $a_post_var)

References ilTable2GUI\getFilterItemByPostVar(), ilObjUser\getUserIdByLogin(), ILIAS\Repository\object(), and ilCmiXapiStatementsReportFilter\setActor().

Referenced by showCmd().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ initLimitingAndOrdering()

ilCmiXapiStatementsGUI::initLimitingAndOrdering ( ilCmiXapiStatementsReportFilter  $filter,
ilCmiXapiStatementsTableGUI  $table 
)
protected

Definition at line 104 of file class.ilCmiXapiStatementsGUI.php.

104 : void
105 {
106 $table->determineOffsetAndOrder();
107
108 $filter->setLimit($table->getLimit());
109 $filter->setOffset($table->getOffset());
110
111 $filter->setOrderField($table->getOrderField());
112 $filter->setOrderDirection($table->getOrderDirection());
113 }
determineOffsetAndOrder(bool $a_omit_offset=false)

References ilTable2GUI\determineOffsetAndOrder(), ilTable2GUI\getLimit(), ilTable2GUI\getOffset(), ilTableGUI\getOrderDirection(), ilTable2GUI\getOrderField(), ilCmiXapiStatementsReportFilter\setLimit(), ilCmiXapiStatementsReportFilter\setOffset(), ilCmiXapiStatementsReportFilter\setOrderDirection(), and ilCmiXapiStatementsReportFilter\setOrderField().

Referenced by showCmd().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ initPeriodFilter()

ilCmiXapiStatementsGUI::initPeriodFilter ( ilCmiXapiStatementsReportFilter  $filter,
ilCmiXapiStatementsTableGUI  $table 
)
protected

Definition at line 149 of file class.ilCmiXapiStatementsGUI.php.

152 : void {
153 if ($table->getFilterItemByPostVar('period') != null) {
154 $period = $table->getFilterItemByPostVar('period');
155
156 if ($period->getStartXapiDateTime()) {
157 $filter->setStartDate($period->getStartXapiDateTime());
158 }
159
160 if ($period->getEndXapiDateTime()) {
161 $filter->setEndDate($period->getEndXapiDateTime());
162 }
163 }
164 }

References ilTable2GUI\getFilterItemByPostVar(), ilCmiXapiStatementsReportFilter\setEndDate(), and ilCmiXapiStatementsReportFilter\setStartDate().

Referenced by showCmd().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ initTableData()

ilCmiXapiStatementsGUI::initTableData ( ilCmiXapiStatementsTableGUI  $table,
ilCmiXapiStatementsReportFilter  $filter 
)
protected

Definition at line 188 of file class.ilCmiXapiStatementsGUI.php.

191 : void {
192 global $DIC;
193 if ($this->access->hasOutcomesAccess()) {
194 if (!ilCmiXapiUser::getUsersForObject($this->object->getId())) {
195 $table->setData(array());
196 $table->setMaxCount(0);
197 $table->resetOffset();
198 return;
199 }
200 } else {
201 $usrId = $DIC->user()->getId();
202 // if (!ilCmiXapiUser::getUsersForObject($this->object->getId(), $usrId)) {
203 if (!ilCmiXapiUser::getUsersForObject($this->object->getId())) {
204 $table->setData(array());
205 $table->setMaxCount(0);
206 $table->resetOffset();
207 return;
208 }
209 }
210 $linkBuilder = new ilCmiXapiStatementsReportLinkBuilder(
211 $this->object->getId(),
212 $this->object->getLrsType()->getLrsEndpointStatementsAggregationLink(),
213 $filter
214 );
215
217 $this->object->getLrsType()->getBasicAuth(),
218 $linkBuilder
219 );
220 $statementsReport = $request->queryReport($this->object->getId());
221 $data = $statementsReport->getTableData();
222 $table->setData($data);
223 $table->setMaxCount($statementsReport->getMaxCount());
224 }
static getUsersForObject(int $objId, bool $asUsrId=false)
resetOffset(bool $a_in_determination=false)
setData(array $a_data)
Set table data.
setMaxCount(int $a_max_count)
set max.

References ilCmiXapiUser\getUsersForObject(), ILIAS\Repository\object(), ilTable2GUI\resetOffset(), ilTable2GUI\setData(), and ilTableGUI\setMaxCount().

Referenced by showCmd().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ initVerbFilter()

ilCmiXapiStatementsGUI::initVerbFilter ( ilCmiXapiStatementsReportFilter  $filter,
ilCmiXapiStatementsTableGUI  $table 
)
protected

Definition at line 136 of file class.ilCmiXapiStatementsGUI.php.

139 : void {
140 if ($table->getFilterItemByPostVar('verb') != null) {
141 $verb = urldecode($table->getFilterItemByPostVar('verb')->getValue());
142
143 if (ilCmiXapiVerbList::getInstance()->isValidVerb($verb)) {
144 $filter->setVerb($verb);
145 }
146 }
147 }

References ilTable2GUI\getFilterItemByPostVar(), ilCmiXapiVerbList\getInstance(), and ilCmiXapiStatementsReportFilter\setVerb().

Referenced by showCmd().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ resetFilterCmd()

ilCmiXapiStatementsGUI::resetFilterCmd ( )
protected

Definition at line 65 of file class.ilCmiXapiStatementsGUI.php.

65 : void
66 {
67 $table = $this->buildTableGUI();
68 $table->resetFilter();
69 $table->resetOffset();
70 $this->showCmd();
71 }

References buildTableGUI(), and showCmd().

+ Here is the call graph for this function:

◆ showCmd()

ilCmiXapiStatementsGUI::showCmd ( )
protected

Definition at line 81 of file class.ilCmiXapiStatementsGUI.php.

81 : void
82 {
83 $table = $this->buildTableGUI();
84
85 try {
86 $statementsFilter = new ilCmiXapiStatementsReportFilter();
87 $statementsFilter->setActivityId($this->object->getActivityId());
88 $this->initLimitingAndOrdering($statementsFilter, $table);
89 $this->initActorFilter($statementsFilter, $table);
90 $this->initVerbFilter($statementsFilter, $table);
91 $this->initPeriodFilter($statementsFilter, $table);
92
93 $this->initTableData($table, $statementsFilter);
94 } catch (Exception $e) {
95 $this->main_tpl->setOnScreenMessage('failure', $e->getMessage());
96 $table->setData(array());
97 $table->setMaxCount(0);
98 $table->resetOffset();
99 }
100
101 $this->dic->ui()->mainTemplate()->setContent($table->getHTML());
102 }
initActorFilter(ilCmiXapiStatementsReportFilter $filter, ilCmiXapiStatementsTableGUI $table)
initVerbFilter(ilCmiXapiStatementsReportFilter $filter, ilCmiXapiStatementsTableGUI $table)
initTableData(ilCmiXapiStatementsTableGUI $table, ilCmiXapiStatementsReportFilter $filter)
initLimitingAndOrdering(ilCmiXapiStatementsReportFilter $filter, ilCmiXapiStatementsTableGUI $table)
initPeriodFilter(ilCmiXapiStatementsReportFilter $filter, ilCmiXapiStatementsTableGUI $table)

References Vendor\Package\$e, buildTableGUI(), initActorFilter(), initLimitingAndOrdering(), initPeriodFilter(), initTableData(), initVerbFilter(), and ILIAS\Repository\object().

Referenced by applyFilterCmd(), and resetFilterCmd().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Field Documentation

◆ $access

ilCmiXapiAccess ilCmiXapiStatementsGUI::$access
protected

Definition at line 33 of file class.ilCmiXapiStatementsGUI.php.

◆ $dic

ILIAS DI Container ilCmiXapiStatementsGUI::$dic
private

Definition at line 35 of file class.ilCmiXapiStatementsGUI.php.

◆ $main_tpl

ilGlobalTemplateInterface ilCmiXapiStatementsGUI::$main_tpl
private

Definition at line 34 of file class.ilCmiXapiStatementsGUI.php.

◆ $object

ilObjCmiXapi ilCmiXapiStatementsGUI::$object
protected

Definition at line 32 of file class.ilCmiXapiStatementsGUI.php.

Referenced by __construct().


The documentation for this class was generated from the following file: