19 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);
138 $cmixUser->setSatisfied(
true);
148 if ($progressedScore !==
null && $progressedScore > 0) {
149 $userResult->setScore((
float) ($progressedScore / 100));
158 if (!isset($xapiStatement->actor)) {
162 if (!isset($xapiStatement->verb) || !isset($xapiStatement->verb->id)) {
166 if (!isset($xapiStatement->object) || !isset($xapiStatement->object->id)) {
178 if ($xapiStatement->object->id != $this->object->getActivityId()) {
179 $this->log->debug($xapiStatement->object->id .
" != " . $this->object->getActivityId());
188 return $xapiStatement->verb->id;
193 return $this->resultStatusByXapiVerbMap[$xapiVerb];
198 return isset($this->resultStatusByXapiVerbMap[$xapiVerb]);
203 return $this->resultProgressByXapiVerbMap[$xapiVerb];
208 return isset($this->resultProgressByXapiVerbMap[$xapiVerb]);
213 if (!isset($xapiStatement->result)) {
217 if (!isset($xapiStatement->result->score)) {
221 if (!isset($xapiStatement->result->score->scaled)) {
230 return $xapiStatement->result->score->scaled;
235 if (!isset($xapiStatement->result)) {
239 if (!isset($xapiStatement->result->extensions)) {
243 if (!isset($xapiStatement->result->extensions->{
'https://w3id.org/xapi/cmi5/result/extensions/progress'})) {
246 return (
float) $xapiStatement->result->extensions->{
'https://w3id.org/xapi/cmi5/result/extensions/progress'};
255 $result->setObjId($this->
object->getId());
256 $result->setUsrId($usrId);
265 $this->log->debug(
"isLpModeInterestedInResultStatus: false");
270 $this->log->debug(
"doesNewResultStatusDominateOldOne: false");
275 $this->log->debug(
"needsAvoidFailedEvaluation: false");
288 switch ($resultStatus) {
291 return in_array($this->lpMode, [
299 return in_array($this->lpMode, [
308 return in_array($this->lpMode, [
321 if ($oldResultStatus ==
'') {
325 if (in_array($newResultStatus, [
'passed',
'failed'])) {
329 if (!in_array($oldResultStatus, [
'passed',
'failed'])) {
338 if (!$this->
object->isKeepLpStatusEnabled()) {
342 if ($newResultStatus !=
'failed') {
346 return $oldResultStatus ==
'completed' || $oldResultStatus ==
'passed';
353 $lrsType = $this->
object->getLrsType();
354 $defaultLrs = $lrsType->getLrsEndpoint();
356 $defaultBasicAuth = $lrsType->getBasicAuth();
359 'X-Experience-API-Version' =>
'1.0.3',
360 'Authorization' => $defaultBasicAuth,
361 'Content-Type' =>
'application/json;charset=utf-8',
362 'Cache-Control' =>
'no-cache, no-store, must-revalidate' 372 $satisfiedStatement = $this->
object->getSatisfiedStatement($cmixUser);
373 $satisfiedStatementParams = [];
374 $satisfiedStatementParams[
'statementId'] = $satisfiedStatement[
'id'];
375 $defaultStatementsUrl = $defaultLrs .
"/statements";
381 GuzzleHttp\RequestOptions::CONNECT_TIMEOUT => 10,
382 GuzzleHttp\RequestOptions::HTTP_ERRORS =>
false 387 $defaultSatisfiedStatementUrl,
389 json_encode($satisfiedStatement)
392 $promises[
'defaultSatisfiedStatement'] =
$client->sendAsync($defaultSatisfiedStatementRequest, $req_opts);
394 $responses = GuzzleHttp\Promise\Utils::settle($promises)->wait();
398 $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)
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
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)