ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
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

 $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.

References $object, and ilCmiXapiAccess\getInstance().

31  {
32  $this->object = $object;
33 
34  $this->access = ilCmiXapiAccess::getInstance($this->object);
35  }
static getInstance(ilObjCmiXapi $object)
+ Here is the call graph for this function:

Member Function Documentation

◆ applyFilterCmd()

ilCmiXapiStatementsGUI::applyFilterCmd ( )
protected

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

References buildTableGUI(), and showCmd().

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

◆ asyncUserAutocompleteCmd()

ilCmiXapiStatementsGUI::asyncUserAutocompleteCmd ( )

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

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

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  }
exit
Definition: login.php:29
$result
static stripSlashes($a_str, $a_strip_html=true, $a_allow="")
strip slashes if magic qoutes is enabled
setSearchFields($a_fields)
Set searchable fields.
+ Here is the call graph for this function:

◆ buildTableGUI()

ilCmiXapiStatementsGUI::buildTableGUI ( )
protected
Returns
ilCmiXapiStatementsTableGUI

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

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

209  {
210  $isMultiActorReport = $this->access->hasOutcomesAccess();
211  $table = new ilCmiXapiStatementsTableGUI($this, 'show', $isMultiActorReport);
212  $table->setFilterCommand('applyFilter');
213  $table->setResetCommand('resetFilter');
214  return $table;
215  }
+ Here is the caller graph for this function:

◆ executeCommand()

ilCmiXapiStatementsGUI::executeCommand ( )
Exceptions
ilCmiXapiException

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

References $DIC.

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  }
$DIC
Definition: xapitoken.php:46

◆ getVerbs()

ilCmiXapiStatementsGUI::getVerbs ( )

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

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

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

◆ getVerbsPipline()

ilCmiXapiStatementsGUI::getVerbsPipline ( )

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

References $DIC, and ilObjCmiXapi\CONT_TYPE_CMI5.

Referenced by getVerbs().

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

References $DIC, ilTable2GUI\getFilterItemByPostVar(), ilObjUser\getUserIdByLogin(), and ilCmiXapiStatementsReportFilter\setActor().

Referenced by showCmd().

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)
$DIC
Definition: xapitoken.php:46
+ 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.

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

Referenced by showCmd().

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

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

Referenced by showCmd().

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

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

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

Referenced by showCmd().

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  }
180  else {
181  $usrId = $DIC->user()->getId();
182  if (!ilCmiXapiUser::getUsersForObject($this->object->getId(),$usrId)) {
183  $table->setData(array());
184  $table->setMaxCount(0);
185  $table->resetOffset();
186  return;
187  }
188  }
189  $linkBuilder = new ilCmiXapiStatementsReportLinkBuilder(
190  $this->object,
191  $this->object->getLrsType()->getLrsEndpointStatementsAggregationLink(),
192  $filter
193  );
194 
195  $request = new ilCmiXapiStatementsReportRequest(
196  $this->object->getLrsType()->getBasicAuth(),
197  $linkBuilder
198  );
199  $statementsReport = $request->queryReport($this->object);
200  $data = $statementsReport->getTableData();
201  $table->setData($data);
202  $table->setMaxCount($statementsReport->getMaxCount());
203  }
static getUsersForObject($objId, $asUsrId=false)
$data
Definition: storeScorm.php:23
resetOffset($a_in_determination=false)
Reset offset.
$DIC
Definition: xapitoken.php:46
setMaxCount($a_max_count)
set max.
+ 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.

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

Referenced by showCmd().

128  {
129  $verb = urldecode($table->getFilterItemByPostVar('verb')->getValue());
130 
131  if (ilCmiXapiVerbList::getInstance()->isValidVerb($verb)) {
132  $filter->setVerb($verb);
133  }
134  }
getFilterItemByPostVar($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 55 of file class.ilCmiXapiStatementsGUI.php.

References buildTableGUI(), and showCmd().

56  {
57  $table = $this->buildTableGUI();
58  $table->resetFilter();
59  $table->resetOffset();
60  $this->showCmd();
61  }
+ Here is the call graph for this function:

◆ showCmd()

ilCmiXapiStatementsGUI::showCmd ( )
protected

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

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

Referenced by applyFilterCmd(), and resetFilterCmd().

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)
initPeriodFilter(ilCmiXapiStatementsReportFilter $filter, ilCmiXapiStatementsTableGUI $table)
initLimitingAndOrdering(ilCmiXapiStatementsReportFilter $filter, ilCmiXapiStatementsTableGUI $table)
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
$DIC
Definition: xapitoken.php:46
+ 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: