232 $this->lrsTypeId = 0;
235 $this->contentType = self::CONT_TYPE_GENERIC;
236 $this->sourceType = self::SRC_TYPE_REMOTE;
238 $this->activityId =
'';
240 $this->publisherId =
'';
242 $this->instructions =
'';
244 $this->launchUrl =
'';
245 $this->launchParameters =
'';
247 $this->entitlementKey =
'';
249 $this->authFetchUrlEnabled = 0;
251 $this->launchMethod = self::LAUNCH_METHOD_NEW_WIN;
252 $this->launchMode = self::LAUNCH_MODE_NORMAL;
254 $this->switchToReviewEnabled = 1;
256 $this->masteryScore = self::LMS_MASTERY_SCORE;
257 $this->keepLpStatusEnabled = 1;
259 $this->userIdent = self::PRIVACY_IDENT_IL_UUID_USER_ID;
260 $this->userName = self::PRIVACY_NAME_NONE;
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";
367 return $this->sourceType == self::SRC_TYPE_REMOTE;
375 return $this->sourceType == self::SRC_TYPE_EXTERNAL;
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";
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()],
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') .
" ";
1685 $res = $DIC->database()->queryF(
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)
1723 if (null === $cmixUser)
1735 if (null === $cmixUser)
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)
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)
1822 $id = self::guidv4();
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) {
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);
2056 GuzzleHttp\RequestOptions::VERIFY =>
true,
2057 GuzzleHttp\RequestOptions::CONNECT_TIMEOUT => 10,
2058 GuzzleHttp\RequestOptions::HTTP_ERRORS =>
false 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');
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)
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.