5 require_once(
"./Services/Container/classes/class.ilContainer.php");
6 require_once(
'./Services/Container/classes/class.ilContainerSorting.php');
7 require_once(
"./Modules/StudyProgramme/classes/model/class.ilStudyProgramme.php");
8 require_once(
"./Modules/StudyProgramme/classes/class.ilObjectFactoryWrapper.php");
9 require_once(
"./Modules/StudyProgramme/classes/interfaces/interface.ilStudyProgrammeLeaf.php");
10 require_once(
"./Modules/StudyProgramme/classes/exceptions/class.ilStudyProgrammeTreeException.php");
11 require_once(
"./Modules/StudyProgramme/classes/class.ilObjStudyProgrammeCache.php");
40 public function __construct($a_id = 0, $a_call_by_reference =
true) {
42 $this->settings = null;
54 self::initStudyProgrammeCache();
58 if (self::$study_programme_cache === null) {
68 $this->parent =
false;
75 $this->children = null;
82 $this->lp_children = null;
93 require_once(
"Modules/StudyProgramme/classes/class.ilObjStudyProgrammeCache.php");
94 if (self::$study_programme_cache === null) {
95 self::initStudyProgrammeCache();
97 return self::$study_programme_cache->getInstanceByRefId($a_ref_id);
106 $obj->createReference();
107 self::$study_programme_cache->addInstance($obj);
121 if ($this->settings !== null) {
122 throw new ilException(
"ilObjStudyProgramme::loadSettings: already loaded.");
126 throw new ilException(
"ilObjStudyProgramme::loadSettings: no id.");
136 if ($this->settings !== null) {
137 throw new ilException(
"ilObjStudyProgramme::createSettings: already loaded.");
142 throw new ilException(
"ilObjStudyProgramme::loadSettings: no id.");
152 if ($this->settings === null) {
153 throw new ilException(
"ilObjStudyProgramme::updateSettings: no settings loaded.");
155 $this->settings->update();
163 if ($this->settings === null) {
164 throw new Exception(
"ilObjStudyProgramme::deleteSettings: no settings loaded.");
166 $this->settings->delete();
185 $id = parent::create();
211 public function delete() {
213 if (!parent::delete()) {
237 return $this->settings->getLastChange();
246 return $this->settings->getPoints();
257 $this->settings->setPoints($a_points);
268 return $this->settings->getLPMode();
302 return $this->settings->getStatus();
312 $this->settings->setStatus($a_status);
332 return $this->settings->getSubtypeId();
344 $this->settings->setSubtypeId($a_subtype_id);
377 $root = self::getInstanceByRefId($a_ref_id);
378 $root_id = $root->getId();
379 $root->applyToSubTreeNodes(
function($prg) use (&
$ret, $root_id) {
381 if ($prg->getId() == $root_id) {
400 if ($this->children === null) {
401 $ref_ids = $this->tree->getChildsByType($this->
getRefId(),
"prg");
405 $ref_ids = $sorting->sortItems(array(
'prg'=>$ref_ids));
406 $ref_ids = $ref_ids[
'prg'];
408 $this->children = array_map(
function($node_data) {
425 if ($this->parent ===
false) {
427 $parent_data = $this->tree->getParentNodeData($this->
getRefId());
428 if ($parent_data[
"type"] !=
"prg") {
429 $this->parent = null;
447 $current = $current->getParent();
448 if ($current === null) {
449 return array_reverse($parents);
451 $parents[] = $current;
489 while ($cur = $cur->getParent()) {
518 if ($this->lp_children === null) {
519 $this->lp_children = array();
522 $ref_ids = $this->tree->getChildsByType($this->
getRefId(),
"crsr");
526 $ref_ids = $sorting->sortItems(array(
'crs_ref'=>$ref_ids));
527 $ref_ids = $ref_ids[
'crs_ref'];
531 $lp_children = array_map(
function($node_data) use ($self) {
532 $lp_obj = $self->object_factory->getInstanceByRefId($node_data[
"child"]);
535 return ($lp_obj instanceof $self)? 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);
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);
819 $rbacadmin->adjustMovedObjectPermissions($this->
getRefId(),
$parent->getRefId());
827 $parent->clearLPChildrenCache();
853 public function assignUser($a_usr_id, $a_assigning_usr_id = null) {
854 require_once(
"./Modules/StudyProgramme/classes/class.ilStudyProgrammeUserAssignment.php");
855 require_once(
"./Modules/StudyProgramme/classes/model/class.ilStudyProgrammeAssignment.php");
856 require_once(
"./Modules/StudyProgramme/classes/model/class.ilStudyProgrammeProgress.php");
857 require_once(
"./Modules/StudyProgramme/classes/class.ilStudyProgrammeEvents.php");
859 if ($this->settings === null) {
860 throw new ilException(
"ilObjStudyProgramme::assignUser: Program was not properly created.'");
864 throw new ilException(
"ilObjStudyProgramme::assignUser: Can't assign user to program '" 865 .$this->
getId().
"', since it's not in active status.");
868 if ($a_assigning_usr_id === null) {
869 $a_assigning_usr_id = $this->ilUser->getId();
897 require_once(
"./Modules/StudyProgramme/classes/class.ilStudyProgrammeEvents.php");
900 throw new ilException(
"ilObjStudyProgramme::removeAssignment: Assignment '" 901 .$a_assignment->
getId().
"' does not belong to study " 902 .
"program '".$this->
getId().
"'.");
942 require_once(
"./Modules/StudyProgramme/classes/class.ilStudyProgrammeUserAssignment.php");
946 ,
"root_prg_id" => $prg_ids
948 ->orderBy(
"last_change",
"DESC")
950 return array_map(
function($ass) {
952 }, array_values($assignments));
961 return array_map(
function($ass) {
982 foreach ($assignments as $ass) {
983 $ass->updateFromProgram();
1009 require_once(
"./Modules/StudyProgramme/classes/class.ilStudyProgrammeUserProgress.php");
1023 require_once(
"./Modules/StudyProgramme/classes/class.ilStudyProgrammeUserProgress.php");
1036 $ass->addMissingProgresses();
1046 require_once(
"./Modules/StudyProgramme/classes/class.ilStudyProgrammeUserProgress.php");
1066 if ($progress->isRelevant()) {
1081 if ($progress->isRelevant()) {
1082 $returns[] = $progress->getUserId();
1085 return array_unique($returns);
1096 if ($progress->isSuccessful()) {
1097 $returns[] = $progress->getUserId();
1100 return array_unique($returns);
1112 if ($progress->isRelevant() && !$progress->isSuccessful()) {
1113 $returns[] = $progress->getUserId();
1116 return array_unique($returns);
1127 $this->settings->updateLastChange();
1139 $prg_ids =array_map(
function($par) {
1140 return $par->getId();
1142 $prg_ids[] = $this->
getId();
1150 require_once(
"./Modules/StudyProgramme/classes/class.ilStudyProgrammeUserAssignment.php");
1153 ->orderBy(
"last_change",
"DESC")
1164 if (
$type ==
"crs") {
1165 require_once(
"Services/ContainerReference/classes/class.ilContainerReference.php");
1167 foreach ($crs_reference_obj_ids as $obj_id) {
1169 self::setProgressesCompletedIfParentIsProgrammeInLPCompletedMode($ref_id, $obj_id, $a_user_id);
1175 self::setProgressesCompletedIfParentIsProgrammeInLPCompletedMode($ref_id, $a_obj_id, $a_user_id);
1182 $node_data = $tree->getParentNodeData($a_ref_id);
1183 if ($node_data[
"type"] !==
"prg") {
1186 self::initStudyProgrammeCache();
1191 foreach ($prg->getProgressesOf($a_user_id) as $progress) {
1192 $progress->setLPCompleted($a_obj_id, $a_user_id);
1204 if (!$tree->isInTree($a_object->
getRefId())) {
1208 $nd = $tree->getParentNodeData($a_object->
getRefId());
1209 return $nd[
"obj_id"];
1231 if(is_file($subtype->getIconPath(
true))) {
1232 $icon = $subtype->getIconPath(
true);
1257 if ($a_ref_id === null) {
1258 return $a_subobjects;
1262 throw new ilException(
"Ref-Id '$a_ref_id' does not belong to a study programme object.");
1271 return $a_subobjects;
1273 return array(
"prg" => $a_subobjects[
"prg"]);
1275 unset($a_subobjects[
"prg"]);
1276 return $a_subobjects;
1279 throw new ilException(
"Undefined mode for study programme: '$mode'");
1296 if ($a_custom_icon !=
"")
1298 $file_name = $cont_dir.
"/icon_custom.svg";
1302 if ($file_name !=
"" && is_file($file_name))
updateAllAssignments()
Update all assignments to this program node.
adjustLPMode()
Adjust the lp mode to match current state of tree:
addNode(ilObjStudyProgramme $a_prg)
Inserts another ilObjStudyProgramme in this object.
clearLPChildrenCache()
Clear the cached lp children.
static getAllChildren($a_ref_id)
Get a list of all ilObjStudyProgrammes in the subtree starting at $a_ref_id.
Base class for ILIAS Exception handling.
getSubType()
Gets the SubType Object.
applyToSubTreeNodes(Closure $fun)
Apply the given Closure to every node in the subtree starting at this object.
setPoints($a_points)
Set the amount of points.
static createFor(ilStudyProgramme $a_prg, ilStudyProgrammeAssignment $a_ass)
Create a new progress object for a given program node and assignment.
getParent()
Get the parent ilObjStudyProgramme of this object.
assignUser($a_usr_id, $a_assigning_usr_id=null)
Assign a user to this node at the study program.
addLeaf( $a_leaf)
Insert a leaf in this object.
static getInstanceForAssignment($a_program_id, $a_assignment_id)
Get the instance for the assignment on the program.
getIdsOfUsersWithCompletedProgress()
Get the ids of all users that have completed this programme.
createSettings()
Create new settings object.
getCompletedCourses($a_user_id)
Get courses in this program that the given user already completed.
hasChildren()
Does this StudyProgramme have other ilObjStudyProgrammes as children?
updateSettings()
Update settings in DB.
removeCustomIcon()
remove small icon
setSubtypeId($a_subtype_id)
Sets the meta-data subtype id.
getStatus()
Get the status.
getLPChildren()
Get the leafs the study programme contains.
Class ilObject Basic functions for all objects.
getStudyProgramme()
Get the program node where this assignment was made.
updateCustomIcon()
updates the selected custom icon in container folder by type
removeLeaf( $a_leaf)
Remove a leaf from this object.
hasProgresses()
Are there any users that have a progress on this programme?
_writeContainerSetting($a_id, $a_keyword, $a_value)
getAmountOfChildren()
Get the amount of other StudyProgrammes this StudyProgramme has as children.
static userAssigned(ilStudyProgrammeUserAssignment $a_assignment)
static initStudyProgrammeCache()
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.
isActive()
Check whether this programme is active.
deleteSettings()
Delete settings from DB.
getLPMode()
Get the lp mode.
getAssignmentsOf($a_user_id)
Get the assignments of user at this program or any node above.
static getInstancesForUser($a_program_id, $a_user_id)
Get the instances that user has on program.
static saveObjRecSelection($a_obj_id, $a_sub_type="", array $a_records=null, $a_delete_before=true)
Save repository object record selection.
hasLPChildren()
Does this StudyProgramme has leafs?
static _getAllReferences($a_id)
get all reference ids of object
setStatus($a_status)
Set the status of the node.
getAmountOfLPChildren()
Get the amount of leafs, the study programme contains.
saveIcons($a_custom_icon)
save container icons
getRoot()
Get the ilObjStudyProgramme that is the root node of the tree this programme is in.
static getInstanceByRefId($a_ref_id)
Get an instance of ilObjStudyProgramme, use cache.
static getParentId(ilObject $a_object)
Get the obj id of the parent object for the given object.
createReference()
creates reference for object
removeNode(ilObjStudyProgramme $a_prg)
Remove a node from this object.
hasAssignments()
Are there any assignments on this node or any node above?
getProgresses()
Get all progresses on this node.
getContainerDirectory()
Get the container directory.
clearChildrenCache()
Clear the cached children.
getId()
get object id public
hasRelevantProgresses()
Are there any users that have a relevant progress on this programme?
static moveUploadedFile($a_file, $a_name, $a_target, $a_raise_errors=true, $a_mode="move_uploaded")
move uploaded file
static _hasUserCompleted($a_obj_id, $a_user_id)
Lookup user object completion.
Class ilObjStudyProgramme.
getProgressForAssignment($a_assignment_id)
Get the progress for an assignment on this node.
nodeInserted(ilObjStudyProgramme $a_prg)
Clears child chache and adds progress for new node.
getIdsOfUsersWithNotCompletedAndRelevantProgress()
Get the ids of all users that have not completed this programme but have a relevant progress on it...
static _lookupTargetTitle($a_obj_id)
Lookup target title.
Class ilStudyProgrammeAssignment.
static where($where, $operator=NULL)
delete()
Delete the assignment from database.
const STATUS_NOT_RELEVANT
static setProgressesCompletedIfParentIsProgrammeInLPCompletedMode($a_ref_id, $a_obj_id, $a_user_id)
static userDeassigned(ilStudyProgrammeUserAssignment $a_assignment)
getId()
Get the id of the assignment.
static _lookupType($a_id, $a_reference=false)
lookup object type
ilContainer($a_id=0, $a_call_by_reference=true)
Constructor public.
getIdsOfUsersWithRelevantProgress()
Get the ids of all users that have a relevant progress at this programme.
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...
getProgressesOf($a_user_id)
Get the progresses the user has on this node.
getLastChange()
Get the timestamp of the last change on this program or sub program.
static createForObject(ilObject $a_object)
Create new study program settings for an object.
static getInstancesForProgram($a_program_id)
Get all assignments that were made to the given program.
addMissingProgresses()
Add missing progress records for all assignments of this programm.
putInTree($a_parent_ref)
Overwritten from ilObject.
Class ilStudyProgrammeType.
getSubtypeId()
Gets the meta-data subtype id (allows to add additional meta-data based on a type) ...
canBeRemoved()
Check weather a node can be removed.
getDepth()
Get the depth of this StudyProgramme in the tree starting at the topmost StudyProgramme (not root nod...
getRawSettings()
Get the underlying model of this program.
getChildren()
Get all ilObjStudyProgrammes that are direct children of this object.
getLPChildrenIds()
Get the ids of the leafs the program contains.
getRefId()
get reference id public
static createFor(ilStudyProgramme $a_prg, $a_usr_id, $a_assigning_usr_id)
Create new assignment object for study program and user.
static createInstance()
Create an instance of ilObjStudyProgramme, put in cache.
removeAssignment(ilStudyProgrammeUserAssignment $a_assignment)
Remove an assignment from this program.
getPoints()
Get the amount of points.
static _getInstance($a_obj_id)
get instance by obj_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...
throwIfNotInTree()
Helper function to check, weather object is in tree.
deleteAssignments()
Delete all assignments from the DB.
createContainerDirectory()
Create directory for the container.
hasAssignmentOf($a_user_id)
Check whether user is assigned to this program or any node above.
static _lookupSourceIds($a_target_id)
Get ids of all container references that target the object with the given id.
__construct($a_id=0, $a_call_by_reference=true)
ATTENTION: After using the constructor the object won't be in the cache.
Exception is thrown when invariants on the program tree would be violated by manipulation of tree...
moveTo(ilObjStudyProgramme $a_new_parent)
Move this tree node to a new parent.
getIdsFromNodesOnPathFromRootToHere()
Get the ids from the nodes in the path leading from the root node of this program to this node...
static _lookupTargetId($a_obj_id)
lookup target id
getParents()
Get all parents of the node, where the root of the program comes first.
Represents one assignment of a user to a study programme.
static getInstancesForProgram($a_program_id)
Get the instances for a program node.
updateLastChange()
Update last change timestamp on this node and its parents.
clearParentCache()
Clear the cached parent to query it again at the tree.
static $study_programme_cache
readSettings()
Load Settings from DB.
createProgressForAssignment(ilStudyProgrammeAssignment $ass)
Create a progress on this programme for the given assignment.
getAssignments()
Get all assignments to this program or any node above.