3 declare(strict_types=1);
    52         $this->
user = $DIC->user();
    53         $this->
ctrl = $DIC->ctrl();
    66         $this->
ctrl->redirectToURL($launchLink);
    74             $launchLink = $this->
object->getLaunchUrl();
    76             if (preg_match(
"/^(https?:\/\/)/", $this->
object->getLaunchUrl()) == 1) {
    77                 $launchLink = $this->
object->getLaunchUrl();
    79                 $launchLink = implode(
'/', [
    85                 $launchLink .= DIRECTORY_SEPARATOR . $this->
object->getLaunchUrl();
   103         if ($this->
object->isBypassProxyEnabled()) {
   104             $params[
'endpoint'] = urlencode(rtrim($this->
object->getLrsType()->getLrsEndpoint(), 
'/') . 
'/');
   106             $params[
'endpoint'] = urlencode(rtrim(ILIAS_HTTP_PATH . 
'/' . self::XAPI_PROXY_ENDPOINT, 
'/') . 
'/');
   109         if ($this->
object->isAuthFetchUrlEnabled()) {
   112             if ($this->
object->isBypassProxyEnabled()) {
   113                 $params[
'auth'] = urlencode($this->
object->getLrsType()->getBasicAuth());
   115                 $params[
'auth'] = urlencode(
'Basic ' . base64_encode(
   121         $params[
'activity_id'] = urlencode($this->
object->getActivityId());
   122         $params[
'activityId'] = urlencode($this->
object->getActivityId());
   123         $params[
'actor'] = urlencode(json_encode($this->
object->getStatementActor($this->cmixUser)));
   125             $registration = $this->cmixUser->getRegistration();
   127             if ($registration == 
'') {
   130             $params[
'registration'] = $registration;
   142         $link = ILIAS_HTTP_PATH . 
'/xapitoken.php';
   146         return iLUtil::appendUrlParameterString($link, 
"param={$param}");
   155             session_name() => session_id(),
   156             'obj_id' => $this->
object->getId(),
   157             'ref_id' => $this->
object->getRefId(),
   162         return urlencode(base64_encode(openssl_encrypt(
   174             $this->
user->getId(),
   175             $this->
object->getRefId(),
   176             $this->
object->getId(),
   177             $this->
object->getLrsType()->getTypeId()
   184         $this->cmixUser = 
new ilCmiXapiUser($this->
object->getId(), $this->
user->getId(), $this->
object->getPrivacyIdent());
   186         if ($user_ident == 
'' || $user_ident == null) {
   188             $this->cmixUser->setUsrIdent($user_ident);
   193             $this->cmixUser->save();
   205         $language = $this->
user->getLanguage();
   208             "languagePreference" => 
"{$language}",
   209             "audioPreference" => 
"{$audio}"   224         $DIC->language()->loadLanguageModule(
"cmix");
   226         $lrsType = $this->
object->getLrsType();
   227         $defaultLrs = $lrsType->getLrsEndpoint();
   229         $defaultBasicAuth = $lrsType->getBasicAuth();
   232             'X-Experience-API-Version' => 
'1.0.3',
   233             'Authorization' => $defaultBasicAuth,
   234             'Content-Type' => 
'application/json;charset=utf-8',
   235             'Cache-Control' => 
'no-cache, no-store, must-revalidate'   238         $registration = $this->cmixUser->getRegistration();
   240         if ($registration == 
'') {
   244         $activityId = $this->
object->getActivityId();
   248         $defaultAgentProfileUrl = $defaultLrs . 
"/agents/profile";
   249         $profileParams[
'agent'] = json_encode($this->
object->getStatementActor($this->cmixUser));
   250         $profileParams[
'profileId'] = 
'cmi5LearnerPreferences';
   254         $launchDataParams = [];
   255         $defaultStateUrl = $defaultLrs . 
"/activities/state";
   257         $launchDataParams[
'agent'] = json_encode($this->
object->getStatementActor($this->cmixUser));
   258         $launchDataParams[
'activityId'] = $activityId;
   259         $launchDataParams[
'activity_id'] = $activityId;
   260         $launchDataParams[
'registration'] = $registration;
   261         $launchDataParams[
'stateId'] = 
'LMS.LaunchData';
   264         $cmi5LearnerPreferences = json_encode($cmi5LearnerPreferencesObj);
   265         $lang = $cmi5LearnerPreferencesObj[
'languagePreference'];
   268         $oldSession = $tokenObject->getCmi5Session();
   269         $oldSessionLaunchedTimestamp = 
'';
   272         if ($oldSession != null && !empty($oldSession)) {
   273             $oldSessionData = json_decode($tokenObject->getCmi5SessionData());
   274             $oldSessionLaunchedTimestamp = $oldSessionData->launchedTimestamp;
   275             $tokenObject->delete();
   278             $lastStatement = $this->
object->getLastStatement($oldSession);
   280             if (isset($lastStatement[0][
'statement'][
'verb'][
'id']) && $lastStatement[0][
'statement'][
'verb'][
'id'] != 
ilCmiXapiVerbList::getInstance()->getVerbUri(
'terminated')) {
   282                 $start = 
new DateTime($oldSessionLaunchedTimestamp);
   283                 $end = 
new DateTime($lastStatement[0][
'statement'][
'timestamp']);
   284                 $diff = $end->diff($start);
   294         $lpMode = $this->
object->getLPMode();
   301         $tokenObject->setCmi5Session($cmi5_session);
   302         $sessionData = array();
   303         $sessionData[
'cmi5LearnerPreferences'] = $cmi5LearnerPreferencesObj;
   306         $sessionData[
'launchedTimestamp'] = $now->toXapiTimestamp(); 
   307         $tokenObject->setCmi5SessionData(json_encode($sessionData));
   308         $tokenObject->update();
   309         $defaultStatementsUrl = $defaultLrs . 
"/statements";
   312         $launchData = json_encode($this->
object->getLaunchData($DIC->language()->txt(
'cmiexit'), 
$this->cmixUser));
   313         $launchedStatement = $this->
object->getLaunchedStatement($this->cmixUser);
   314         $launchedStatementParams = [];
   315         $launchedStatementParams[
'statementId'] = $launchedStatement[
'id'];
   320             $abandonedStatement = $this->
object->getAbandonedStatement($oldSession, 
$duration, $this->cmixUser);
   321             $abandonedStatementParams = [];
   322             $abandonedStatementParams[
'statementId'] = $abandonedStatement[
'id'];
   327             $satisfiedStatement = $this->
object->getSatisfiedStatement($this->cmixUser);
   328             $satisfiedStatementParams = [];
   329             $satisfiedStatementParams[
'statementId'] = $satisfiedStatement[
'id'];
   335             GuzzleHttp\RequestOptions::CONNECT_TIMEOUT => 10,
   336             GuzzleHttp\RequestOptions::HTTP_ERRORS => 
false   342             $cmi5LearnerPreferences
   346             $defaultLaunchDataUrl,
   352             $defaultLaunchedStatementUrl,
   354             json_encode($launchedStatement)
   359                 $defaultAbandonedStatementUrl,
   361                 json_encode($abandonedStatement)
   367                 $defaultSatisfiedStatementUrl,
   369                 json_encode($satisfiedStatement)
   373         $promises[
'defaultProfile'] = 
$client->sendAsync($defaultProfileRequest, $req_opts);
   374         $promises[
'defaultLaunchData'] = 
$client->sendAsync($defaultLaunchDataRequest, $req_opts);
   375         $promises[
'defaultLaunchedStatement'] = 
$client->sendAsync($defaultLaunchedStatementRequest, $req_opts);
   377             $promises[
'defaultAbandonedStatement'] = 
$client->sendAsync($defaultAbandonedStatementRequest, $req_opts);
   380             $promises[
'defaultSatisfiedStatement'] = 
$client->sendAsync($defaultSatisfiedStatementRequest, $req_opts);
   383             $responses = GuzzleHttp\Promise\Utils::settle($promises)->wait();
   389             $this->
log()->error(
'error:' . $e->getMessage());
   391         return array(
'cmi5_session' => $cmi5_session, 
'token' => $token);
   403             return \ilLoggerFactory::getLogger(
'cmix');
 
static getWebspaceDir(string $mode="filesystem")
get webspace directory 
 
static appendUrlParameterString(string $a_url, string $a_par, bool $xml_style=false)
 
static generateRegistration(ilObjCmiXapi $obj, ilObjUser $user)
 
static getInstanceByToken(string $token)
 
if(! $DIC->user() ->getId()||!ilLTIConsumerAccess::hasCustomProviderCreationAccess()) $params
 
buildLaunchLink(string $token)
 
static fillToken(int $usrId, int $refId, int $objId, int $lrsTypeId=0)
 
const OPENSSL_ENCRYPTION_METHOD
 
const RELATIVE_CONTENT_DIRECTORY_NAMEBASE
 
static generateCMI5Registration(int $objId, int $usrId)
 
static getIdent(int $userIdentMode, ilObjUser $user)
 
__construct(ilObjCmiXapi $object)
 
getLaunchParameters(string $token)
 
buildAuthTokenFetchParam()
 
CMI5preLaunch(string $token)
Prelaunch post cmi5LearnerPreference (agent profile) post LMS.LaunchData. 
 
const XAPI_PROXY_ENDPOINT
 
static _isAnonymous(int $usr_id)
 
static guidv4(?string $data=null)
 
const LP_MODE_DEACTIVATED
 
static buildQuery(array $params, $encoding=PHP_QUERY_RFC3986)
 
getCmi5LearnerPreferences()
 
static checkResponse(array $response, &$body, array $allowedStatus=[200, 204])
 
static dateIntervalToISO860Duration(\DateInterval $d)
 
static _updateStatus(int $a_obj_id, int $a_usr_id, ?object $a_obj=null, bool $a_percentage=false, bool $a_force_raise=false)