3 declare(strict_types=1);
64 $this->lpMode = $objLP->getCurrentMode();
71 # "handle statement:\n".json_encode($xapiStatement, JSON_PRETTY_PRINT) 75 $xapiStatement = json_decode(json_encode($xapiStatement));
78 if ($cmixUser != null) {
81 $this->log->debug(
'update lp for object (' . $this->
object->getId() .
')');
93 if (isset($xapiStatement->actor->account->name)) {
96 $xapiStatement->actor->account->name
102 str_replace(
'mailto:',
'', $xapiStatement->actor->mbox)
121 $oldResultStatus = $userResult->getStatus();
126 $this->log->debug(
"isResultStatusToBeReplaced: true");
127 $userResult->setStatus($newResultStatus);
132 $this->log->debug(
"Score: " . $xapiScore);
133 $userResult->setScore((
float) $xapiScore);
142 if ($cmixUser != null) {
143 $cmixUser->setSatisfied(
true);
154 if ($progressedScore !== null && $progressedScore > 0) {
155 $userResult->setScore((
float) ($progressedScore / 100));
164 if (!isset($xapiStatement->actor)) {
168 if (!isset($xapiStatement->verb) || !isset($xapiStatement->verb->id)) {
172 if (!isset($xapiStatement->object) || !isset($xapiStatement->object->id)) {
184 if ($xapiStatement->object->id != $this->object->getActivityId()) {
185 $this->log->debug($xapiStatement->object->id .
" != " . $this->object->getActivityId());
194 return $xapiStatement->verb->id;
199 return $this->resultStatusByXapiVerbMap[$xapiVerb];
204 return isset($this->resultStatusByXapiVerbMap[$xapiVerb]);
209 return $this->resultProgressByXapiVerbMap[$xapiVerb];
214 return isset($this->resultProgressByXapiVerbMap[$xapiVerb]);
219 if (!isset($xapiStatement->result)) {
223 if (!isset($xapiStatement->result->score)) {
227 if (!isset($xapiStatement->result->score->scaled)) {
236 return $xapiStatement->result->score->scaled;
241 if (!isset($xapiStatement->result)) {
245 if (!isset($xapiStatement->result->extensions)) {
249 if (!isset($xapiStatement->result->extensions->{
'https://w3id.org/xapi/cmi5/result/extensions/progress'})) {
252 return (
float) $xapiStatement->result->extensions->{
'https://w3id.org/xapi/cmi5/result/extensions/progress'};
261 $result->setObjId($this->
object->getId());
262 $result->setUsrId($usrId);
271 $this->log->debug(
"isLpModeInterestedInResultStatus: false");
276 $this->log->debug(
"doesNewResultStatusDominateOldOne: false");
281 $this->log->debug(
"needsAvoidFailedEvaluation: false");
294 switch ($resultStatus) {
297 return in_array($this->lpMode, [
305 return in_array($this->lpMode, [
314 return in_array($this->lpMode, [
327 if ($oldResultStatus ==
'') {
331 if (in_array($newResultStatus, [
'passed',
'failed'])) {
335 if (!in_array($oldResultStatus, [
'passed',
'failed'])) {
344 if (!$this->
object->isKeepLpStatusEnabled()) {
348 if ($newResultStatus !=
'failed') {
352 return $oldResultStatus ==
'completed' || $oldResultStatus ==
'passed';
359 $lrsType = $this->
object->getLrsType();
360 $defaultLrs = $lrsType->getLrsEndpoint();
362 $defaultBasicAuth = $lrsType->getBasicAuth();
365 'X-Experience-API-Version' =>
'1.0.3',
366 'Authorization' => $defaultBasicAuth,
367 'Content-Type' =>
'application/json;charset=utf-8',
368 'Cache-Control' =>
'no-cache, no-store, must-revalidate' 378 $satisfiedStatement = $this->
object->getSatisfiedStatement($cmixUser);
379 $satisfiedStatementParams = [];
380 $satisfiedStatementParams[
'statementId'] = $satisfiedStatement[
'id'];
381 $defaultStatementsUrl = $defaultLrs .
"/statements";
387 GuzzleHttp\RequestOptions::CONNECT_TIMEOUT => 10,
388 GuzzleHttp\RequestOptions::HTTP_ERRORS =>
false 393 $defaultSatisfiedStatementUrl,
395 json_encode($satisfiedStatement)
398 $promises[
'defaultSatisfiedStatement'] =
$client->sendAsync($defaultSatisfiedStatementRequest, $req_opts);
400 $responses = GuzzleHttp\Promise\Utils::settle($promises)->wait();
404 $this->log->error(
'error:' . $e->getMessage());
const LP_MODE_CMIX_COMPLETED
const LP_MODE_CMIX_COMPLETED_OR_PASSED
getXapiVerb(object $xapiStatement)
array $resultProgressByXapiVerbMap
isResultStatusToBeReplaced(string $oldResultStatus, string $newResultStatus)
isLpModeInterestedInResultStatus(string $resultStatus, ?bool $deactivated=true)
const LP_MODE_CMIX_PASSED_WITH_FAILED
hasResultProgressRelevantXapiVerb(string $xapiVerb)
isValidXapiStatement(object $xapiStatement)
const LP_MODE_CMIX_PASSED
doesNewResultStatusDominateOldOne(string $oldResultStatus, string $newResultStatus)
evaluateStatement(object $xapiStatement, int $usrId)
getResultStatusForXapiVerb(string $xapiVerb)
sendSatisfiedStatement(ilCmiXapiUser $cmixUser)
__construct(ilLogger $log, ilObject $object)
ilXapiStatementEvaluation constructor.
static getInstanceByObjIdAndUsrId(int $objId, int $usrId)
getProgressedScore(object $xapiStatement)
const LP_MODE_CMIX_COMPL_WITH_FAILED
array $resultStatusByXapiVerbMap
http://adlnet.gov/expapi/verbs/satisfied: should never be sent by AU https://github.com/AICC/CMI-5_Spec_Current/blob/quartz/cmi5_spec.md#939-satisfied
needsAvoidFailedEvaluation(string $oldResultStatus, string $newResultStatus)
hasResultStatusRelevantXapiVerb(string $xapiVerb)
getCmixUser(object $xapiStatement)
static getInstanceByObjectIdAndUsrIdent(int $objId, string $usrIdent)
static getEmptyInstance()
getXapiScore(object $xapiStatement)
hasXapiScore(object $xapiStatement)
evaluateReport(ilCmiXapiStatementsReport $report)
const LP_MODE_DEACTIVATED
const LP_MODE_CMIX_COMPL_OR_PASSED_WITH_FAILED
getResultProgressForXapiVerb(string $xapiVerb)
static buildQuery(array $params, $encoding=PHP_QUERY_RFC3986)
getUserResult(int $usrId)
static getInstance(int $obj_id)
isValidObject(object $xapiStatement)
static checkResponse(array $response, &$body, array $allowedStatus=[200, 204])
static _updateStatus(int $a_obj_id, int $a_usr_id, ?object $a_obj=null, bool $a_percentage=false, bool $a_force_raise=false)