ILIAS  release_7 Revision v7.30-3-g800a261c036
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

 $object
 
 $access
 

Detailed Description

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

Constructor & Destructor Documentation

◆ __construct()

ilCmiXapiStatementsGUI::__construct ( ilObjCmiXapi  $object)
Parameters
ilObjCmiXapi$object

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

31 {
32 $this->object = $object;
33
34 $this->access = ilCmiXapiAccess::getInstance($this->object);
35 }
static getInstance(ilObjCmiXapi $object)

References $object, and ilCmiXapiAccess\getInstance().

+ Here is the call graph for this function:

Member Function Documentation

◆ applyFilterCmd()

ilCmiXapiStatementsGUI::applyFilterCmd ( )
protected

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

64 {
65 $table = $this->buildTableGUI();
66 $table->writeFilterToSession();
67 $table->resetOffset();
68 $this->showCmd();
69 }

References buildTableGUI(), and showCmd().

+ Here is the call graph for this function:

◆ asyncUserAutocompleteCmd()

ilCmiXapiStatementsGUI::asyncUserAutocompleteCmd ( )

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

150 {
151 $auto = new ilCmiXapiUserAutocomplete($this->object->getId());
152 $auto->setSearchFields(array('login','firstname','lastname','email'));
153 $auto->setResultField('login');
154 $auto->enableFieldSearchableCheck(true);
155 $auto->setMoreLinkAvailable(true);
156
157 //$auto->setLimit(ilUserAutoComplete::MAX_ENTRIES);
158
159 $result = json_decode($auto->getList(ilUtil::stripSlashes($_REQUEST['term'])), true);
160
161 echo json_encode($result);
162 exit();
163 }
$result
static stripSlashes($a_str, $a_strip_html=true, $a_allow="")
strip slashes if magic qoutes is enabled
exit
Definition: login.php:29

References $result, exit, and ilUtil\stripSlashes().

+ Here is the call graph for this function:

◆ buildTableGUI()

ilCmiXapiStatementsGUI::buildTableGUI ( )
protected
Returns
ilCmiXapiStatementsTableGUI

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

208 {
209 $isMultiActorReport = $this->access->hasOutcomesAccess();
210 $table = new ilCmiXapiStatementsTableGUI($this, 'show', $isMultiActorReport);
211 $table->setFilterCommand('applyFilter');
212 $table->setResetCommand('resetFilter');
213 return $table;
214 }

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

+ Here is the caller graph for this function:

◆ executeCommand()

ilCmiXapiStatementsGUI::executeCommand ( )
Exceptions
ilCmiXapiException

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

41 {
42 global $DIC; /* @var \ILIAS\DI\Container $DIC */
43
44 if (!$this->access->hasStatementsAccess()) {
45 throw new ilCmiXapiException('access denied!');
46 }
47
48 switch ($DIC->ctrl()->getNextClass($this)) {
49 default:
50 $cmd = $DIC->ctrl()->getCmd('show') . 'Cmd';
51 $this->{$cmd}();
52 }
53 }
global $DIC
Definition: goto.php:24

References $DIC.

◆ getVerbs()

ilCmiXapiStatementsGUI::getVerbs ( )

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

218 {
219 global $DIC;
220 $lrsType = $this->object->getLrsType();
221
222 //$this->getLrsEndpoint())) . '/api/' . self::ENDPOINT_AGGREGATE_SUFFIX;
223 $defaultLrs = $lrsType->getLrsEndpointStatementsAggregationLink();
224 //$fallbackLrs = $lrsType->getLrsFallbackEndpoint();
225 $defaultBasicAuth = $lrsType->getBasicAuth();
226 //$fallbackBasicAuth = $lrsType->getFallbackBasicAuth();
227 $defaultHeaders = [
228 'X-Experience-API-Version' => '1.0.3',
229 'Authorization' => $defaultBasicAuth,
230 'Cache-Control' => 'no-cache, no-store, must-revalidate'
231 ];
232// $fallbackHeaders = [
233// 'X-Experience-API-Version' => '1.0.3',
234// 'Authorization' => $fallbackBasicAuth,
235// 'Content-Type' => 'application/json;charset=utf-8',
236// 'Cache-Control' => 'no-cache, no-store, must-revalidate'
237// ];
238 $pipeline = json_encode($this->getVerbsPipline());
239// $pipeline2 = json_encode($this->getVerbsPipline(),JSON_PRETTY_PRINT);
240 //$DIC->logger()->root()->log($pipeline2);
241
242 $defaultVerbsUrl = $defaultLrs . "?pipeline=" . urlencode($pipeline);
243 //$DIC->logger()->root()->log($defaultVerbsUrl);
244
245 $client = new GuzzleHttp\Client();
246 $req_opts = array(
247 GuzzleHttp\RequestOptions::VERIFY => true,
248 GuzzleHttp\RequestOptions::CONNECT_TIMEOUT => 10,
249 GuzzleHttp\RequestOptions::HTTP_ERRORS => false
250 );
251 //new GuzzleHttp\Psr7\Request('POST', $defaultUrl, $this->defaultHeaders, $body);
252 $defaultVerbsRequest = new GuzzleHttp\Psr7\Request(
253 'GET',
254 $defaultVerbsUrl,
255 $defaultHeaders
256 );
257 $promises = array();
258 $promises['defaultVerbs'] = $client->sendAsync($defaultVerbsRequest, $req_opts);
259 try {
260 $responses = GuzzleHttp\Promise\Utils::settle($promises)->wait();
261 $body = '';
262 //$DIC->logger()->root()->log(var_export($responses['defaultVerbs'],TRUE));
263 ilCmiXapiAbstractRequest::checkResponse($responses['defaultVerbs'], $body, [200]);
264 return json_decode($body, JSON_OBJECT_AS_ARRAY);
265 } catch (Exception $e) {
266 $this->log()->error('error:' . $e->getMessage());
267 return null;
268 }
269 return null;
270 }
static checkResponse($response, &$body, $allowedStatus=[200, 204])
if($_SERVER['argc']< 4) $client
Definition: cron.php:12

References $client, $DIC, Vendor\Package\$e, ilCmiXapiAbstractRequest\checkResponse(), and getVerbsPipline().

+ Here is the call graph for this function:

◆ getVerbsPipline()

ilCmiXapiStatementsGUI::getVerbsPipline ( )

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

273 {
274 global $DIC;
275 $pipeline = array();
276
277 // filter activityId
278 $match = array();
279 $match['statement.object.objectType'] = 'Activity';
280 $match['statement.actor.objectType'] = 'Agent';
281
282 $activityId = array();
283
284 if ($this->object->getContentType() == ilObjCmiXapi::CONT_TYPE_CMI5 && !$this->object->isMixedContentType()) {
285 // https://github.com/AICC/CMI-5_Spec_Current/blob/quartz/cmi5_spec.md#963-extensions
286 $activityId['statement.context.extensions.https://ilias&46;de/cmi5/activityid'] = $this->object->getActivityId();
287 } else {
288 $activityQuery = [
289 '$regex' => '^' . preg_quote($this->object->getActivityId()) . ''
290 ];
291 $activityId['$or'] = [];
292 $activityId['$or'][] = ['statement.object.id' => $activityQuery];
293 $activityId['$or'][] = ['statement.context.contextActivities.parent.id' => $activityQuery];
294 }
295 $match['$and'] = [];
296 $match['$and'][] = $activityId;
297
298 $sort = array();
299 $sort['statement.verb.id'] = 1;
300
301 // project distinct verbs
302 $group = array('_id' => '$statement.verb.id');
303 // $project = array('statement.verb.id' => 1);
304 // project distinct verbs
305
306 $pipeline[] = array('$match' => $match);
307 $pipeline[] = array('$group' => $group);
308 $pipeline[] = array('$sort' => $sort);
309 //$pipeline[] = array('$project' => $project);
310
311 return $pipeline;
312 }

References $DIC, and ilObjCmiXapi\CONT_TYPE_CMI5.

Referenced by getVerbs().

+ Here is the caller graph for this function:

◆ initActorFilter()

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

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

108 {
109 global $DIC;
110 if ($this->access->hasOutcomesAccess()) {
111 $actor = $table->getFilterItemByPostVar('actor')->getValue();
112 if (strlen($actor)) {
113 $usrId = ilObjUser::getUserIdByLogin($actor);
114 if ($usrId) {
115 $filter->setActor(new ilCmiXapiUser($this->object->getId(), $usrId, $this->object->getPrivacyIdent()));
116 } else {
118 "given actor ({$actor}) is not a valid actor for object ({$this->object->getId()})"
119 );
120 }
121 }
122 } else {
123 $filter->setActor(new ilCmiXapiUser($this->object->getId(), $DIC->user()->getId(), $this->object->getPrivacyIdent()));
124 }
125 }
static getUserIdByLogin($a_login)
getFilterItemByPostVar($a_post_var)

References $DIC, ilTable2GUI\getFilterItemByPostVar(), ilObjUser\getUserIdByLogin(), 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 96 of file class.ilCmiXapiStatementsGUI.php.

97 {
99
100 $filter->setLimit($table->getLimit());
101 $filter->setOffset($table->getOffset());
102
103 $filter->setOrderField($table->getOrderField());
104 $filter->setOrderDirection($table->getOrderDirection());
105 }
determineOffsetAndOrder($a_omit_offset=false)
Determine offset and order.
getLimit()
Get limit.
getOffset()
Get offset.
getOrderDirection()
Get order direction.

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 136 of file class.ilCmiXapiStatementsGUI.php.

137 {
138 $period = $table->getFilterItemByPostVar('period');
139
140 if ($period->getStartXapiDateTime()) {
141 $filter->setStartDate($period->getStartXapiDateTime());
142 }
143
144 if ($period->getEndXapiDateTime()) {
145 $filter->setEndDate($period->getEndXapiDateTime());
146 }
147 }

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
Parameters
ilCmiXapiStatementsTableGUI$table
ilCmiXapiStatementsReportFilter$filter

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

170 {
171 global $DIC;
172 if ($this->access->hasOutcomesAccess()) {
173 if (!ilCmiXapiUser::getUsersForObject($this->object->getId())) {
174 $table->setData(array());
175 $table->setMaxCount(0);
176 $table->resetOffset();
177 return;
178 }
179 } else {
180 $usrId = $DIC->user()->getId();
181 if (!ilCmiXapiUser::getUsersForObject($this->object->getId(), $usrId)) {
182 $table->setData(array());
183 $table->setMaxCount(0);
184 $table->resetOffset();
185 return;
186 }
187 }
188 $linkBuilder = new ilCmiXapiStatementsReportLinkBuilder(
189 $this->object,
190 $this->object->getLrsType()->getLrsEndpointStatementsAggregationLink(),
191 $filter
192 );
193
195 $this->object->getLrsType()->getBasicAuth(),
196 $linkBuilder
197 );
198 $statementsReport = $request->queryReport($this->object);
199 $data = $statementsReport->getTableData();
200 $table->setData($data);
201 $table->setMaxCount($statementsReport->getMaxCount());
202 }
static getUsersForObject($objId, $asUsrId=false)
setData($a_data)
set table data @access public
resetOffset($a_in_determination=false)
Reset offset.
setMaxCount($a_max_count)
set max.
$data
Definition: storeScorm.php:23

References $data, $DIC, ilCmiXapiUser\getUsersForObject(), 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 127 of file class.ilCmiXapiStatementsGUI.php.

128 {
129 $verb = urldecode($table->getFilterItemByPostVar('verb')->getValue());
130
131 if (ilCmiXapiVerbList::getInstance()->isValidVerb($verb)) {
132 $filter->setVerb($verb);
133 }
134 }

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 55 of file class.ilCmiXapiStatementsGUI.php.

56 {
57 $table = $this->buildTableGUI();
58 $table->resetFilter();
59 $table->resetOffset();
60 $this->showCmd();
61 }

References buildTableGUI(), and showCmd().

+ Here is the call graph for this function:

◆ showCmd()

ilCmiXapiStatementsGUI::showCmd ( )
protected

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

72 {
73 global $DIC; /* @var \ILIAS\DI\Container $DIC */
74
75 $table = $this->buildTableGUI();
76
77 try {
78 $statementsFilter = new ilCmiXapiStatementsReportFilter();
79 $statementsFilter->setActivityId($this->object->getActivityId());
80 $this->initLimitingAndOrdering($statementsFilter, $table);
81 $this->initActorFilter($statementsFilter, $table);
82 $this->initVerbFilter($statementsFilter, $table);
83 $this->initPeriodFilter($statementsFilter, $table);
84
85 $this->initTableData($table, $statementsFilter);
86 } catch (Exception $e) {
87 ilUtil::sendFailure($e->getMessage());
88 $table->setData(array());
89 $table->setMaxCount(0);
90 $table->resetOffset();
91 }
92
93 $DIC->ui()->mainTemplate()->setContent($table->getHTML());
94 }
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)
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.

References $DIC, Vendor\Package\$e, buildTableGUI(), initActorFilter(), initLimitingAndOrdering(), initPeriodFilter(), initTableData(), initVerbFilter(), and ilUtil\sendFailure().

Referenced by applyFilterCmd(), and resetFilterCmd().

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

Field Documentation

◆ $access

ilCmiXapiStatementsGUI::$access
protected

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

◆ $object

ilCmiXapiStatementsGUI::$object
protected

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

Referenced by __construct().


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