5require_once(
"./Services/Container/classes/class.ilContainer.php");
6require_once(
'./Services/Container/classes/class.ilContainerSorting.php');
7require_once(
"./Modules/StudyProgramme/classes/model/class.ilStudyProgramme.php");
8require_once(
"./Modules/StudyProgramme/classes/class.ilObjectFactoryWrapper.php");
9require_once(
"./Modules/StudyProgramme/classes/interfaces/interface.ilStudyProgrammeLeaf.php");
10require_once(
"./Modules/StudyProgramme/classes/exceptions/class.ilStudyProgrammeTreeException.php");
11require_once(
"./Modules/StudyProgramme/classes/class.ilObjStudyProgrammeCache.php");
40 public function __construct($a_id = 0, $a_call_by_reference =
true) {
43 parent::__construct($a_id, $a_call_by_reference);
60 if (self::$study_programme_cache ===
null) {
70 $this->parent =
false;
77 $this->children =
null;
84 $this->lp_children =
null;
95 require_once(
"Modules/StudyProgramme/classes/class.ilObjStudyProgrammeCache.php");
96 if (self::$study_programme_cache ===
null) {
99 return self::$study_programme_cache->getInstanceByRefId($a_ref_id);
108 $obj->createReference();
109 self::$study_programme_cache->addInstance($obj);
124 throw new ilException(
"ilObjStudyProgramme::loadSettings: already loaded.");
128 throw new ilException(
"ilObjStudyProgramme::loadSettings: no id.");
139 throw new ilException(
"ilObjStudyProgramme::createSettings: already loaded.");
144 throw new ilException(
"ilObjStudyProgramme::loadSettings: no id.");
155 throw new ilException(
"ilObjStudyProgramme::updateSettings: no settings loaded.");
166 throw new Exception(
"ilObjStudyProgramme::deleteSettings: no settings loaded.");
187 $id = parent::create();
213 public function delete() {
215 if (!parent::delete()) {
239 return $this->
settings->getLastChange();
248 return $this->
settings->getPoints();
259 $this->
settings->setPoints($a_points);
270 return $this->
settings->getLPMode();
304 return $this->
settings->getStatus();
314 $this->
settings->setStatus($a_status);
334 return $this->
settings->getSubtypeId();
346 $this->
settings->setSubtypeId($a_subtype_id);
380 $root_id = $root->getId();
381 $root->applyToSubTreeNodes(
function($prg) use (&
$ret, $root_id) {
383 if ($prg->getId() == $root_id) {
402 if ($this->children ===
null) {
403 $ref_ids = $this->tree->getChildsByType($this->
getRefId(),
"prg");
407 $ref_ids = $sorting->sortItems(array(
'prg'=>$ref_ids));
408 $ref_ids = $ref_ids[
'prg'];
410 $this->children = array_map(
function($node_data) {
427 if ($this->parent ===
false) {
429 $parent_data = $this->tree->getParentNodeData($this->
getRefId());
430 if ($parent_data[
"type"] !=
"prg") {
431 $this->parent =
null;
449 $current = $current->getParent();
450 if ($current ===
null) {
451 return array_reverse($parents);
453 $parents[] = $current;
491 while ($cur = $cur->getParent()) {
520 if ($this->lp_children ===
null) {
521 $this->lp_children = array();
524 $ref_ids = $this->tree->getChildsByType($this->
getRefId(),
"crsr");
528 $ref_ids = $sorting->sortItems(array(
'crs_ref'=>$ref_ids));
529 $ref_ids = $ref_ids[
'crs_ref'];
532 $lp_obj = $this->object_factory->getInstanceByRefId($node_data[
"child"]);
535 return ($lp_obj instanceof $this)?
null : $lp_obj;
551 return array_map(
function($child) {
552 return $child->getId();
581 if (!$this->tree->isInTree($this->getRefId())) {
603 if ($fun($this) !==
false) {
605 $child->applyToSubTreeNodes($fun);
617 require_once(
"Services/ContainerReference/classes/class.ilContainerReference.php");
618 require_once(
"Services/Tracking/classes/class.ilLPStatus.php");
620 $node_data = $this->tree->getNodeData($this->
getRefId());
621 $crsrs = $this->tree->getSubTree($node_data,
true,
"crsr");
623 $completed_crss = array();
624 foreach ($crsrs as $ref) {
627 $completed_crss[] = array(
"crs_id" => $crs_id
628 ,
"prg_ref_id" => $ref[
"parent"]
629 ,
"crsr_ref_id" => $ref[
"child"]
630 ,
"crsr_id" => $ref[
"obj_id"]
636 return $completed_crss;
660 if ($this->tree->isInTree($a_prg->
getRefId())) {
694 $res = parent::putInTree($a_parent_ref);
698 $par->nodeInserted($this);
715 if ($a_prg->
getParent()->getId() !== $this->getId()) {
724 $node_data = $this->tree->getNodeData($a_prg->
getRefId());
725 $this->tree->deleteTree($node_data);
743 if ($progress->getLastChangeBy() !==
null) {
766 if ($a_leaf->getRefId() ===
null) {
767 $a_leaf->createReference();
769 $a_leaf->putInTree($this->
getRefId());
789 if (self::getParentId($a_leaf) !== $this->
getId()) {
793 $node_data = $this->tree->getNodeData($a_leaf->getRefId());
794 $this->tree->deleteTree($node_data);
812 $rbacadmin =
$DIC[
'rbacadmin'];
820 $rbacadmin->adjustMovedObjectPermissions($this->
getRefId(),
$parent->getRefId());
828 $parent->clearLPChildrenCache();
854 public function assignUser($a_usr_id, $a_assigning_usr_id =
null) {
855 require_once(
"./Modules/StudyProgramme/classes/class.ilStudyProgrammeUserAssignment.php");
856 require_once(
"./Modules/StudyProgramme/classes/model/class.ilStudyProgrammeAssignment.php");
857 require_once(
"./Modules/StudyProgramme/classes/model/class.ilStudyProgrammeProgress.php");
858 require_once(
"./Modules/StudyProgramme/classes/class.ilStudyProgrammeEvents.php");
861 throw new ilException(
"ilObjStudyProgramme::assignUser: Program was not properly created.'");
865 throw new ilException(
"ilObjStudyProgramme::assignUser: Can't assign user to program '"
866 .$this->
getId().
"', since it's not in active status.");
869 if ($a_assigning_usr_id ===
null) {
870 $a_assigning_usr_id = $this->ilUser->getId();
879 $progress->setStatus(ilStudyProgrammeProgress::STATUS_NOT_RELEVANT)
898 require_once(
"./Modules/StudyProgramme/classes/class.ilStudyProgrammeEvents.php");
901 throw new ilException(
"ilObjStudyProgramme::removeAssignment: Assignment '"
902 .$a_assignment->
getId().
"' does not belong to study "
903 .
"program '".$this->getId().
"'.");
943 require_once(
"./Modules/StudyProgramme/classes/class.ilStudyProgrammeUserAssignment.php");
947 ,
"root_prg_id" => $prg_ids
949 ->orderBy(
"last_change",
"DESC")
951 return array_map(
function($ass) {
953 }, array_values($assignments));
962 return array_map(
function($ass) {
983 foreach ($assignments as $ass) {
984 $ass->updateFromProgram();
1010 require_once(
"./Modules/StudyProgramme/classes/class.ilStudyProgrammeUserProgress.php");
1024 require_once(
"./Modules/StudyProgramme/classes/class.ilStudyProgrammeUserProgress.php");
1037 $ass->addMissingProgresses();
1047 require_once(
"./Modules/StudyProgramme/classes/class.ilStudyProgrammeUserProgress.php");
1067 if ($progress->isRelevant()) {
1082 if ($progress->isRelevant()) {
1083 $returns[] = $progress->getUserId();
1086 return array_unique($returns);
1097 if ($progress->isSuccessful()) {
1098 $returns[] = $progress->getUserId();
1101 return array_unique($returns);
1113 if ($progress->isRelevant() && !$progress->isSuccessful()) {
1114 $returns[] = $progress->getUserId();
1117 return array_unique($returns);
1128 $this->
settings->updateLastChange();
1140 $prg_ids =array_map(
function($par) {
1141 return $par->getId();
1143 $prg_ids[] = $this->
getId();
1151 require_once(
"./Modules/StudyProgramme/classes/class.ilStudyProgrammeUserAssignment.php");
1154 ->orderBy(
"last_change",
"DESC")
1165 if (
$type ==
"crs") {
1166 require_once(
"Services/ContainerReference/classes/class.ilContainerReference.php");
1168 foreach ($crs_reference_obj_ids as $obj_id) {
1184 $node_data =
$tree->getParentNodeData($a_ref_id);
1185 if ($node_data[
"type"] !==
"prg") {
1193 foreach ($prg->getProgressesOf($a_user_id) as $progress) {
1194 $progress->setLPCompleted($a_obj_id, $a_user_id);
1212 return $nd[
"obj_id"];
1234 if(is_file($subtype->getIconPath(
true))) {
1235 $icon = $subtype->getIconPath(
true);
1260 if ($a_ref_id ===
null) {
1261 return $a_subobjects;
1265 throw new ilException(
"Ref-Id '$a_ref_id' does not belong to a study programme object.");
1274 return $a_subobjects;
1276 return array(
"prg" => $a_subobjects[
"prg"]);
1278 unset($a_subobjects[
"prg"]);
1279 return $a_subobjects;
1282 throw new ilException(
"Undefined mode for study programme: '$mode'");
1300 if ($a_custom_icon !=
"")
1302 $file_name = $cont_dir.
"/icon_custom.svg";
1306 if ($file_name !=
"" && is_file($file_name))
static where($where, $operator=null)
An exception for terminatinating execution or to throw for unit testing.
static saveObjRecSelection($a_obj_id, $a_sub_type="", array $a_records=null, $a_delete_before=true)
Save repository object record selection.
static _lookupTargetId($a_obj_id)
lookup target id
static _lookupTargetTitle($a_obj_id)
Lookup target title.
static _lookupSourceIds($a_target_id)
Get ids of all container references that target the object with the given id.
static _getInstance($a_obj_id)
get instance by obj_id
getContainerDirectory()
Get the container directory.
createContainerDirectory()
Create directory for the container.
static _writeContainerSetting($a_id, $a_keyword, $a_value)
removeCustomIcon()
remove small icon
Base class for ILIAS Exception handling.
static _hasUserCompleted($a_obj_id, $a_user_id)
Lookup user object completion.
Class ilObjStudyProgramme.
getLPChildren()
Get the leafs the study programme contains.
getCompletedCourses($a_user_id)
Get courses in this program that the given user already completed.
hasLPChildren()
Does this StudyProgramme has leafs?
getRoot()
Get the ilObjStudyProgramme that is the root node of the tree this programme is in.
getAssignmentsRaw()
Get model objects for the assignments on this programm.
getAmountOfAssignmentsOf($a_user_id)
Get the amount of assignments a user has on this program node or any node above.
getIdsFromNodesOnPathFromRootToHere()
Get the ids from the nodes in the path leading from the root node of this program to this node,...
getProgressesOf($a_user_id)
Get the progresses the user has on this node.
getAmountOfChildren()
Get the amount of other StudyProgrammes this StudyProgramme has as children.
saveIcons($a_custom_icon)
save container icons
static initStudyProgrammeCache()
canBeRemoved()
Check weather a node can be removed.
getIdsOfUsersWithNotCompletedAndRelevantProgress()
Get the ids of all users that have not completed this programme but have a relevant progress on it.
static $study_programme_cache
static getCreatableSubObjects($a_subobjects, $a_ref_id)
Filter the list of possible subobjects for the objects that actually could be created on a concrete n...
setStatus($a_status)
Set the status of the node.
deleteAssignments()
Delete all assignments from the DB.
updateCustomIcon()
updates the selected custom icon in container folder by type
readSettings()
Load Settings from DB.
hasAssignmentOf($a_user_id)
Check whether user is assigned to this program or any node above.
createProgressForAssignment(ilStudyProgrammeAssignment $ass)
Create a progress on this programme for the given assignment.
getProgressForAssignment($a_assignment_id)
Get the progress for an assignment on this node.
static setProgressesCompletedIfParentIsProgrammeInLPCompletedMode($a_ref_id, $a_obj_id, $a_user_id)
static setProgressesCompletedFor($a_obj_id, $a_user_id)
Set all progresses to completed where the object with given id is a leaf and that belong to the user.
getSubtypeId()
Gets the meta-data subtype id (allows to add additional meta-data based on a type)
static getAllChildren($a_ref_id)
Get a list of all ilObjStudyProgrammes in the subtree starting at $a_ref_id.
static getInstanceByRefId($a_ref_id)
Get an instance of ilObjStudyProgramme, use cache.
getPoints()
Get the amount of points.
getParents()
Get all parents of the node, where the root of the program comes first.
addLeaf( $a_leaf)
Insert a leaf in this object.
moveTo(ilObjStudyProgramme $a_new_parent)
Move this tree node to a new parent.
createSettings()
Create new settings object.
getAssignments()
Get all assignments to this program or any node above.
clearLPChildrenCache()
Clear the cached lp children.
static getParentId(ilObject $a_object)
Get the obj id of the parent object for the given object.
removeLeaf( $a_leaf)
Remove a leaf from this object.
getRawSettings()
Get the underlying model of this program.
clearParentCache()
Clear the cached parent to query it again at the tree.
addMissingProgresses()
Add missing progress records for all assignments of this programm.
getProgresses()
Get all progresses on this node.
updateAllAssignments()
Update all assignments to this program node.
setPoints($a_points)
Set the amount of points.
getLPMode()
Get the lp mode.
applyToSubTreeNodes(Closure $fun)
Apply the given Closure to every node in the subtree starting at this object.
nodeInserted(ilObjStudyProgramme $a_prg)
Clears child chache and adds progress for new node.
getChildren()
Get all ilObjStudyProgrammes that are direct children of this object.
getLastChange()
Get the timestamp of the last change on this program or sub program.
throwIfNotInTree()
Helper function to check, weather object is in tree.
clearChildrenCache()
Clear the cached children.
hasProgresses()
Are there any users that have a progress on this programme?
getIdsOfUsersWithRelevantProgress()
Get the ids of all users that have a relevant progress at this programme.
getDepth()
Get the depth of this StudyProgramme in the tree starting at the topmost StudyProgramme (not root nod...
static createInstance()
Create an instance of ilObjStudyProgramme, put in cache.
getSubType()
Gets the SubType Object.
isActive()
Check whether this programme is active.
getAssignmentsOf($a_user_id)
Get the assignments of user at this program or any node above.
removeNode(ilObjStudyProgramme $a_prg)
Remove a node from this object.
__construct($a_id=0, $a_call_by_reference=true)
ATTENTION: After using the constructor the object won't be in the cache.
removeAssignment(ilStudyProgrammeUserAssignment $a_assignment)
Remove an assignment from this program.
hasAssignments()
Are there any assignments on this node or any node above?
setSubtypeId($a_subtype_id)
Sets the meta-data subtype id.
getParent()
Get the parent ilObjStudyProgramme of this object.
hasRelevantProgresses()
Are there any users that have a relevant progress on this programme?
assignUser($a_usr_id, $a_assigning_usr_id=null)
Assign a user to this node at the study program.
getLPChildrenIds()
Get the ids of the leafs the program contains.
deleteSettings()
Delete settings from DB.
updateLastChange()
Update last change timestamp on this node and its parents.
getAmountOfLPChildren()
Get the amount of leafs, the study programme contains.
putInTree($a_parent_ref)
Overwritten from ilObject.
adjustLPMode()
Adjust the lp mode to match current state of tree:
getStatus()
Get the status.
addNode(ilObjStudyProgramme $a_prg)
Inserts another ilObjStudyProgramme in this object.
getIdsOfUsersWithCompletedProgress()
Get the ids of all users that have completed this programme.
updateSettings()
Update settings in DB.
hasChildren()
Does this StudyProgramme have other ilObjStudyProgrammes as children?
Class ilObject Basic functions for all objects.
createReference()
creates reference for object
getRefId()
get reference id @access public
static _getAllReferences($a_id)
get all reference ids of object
getId()
get object id @access public
static _lookupType($a_id, $a_reference=false)
lookup object type
Class ilStudyProgrammeAssignment.
static createFor(ilStudyProgramme $a_prg, $a_usr_id, $a_assigning_usr_id)
Create new assignment object for study program and user.
static userAssigned(ilStudyProgrammeUserAssignment $a_assignment)
static userDeassigned(ilStudyProgrammeUserAssignment $a_assignment)
const STATUS_NOT_RELEVANT
static createFor(ilStudyProgramme $a_prg, ilStudyProgrammeAssignment $a_ass)
Create a new progress object for a given program node and assignment.
Exception is thrown when invariants on the program tree would be violated by manipulation of tree.
Class ilStudyProgrammeType.
Represents one assignment of a user to a study programme.
getStudyProgramme()
Get the program node where this assignment was made.
getId()
Get the id of the assignment.
delete()
Delete the assignment from database.
static getInstancesForProgram($a_program_id)
Get all assignments that were made to the given program.
static getInstancesForUser($a_program_id, $a_user_id)
Get the instances that user has on program.
static getInstanceForAssignment($a_program_id, $a_assignment_id)
Get the instance for the assignment on the program.
static getInstancesForProgram($a_program_id)
Get the instances for a program node.
static createForObject(ilObject $a_object)
Create new study program settings for an object.
static moveUploadedFile($a_file, $a_name, $a_target, $a_raise_errors=true, $a_mode="move_uploaded")
move uploaded file