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;
47 static $instances = array();
49 if (!isset($instances[$a_obj_id])) {
51 $class = self::getTypeClass(
$type);
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 include_once
"Modules/Group/classes/class.ilGroupLP.php";
83 include_once
"Modules/Folder/classes/class.ilFolderLP.php";
87 include_once
"Modules/LearningSequence/classes/LearnerProgress/class.ilLSLP.php";
94 include_once
"Modules/LearningModule/classes/class.ilLearningModuleLP.php";
95 return "ilLearningModuleLP";
98 include_once
"Modules/HTMLLearningModule/classes/class.ilHTMLLearningModuleLP.php";
99 return "ilHTMLLearningModuleLP";
102 include_once
"Modules/ScormAicc/classes/class.ilScormLP.php";
109 include_once
"Modules/Test/classes/class.ilTestLP.php";
113 include_once
"Modules/Exercise/classes/class.ilExerciseLP.php";
114 return "ilExerciseLP";
117 require_once
'Modules/File/classes/class.ilFileLP.php';
121 require_once
"Modules/MediaCast/classes/class.ilMediaCastLP.php";
122 return "ilMediaCastLP";
125 include_once
"Modules/Session/classes/class.ilSessionLP.php";
126 return "ilSessionLP";
129 include_once
"Modules/Survey/classes/class.ilSurveyLP.php";
133 include_once
"Modules/StudyProgramme/classes/class.ilStudyProgrammeLP.php";
134 return "ilStudyProgrammeLP";
137 include_once
"Modules/IndividualAssessment/classes/class.ilIndividualAssessmentLP.php";
138 return "ilIndividualAssessmentLP";
141 return "ilContentPageLP";
144 case $objDefinition->isPluginTypeName(
$a_type):
145 include_once
"Services/Component/classes/class.ilPluginLP.php";
154 $objDefinition = $DIC[
"objDefinition"];
156 $valid = array(
"crs",
"grp",
"fold",
"lm",
"htlm",
"sahs",
"tst",
"exc",
157 "sess",
"svy",
"file",
"mcst",
"prg",
"iass",
"copa",
"lso");
163 if ($objDefinition->isPluginTypeName(
$a_type)) {
164 include_once
'Services/Repository/classes/class.ilRepositoryObjectPluginSlot.php';
174 $this->collection_instance = null;
200 if ($this->mode === null) {
202 include_once
"Services/Tracking/classes/class.ilObjUserTracking.php";
205 if (
$mode === null) {
213 if (
$mode === null) {
218 $this->mode = (int)
$mode;
258 if ($this->collection_instance === null) {
259 include_once
"Services/Tracking/classes/collection/class.ilLPCollection.php";
280 $ref_id = current($ref_ids);
285 foreach (array_reverse(
$path) as $path_ref_id) {
287 $all = $olp->getMembers(
false);
288 if (is_array($all)) {
302 if (
sizeof($user_ids)) {
309 if ((
bool) $a_recursive &&
310 method_exists($this,
"getPossibleCollectionItems")) {
311 $subitems = $this->getPossibleCollectionItems();
312 if (is_array($subitems)) {
313 foreach ($subitems as $sub_ref_id) {
315 $olp->resetLPDataForUserIds($a_user_ids,
false);
322 include_once
"Services/Tracking/classes/class.ilLPMarks.php";
325 include_once
"Services/Tracking/classes/class.ilChangeEvent.php";
329 include_once
"Services/Tracking/classes/class.ilLPStatusWrapper.php";
330 foreach ($a_user_ids as $user_id) {
342 include_once
"Services/Tracking/classes/class.ilLPMarks.php";
345 include_once
"Services/Tracking/classes/class.ilChangeEvent.php";
360 $tree = $DIC->repositoryTree();
361 $ilDB = $DIC->database();
363 $ref_ids =
$tree->getSubTreeIds($a_source_ref_id);
364 $ref_ids[] = $a_source_ref_id;
367 $new_path =
$tree->getPathId($a_source_ref_id);
368 array_pop($new_path);
369 $new_path = implode(
"/", $new_path);
371 include_once(
"./Services/Tracking/classes/class.ilLPStatusWrapper.php");
374 $set =
$ilDB->query(
"SELECT DISTINCT(ut_lp_collections.obj_id) obj_id" .
375 " FROM object_reference" .
376 " JOIN ut_lp_collections ON" .
377 " (" .
$ilDB->in(
"object_reference.ref_id", $ref_ids,
"",
"integer") .
378 " AND object_reference.ref_id = ut_lp_collections.item_id)");
379 while ($rec =
$ilDB->fetchAssoc($set)) {
382 $coll_ref_id = array_pop($coll_ref_id);
385 if ($coll_ref_id == $a_source_ref_id) {
390 if (
$tree->isGrandChild($a_source_ref_id, $coll_ref_id)) {
395 $coll_path =
$tree->getPathId($coll_ref_id);
396 $coll_path = implode(
"/", $coll_path);
399 if (!stristr($new_path, $coll_path)) {
401 $query =
"DELETE FROM ut_lp_collections" .
402 " WHERE obj_id = " .
$ilDB->quote($rec[
"obj_id"],
"integer") .
403 " AND " .
$ilDB->in(
"item_id", $ref_ids,
"",
"integer");
419 include_once
"Services/Tracking/classes/class.ilLPMarks.php";
422 include_once
"Services/Tracking/classes/class.ilChangeEvent.php";
427 $collection->delete();
437 include_once(
"./Services/Tracking/classes/class.ilLPStatusWrapper.php");
440 $set =
$ilDB->query(
"SELECT ut_lp_collections.obj_id obj_id FROM " .
441 "object_reference JOIN ut_lp_collections ON " .
442 "(object_reference.obj_id = " .
$ilDB->quote($this->obj_id,
"integer") .
443 " AND object_reference.ref_id = ut_lp_collections.item_id)");
444 while ($rec =
$ilDB->fetchAssoc($set)) {
447 $query =
"DELETE FROM ut_lp_collections" .
448 " WHERE obj_id = " .
$ilDB->quote($rec[
"obj_id"],
"integer") .
449 " AND item_id = " .
$ilDB->quote($this->obj_id,
"integer");
469 protected static function isLPMember(array &$a_res, $a_usr_id, $a_obj_ids)
485 protected static function findMembershipsByPath(array &$a_res, $a_usr_id, $a_parent_ref_id, array $a_obj_ids, $a_mapped_ref_ids =
false)
489 $tree = $DIC->repositoryTree();
495 foreach (array_reverse(
$path) as $path_ref_id) {
497 if (
$type ==
"crs" ||
499 $class = self::getTypeClass(
$type);
502 $class::isLPMember($chk, $a_usr_id, array($path_ob_id));
503 if (!$a_mapped_ref_ids) {
505 foreach ($a_obj_ids as
$obj_id) {
507 if ($chk[$path_ob_id]) {
513 foreach ($a_obj_ids as
$obj_id => $ref_ids) {
514 foreach ($ref_ids as $ref_id) {
515 if (
$tree->isGrandChild($path_ref_id, $ref_id)) {
517 if ($chk[$path_ob_id]) {
541 public static function getLPMemberships($a_usr_id, array $a_obj_ids, $a_parent_ref_id = null, $a_mapped_ref_ids =
false)
545 $ilDB = $DIC->database();
546 $tree = $DIC->repositoryTree();
552 if ((
bool) $a_mapped_ref_ids) {
553 $ref_map = $a_obj_ids;
554 $a_obj_ids = array_keys($a_obj_ids);
560 $types_map = array();
561 $query =
" SELECT obj_id, type" .
562 " FROM object_data" .
563 " WHERE " .
$ilDB->in(
"obj_id", $a_obj_ids,
"",
"integer");
566 $types_map[
$row[
"type"]][] = $row[
"obj_id"];
567 $res[$row[
"obj_id"]] =
false;
570 $find_by_parent = array();
571 foreach ($types_map as
$type => $type_obj_ids) {
572 $class = self::getTypeClass(
$type);
575 if (!$class::isLPMember(
$res, $a_usr_id, $type_obj_ids)) {
576 $find_by_parent = array_merge($find_by_parent, $type_obj_ids);
581 if (
sizeof($find_by_parent)) {
583 if ($a_parent_ref_id) {
584 if (self::findMembershipsByPath(
$res, $a_usr_id, $a_parent_ref_id, $find_by_parent)) {
586 $find_by_parent = null;
590 elseif (is_array($ref_map) && count($ref_map) > 0) {
591 foreach ($find_by_parent as
$obj_id) {
593 if (
$res[$obj_id] ===
false) {
594 if (isset($ref_map[$obj_id]) && is_array($ref_map[$obj_id])) {
596 foreach ($ref_map[$obj_id] as $ref_id) {
597 $parent_ref_id =
$tree->getParentId($ref_id);
598 if ($parent_ref_id == ROOT_FOLDER_ID) {
604 $found = self::findMembershipsByPath(
$res, $a_usr_id, $parent_ref_id, $ref_map,
true);
605 if (is_array($found) && count($found) > 0) {
608 foreach ($found as $found_obj_id => $found_ref_ids) {
609 $diff = array_diff($ref_map[$found_obj_id], $found_ref_ids);
613 $ref_map[$found_obj_id] = $diff;
617 unset($ref_map[$found_obj_id]);
627 $find_by_parent = array_keys($ref_map);
631 if (is_array($find_by_parent) && count($find_by_parent) > 0) {
632 $set =
$ilDB->query(
"SELECT obj_id" .
634 " WHERE " .
$ilDB->in(
"obj_id", $find_by_parent,
"",
"integer") .
635 " AND usr_id = " .
$ilDB->quote($a_usr_id,
"integer"));
657 return !in_array($a_obj_type, array(
"exc",
"file",
"mcst",
"mob",
"htlm",
"copa"));
662 return !in_array($a_obj_type, array(
"lm",
"dbk"));
667 return !in_array($a_obj_type, array(
'svy',
'tst',
'htlm',
'exc',
'sess',
'file',
'prg',
'copa'));
687 $ilDB = $DIC->database();
689 if (!is_array(self::$type_defaults)) {
690 self::$type_defaults = array();
691 $set =
$ilDB->query(
"SELECT * FROM ut_lp_defaults");
693 self::$type_defaults[
$row[
"type_id"]] = $row[
"lp_mode"];
696 return self::$type_defaults[
$a_type];
703 $ilDB = $DIC->database();
705 $ilDB->manipulate(
"DELETE FROM ut_lp_defaults");
707 $ilDB->insert(
"ut_lp_defaults", array(
708 "type_id" => array(
"text",
$type),
709 "lp_mode" => array(
"integer",
$mode)
727 $class = self::getTypeClass(
$a_type);
728 $olp =
new $class(0);
729 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)
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)