5 include_once
"Services/Tracking/classes/class.ilLPObjSettings.php";
24 $this->obj_id = (int)$a_obj_id;
29 static $instances =
array();
31 if(!isset($instances[$a_obj_id]))
34 $class = self::getTypeClass($type);
37 $instance =
new $class($a_obj_id);
42 $instance =
new self($a_obj_id);
44 $instances[$a_obj_id] = $instance;
47 return $instances[$a_obj_id];
52 global $objDefinition;
54 if(self::isSupportedObjectType(
$a_type))
61 include_once
"Modules/Course/classes/class.ilCourseLP.php";
65 include_once
"Modules/Group/classes/class.ilGroupLP.php";
69 include_once
"Modules/Folder/classes/class.ilFolderLP.php";
76 include_once
"Modules/LearningModule/classes/class.ilLearningModuleLP.php";
77 return "ilLearningModuleLP";
80 include_once
"Modules/HTMLLearningModule/classes/class.ilHTMLLearningModuleLP.php";
81 return "ilHTMLLearningModuleLP";
84 include_once
"Modules/ScormAicc/classes/class.ilScormLP.php";
91 include_once
"Modules/Test/classes/class.ilTestLP.php";
95 include_once
"Modules/Exercise/classes/class.ilExerciseLP.php";
96 return "ilExerciseLP";
99 require_once
'Modules/File/classes/class.ilFileLP.php';
103 require_once
"Modules/MediaCast/classes/class.ilMediaCastLP.php";
104 return "ilMediaCastLP";
107 include_once
"Modules/Session/classes/class.ilSessionLP.php";
108 return "ilSessionLP";
111 include_once
"Modules/Survey/classes/class.ilSurveyLP.php";
115 include_once
"Modules/StudyProgramme/classes/class.ilStudyProgrammeLP.php";
116 return "ilStudyProgrammeLP";
119 include_once
"Modules/IndividualAssessment/classes/class.ilIndividualAssessmentLP.php";
120 return "ilIndividualAssessmentLP";
123 case $objDefinition->isPluginTypeName(
$a_type):
124 include_once
"Services/Component/classes/class.ilPluginLP.php";
132 global $objDefinition;
134 $valid =
array(
"crs",
"grp",
"fold",
"lm",
"htlm",
"sahs",
"tst",
"exc",
"sess",
"svy",
"file",
"mcst",
"prg",
"iass");
141 if($objDefinition->isPluginTypeName(
$a_type))
143 include_once
'Services/Repository/classes/class.ilRepositoryObjectPluginSlot.php';
153 $this->collection_instance = null;
180 if($this->mode === null)
183 include_once
"Services/Tracking/classes/class.ilObjUserTracking.php";
203 $this->mode = (int)
$mode;
244 if($this->collection_instance === null)
246 include_once
"Services/Tracking/classes/collection/class.ilLPCollection.php";
273 foreach(array_reverse(
$path) as $path_ref_id)
276 $all = $olp->getMembers(
false);
292 if(
sizeof($user_ids))
300 if((
bool)$a_recursive &&
301 method_exists($this,
"getPossibleCollectionItems"))
303 $subitems = $this->getPossibleCollectionItems();
304 if(is_array($subitems))
306 foreach($subitems as $sub_ref_id)
309 $olp->resetLPDataForUserIds($a_user_ids,
false);
316 include_once
"Services/Tracking/classes/class.ilLPMarks.php";
319 include_once
"Services/Tracking/classes/class.ilChangeEvent.php";
323 include_once
"Services/Tracking/classes/class.ilLPStatusWrapper.php";
324 foreach($a_user_ids as $user_id)
337 include_once
"Services/Tracking/classes/class.ilLPMarks.php";
340 include_once
"Services/Tracking/classes/class.ilChangeEvent.php";
355 $ref_ids = $tree->getSubTreeIds($a_source_ref_id);
356 $ref_ids[] = $a_source_ref_id;
359 $new_path = $tree->getPathId($a_source_ref_id);
360 array_pop($new_path);
361 $new_path = implode(
"/", $new_path);
363 include_once(
"./Services/Tracking/classes/class.ilLPStatusWrapper.php");
366 $set = $ilDB->query(
"SELECT DISTINCT(ut_lp_collections.obj_id) obj_id".
367 " FROM object_reference".
368 " JOIN ut_lp_collections ON".
369 " (".$ilDB->in(
"object_reference.ref_id", $ref_ids,
"",
"integer").
370 " AND object_reference.ref_id = ut_lp_collections.item_id)");
371 while ($rec = $ilDB->fetchAssoc($set))
376 $coll_ref_id = array_pop($coll_ref_id);
379 if($coll_ref_id == $a_source_ref_id)
385 if($tree->isGrandChild($a_source_ref_id, $coll_ref_id))
391 $coll_path = $tree->getPathId($coll_ref_id);
392 $coll_path = implode(
"/", $coll_path);
395 if(!stristr($new_path, $coll_path))
398 $query =
"DELETE FROM ut_lp_collections".
399 " WHERE obj_id = ".$ilDB->quote($rec[
"obj_id"],
"integer").
400 " AND ".$ilDB->in(
"item_id", $ref_ids,
"",
"integer");
401 $ilDB->manipulate(
$query);
416 include_once
"Services/Tracking/classes/class.ilLPMarks.php";
419 include_once
"Services/Tracking/classes/class.ilChangeEvent.php";
425 $collection->delete();
435 include_once(
"./Services/Tracking/classes/class.ilLPStatusWrapper.php");
438 $set = $ilDB->query(
"SELECT ut_lp_collections.obj_id obj_id FROM ".
439 "object_reference JOIN ut_lp_collections ON ".
440 "(object_reference.obj_id = ".$ilDB->quote($this->obj_id,
"integer").
441 " AND object_reference.ref_id = ut_lp_collections.item_id)");
442 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");
450 $ilDB->manipulate(
$query);
492 $path = $tree->getPathId($a_parent_ref_id);
493 foreach(array_reverse(
$path) as $path_ref_id)
499 $class = self::getTypeClass($type);
502 $class::isLPMember($chk, $a_usr_id,
array($path_ob_id));
503 if(!$a_mapped_ref_ids)
509 if($chk[$path_ob_id])
518 foreach($a_obj_ids as
$obj_id => $ref_ids)
522 if($tree->isGrandChild($path_ref_id, $ref_id))
525 if($chk[$path_ob_id])
550 public static function getLPMemberships($a_usr_id,
array $a_obj_ids, $a_parent_ref_id = null, $a_mapped_ref_ids =
false)
557 if((
bool)$a_mapped_ref_ids)
559 $ref_map = $a_obj_ids;
560 $a_obj_ids = array_keys($a_obj_ids);
566 $types_map =
array();
567 $query =
" SELECT obj_id, type".
569 " WHERE ".$ilDB->in(
"obj_id", $a_obj_ids,
"",
"integer");
570 $set = $ilDB->query(
$query);
571 while(
$row = $ilDB->fetchAssoc($set))
573 $types_map[
$row[
"type"]][] = $row[
"obj_id"];
574 $res[$row[
"obj_id"]] =
false;
577 $find_by_parent =
array();
578 foreach($types_map as $type => $type_obj_ids)
580 $class = self::getTypeClass($type);
584 if(!$class::isLPMember(
$res, $a_usr_id, $type_obj_ids))
586 $find_by_parent = array_merge($find_by_parent, $type_obj_ids);
591 if(
sizeof($find_by_parent))
596 if(self::findMembershipsByPath(
$res, $a_usr_id, $a_parent_ref_id, $find_by_parent))
599 $find_by_parent = null;
603 else if(
sizeof($ref_map))
605 foreach($find_by_parent as
$obj_id)
608 if(
$res[$obj_id] ===
false)
610 if(isset($ref_map[$obj_id]))
613 foreach($ref_map[$obj_id] as
$ref_id)
615 $parent_ref_id = $tree->getParentId($ref_id);
616 if($parent_ref_id == ROOT_FOLDER_ID)
623 $found = self::findMembershipsByPath(
$res, $a_usr_id, $parent_ref_id, $ref_map,
true);
628 foreach($found as $found_obj_id => $found_ref_ids)
630 $diff = array_diff($ref_map[$found_obj_id], $found_ref_ids);
635 $ref_map[$found_obj_id] = $diff;
641 unset($ref_map[$found_obj_id]);
651 $find_by_parent = array_keys($ref_map);
655 if(
sizeof($find_by_parent))
657 $set = $ilDB->query(
"SELECT obj_id".
659 " WHERE ".$ilDB->in(
"obj_id", $find_by_parent,
"",
"integer").
660 " AND usr_id = ".$ilDB->quote($a_usr_id,
"integer"));
661 while(
$row = $ilDB->fetchAssoc($set))
683 return !in_array($a_obj_type,
array(
"exc",
"file",
"mcst",
"mob",
"htlm"));
688 return !in_array($a_obj_type,
array(
"lm",
"dbk"));
693 return !in_array($a_obj_type,
array(
'svy',
'tst',
'htlm',
'exc',
'sess',
'file',
'prg'));
713 if(!is_array(self::$type_defaults))
715 self::$type_defaults =
array();
716 $set = $ilDB->query(
"SELECT * FROM ut_lp_defaults");
717 while(
$row = $ilDB->fetchAssoc($set))
719 self::$type_defaults[
$row[
"type_id"]] = $row[
"lp_mode"];
722 return self::$type_defaults[
$a_type];
729 $ilDB->manipulate(
"DELETE FROM ut_lp_defaults");
730 foreach($a_data as $type =>
$mode)
732 $ilDB->insert(
"ut_lp_defaults",
array(
733 "type_id" =>
array(
"text", $type),
747 $db = self::getTypeDefaultFromDB(
$a_type);
753 $class = self::getTypeClass(
$a_type);
754 $olp =
new $class(0);
755 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)
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)