ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
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.

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

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: feed.php:28
+ Here is the call graph for this function:

Member Function Documentation

◆ applyFilterCmd()

ilCmiXapiStatementsGUI::applyFilterCmd ( )
protected

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

References buildTableGUI(), and showCmd().

73  : void
74  {
75  $table = $this->buildTableGUI();
76  $table->writeFilterToSession();
77  $table->resetOffset();
78  $this->showCmd();
79  }
+ Here is the call graph for this function:

◆ asyncUserAutocompleteCmd()

ilCmiXapiStatementsGUI::asyncUserAutocompleteCmd ( )

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

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

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  }
exit
Definition: login.php:28
static stripSlashes(string $a_str, bool $a_strip_html=true, string $a_allow="")
setSearchFields(array $a_fields)
Set searchable fields.
+ Here is the call graph for this function:

◆ buildTableGUI()

ilCmiXapiStatementsGUI::buildTableGUI ( )
protected

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

References ILIAS\Repository\access().

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

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  }
+ 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.

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

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  }
global $DIC
Definition: feed.php:28
+ Here is the call graph for this function:

◆ getVerbs()

ilCmiXapiStatementsGUI::getVerbs ( )

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

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

236  : ?array
237  {
238  $lrsType = $this->object->getLrsType();
239 
240  //$this->getLrsEndpoint())) . '/api/' . self::ENDPOINT_AGGREGATE_SUFFIX;
241  $defaultLrs = $lrsType->getLrsEndpointStatementsAggregationLink();
242  //$fallbackLrs = $lrsType->getLrsFallbackEndpoint();
243  $defaultBasicAuth = $lrsType->getBasicAuth();
244  //$fallbackBasicAuth = $lrsType->getFallbackBasicAuth();
245  $defaultHeaders = [
246  'X-Experience-API-Version' => '1.0.3',
247  'Authorization' => $defaultBasicAuth,
248  'Cache-Control' => 'no-cache, no-store, must-revalidate'
249  ];
250 // $fallbackHeaders = [
251 // 'X-Experience-API-Version' => '1.0.3',
252 // 'Authorization' => $fallbackBasicAuth,
253 // 'Content-Type' => 'application/json;charset=utf-8',
254 // 'Cache-Control' => 'no-cache, no-store, must-revalidate'
255 // ];
256  $pipeline = json_encode($this->getVerbsPipline());
257 
258  $defaultVerbsUrl = $defaultLrs . "?pipeline=" . urlencode($pipeline);
259 
260  $client = new GuzzleHttp\Client();
261  $req_opts = array(
262  GuzzleHttp\RequestOptions::VERIFY => true,
263  GuzzleHttp\RequestOptions::CONNECT_TIMEOUT => 10,
264  GuzzleHttp\RequestOptions::HTTP_ERRORS => false
265  );
266  //new GuzzleHttp\Psr7\Request('POST', $defaultUrl, $this->defaultHeaders, $body);
267  $defaultVerbsRequest = new GuzzleHttp\Psr7\Request(
268  'GET',
269  $defaultVerbsUrl,
270  $defaultHeaders
271  );
272  $promises = array();
273  $promises['defaultVerbs'] = $client->sendAsync($defaultVerbsRequest, $req_opts);
274  try {
275  $responses = GuzzleHttp\Promise\Utils::settle($promises)->wait();
276  $body = '';
277  ilCmiXapiAbstractRequest::checkResponse($responses['defaultVerbs'], $body, [200]);
278  return json_decode($body, (bool) JSON_OBJECT_AS_ARRAY);
279  } catch (Exception $e) {
280  //$this->log()->error('error:' . $e->getMessage());
281  return null;
282  }
283  return null;
284  }
$client
static checkResponse(array $response, &$body, array $allowedStatus=[200, 204])
+ Here is the call graph for this function:

◆ getVerbsPipline()

ilCmiXapiStatementsGUI::getVerbsPipline ( )

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

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

Referenced by getVerbs().

286  : array
287  {
288  $pipeline = array();
289 
290  // filter activityId
291  $match = array();
292  $match['statement.object.objectType'] = 'Activity';
293  $match['statement.actor.objectType'] = 'Agent';
294 
295  $activityId = array();
296 
297  if ($this->object->getContentType() == ilObjCmiXapi::CONT_TYPE_CMI5 && !$this->object->isMixedContentType()) {
298  // https://github.com/AICC/CMI-5_Spec_Current/blob/quartz/cmi5_spec.md#963-extensions
299  $activityId['statement.context.extensions.https://ilias&46;de/cmi5/activityid'] = $this->object->getActivityId();
300  } else {
301  $activityQuery = [
302  '$regex' => '^' . preg_quote($this->object->getActivityId()) . ''
303  ];
304  $activityId['$or'] = [];
305  $activityId['$or'][] = ['statement.object.id' => $activityQuery];
306  $activityId['$or'][] = ['statement.context.contextActivities.parent.id' => $activityQuery];
307  }
308  $match['$and'] = [];
309  $match['$and'][] = $activityId;
310 
311  $sort = array();
312  $sort['statement.verb.id'] = 1;
313 
314  // project distinct verbs
315  $group = array('_id' => '$statement.verb.id');
316  // $project = array('statement.verb.id' => 1);
317  // project distinct verbs
318 
319  $pipeline[] = array('$match' => $match);
320  $pipeline[] = array('$group' => $group);
321  $pipeline[] = array('$sort' => $sort);
322  //$pipeline[] = array('$project' => $project);
323 
324  return $pipeline;
325  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ initActorFilter()

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

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

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

Referenced by showCmd().

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  }
getFilterItemByPostVar(string $a_post_var)
static getUserIdByLogin(string $a_login)
+ 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.

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

Referenced by showCmd().

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)
+ 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.

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

Referenced by showCmd().

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  }
getFilterItemByPostVar(string $a_post_var)
+ 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.

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

Referenced by showCmd().

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 
216  $request = new ilCmiXapiStatementsReportRequest(
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  }
setData(array $a_data)
global $DIC
Definition: feed.php:28
resetOffset(bool $a_in_determination=false)
setMaxCount(int $a_max_count)
set max.
static getUsersForObject(int $objId, bool $asUsrId=false)
+ 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.

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

Referenced by showCmd().

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  }
getFilterItemByPostVar(string $a_post_var)
+ 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.

References buildTableGUI(), and showCmd().

65  : void
66  {
67  $table = $this->buildTableGUI();
68  $table->resetFilter();
69  $table->resetOffset();
70  $this->showCmd();
71  }
+ Here is the call graph for this function:

◆ showCmd()

ilCmiXapiStatementsGUI::showCmd ( )
protected

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

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

Referenced by applyFilterCmd(), and resetFilterCmd().

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)
initPeriodFilter(ilCmiXapiStatementsReportFilter $filter, ilCmiXapiStatementsTableGUI $table)
initLimitingAndOrdering(ilCmiXapiStatementsReportFilter $filter, ilCmiXapiStatementsTableGUI $table)
+ 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: