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));
80 $this->log->debug(
'update lp for object (' . $this->
object->getId() .
')');
93 $xapiStatement->actor->account->name
98 str_replace(
'mailto:',
'', $xapiStatement->actor->mbox)
117 $oldResultStatus = $userResult->getStatus();
122 $this->log->debug(
"isResultStatusToBeReplaced: true");
123 $userResult->setStatus($newResultStatus);
128 $this->log->debug(
"Score: " . $xapiScore);
129 $userResult->setScore((
float) $xapiScore);
139 if (!$cmixUser->getSatisfied()) {
140 $cmixUser->setSatisfied(
true);
151 if ($progressedScore !== null && $progressedScore > 0) {
152 $userResult->setScore((
float) ($progressedScore / 100));
161 if (!isset($xapiStatement->actor)) {
165 if (!isset($xapiStatement->verb) || !isset($xapiStatement->verb->id)) {
169 if (!isset($xapiStatement->object) || !isset($xapiStatement->object->id)) {
181 if ($xapiStatement->object->id != $this->object->getActivityId()) {
182 $this->log->debug($xapiStatement->object->id .
" != " . $this->object->getActivityId());
191 return $xapiStatement->verb->id;
196 return $this->resultStatusByXapiVerbMap[$xapiVerb];
201 return isset($this->resultStatusByXapiVerbMap[$xapiVerb]);
206 return $this->resultProgressByXapiVerbMap[$xapiVerb];
211 return isset($this->resultProgressByXapiVerbMap[$xapiVerb]);
216 if (!isset($xapiStatement->result)) {
220 if (!isset($xapiStatement->result->score)) {
224 if (!isset($xapiStatement->result->score->scaled)) {
233 return $xapiStatement->result->score->scaled;
238 if (!isset($xapiStatement->result)) {
242 if (!isset($xapiStatement->result->extensions)) {
246 if (!isset($xapiStatement->result->extensions->{
'https://w3id.org/xapi/cmi5/result/extensions/progress'})) {
249 return (
float) $xapiStatement->result->extensions->{
'https://w3id.org/xapi/cmi5/result/extensions/progress'};
258 $result->setObjId($this->
object->getId());
259 $result->setUsrId($usrId);
268 $this->log->debug(
"isLpModeInterestedInResultStatus: false");
273 $this->log->debug(
"doesNewResultStatusDominateOldOne: false");
278 $this->log->debug(
"needsAvoidFailedEvaluation: false");
291 switch ($resultStatus) {
294 return in_array($this->lpMode, [
302 return in_array($this->lpMode, [
311 return in_array($this->lpMode, [
324 if ($oldResultStatus ==
'') {
328 if (in_array($newResultStatus, [
'passed',
'failed'])) {
332 if (!in_array($oldResultStatus, [
'passed',
'failed'])) {
341 if (!$this->
object->isKeepLpStatusEnabled()) {
345 if ($newResultStatus !=
'failed') {
349 return $oldResultStatus ==
'completed' || $oldResultStatus ==
'passed';
356 $lrsType = $this->
object->getLrsType();
357 $defaultLrs = $lrsType->getLrsEndpoint();
359 $defaultBasicAuth = $lrsType->getBasicAuth();
362 'X-Experience-API-Version' =>
'1.0.3',
363 'Authorization' => $defaultBasicAuth,
364 'Content-Type' =>
'application/json;charset=utf-8',
365 'Cache-Control' =>
'no-cache, no-store, must-revalidate' 375 $satisfiedStatement = $this->
object->getSatisfiedStatement($cmixUser);
376 $satisfiedStatementParams = [];
377 $satisfiedStatementParams[
'statementId'] = $satisfiedStatement[
'id'];
378 $defaultStatementsUrl = $defaultLrs .
"/statements";
383 GuzzleHttp\RequestOptions::VERIFY =>
true,
384 GuzzleHttp\RequestOptions::CONNECT_TIMEOUT => 10,
385 GuzzleHttp\RequestOptions::HTTP_ERRORS =>
false 390 $defaultSatisfiedStatementUrl,
392 json_encode($satisfiedStatement)
395 $promises[
'defaultSatisfiedStatement'] =
$client->sendAsync($defaultSatisfiedStatementRequest, $req_opts);
397 $responses = GuzzleHttp\Promise\Utils::settle($promises)->wait();
401 $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)