5 include_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;
43 static $instances =
array();
45 if (!isset($instances[$a_obj_id])) {
47 $class = self::getTypeClass(
$type);
49 $instance =
new $class($a_obj_id);
52 $instance =
new self($a_obj_id);
54 $instances[$a_obj_id] = $instance;
57 return $instances[$a_obj_id];
64 $objDefinition = $DIC[
"objDefinition"];
66 if (self::isSupportedObjectType(
$a_type)) {
71 include_once
"Modules/Course/classes/class.ilCourseLP.php";
75 include_once
"Modules/Group/classes/class.ilGroupLP.php";
79 include_once
"Modules/Folder/classes/class.ilFolderLP.php";
86 include_once
"Modules/LearningModule/classes/class.ilLearningModuleLP.php";
87 return "ilLearningModuleLP";
90 include_once
"Modules/HTMLLearningModule/classes/class.ilHTMLLearningModuleLP.php";
91 return "ilHTMLLearningModuleLP";
94 include_once
"Modules/ScormAicc/classes/class.ilScormLP.php";
101 include_once
"Modules/Test/classes/class.ilTestLP.php";
105 include_once
"Modules/Exercise/classes/class.ilExerciseLP.php";
106 return "ilExerciseLP";
109 require_once
'Modules/File/classes/class.ilFileLP.php';
113 require_once
"Modules/MediaCast/classes/class.ilMediaCastLP.php";
114 return "ilMediaCastLP";
117 include_once
"Modules/Session/classes/class.ilSessionLP.php";
118 return "ilSessionLP";
121 include_once
"Modules/Survey/classes/class.ilSurveyLP.php";
125 include_once
"Modules/StudyProgramme/classes/class.ilStudyProgrammeLP.php";
126 return "ilStudyProgrammeLP";
129 include_once
"Modules/IndividualAssessment/classes/class.ilIndividualAssessmentLP.php";
130 return "ilIndividualAssessmentLP";
133 case $objDefinition->isPluginTypeName(
$a_type):
134 include_once
"Services/Component/classes/class.ilPluginLP.php";
144 $objDefinition = $DIC[
"objDefinition"];
146 $valid =
array(
"crs",
"grp",
"fold",
"lm",
"htlm",
"sahs",
"tst",
"exc",
"sess",
"svy",
"file",
"mcst",
"prg",
"iass");
152 if ($objDefinition->isPluginTypeName(
$a_type)) {
153 include_once
'Services/Repository/classes/class.ilRepositoryObjectPluginSlot.php';
163 $this->collection_instance = null;
189 if ($this->mode === null) {
191 include_once
"Services/Tracking/classes/class.ilObjUserTracking.php";
194 if (
$mode === null) {
202 if (
$mode === null) {
207 $this->mode = (int)
$mode;
247 if ($this->collection_instance === null) {
248 include_once
"Services/Tracking/classes/collection/class.ilLPCollection.php";
269 $ref_id = current($ref_ids);
274 foreach (array_reverse(
$path) as $path_ref_id) {
276 $all = $olp->getMembers(
false);
277 if (is_array($all)) {
291 if (
sizeof($user_ids)) {
298 if ((
bool) $a_recursive &&
299 method_exists($this,
"getPossibleCollectionItems")) {
300 $subitems = $this->getPossibleCollectionItems();
301 if (is_array($subitems)) {
302 foreach ($subitems as $sub_ref_id) {
304 $olp->resetLPDataForUserIds($a_user_ids,
false);
311 include_once
"Services/Tracking/classes/class.ilLPMarks.php";
314 include_once
"Services/Tracking/classes/class.ilChangeEvent.php";
318 include_once
"Services/Tracking/classes/class.ilLPStatusWrapper.php";
319 foreach ($a_user_ids as $user_id) {
331 include_once
"Services/Tracking/classes/class.ilLPMarks.php";
334 include_once
"Services/Tracking/classes/class.ilChangeEvent.php";
349 $tree = $DIC->repositoryTree();
350 $ilDB = $DIC->database();
352 $ref_ids =
$tree->getSubTreeIds($a_source_ref_id);
353 $ref_ids[] = $a_source_ref_id;
356 $new_path =
$tree->getPathId($a_source_ref_id);
357 array_pop($new_path);
358 $new_path = implode(
"/", $new_path);
360 include_once(
"./Services/Tracking/classes/class.ilLPStatusWrapper.php");
363 $set =
$ilDB->query(
"SELECT DISTINCT(ut_lp_collections.obj_id) obj_id" .
364 " FROM object_reference" .
365 " JOIN ut_lp_collections ON" .
366 " (" .
$ilDB->in(
"object_reference.ref_id", $ref_ids,
"",
"integer") .
367 " AND object_reference.ref_id = ut_lp_collections.item_id)");
368 while ($rec =
$ilDB->fetchAssoc($set)) {
371 $coll_ref_id = array_pop($coll_ref_id);
374 if ($coll_ref_id == $a_source_ref_id) {
379 if (
$tree->isGrandChild($a_source_ref_id, $coll_ref_id)) {
384 $coll_path =
$tree->getPathId($coll_ref_id);
385 $coll_path = implode(
"/", $coll_path);
388 if (!stristr($new_path, $coll_path)) {
390 $query =
"DELETE FROM ut_lp_collections" .
391 " WHERE obj_id = " .
$ilDB->quote($rec[
"obj_id"],
"integer") .
392 " AND " .
$ilDB->in(
"item_id", $ref_ids,
"",
"integer");
408 include_once
"Services/Tracking/classes/class.ilLPMarks.php";
411 include_once
"Services/Tracking/classes/class.ilChangeEvent.php";
416 $collection->delete();
426 include_once(
"./Services/Tracking/classes/class.ilLPStatusWrapper.php");
429 $set =
$ilDB->query(
"SELECT ut_lp_collections.obj_id obj_id FROM " .
430 "object_reference JOIN ut_lp_collections ON " .
431 "(object_reference.obj_id = " .
$ilDB->quote($this->obj_id,
"integer") .
432 " AND object_reference.ref_id = ut_lp_collections.item_id)");
433 while ($rec =
$ilDB->fetchAssoc($set)) {
436 $query =
"DELETE FROM ut_lp_collections" .
437 " WHERE obj_id = " .
$ilDB->quote($rec[
"obj_id"],
"integer") .
438 " AND item_id = " .
$ilDB->quote($this->obj_id,
"integer");
478 $tree = $DIC->repositoryTree();
484 foreach (array_reverse(
$path) as $path_ref_id) {
486 if (
$type ==
"crs" ||
488 $class = self::getTypeClass(
$type);
491 $class::isLPMember($chk, $a_usr_id,
array($path_ob_id));
492 if (!$a_mapped_ref_ids) {
494 foreach ($a_obj_ids as
$obj_id) {
496 if ($chk[$path_ob_id]) {
502 foreach ($a_obj_ids as
$obj_id => $ref_ids) {
503 foreach ($ref_ids as $ref_id) {
504 if (
$tree->isGrandChild($path_ref_id, $ref_id)) {
506 if ($chk[$path_ob_id]) {
530 public static function getLPMemberships($a_usr_id,
array $a_obj_ids, $a_parent_ref_id = null, $a_mapped_ref_ids =
false)
534 $ilDB = $DIC->database();
535 $tree = $DIC->repositoryTree();
541 if ((
bool) $a_mapped_ref_ids) {
542 $ref_map = $a_obj_ids;
543 $a_obj_ids = array_keys($a_obj_ids);
549 $types_map =
array();
550 $query =
" SELECT obj_id, type" .
551 " FROM object_data" .
552 " WHERE " .
$ilDB->in(
"obj_id", $a_obj_ids,
"",
"integer");
555 $types_map[
$row[
"type"]][] = $row[
"obj_id"];
556 $res[$row[
"obj_id"]] =
false;
559 $find_by_parent =
array();
560 foreach ($types_map as
$type => $type_obj_ids) {
561 $class = self::getTypeClass(
$type);
564 if (!$class::isLPMember(
$res, $a_usr_id, $type_obj_ids)) {
565 $find_by_parent = array_merge($find_by_parent, $type_obj_ids);
570 if (
sizeof($find_by_parent)) {
572 if ($a_parent_ref_id) {
573 if (self::findMembershipsByPath(
$res, $a_usr_id, $a_parent_ref_id, $find_by_parent)) {
575 $find_by_parent = null;
579 elseif (is_array($ref_map) && count($ref_map) > 0) {
580 foreach ($find_by_parent as
$obj_id) {
582 if (
$res[$obj_id] ===
false) {
583 if (isset($ref_map[$obj_id]) && is_array($ref_map[$obj_id])) {
585 foreach ($ref_map[$obj_id] as $ref_id) {
586 $parent_ref_id =
$tree->getParentId($ref_id);
587 if ($parent_ref_id == ROOT_FOLDER_ID) {
593 $found = self::findMembershipsByPath(
$res, $a_usr_id, $parent_ref_id, $ref_map,
true);
594 if (is_array($found) && count($found) > 0) {
597 foreach ($found as $found_obj_id => $found_ref_ids) {
598 $diff = array_diff($ref_map[$found_obj_id], $found_ref_ids);
602 $ref_map[$found_obj_id] = $diff;
606 unset($ref_map[$found_obj_id]);
616 $find_by_parent = array_keys($ref_map);
620 if (is_array($find_by_parent) && count($find_by_parent) > 0) {
621 $set =
$ilDB->query(
"SELECT obj_id" .
623 " WHERE " .
$ilDB->in(
"obj_id", $find_by_parent,
"",
"integer") .
624 " AND usr_id = " .
$ilDB->quote($a_usr_id,
"integer"));
646 return !in_array($a_obj_type,
array(
"exc",
"file",
"mcst",
"mob",
"htlm"));
651 return !in_array($a_obj_type,
array(
"lm",
"dbk"));
656 return !in_array($a_obj_type,
array(
'svy',
'tst',
'htlm',
'exc',
'sess',
'file',
'prg'));
676 $ilDB = $DIC->database();
678 if (!is_array(self::$type_defaults)) {
679 self::$type_defaults =
array();
680 $set =
$ilDB->query(
"SELECT * FROM ut_lp_defaults");
682 self::$type_defaults[
$row[
"type_id"]] = $row[
"lp_mode"];
685 return self::$type_defaults[
$a_type];
692 $ilDB = $DIC->database();
694 $ilDB->manipulate(
"DELETE FROM ut_lp_defaults");
716 $class = self::getTypeClass(
$a_type);
717 $olp =
new $class(0);
718 return $olp->getDefaultMode();
static isTypePluginWithLP($a_type, $a_active_status=true)
Check whether a repository type is a plugin which has active learning progress.
static getTypeDefaultFromDB($a_type)
resetLPDataForUserIds(array $a_user_ids, $a_recursive=true)
static getTypeClass($a_type)
resetLPDataForCompleteObject($a_recursive=true)
static _updateStatus($a_obj_id, $a_usr_id, $a_obj=null, $a_percentage=false, $a_force_raise=false)
Update status.
static isSupportedObjectType($a_type)
static getInstanceByMode($a_obj_id, $a_mode)
static _getAllUserIds($a_obj_id)
static _refreshStatus($a_obj_id, $a_users=null)
Set dirty.
updateParentCollections()
static _getAllUserIds($a_obj_id)
static _getAllReferences($a_id)
get all reference ids of object
resetCustomLPDataForUserIds(array $a_user_ids, $a_recursive=true)
static getTypeDefault($a_type)
Get current type default.
static _enabledLearningProgress()
check wether learing progress is enabled or not
static _delete($a_obj_id)
Delete object entries.
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 _lookupDBMode($a_obj_id)
foreach($_POST as $key=> $value) $res
static _lookupObjId($a_id)
static saveTypeDefaults(array $a_data)
static getDefaultModes($a_lp_active)
Get available type-specific default modes (no administration needed)
static _deleteForUsers($a_obj_id, array $a_user_ids)
static supportsMatrixView($a_obj_type)
Create styles array
The data for the language used.
static _lookupType($a_id, $a_reference=false)
lookup object type
static supportsMark($a_obj_type)
static _mode2InfoText($a_mode)
const LP_MODE_DEACTIVATED
static supportsSpentSeconds($a_obj_type)
static isLPMember(array &$a_res, $a_usr_id, $a_obj_ids)
Find (lp-relevant) members for given object ids.
static deleteObject($a_obj_id)
Delete object.
getMembers($a_search=true)
static _deleteReadEventsForUsers($a_obj_id, array $a_user_ids)
static handleMove($a_source_ref_id)
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 getInstance($a_obj_id)
static _mode2Text($a_mode)