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");
47 public function __construct($a_id = 0, $a_call_by_reference =
true)
51 parent::__construct($a_id, $a_call_by_reference);
60 $this->webdir = $DIC->filesystem()->web();
65 self::initStudyProgrammeCache();
70 if (self::$study_programme_cache === null) {
82 if (!$this->sp_user_progress_db) {
83 $this->sp_user_progress_db = static::_getStudyProgrammeUserProgressDB();
95 require_once(
"./Modules/StudyProgramme/classes/class.ilStudyProgrammeUserProgressDB.php");
118 $this->children = null;
126 $this->lp_children = null;
138 require_once(
"Modules/StudyProgramme/classes/class.ilObjStudyProgrammeCache.php");
139 if (self::$study_programme_cache === null) {
140 self::initStudyProgrammeCache();
142 return self::$study_programme_cache->getInstanceByRefId($a_ref_id);
152 $obj->createReference();
153 self::$study_programme_cache->addInstance($obj);
169 throw new ilException(
"ilObjStudyProgramme::loadSettings: already loaded.");
173 throw new ilException(
"ilObjStudyProgramme::loadSettings: no id.");
185 throw new ilException(
"ilObjStudyProgramme::createSettings: already loaded.");
190 throw new ilException(
"ilObjStudyProgramme::loadSettings: no id.");
202 throw new ilException(
"ilObjStudyProgramme::updateSettings: no settings loaded.");
214 throw new Exception(
"ilObjStudyProgramme::deleteSettings: no settings loaded.");
238 $id = parent::create();
265 public function delete()
268 if (!parent::delete()) {
293 return $this->
settings->getLastChange();
303 return $this->
settings->getPoints();
315 $this->
settings->setPoints($a_points);
327 return $this->
settings->getLPMode();
361 return $this->
settings->getStatus();
372 $this->
settings->setStatus($a_status);
394 return $this->
settings->getSubtypeId();
407 $this->
settings->setSubtypeId($a_subtype_id);
418 if (!in_array($this->
getSubtypeId(), array(
"-",
"0"))) {
442 $root = self::getInstanceByRefId($a_ref_id);
443 $root_id =
$root->getId();
444 $root->applyToSubTreeNodes(
function ($prg) use (&
$ret, $root_id) {
446 if ($prg->getId() == $root_id) {
466 if ($this->children === null) {
467 $ref_ids = $this->tree->getChildsByType($this->
getRefId(),
"prg");
471 $ref_ids = $sorting->sortItems(array(
'prg' => $ref_ids));
472 $ref_ids = $ref_ids[
'prg'];
474 $this->children = array_map(
function ($node_data) {
492 if ($this->
parent ===
false) {
494 $parent_data = $this->tree->getParentNodeData($this->
getRefId());
495 if ($parent_data[
"type"] !=
"prg") {
516 return array_reverse($parents);
559 while ($cur = $cur->getParent()) {
590 if ($this->lp_children === null) {
591 $this->lp_children = array();
594 $ref_ids = $this->tree->getChildsByType($this->
getRefId(),
"crsr");
598 $ref_ids = $sorting->sortItems(array(
'crs_ref' => $ref_ids));
599 $ref_ids = $ref_ids[
'crs_ref'];
602 $lp_obj = $this->object_factory->getInstanceByRefId($node_data[
"child"]);
605 return ($lp_obj instanceof $this)? null : $lp_obj;
622 return array_map(
function ($child) {
623 return $child->getId();
655 if (!$this->tree->isInTree($this->getRefId())) {
678 if ($fun($this) !==
false) {
680 $child->applyToSubTreeNodes($fun);
693 require_once(
"Services/ContainerReference/classes/class.ilContainerReference.php");
694 require_once(
"Services/Tracking/classes/class.ilLPStatus.php");
696 $node_data = $this->tree->getNodeData($this->
getRefId());
697 $crsrs = $this->tree->getSubTree($node_data,
true,
"crsr");
699 $completed_crss = array();
700 foreach ($crsrs as $ref) {
703 $completed_crss[] = array(
"crs_id" => $crs_id
704 ,
"prg_ref_id" => $ref[
"parent"]
705 ,
"crsr_ref_id" => $ref[
"child"]
706 ,
"crsr_id" => $ref[
"obj_id"]
712 return $completed_crss;
737 if ($this->tree->isInTree($a_prg->
getRefId())) {
773 $res = parent::putInTree($a_parent_ref);
777 $par->nodeInserted($this);
804 $node_data = $this->tree->getNodeData($a_prg->
getRefId());
805 $this->tree->deleteTree($node_data);
824 if ($progress->getLastChangeBy() !== null) {
848 if ($a_leaf->getRefId() === null) {
849 $a_leaf->createReference();
851 $a_leaf->putInTree($this->
getRefId());
872 if (self::getParentId($a_leaf) !== $this->
getId()) {
876 $node_data = $this->tree->getNodeData($a_leaf->getRefId());
877 $this->tree->deleteTree($node_data);
912 $parent->clearLPChildrenCache();
938 public function assignUser($a_usr_id, $a_assigning_usr_id = null)
940 require_once(
"./Modules/StudyProgramme/classes/class.ilStudyProgrammeUserAssignment.php");
941 require_once(
"./Modules/StudyProgramme/classes/model/class.ilStudyProgrammeAssignment.php");
942 require_once(
"./Modules/StudyProgramme/classes/model/class.ilStudyProgrammeProgress.php");
943 require_once(
"./Modules/StudyProgramme/classes/class.ilStudyProgrammeEvents.php");
946 throw new ilException(
"ilObjStudyProgramme::assignUser: Program was not properly created.'");
950 throw new ilException(
"ilObjStudyProgramme::assignUser: Can't assign user to program '" 951 . $this->
getId() .
"', since it's not in active status.");
954 if ($a_assigning_usr_id === null) {
955 $a_assigning_usr_id = $this->ilUser->getId();
984 require_once(
"./Modules/StudyProgramme/classes/class.ilStudyProgrammeEvents.php");
987 throw new ilException(
"ilObjStudyProgramme::removeAssignment: Assignment '" 988 . $a_assignment->
getId() .
"' does not belong to study " 989 .
"program '" . $this->
getId() .
"'.");
1032 require_once(
"./Modules/StudyProgramme/classes/class.ilStudyProgrammeUserAssignment.php");
1036 ,
"root_prg_id" => $prg_ids
1038 ->orderBy(
"last_change",
"DESC")
1040 return array_map(
function ($ass) {
1042 }, array_values($assignments));
1052 return array_map(
function ($ass) {
1075 foreach ($assignments as $ass) {
1076 $ass->updateFromProgram();
1131 $ass->addMissingProgresses();
1163 if ($progress->isRelevant()) {
1179 if ($progress->isRelevant()) {
1180 $returns[] = $progress->getUserId();
1183 return array_unique($returns);
1195 if ($progress->isSuccessful()) {
1196 $returns[] = $progress->getUserId();
1199 return array_unique($returns);
1211 $progress->recalculateFailedToDeadline();
1212 if ($progress->isFailed()) {
1213 $returns[] = $progress->getUserId();
1216 return array_unique($returns);
1229 if ($progress->isRelevant() && !$progress->isSuccessful()) {
1230 $returns[] = $progress->getUserId();
1233 return array_unique($returns);
1245 $this->
settings->updateLastChange();
1258 $prg_ids = array_map(
function ($par) {
1259 return $par->getId();
1261 $prg_ids[] = $this->
getId();
1270 require_once(
"./Modules/StudyProgramme/classes/class.ilStudyProgrammeUserAssignment.php");
1273 ->orderBy(
"last_change",
"DESC")
1285 if (
$type ==
"crs") {
1286 require_once(
"Services/ContainerReference/classes/class.ilContainerReference.php");
1288 foreach ($crs_reference_obj_ids as $obj_id) {
1290 self::setProgressesCompletedIfParentIsProgrammeInLPCompletedMode($ref_id, $obj_id, $a_user_id);
1295 self::setProgressesCompletedIfParentIsProgrammeInLPCompletedMode($ref_id, $a_obj_id, $a_user_id);
1303 $tree = $DIC[
'tree'];
1304 $node_data =
$tree->getParentNodeData($a_ref_id);
1305 if ($node_data[
"type"] !==
"prg") {
1308 self::initStudyProgrammeCache();
1313 foreach ($prg->getProgressesOf($a_user_id) as $progress) {
1314 $progress->setLPCompleted($a_obj_id, $a_user_id);
1327 $tree = $DIC[
'tree'];
1333 return $nd[
"obj_id"];
1352 public function updateCustomIcon()
1357 $customIconFactory = $DIC[
'object.customicons.factory'];
1358 $customIcon = $customIconFactory->getByObjId($this->
getId(), $this->
getType());
1363 if ($this->webdir->has($subtype->getIconPath(
true))) {
1364 $icon = $subtype->getIconPath(
true);
1365 $customIcon->saveFromSourceFile($icon);
1367 $customIcon->remove();
1370 $customIcon->remove();
1390 if ($a_ref_id === null) {
1391 return $a_subobjects;
1395 throw new ilException(
"Ref-Id '$a_ref_id' does not belong to a study programme object.");
1404 return $a_subobjects;
1406 return array(
"prg" => $a_subobjects[
"prg"]);
1408 unset($a_subobjects[
"prg"]);
1409 return $a_subobjects;
1412 throw new ilException(
"Undefined mode for study programme: '$mode'");
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.
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.
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.
setSubtypeId($a_subtype_id)
Sets the meta-data subtype id.
getStatus()
Get the status.
getLPChildren()
Get the leafs the study programme contains.
getStudyProgramme()
Get the program node where this assignment was made.
removeLeaf( $a_leaf)
Remove a leaf from this object.
hasProgresses()
Are there any users that have a progress on this programme?
getAmountOfChildren()
Get the amount of other StudyProgrammes this StudyProgramme has as children.
static userAssigned(ilStudyProgrammeUserAssignment $a_assignment)
Storage implementation for ilStudyProgrammeUserProgress.
static initStudyProgrammeCache()
getStudyProgrammeUserProgressDB()
Get a (cached) instance of ilStudyProgrammeUserProgressDB.
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.
getIdsOfUsersWithFailedProgress()
Get the ids of all users that have failed this programme.
static where($where, $operator=null)
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.
static _getStudyProgrammeUserProgressDB()
Get an instance of ilStudyProgrammeUserProgressDB.
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.
foreach($_POST as $key=> $value) $res
clearChildrenCache()
Clear the cached children.
getId()
get object id public
hasRelevantProgresses()
Are there any users that have a relevant progress on this programme?
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.
delete()
Delete the assignment from database.
const STATUS_NOT_RELEVANT
getType()
get object type public
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
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...
update($pash, $contents, Config $config)
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.
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.
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.