232        $this->lrsTypeId = 0;
 
  238        $this->activityId = 
'';
 
  240        $this->publisherId = 
'';
 
  242        $this->instructions = 
'';
 
  244        $this->launchUrl = 
'';
 
  245        $this->launchParameters = 
'';
 
  247        $this->entitlementKey = 
'';
 
  249        $this->authFetchUrlEnabled = 0;
 
  254        $this->switchToReviewEnabled = 1;
 
  257        $this->keepLpStatusEnabled = 1;
 
  261        $this->userPrivacyComment = 
'';
 
  263        $this->currentCmixUser = 
null;
 
  265        $this->statementsReportEnabled = 0;
 
  267        $this->xmlManifest = 
'';
 
  270        $this->bypassProxyEnabled = 
false;
 
  276    public static function getInstance($a_id = 0, $a_reference = 
true)
 
  278        return new self($a_id, $a_reference);
 
  283        $this->type = 
"cmix";
 
  493        return $olp->getCurrentMode();
 
  577        return ucfirst($this->launchMode);
 
  633        return $this->masteryScore * 100;
 
  641        $this->masteryScore = $masteryScorePercent / 100;
 
 1005        $query = 
"SELECT * FROM " . self::DB_TABLE_NAME . 
" WHERE obj_id = %s";
 
 1008        while ($row = 
$DIC->database()->fetchAssoc(
$res)) {
 
 1009            if ($row[
'lrs_type_id']) {
 
 1041            $this->
setFailed((
bool) $row[
'failed']);
 
 1043            $this->
setPassed((
bool) $row[
'passed']);
 
 1082        $DIC->database()->replace(self::DB_TABLE_NAME, [
 
 1083            'obj_id' => [
'integer', $this->
getId()]
 
 1093            'moveon' => [
'text', $this->
getMoveOn()],
 
 1106            'version' => [
'integer', $this->
getVersion()],
 
 1116            'achieved' => [
'integer', (
int)$this->
getAchieved()],
 
 1117            'answered' => [
'integer', (
int)$this->
getAnswered()],
 
 1118            'completed' => [
'integer', (
int)$this->
getCompleted()],
 
 1119            'failed' => [
'integer', (
int)$this->
getFailed()],
 
 1121            'passed' => [
'integer', (
int)$this->
getPassed()],
 
 1123            'satisfied' => [
'integer', (
int)$this->
getSatisfied()],
 
 1125            'hide_data' => [
'integer', (
int)$this->
getHideData()],
 
 1126            'c_timestamp' => [
'integer', (
int)$this->
getTimestamp()],
 
 1127            'duration' => [
'integer', (
int)$this->
getDuration()],
 
 1136        if ($this->ref_id) {
 
 1137            include_once 
"./Services/Object/classes/class.ilObjectActivation.php";
 
 1139            switch ($activation[
"timing_type"]) {
 
 1156        if ($this->ref_id) {
 
 1157            include_once 
"./Services/Object/classes/class.ilObjectActivation.php";
 
 1170            $item->update($this->ref_id);
 
 1182                        SET privacy_ident = %s,  
 1197                no_substatements = %s 
 1198            WHERE lrs_type_id = %s 
 1201        $DIC->database()->manipulateF(
 
 1250                        SET bypass_proxy = %s 
 1251                        WHERE lrs_type_id = %s 
 1254        $DIC->database()->manipulateF(
 
 1256            [
'integer', 
'integer'],
 
 1266                        SELECT DISTINCT s.obj_id FROM " . self::DB_TABLE_NAME . 
" s 
 1267                        INNER JOIN " . self::DB_USERS_TABLE_NAME . 
" u ON u.obj_id = s.obj_id 
 1268                        WHERE bypass_proxy = %s 
 1271        $res = 
$DIC->database()->queryF(
$query, array(
'integer'), array(1));
 
 1275        while ($row = 
$DIC->database()->fetchAssoc(
$res)) {
 
 1276            $objects[] = $row[
'obj_id'];
 
 1341        $this->_highscore_enabled = (bool) $a_enabled;
 
 1361        $this->_highscore_achieved_ts = (bool) $a_achieved_ts;
 
 1381        $this->_highscore_percentage = (bool) $a_percentage;
 
 1401        $this->_highscore_wtime = (bool) $a_wtime;
 
 1421        $this->_highscore_own_table = (bool) $a_own_table;
 
 1441        $this->_highscore_top_table = (bool) $a_top_table;
 
 1462        $this->_highscore_top_num = (int) $a_top_num;
 
 1475        $retval = $a_retval;
 
 1476        if ((
int) $this->_highscore_top_num != 0) {
 
 1534            'obj_id' => $this->
getId(),
 
 1590        protected function doCloneObject($new_obj, $a_target_id, $a_copy_id = 
null, $a_omit_tree = 
false)
 
 1604        $new_obj->setMoveOn($this->
getMoveOn());
 
 1630        $new_obj->setFailed($this->
getFailed());
 
 1632        $new_obj->setPassed($this->
getPassed());
 
 1644                        $dirUtil->ensureCreatedObjectDirectory();
 
 1645                        $newDir = implode(DIRECTORY_SEPARATOR, [\
ilUtil::getWebspaceDir(), $dirUtil->getWebDataDirRelativeObjectDirectory()]);
 
 1647                        $thisDir = implode(DIRECTORY_SEPARATOR, [\
ilUtil::getWebspaceDir(), $dirUtil->getWebDataDirRelativeObjectDirectory()]);
 
 1658        $query = 
"DELETE FROM " . self::DB_TABLE_NAME . 
" WHERE obj_id = " . 
$ilDB->quote($this->
getId(), 
'integer');
 
 1662        require_once(
"./Services/History/classes/class.ilHistory.php");
 
 1667                $thisDir = implode(DIRECTORY_SEPARATOR, [\
ilUtil::getWebspaceDir(), $dirUtil->getWebDataDirRelativeObjectDirectory()]);
 
 1668        if (is_dir($thisDir)) {
 
 1676                $query = 
"DELETE FROM " . self::DB_RESULTS_TABLE_NAME .
 
 1677                                "WHERE obj_id = " . 
$ilDB->quote($this->
getId(), 
'integer') . 
" ";
 
 1686            "SELECT DISTINCT registration FROM " . self::DB_USERS_TABLE_NAME .
" WHERE obj_id = %s",
 
 1688            array($this->
getId())
 
 1691        while ($row = 
$DIC->database()->fetchAssoc(
$res)) {
 
 1692            $ret[] = $row[
'registration'];
 
 1700        assert(strlen(
$data) == 16);
 
 1708        return vsprintf(
'%s%s-%s-%s-%s-%s%s%s', str_split(bin2hex(
$data), 4));
 
 1714        if (
null === $this->currentCmixUser)
 
 1716            $this->currentCmixUser = 
new ilCmiXapiUser($this->
getId(), $DIC->user()->getId(), $this->getPrivacyIdent());
 
 1723        if (
null === $cmixUser)
 
 1735        if (
null === $cmixUser)
 
 1748            if ($cmixUser->getSatisfied() && $this->isSwitchToReviewEnabled()) {
 
 1755            "launchMethod" => 
"OwnWindow",
 
 1759        if ($lmsLaunchMethod === 
"ownWin") {
 
 1760            include_once(
'./Services/Link/classes/class.ilLink.php');
 
 1765            $ctxTemplate[
'returnURL'] = $href;
 
 1768            $ctxTemplate[
'returnURL'] = 
ILIAS_HTTP_PATH.
"/Modules/CmiXapi/xapiexit.php?lang={$lang}";
 
 1777            $ctxTemplate[
'entitlementKey'] = array(
"courseStructure" => $this->
getEntitlementKey());
 
 1779        return $ctxTemplate;
 
 1784        if (
null === $cmixUser)
 
 1791            if ($cmixUser->getSatisfied() && $this->isSwitchToReviewEnabled()) {
 
 1796        $extensions[
'https://w3id.org/xapi/cmi5/context/extensions/launchmode'] =  
$launchMode;
 
 1798            $extensions[
'https://w3id.org/xapi/cmi5/context/extensions/moveon'] = $this->
getLMSMoveOn();
 
 1801            $extensions[
'https://w3id.org/xapi/cmi5/context/extensions/launchparameters'] = $this->
getLaunchParameters();
 
 1804            $extensions[
'https://w3id.org/xapi/cmi5/context/extensions/masteryscore'] = $this->
getMasteryScore();
 
 1806        $contextTemplate = array(
 
 1808            "extensions" => $extensions
 
 1810        return $contextTemplate;
 
 1818        if (
null === $cmixUser)
 
 1826        $registration = $cmixUser->getRegistration();
 
 1829        $statement = array (
 
 1838                'extensions' => $extensions,
 
 1839                'registration' => $registration,
 
 1840                'contextActivities' => $contextActivities
 
 1853        if (
null === $cmixUser)
 
 1857        $user = 
new ilObjUser($cmixUser->getUsrId()); 
 
 1860            $this->
log()->error(
'error: no name in cmixuser');
 
 1861            $name = 
'UNDEFINED';
 
 1863        $homePage = ($this->anonymousHomePage == 
true) ? self::ANONYMOUS_HOMEPAGE : self::iliasUrl();
 
 1867                'objectType' => 
'Agent',
 
 1869                    'homePage' => $homePage,
 
 1870                    'name' => $cmixUser->getUsrIdent()
 
 1875                $actor[
'name'] = 
$name;
 
 1881                'objectType' => 
'Agent',
 
 1882                'mbox' => 
'mailto:'.$cmixUser->getUsrIdent()
 
 1886                $actor[
'name'] = 
$name;
 
 1897        if (
null === $cmixUser)
 
 1901        $extensions = array (
 
 1902            'https://w3id.org/xapi/cmi5/context/extensions/sessionid' => $this->
getSessionId($cmixUser),
 
 1903            'https://ilias.de/cmi5/activityid' => $this->
getActivityId()
 
 1919        $ctxActivities = array(
 
 1922                "objectType" => 
"Activity",
 
 1923                "id" => 
"{$publisherId}",
 
 1940                    "id" => 
"https://w3id.org/xapi/cmi5/context/categories/cmi5",
 
 1941                    "objectType" => 
"Activity" 
 1945        return $ctxActivities;
 
 1971        if (
null === $cmixUser) {
 
 1977            if ($cmixUser->getSatisfied() && $this->isSwitchToReviewEnabled()) {
 
 1982        $statement = $this->
getStatement(
'launched', $cmixUser);
 
 1983        $statement[
'context'][
'extensions'][
'https://w3id.org/xapi/cmi5/context/extensions/launchmode'] = 
$launchMode;
 
 1985            $statement[
'context'][
'extensions'][
'https://w3id.org/xapi/cmi5/context/extensions/moveon'] = $this->
getLMSMoveOn();
 
 1988            $statement[
'context'][
'extensions'][
'https://w3id.org/xapi/cmi5/context/extensions/launchparameters'] = $this->
getLaunchParameters();
 
 1991            $statement[
'context'][
'extensions'][
'https://w3id.org/xapi/cmi5/context/extensions/masteryscore'] = $this->
getMasteryScore();
 
 1998        if (
null === $cmixUser)
 
 2002        $statement = $this->
getStatement(
'abandoned',$cmixUser);
 
 2004        $statement[
'context'][
'extensions'][
'https://w3id.org/xapi/cmi5/context/extensions/sessionid'] = $sessionId;
 
 2005        $statement[
'result'] = array(
 
 2013        if (
null === $cmixUser)
 
 2017        $statement = $this->
getStatement(
'satisfied', $cmixUser);
 
 2020        $type = 
"https://w3id.org/xapi/cmi5/activitytype/course";
 
 2021        $statement[
'object'][
'definition'][
'type'] = 
$type;
 
 2022        $statement[
'context'][
'contextActivities'][
'grouping'][0][
'definition'][
'type'] = 
$type;
 
 2035        $defaultLrs = 
$lrsType->getLrsEndpointStatementsAggregationLink();
 
 2037        $defaultBasicAuth = 
$lrsType->getBasicAuth();
 
 2040            'X-Experience-API-Version' => 
'1.0.3',
 
 2041            'Authorization' => $defaultBasicAuth,
 
 2042            'Cache-Control' => 
'no-cache, no-store, must-revalidate' 
 2053        $defaultLastStatementUrl = $defaultLrs . 
"?pipeline=" . urlencode($pipeline);
 
 2054        $client = 
new GuzzleHttp\Client();
 
 2056            GuzzleHttp\RequestOptions::VERIFY => 
true,
 
 2057            GuzzleHttp\RequestOptions::CONNECT_TIMEOUT => 10,
 
 2058            GuzzleHttp\RequestOptions::HTTP_ERRORS => 
false 
 2060        $defaultLastStatementRequest = 
new GuzzleHttp\Psr7\Request(
 
 2062            $defaultLastStatementUrl,
 
 2065        $promises = array();
 
 2066        $promises[
'defaultLastStatement'] = 
$client->sendAsync($defaultLastStatementRequest, $req_opts);
 
 2069            $responses = GuzzleHttp\Promise\Utils::settle($promises)->wait();
 
 2072            return json_decode($body,JSON_OBJECT_AS_ARRAY);
 
 2076            $this->
log()->error(
'error:' . $e->getMessage());
 
 2084        $pipeline = array();
 
 2088        $match[
'statement.object.objectType'] = 
'Activity';
 
 2089        $match[
'statement.actor.objectType'] = 
'Agent';
 
 2104            $activityId[
'$or'][] = [
'statement.object.id' => $activityQuery];
 
 2105            $activityId[
'$or'][] = [
'statement.context.contextActivities.parent.id' => $activityQuery];
 
 2106            $activityId[
'$or'][] = [
'statement.context.contextActivities.grouping.id' => $activityQuery];
 
 2109        $sessionId = array();
 
 2110        $sessionId[
'statement.context.extensions.https://w3id&46;org/xapi/cmi5/context/extensions/sessionid'] = 
$sess;
 
 2111        $match[
'$and'] = array();
 
 2113        $match[
'$and'][] = $sessionId;
 
 2114        $sort = array(
'statement.timestamp' => -1);
 
 2115        $project = array(
'statement.timestamp' => 1, 
'statement.verb.id' => 1);
 
 2116        $pipeline[] = array(
'$match' => $match);
 
 2117        $pipeline[] = array(
'$sort' => $sort);
 
 2118        $pipeline[] = array(
'$limit' => 1);
 
 2119        $pipeline[] = array(
'$project' => $project);
 
 2125        $regex = 
'/^(https?\:\/\/[^\/]+).*/';
 
 2126        preg_match($regex, 
$GLOBALS[
'DIC']->
http()->request()->getUri(), $request_parts);
 
 2127        return $request_parts[1];
 
 2130    public static function log() {
 
 2136            return \ilLoggerFactory::getLogger(
'cmix');
 
if(!defined('PATH_SEPARATOR')) $GLOBALS['_PEAR_default_error_mode']
An exception for terminatinating execution or to throw for unit testing.
static checkResponse($response, &$body, $allowedStatus=[200, 204])
static getCmi5SessionByUsrIdAndObjIdAndRefId(int $usrId, int $objId, $refId=null)
const MOVEON_COMPLETED_OR_PASSED
const MOVEON_NOT_APPLICABLE
static getName($userNameMode, ilObjUser $user)
static _removeEntriesForObject($a_obj_id)
remove all history entries for an object
const LP_MODE_CMIX_COMPLETED_OR_PASSED
const LP_MODE_CMIX_COMPL_WITH_FAILED
const LP_MODE_CMIX_PASSED
const LP_MODE_CMIX_COMPL_OR_PASSED_WITH_FAILED
const LP_MODE_DEACTIVATED
const LP_MODE_CMIX_COMPLETED
const LP_MODE_CMIX_PASSED_WITH_FAILED
static _getStaticLink( $a_ref_id, $a_type='', $a_fallback_goto=true, $append="")
Get static link.
setMasteryScore($masteryScore)
setDuration(bool $duration)
setBypassProxyEnabled(bool $bypassProxyEnabled)
doCloneObject($new_obj, $a_target_id, $a_copy_id=null, $a_omit_tree=false)
Clone object.
setOnlyMoveon(bool $only_moveon)
setActivityId($activityId)
getHighscoreWTime()
Gets if the column with the workingtime should be shown.
setPublisherId($publisherId)
setHideData(bool $hide_data)
getLastStatementPipline($sess)
const DB_RESULTS_TABLE_NAME
setPrivacyIdent($userIdent)
getActivationStartingTime()
getLaunchedStatement($cmixUser=null)
setMasteryScorePercent($masteryScorePercent)
getLastStatement($sess)
get latest statement from session
setStatementsReportEnabled($statementsReportEnabled)
const PRIVACY_NAME_FULLNAME
setSourceType($sourceType)
getHighscoreTopNum($a_retval=10)
Gets the number of entries which are to be shown in the top-rankings table.
setLaunchMode($launchMode)
getLaunchData($cmixUser=null, $lang='en')
LMS.LaunchData.
getActivationEndingTime()
const LAUNCH_METHOD_NEW_WIN
const PRIVACY_NAME_FIRSTNAME
setNoSubstatements(bool $no_substatements)
getActivationVisibility()
static getObjectsHavingBypassProxyEnabledAndRegisteredUsers()
setLaunchMethod($launchMethod)
const PRIVACY_IDENT_IL_UUID_USER_ID
setHighscoreEnabled($a_enabled)
Sets if the highscore feature should be enabled.
setHighscoreTopNum($a_top_num)
Sets the number of entries which are to be shown in the top-rankings table.
__construct($a_id=0, $a_reference=true)
ilObjCmiXapi constructor.
const HIGHSCORE_SHOW_ALL_TABLES
getHighscorePercentage()
Gets if the percentage column should be shown.
getStatementExtensions($cmixUser=null)
Minimal extensions.
getSatisfiedStatement($cmixUser=null)
setActivationLimited($activationLimited)
setHighscoreTopTable($a_top_table)
Sets if the top-rankings table should be shown.
getSwitchToReviewEnabled()
const HIGHSCORE_SHOW_TOP_TABLE
setSatisfied(bool $satisfied)
setTimestamp(bool $timestamp)
getHighscoreAchievedTS()
Returns if date and time of the scores achievement should be displayed.
setTerminated(bool $terminated)
const PRIVACY_IDENT_IL_UUID_RANDOM
const DB_USERS_TABLE_NAME
static guidv4($data=null)
setActivationStartingTime($activationStartingTime)
loadRepositoryActivationSettings()
saveRepositoryActivationSettings()
setAnswered(bool $answered)
getStatementActor($cmixUser=null)
statement actor
setActivationVisibility($activationVisibility)
setXmlManifest($xmlManifest)
getHighscoreTopTable()
Gets, if the top-rankings table should be shown.
setAuthFetchUrlEnabled($authFetchUrlEnabled)
setUserPrivacyComment($userPrivacyComment)
setHighscoreOwnTable($a_own_table)
Sets if the table with the own ranking should be shown.
const PRIVACY_IDENT_IL_UUID_LOGIN
setAchieved(bool $achieved)
const PRIVACY_IDENT_REAL_EMAIL
setHighscoreAchievedTS($a_achieved_ts)
Sets if the date and time of the scores achievement should be displayed.
const PRIVACY_IDENT_IL_UUID_SHA256
setProgressed(bool $progressed)
setInstructions($instructions)
const PRIVACY_IDENT_IL_UUID_EXT_ACCOUNT
setHighscorePercentage($a_percentage)
Sets if the percentages of the scores pass should be shown.
const PRIVACY_NAME_LASTNAME
getStatementContextActivities()
Minimal statementActivities.
isStatementsReportEnabled()
getLaunchedContextTemplate($cmixUser=null)
getAbandonedStatement($sessionId, $duration, $cmixUser=null)
setInitialized(bool $initialized)
getHighscoreOwnTable()
Gets if the own rankings table should be shown.
setCompleted(bool $completed)
static getInstance($a_id=0, $a_reference=true)
setLaunchParameters($launchParameters)
const HIGHSCORE_SHOW_OWN_TABLE
$activationLimited
repository object activation settings (handled by ilObject)
getHighscoreEnabled()
Gets the setting which determines if the highscore feature is enabled.
getSessionId($cmixUser=null)
setEntitlementKey($entitlementKey)
setActivationEndingTime($activationEndingTime)
const LAUNCH_METHOD_IFRAME
getStatement(string $verb, $cmixUser=null)
blueprint statement
setPrivacyName($userName)
setHighscoreWTime($a_wtime)
Sets if the workingtime of the scores should be shown.
static updatePrivacySettingsFromLrsType(ilCmiXapiLrsType $lrsType)
static updateByPassProxyFromLrsType(ilCmiXapiLrsType $lrsType)
isSwitchToReviewEnabled()
setSwitchToReviewEnabled($switchToReviewEnabled)
setContentType($contentType)
setKeepLpStatusEnabled($keepLpStatusEnabled)
const LAUNCH_METHOD_OWN_WIN
Class ilObject2 This is an intermediate progress of ilObject class.
getRefId()
get reference id @access public
cloneMetaData($target_obj)
Copy meta data.
deleteMetaData()
delete meta data entry
getType()
get object type @access public
getDescription()
get object description
getTitle()
get object title @access public
Class ilObjectActivation.
const TIMINGS_DEACTIVATED
setTimingType($a_type)
Set timing type.
static getItem($a_ref_id)
Get item data.
static getInstance($a_obj_id)
getId()
get object id @access public
static delDir($a_dir, $a_clean_only=false)
removes a dir and all its content (subdirs and files) recursively
static getWebspaceDir($mode="filesystem")
get webspace directory
static rCopy($a_sdir, $a_tdir, $preserveTimeAttributes=false)
Copies content of a directory $a_sdir recursively to a directory $a_tdir.
if($_SERVER['argc']< 4) $client
static http()
Fetches the global http state from ILIAS.
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
foreach($_POST as $key=> $value) $res