5include_once 
"Services/Tracking/classes/class.ilLPObjSettings.php";
 
   36        $this->tree = 
$DIC->repositoryTree();
 
   37        $this->db = 
$DIC->database();
 
   38        $this->obj_id = (int) $a_obj_id;
 
   47        static $instances = array();
 
   49        if (!isset($instances[$a_obj_id])) {
 
   53                $instance = 
new $class($a_obj_id);
 
   56                $instance = 
new self($a_obj_id);
 
   58            $instances[$a_obj_id] = $instance;
 
   61        return $instances[$a_obj_id];
 
   68        $objDefinition = 
$DIC[
"objDefinition"];
 
   70        if (self::isSupportedObjectType(
$a_type)) {
 
   75                    include_once 
"Modules/Course/classes/class.ilCourseLP.php";
 
   79                    return 'ilCourseReferenceLP';
 
   82                    include_once 
"Modules/Group/classes/class.ilGroupLP.php";
 
   86                    include_once 
"Modules/Folder/classes/class.ilFolderLP.php";
 
   90                    include_once 
"Modules/LearningSequence/classes/LearnerProgress/class.ilLSLP.php";
 
   97                    include_once 
"Modules/LearningModule/classes/class.ilLearningModuleLP.php";
 
   98                    return "ilLearningModuleLP";
 
  101                    include_once 
"Modules/HTMLLearningModule/classes/class.ilHTMLLearningModuleLP.php";
 
  102                    return "ilHTMLLearningModuleLP";
 
  105                    include_once 
"Modules/ScormAicc/classes/class.ilScormLP.php";
 
  112                    include_once 
"Modules/Test/classes/class.ilTestLP.php";
 
  116                    include_once 
"Modules/Exercise/classes/class.ilExerciseLP.php";
 
  117                    return "ilExerciseLP";
 
  120                    require_once 
'Modules/File/classes/class.ilFileLP.php';
 
  124                    require_once 
"Modules/MediaCast/classes/class.ilMediaCastLP.php";
 
  125                    return "ilMediaCastLP";
 
  128                    include_once 
"Modules/Session/classes/class.ilSessionLP.php";
 
  129                    return  "ilSessionLP";
 
  135                    include_once 
"Modules/StudyProgramme/classes/class.ilStudyProgrammeLP.php";
 
  136                    return "ilStudyProgrammeLP";
 
  139                    include_once 
"Modules/IndividualAssessment/classes/class.ilIndividualAssessmentLP.php";
 
  140                    return "ilIndividualAssessmentLP";
 
  143                    return "ilContentPageLP";
 
  146                    return ilCmiXapiLP::class;
 
  149                    return ilLTIConsumerLP::class;
 
  152                case $objDefinition->isPluginTypeName(
$a_type):
 
  153                    include_once 
"Services/Component/classes/class.ilPluginLP.php";
 
  162        $objDefinition = 
$DIC[
"objDefinition"];
 
  164        $valid = array(
"crs", 
"grp", 
"fold", 
"lm", 
"htlm", 
"sahs", 
"tst", 
"exc",
 
  165            "sess", 
"svy", 
"file", 
"mcst", 
"prg", 
"iass", 
"copa", 
"lso", 
'cmix', 
'lti', 
'crsr');
 
  171        if ($objDefinition->isPluginTypeName(
$a_type)) {
 
  172            include_once 
'Services/Repository/classes/class.ilRepositoryObjectPluginSlot.php';
 
  182        $this->collection_instance = 
null;
 
  208        if ($this->mode === 
null) {
 
  210            include_once 
"Services/Tracking/classes/class.ilObjUserTracking.php";
 
  213                if (
$mode === 
null) {
 
  221                if (
$mode === 
null) {
 
  226            $this->mode = (int) 
$mode;
 
  266        if ($this->collection_instance === 
null) {
 
  267            include_once 
"Services/Tracking/classes/collection/class.ilLPCollection.php";
 
  288        $ref_id = current($ref_ids);
 
  291        $path = 
$tree->getPathId($ref_id);
 
  293        foreach (array_reverse($path) as $path_ref_id) {
 
  295            $all = $olp->getMembers(
false);
 
  296            if (is_array($all)) {
 
  310        if (
sizeof($user_ids)) {
 
  317        if ((
bool) $a_recursive &&
 
  318            method_exists($this, 
"getPossibleCollectionItems")) { 
 
  319            $subitems = $this->getPossibleCollectionItems();
 
  320            if (is_array($subitems)) {
 
  321                foreach ($subitems as $sub_ref_id) {
 
  323                    $olp->resetLPDataForUserIds($a_user_ids, 
false);
 
  330        include_once 
"Services/Tracking/classes/class.ilLPMarks.php";
 
  333        include_once 
"Services/Tracking/classes/class.ilChangeEvent.php";
 
  337        include_once 
"Services/Tracking/classes/class.ilLPStatusWrapper.php";
 
  338        foreach ($a_user_ids as $user_id) {
 
  350        include_once 
"Services/Tracking/classes/class.ilLPMarks.php";
 
  353        include_once 
"Services/Tracking/classes/class.ilChangeEvent.php";
 
  371        $ref_ids = 
$tree->getSubTreeIds($a_source_ref_id);
 
  372        $ref_ids[] = $a_source_ref_id;
 
  375        $new_path = 
$tree->getPathId($a_source_ref_id);
 
  376        array_pop($new_path);
 
  377        $new_path = implode(
"/", $new_path);
 
  379        include_once(
"./Services/Tracking/classes/class.ilLPStatusWrapper.php");
 
  382        $set = 
$ilDB->query(
"SELECT DISTINCT(ut_lp_collections.obj_id) obj_id" .
 
  383            " FROM object_reference" .
 
  384            " JOIN ut_lp_collections ON" .
 
  385            " (" . 
$ilDB->in(
"object_reference.ref_id", $ref_ids, 
"", 
"integer") .
 
  386            " AND object_reference.ref_id = ut_lp_collections.item_id)");
 
  387        while ($rec = 
$ilDB->fetchAssoc($set)) {
 
  390                $coll_ref_id = array_pop($coll_ref_id);
 
  393                if ($coll_ref_id == $a_source_ref_id) {
 
  398                if (
$tree->isGrandChild($a_source_ref_id, $coll_ref_id)) {
 
  403                $coll_path = 
$tree->getPathId($coll_ref_id);
 
  404                $coll_path = implode(
"/", $coll_path);
 
  407                if (!stristr($new_path, $coll_path)) {
 
  409                    $query = 
"DELETE FROM ut_lp_collections" .
 
  410                        " WHERE obj_id = " . 
$ilDB->quote($rec[
"obj_id"], 
"integer") .
 
  411                        " AND " . 
$ilDB->in(
"item_id", $ref_ids, 
"", 
"integer");
 
  427        include_once 
"Services/Tracking/classes/class.ilLPMarks.php";
 
  430        include_once 
"Services/Tracking/classes/class.ilChangeEvent.php";
 
  435            $collection->delete();
 
  445        include_once(
"./Services/Tracking/classes/class.ilLPStatusWrapper.php");
 
  448        $set = 
$ilDB->query(
"SELECT ut_lp_collections.obj_id obj_id FROM " .
 
  449                "object_reference JOIN ut_lp_collections ON " .
 
  450                "(object_reference.obj_id = " . 
$ilDB->quote($this->obj_id, 
"integer") .
 
  451                " AND object_reference.ref_id = ut_lp_collections.item_id)");
 
  452        while ($rec = 
$ilDB->fetchAssoc($set)) {
 
  455                $query = 
"DELETE FROM ut_lp_collections" .
 
  456                    " WHERE obj_id = " . 
$ilDB->quote($rec[
"obj_id"], 
"integer") .
 
  457                    " AND item_id = " . 
$ilDB->quote($this->obj_id, 
"integer");
 
  477    protected static function isLPMember(array &$a_res, $a_usr_id, $a_obj_ids)
 
  493    protected static function findMembershipsByPath(array &$a_res, $a_usr_id, $a_parent_ref_id, array $a_obj_ids, $a_mapped_ref_ids = 
false)
 
  502        $path = 
$tree->getPathId($a_parent_ref_id);
 
  503        foreach (array_reverse($path) as $path_ref_id) {
 
  505            if (
$type == 
"crs" ||
 
  510                $class::isLPMember($chk, $a_usr_id, array($path_ob_id));
 
  511                if (!$a_mapped_ref_ids) {
 
  513                    foreach ($a_obj_ids as 
$obj_id) {
 
  515                        if ($chk[$path_ob_id]) {
 
  521                    foreach ($a_obj_ids as 
$obj_id => $ref_ids) {
 
  522                        foreach ($ref_ids as $ref_id) {
 
  523                            if (
$tree->isGrandChild($path_ref_id, $ref_id)) {
 
  525                                if ($chk[$path_ob_id]) {
 
  549    public static function getLPMemberships($a_usr_id, array $a_obj_ids, $a_parent_ref_id = 
null, $a_mapped_ref_ids = 
false)
 
  560        if ((
bool) $a_mapped_ref_ids) {
 
  561            $ref_map = $a_obj_ids;
 
  562            $a_obj_ids = array_keys($a_obj_ids);
 
  568        $types_map = array();
 
  569        $query = 
" SELECT obj_id, type" .
 
  570            " FROM object_data" .
 
  571            " WHERE " . 
$ilDB->in(
"obj_id", $a_obj_ids, 
"", 
"integer");
 
  573        while ($row = 
$ilDB->fetchAssoc($set)) {
 
  574            $types_map[$row[
"type"]][] = $row[
"obj_id"];
 
  575            $res[$row[
"obj_id"]] = 
false;
 
  578        $find_by_parent = array();
 
  579        foreach ($types_map as 
$type => $type_obj_ids) {
 
  583                if (!$class::isLPMember(
$res, $a_usr_id, $type_obj_ids)) {
 
  584                    $find_by_parent = array_merge($find_by_parent, $type_obj_ids);
 
  589        if (
sizeof($find_by_parent)) {
 
  591            if ($a_parent_ref_id) {
 
  592                if (self::findMembershipsByPath(
$res, $a_usr_id, $a_parent_ref_id, $find_by_parent)) {
 
  594                    $find_by_parent = 
null;
 
  598            elseif (is_array($ref_map) && count($ref_map) > 0) {
 
  599                foreach ($find_by_parent as 
$obj_id) {
 
  604                            foreach ($ref_map[
$obj_id] as $ref_id) {
 
  605                                $parent_ref_id = 
$tree->getParentId($ref_id);
 
  606                                if ($parent_ref_id == ROOT_FOLDER_ID) {
 
  613                                if (is_array($found) && count($found) > 0) {
 
  616                                    foreach ($found as $found_obj_id => $found_ref_ids) {
 
  617                                        $diff = array_diff($ref_map[$found_obj_id], $found_ref_ids);
 
  621                                            $ref_map[$found_obj_id] = $diff;
 
  625                                            unset($ref_map[$found_obj_id]);
 
  635                $find_by_parent = array_keys($ref_map);
 
  639            if (is_array($find_by_parent) && count($find_by_parent) > 0) {
 
  640                $set = 
$ilDB->query(
"SELECT obj_id" .
 
  642                    " WHERE " . 
$ilDB->in(
"obj_id", $find_by_parent, 
"", 
"integer") .
 
  643                    " AND usr_id = " . 
$ilDB->quote($a_usr_id, 
"integer"));
 
  644                while ($row = 
$ilDB->fetchAssoc($set)) {
 
  645                    $res[$row[
"obj_id"]] = 
true;
 
  665        return !in_array($a_obj_type, array(
"exc", 
"file", 
"mcst", 
"mob", 
"htlm", 
"copa", 
'cmix', 
'lti'));
 
  670        return !in_array($a_obj_type, array(
"lm", 
"dbk"));
 
  675        return !in_array($a_obj_type, array(
'svy', 
'tst', 
'htlm', 
'exc', 
'sess', 
'file', 
'prg', 
'copa', 
'cmix', 
'lti',
'crsr'));
 
  697        if (!is_array(self::$type_defaults)) {
 
  698            self::$type_defaults = array();
 
  699            $set = 
$ilDB->query(
"SELECT * FROM ut_lp_defaults");
 
  700            while ($row = 
$ilDB->fetchAssoc($set)) {
 
  701                self::$type_defaults[$row[
"type_id"]] = $row[
"lp_mode"];
 
  704        return self::$type_defaults[
$a_type];
 
  713        $ilDB->manipulate(
"DELETE FROM ut_lp_defaults");
 
  715            $ilDB->insert(
"ut_lp_defaults", array(
 
  716                "type_id" => array(
"text", 
$type),
 
  717                "lp_mode" => array(
"integer", 
$mode)
 
  736        $olp = 
new $class(0);
 
  737        return $olp->getDefaultMode();
 
An exception for terminatinating execution or to throw for unit testing.
static _getAllUserIds($a_obj_id)
static _deleteReadEventsForUsers($a_obj_id, array $a_user_ids)
static _delete($a_obj_id)
Delete object entries.
static getInstanceByMode($a_obj_id, $a_mode)
static deleteObject($a_obj_id)
Delete object.
static _getAllUserIds($a_obj_id)
static _deleteForUsers($a_obj_id, array $a_user_ids)
const LP_MODE_DEACTIVATED
static _mode2Text($a_mode)
static _lookupDBMode($a_obj_id)
static _mode2InfoText($a_mode)
static _updateStatus($a_obj_id, $a_usr_id, $a_obj=null, $a_percentage=false, $a_force_raise=false)
Update status.
static _refreshStatus($a_obj_id, $a_users=null)
Set dirty.
static _enabledLearningProgress()
check wether learing progress is enabled or not
static getLPMemberships($a_usr_id, array $a_obj_ids, $a_parent_ref_id=null, $a_mapped_ref_ids=false)
Get all objects where given user is member (from LP POV)
static supportsMark($a_obj_type)
static saveTypeDefaults(array $a_data)
static isSupportedObjectType($a_type)
updateParentCollections()
resetLPDataForUserIds(array $a_user_ids, $a_recursive=true)
static getTypeClass($a_type)
resetCustomLPDataForUserIds(array $a_user_ids, $a_recursive=true)
static getTypeDefaultFromDB($a_type)
static supportsSpentSeconds($a_obj_type)
static getInstance($a_obj_id)
resetLPDataForCompleteObject($a_recursive=true)
static handleMove($a_source_ref_id)
static getTypeDefault($a_type)
Get current type default.
static getDefaultModes($a_lp_active)
Get available type-specific default modes (no administration needed)
static supportsMatrixView($a_obj_type)
static isLPMember(array &$a_res, $a_usr_id, $a_obj_ids)
Find (lp-relevant) members for given object ids.
getMembers($a_search=true)
static findMembershipsByPath(array &$a_res, $a_usr_id, $a_parent_ref_id, array $a_obj_ids, $a_mapped_ref_ids=false)
Find (lp-relevant) memberships by path.
static _lookupObjId($a_id)
static _getAllReferences($a_id)
get all reference ids of object
static _lookupType($a_id, $a_reference=false)
lookup object type
static isTypePluginWithLP($a_type, $a_active_status=true)
Check whether a repository type is a plugin which has active learning progress.
foreach($_POST as $key=> $value) $res