233 $this->lrsTypeId = 0;
236 $this->contentType = self::CONT_TYPE_GENERIC;
237 $this->sourceType = self::SRC_TYPE_REMOTE;
239 $this->activityId =
'';
241 $this->publisherId =
'';
243 $this->instructions =
'';
245 $this->launchUrl =
'';
246 $this->launchParameters =
'';
248 $this->entitlementKey =
'';
250 $this->authFetchUrlEnabled = 0;
252 $this->launchMethod = self::LAUNCH_METHOD_NEW_WIN;
253 $this->launchMode = self::LAUNCH_MODE_NORMAL;
255 $this->switchToReviewEnabled = 1;
257 $this->masteryScore = self::LMS_MASTERY_SCORE;
258 $this->keepLpStatusEnabled = 1;
260 $this->userIdent = self::PRIVACY_IDENT_IL_UUID_USER_ID;
261 $this->userName = self::PRIVACY_NAME_NONE;
262 $this->userPrivacyComment =
'';
264 $this->currentCmixUser = null;
266 $this->statementsReportEnabled = 0;
268 $this->xmlManifest =
'';
271 $this->bypassProxyEnabled =
false;
277 public static function getInstance($a_id = 0, $a_reference =
true)
279 return new self($a_id, $a_reference);
284 $this->type =
"cmix";
368 return $this->sourceType == self::SRC_TYPE_REMOTE;
376 return $this->sourceType == self::SRC_TYPE_EXTERNAL;
494 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";
1006 $res = $DIC->database()->queryF(
$query, [
'integer'], [$this->
getId()]);
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()],
1124 'c_terminated' => [
'integer', (
int) $this->
getTerminated()],
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);
1178 $tableName = self::DB_TABLE_NAME;
1182 SET privacy_ident = %s, 1197 no_substatements = %s 1198 WHERE lrs_type_id = %s 1201 $DIC->database()->manipulateF(
1246 $tableName = self::DB_TABLE_NAME;
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) {
1490 return self::HIGHSCORE_SHOW_ALL_TABLES;
1493 return self::HIGHSCORE_SHOW_TOP_TABLE;
1497 return self::HIGHSCORE_SHOW_OWN_TABLE;
1507 case self::HIGHSCORE_SHOW_ALL_TABLES:
1512 case self::HIGHSCORE_SHOW_TOP_TABLE:
1517 case self::HIGHSCORE_SHOW_OWN_TABLE:
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()]);
1655 $ilDB = $DIC[
'ilDB'];
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 $res = $DIC->database()->queryF(
1687 "SELECT DISTINCT registration FROM " . self::DB_USERS_TABLE_NAME .
" WHERE obj_id = %s",
1689 array($this->
getId())
1692 while ($row = $DIC->database()->fetchAssoc(
$res)) {
1693 $ret[] = $row[
'registration'];
1702 assert(strlen(
$data) == 16);
1710 return vsprintf(
'%s%s-%s-%s-%s-%s%s%s', str_split(bin2hex(
$data), 4));
1716 if (null === $this->currentCmixUser) {
1724 if (null === $cmixUser) {
1735 if (null === $cmixUser) {
1753 "launchMethod" =>
"OwnWindow",
1757 if ($lmsLaunchMethod ===
"ownWin") {
1758 include_once(
'./Services/Link/classes/class.ilLink.php');
1763 $ctxTemplate[
'returnURL'] = $href;
1765 $ctxTemplate[
'returnURL'] = ILIAS_HTTP_PATH .
"/Modules/CmiXapi/xapiexit.php?lang={$lang}";
1774 $ctxTemplate[
'entitlementKey'] = array(
"courseStructure" => $this->
getEntitlementKey());
1776 return $ctxTemplate;
1781 if (null === $cmixUser) {
1792 $extensions[
'https://w3id.org/xapi/cmi5/context/extensions/launchmode'] =
$launchMode;
1794 $extensions[
'https://w3id.org/xapi/cmi5/context/extensions/moveon'] = $this->
getLMSMoveOn();
1797 $extensions[
'https://w3id.org/xapi/cmi5/context/extensions/launchparameters'] = $this->
getLaunchParameters();
1800 $extensions[
'https://w3id.org/xapi/cmi5/context/extensions/masteryscore'] = $this->
getMasteryScore();
1802 $contextTemplate = array(
1804 "extensions" => $extensions
1806 return $contextTemplate;
1814 if (null === $cmixUser) {
1817 $id = self::guidv4();
1821 $registration = $cmixUser->getRegistration();
1833 'extensions' => $extensions,
1834 'registration' => $registration,
1835 'contextActivities' => $contextActivities
1848 if (null === $cmixUser) {
1851 $user =
new ilObjUser($cmixUser->getUsrId());
1854 $this->
log()->error(
'error: no name in cmixuser');
1855 $name =
'UNDEFINED';
1857 $homePage = ($this->anonymousHomePage ==
true) ? self::ANONYMOUS_HOMEPAGE : self::iliasUrl();
1860 'objectType' =>
'Agent',
1862 'homePage' => $homePage,
1863 'name' => $cmixUser->getUsrIdent()
1867 $actor[
'name'] =
$name;
1871 'objectType' =>
'Agent',
1872 'mbox' =>
'mailto:' . $cmixUser->getUsrIdent()
1875 $actor[
'name'] =
$name;
1886 if (null === $cmixUser) {
1889 $extensions = array(
1890 'https://w3id.org/xapi/cmi5/context/extensions/sessionid' => $this->
getSessionId($cmixUser),
1891 'https://ilias.de/cmi5/activityid' => $this->
getActivityId()
1906 $ctxActivities = array(
1909 "objectType" =>
"Activity",
1910 "id" =>
"{$publisherId}",
1927 "id" =>
"https://w3id.org/xapi/cmi5/context/categories/cmi5",
1928 "objectType" =>
"Activity" 1932 return $ctxActivities;
1958 if (null === $cmixUser) {
1969 $statement = $this->
getStatement(
'launched', $cmixUser);
1970 $statement[
'context'][
'extensions'][
'https://w3id.org/xapi/cmi5/context/extensions/launchmode'] =
$launchMode;
1972 $statement[
'context'][
'extensions'][
'https://w3id.org/xapi/cmi5/context/extensions/moveon'] = $this->
getLMSMoveOn();
1975 $statement[
'context'][
'extensions'][
'https://w3id.org/xapi/cmi5/context/extensions/launchparameters'] = $this->
getLaunchParameters();
1978 $statement[
'context'][
'extensions'][
'https://w3id.org/xapi/cmi5/context/extensions/masteryscore'] = $this->
getMasteryScore();
1985 if (null === $cmixUser) {
1988 $statement = $this->
getStatement(
'abandoned', $cmixUser);
1990 $statement[
'context'][
'extensions'][
'https://w3id.org/xapi/cmi5/context/extensions/sessionid'] = $sessionId;
1991 $statement[
'result'] = array(
1999 if (null === $cmixUser) {
2002 $statement = $this->
getStatement(
'satisfied', $cmixUser);
2005 $type =
"https://w3id.org/xapi/cmi5/activitytype/course";
2006 $statement[
'object'][
'definition'][
'type'] =
$type;
2007 $statement[
'context'][
'contextActivities'][
'grouping'][0][
'definition'][
'type'] =
$type;
2020 $defaultLrs =
$lrsType->getLrsEndpointStatementsAggregationLink();
2022 $defaultBasicAuth =
$lrsType->getBasicAuth();
2025 'X-Experience-API-Version' =>
'1.0.3',
2026 'Authorization' => $defaultBasicAuth,
2027 'Cache-Control' =>
'no-cache, no-store, must-revalidate' 2038 $defaultLastStatementUrl = $defaultLrs .
"?pipeline=" . urlencode($pipeline);
2041 GuzzleHttp\RequestOptions::VERIFY =>
true,
2042 GuzzleHttp\RequestOptions::CONNECT_TIMEOUT => 10,
2043 GuzzleHttp\RequestOptions::HTTP_ERRORS =>
false 2047 $defaultLastStatementUrl,
2050 $promises = array();
2051 $promises[
'defaultLastStatement'] =
$client->sendAsync($defaultLastStatementRequest, $req_opts);
2053 $responses = GuzzleHttp\Promise\Utils::settle($promises)->wait();
2056 return json_decode($body, JSON_OBJECT_AS_ARRAY);
2058 $this->
log()->error(
'error:' . $e->getMessage());
2066 $pipeline = array();
2070 $match[
'statement.object.objectType'] =
'Activity';
2071 $match[
'statement.actor.objectType'] =
'Agent';
2083 $activityId[
'$or'][] = [
'statement.object.id' => $activityQuery];
2084 $activityId[
'$or'][] = [
'statement.context.contextActivities.parent.id' => $activityQuery];
2085 $activityId[
'$or'][] = [
'statement.context.contextActivities.grouping.id' => $activityQuery];
2088 $sessionId = array();
2089 $sessionId[
'statement.context.extensions.https://w3id&46;org/xapi/cmi5/context/extensions/sessionid'] = $sess;
2090 $match[
'$and'] = array();
2092 $match[
'$and'][] = $sessionId;
2093 $sort = array(
'statement.timestamp' => -1);
2094 $project = array(
'statement.timestamp' => 1,
'statement.verb.id' => 1);
2095 $pipeline[] = array(
'$match' => $match);
2096 $pipeline[] = array(
'$sort' => $sort);
2097 $pipeline[] = array(
'$limit' => 1);
2098 $pipeline[] = array(
'$project' => $project);
2105 $regex =
'/^(https?\:\/\/[^\/]+).*/';
2106 preg_match($regex,
$GLOBALS[
'DIC']->
http()->request()->getUri(), $request_parts);
2107 return $request_parts[1];
2116 return \ilLoggerFactory::getLogger(
'cmix');
setDuration(bool $duration)
doCloneObject($new_obj, $a_target_id, $a_copy_id=null, $a_omit_tree=false)
Clone object.
const LP_MODE_CMIX_COMPLETED
const DB_RESULTS_TABLE_NAME
setAuthFetchUrlEnabled($authFetchUrlEnabled)
setInstructions($instructions)
setEntitlementKey($entitlementKey)
static getName($userNameMode, ilObjUser $user)
const LP_MODE_CMIX_COMPLETED_OR_PASSED
getLaunchedStatement($cmixUser=null)
const PRIVACY_IDENT_IL_UUID_SHA256URL
getSessionId($cmixUser=null)
static getObjectsHavingBypassProxyEnabledAndRegisteredUsers()
getHighscoreTopTable()
Gets, if the top-rankings table should be shown.
const HIGHSCORE_SHOW_OWN_TABLE
const LP_MODE_CMIX_PASSED_WITH_FAILED
static rCopy($a_sdir, $a_tdir, $preserveTimeAttributes=false)
Copies content of a directory $a_sdir recursively to a directory $a_tdir.
const LAUNCH_METHOD_NEW_WIN
getHighscoreWTime()
Gets if the column with the workingtime should be shown.
const MOVEON_NOT_APPLICABLE
setNoSubstatements(bool $no_substatements)
setOnlyMoveon(bool $only_moveon)
setAchieved(bool $achieved)
const LP_MODE_CMIX_PASSED
static _getStaticLink( $a_ref_id, $a_type='', $a_fallback_goto=true, $append="")
Get static link.
static getItem($a_ref_id)
Get item data.
if($_SERVER['argc']< 4) $client
const TIMINGS_DEACTIVATED
setMasteryScore($masteryScore)
getHighscoreTopNum($a_retval=10)
Gets the number of entries which are to be shown in the top-rankings table.
getAbandonedStatement($sessionId, $duration, $cmixUser=null)
setContentType($contentType)
const PRIVACY_IDENT_IL_UUID_RANDOM
static updatePrivacySettingsFromLrsType(ilCmiXapiLrsType $lrsType)
getActivationStartingTime()
setLaunchMode($launchMode)
const PRIVACY_IDENT_IL_UUID_EXT_ACCOUNT
getHighscoreOwnTable()
Gets if the own rankings table should be shown.
const LP_MODE_CMIX_COMPL_WITH_FAILED
const PRIVACY_IDENT_REAL_EMAIL
getStatementExtensions($cmixUser=null)
Minimal extensions.
setBypassProxyEnabled(bool $bypassProxyEnabled)
getActivationEndingTime()
setActivationEndingTime($activationEndingTime)
const LAUNCH_METHOD_IFRAME
setTerminated(bool $terminated)
const PRIVACY_IDENT_IL_UUID_SHA256
static http()
Fetches the global http state from ILIAS.
setHighscoreTopTable($a_top_table)
Sets if the top-rankings table should be shown.
foreach($_POST as $key=> $value) $res
getHighscoreEnabled()
Gets the setting which determines if the highscore feature is enabled.
getId()
get object id public
setKeepLpStatusEnabled($keepLpStatusEnabled)
setCompleted(bool $completed)
getStatementActor($cmixUser=null)
statement actor
const PRIVACY_NAME_FIRSTNAME
static getCmi5SessionByUsrIdAndObjIdAndRefId(int $usrId, int $objId, $refId=null)
setActivationLimited($activationLimited)
getLastStatement($sess)
get latest statement from session
getLastStatementPipline($sess)
const LAUNCH_METHOD_OWN_WIN
static getInstance($a_id=0, $a_reference=true)
setSwitchToReviewEnabled($switchToReviewEnabled)
if(!defined('PATH_SEPARATOR')) $GLOBALS['_PEAR_default_error_mode']
setActivationStartingTime($activationStartingTime)
__construct($a_id=0, $a_reference=true)
ilObjCmiXapi constructor.
const DB_USERS_TABLE_NAME
getActivationVisibility()
setXmlManifest($xmlManifest)
const PRIVACY_IDENT_IL_UUID_LOGIN
static guidv4($data=null)
setHighscoreEnabled($a_enabled)
Sets if the highscore feature should be enabled.
setPrivacyIdent($userIdent)
setLaunchParameters($launchParameters)
setInitialized(bool $initialized)
setTimingType($a_type)
Set timing type.
const PRIVACY_IDENT_IL_UUID_USER_ID
setProgressed(bool $progressed)
const HIGHSCORE_SHOW_ALL_TABLES
setPublisherId($publisherId)
getSatisfiedStatement($cmixUser=null)
setActivityId($activityId)
setSatisfied(bool $satisfied)
setActivationVisibility($activationVisibility)
getLaunchedContextTemplate($cmixUser=null)
const LP_MODE_DEACTIVATED
setPrivacyName($userName)
getLaunchData($cmixUser=null, $lang='en')
LMS.LaunchData.
static checkResponse($response, &$body, $allowedStatus=[200, 204])
$activationLimited
repository object activation settings (handled by ilObject)
const PRIVACY_NAME_LASTNAME
__construct(Container $dic, ilPlugin $plugin)
setTimestamp(bool $timestamp)
const LP_MODE_CMIX_COMPL_OR_PASSED_WITH_FAILED
getSwitchToReviewEnabled()
setAnswered(bool $answered)
getStatementContextActivities()
Minimal statementActivities.
getHighscorePercentage()
Gets if the percentage column should be shown.
setHighscoreOwnTable($a_own_table)
Sets if the table with the own ranking should be shown.
loadRepositoryActivationSettings()
setStatementsReportEnabled($statementsReportEnabled)
static _removeEntriesForObject($a_obj_id)
remove all history entries for an object
getStatement(string $verb, $cmixUser=null)
blueprint statement
const PRIVACY_NAME_FULLNAME
setHideData(bool $hide_data)
static updateByPassProxyFromLrsType(ilCmiXapiLrsType $lrsType)
isSwitchToReviewEnabled()
setLaunchMethod($launchMethod)
setSourceType($sourceType)
setMasteryScorePercent($masteryScorePercent)
const HIGHSCORE_SHOW_TOP_TABLE
setHighscoreWTime($a_wtime)
Sets if the workingtime of the scores should be shown.
static getInstance($a_obj_id)
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
const MOVEON_COMPLETED_OR_PASSED
Class ilObjectActivation.
setHighscoreAchievedTS($a_achieved_ts)
Sets if the date and time of the scores achievement should be displayed.
setHighscoreTopNum($a_top_num)
Sets the number of entries which are to be shown in the top-rankings table.
setUserPrivacyComment($userPrivacyComment)
isStatementsReportEnabled()
getHighscoreAchievedTS()
Returns if date and time of the scores achievement should be displayed.
cloneMetaData($target_obj)
saveRepositoryActivationSettings()
setHighscorePercentage($a_percentage)
Sets if the percentages of the scores pass should be shown.