ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
class.ilStudyProgrammeUserAssignmentDB.php
Go to the documentation of this file.
1<?php
2
3declare(strict_types=1);
4
6{
11
16
20 protected $tree;
21
25 protected $sp_events;
26
27 public function __construct(
32 ) {
33 $this->sp_user_progress_db = $sp_user_progress_db;
34 $this->assignment_repository = $assignment_repository;
35 $this->tree = $tree;
36 $this->sp_events = $sp_events;
37 }
38
39 public function getInstanceById(int $id)
40 {
41 $assignment = $this->assignment_repository->read($id);
42 if ($assignment === null) {
43 throw new ilException("ilStudyProgrammeUserAssignment::__construct: "
44 . "Unknown assignmemt id '$id'.");
45 }
47 $assignment,
48 $this->sp_user_progress_db,
49 $this->assignment_repository,
50 $this->sp_events
51 );
52 }
53
54 public function getInstanceByModel(\ilStudyProgrammeAssignment $assignment)
55 {
57 $assignment,
58 $this->sp_user_progress_db,
59 $this->assignment_repository,
60 $this->sp_events
61 );
62 }
63
64 public function getInstancesOfUser(int $user_id)
65 {
66 $assignments = $this->assignment_repository->readByUsrId($user_id);
67
68 //if parent object is deleted or in trash
69 //the assignment for the user should not be returned
70 $ret = [];
71 foreach ($assignments as $ass) {
72 foreach (ilObject::_getAllReferences($ass->getRootId()) as $value) {
73 if ($this->tree->isInTree($value)) {
75 $ass,
76 $this->sp_user_progress_db,
77 $this->assignment_repository,
78 $this->sp_events
79 );
80 continue 2;
81 }
82 }
83 }
84 return $ret;
85 }
86
87 public function getInstancesForProgram(int $program_id)
88 {
89 $assignments = $this->assignment_repository->readByPrgId($program_id);
90 return array_map(function ($ass) {
92 $ass,
93 $this->sp_user_progress_db,
94 $this->assignment_repository,
95 $this->sp_events
96 );
97 }, array_values($assignments)); // use array values since we want keys 0...
98 }
99
103 public function getDueToRestartInstances() : array
104 {
105 return array_map(
106 function ($ass) {
108 $ass,
109 $this->sp_user_progress_db,
110 $this->assignment_repository,
111 $this->sp_events
112 );
113 },
114 $this->assignment_repository->readDueToRestart()
115 );
116 }
117
121 public function getDueToRestartAndMail() : array
122 {
123 return array_map(
124 function ($ass) {
126 $ass,
127 $this->sp_user_progress_db,
128 $this->assignment_repository,
129 $this->sp_events
130 );
131 },
132 $this->assignment_repository->readDueToRestartAndMail()
133 );
134 }
135
136 public function reminderSendFor(int $assignment_id) : void
137 {
138 $this->assignment_repository->reminderSendFor($assignment_id);
139 }
140
141 public function getDashboardInstancesforUser(int $usr_id) : array
142 {
143 $ret = [];
144 $assigments_by_prg = $this->assignment_repository->getDashboardInstancesforUser($usr_id);
145 foreach ($assigments_by_prg as $prg => $assignments) {
146 $ret[$prg] = [];
147 foreach ($assignments as $id => $assignment) {
148 $ret[$prg][$id] = new ilStudyProgrammeUserAssignment(
149 $assignment,
150 $this->sp_user_progress_db,
151 $this->assignment_repository,
152 $this->sp_events
153 );
154 }
155 }
156 return $ret;
157 }
158}
An exception for terminatinating execution or to throw for unit testing.
Base class for ILIAS Exception handling.
static _getAllReferences($a_id)
get all reference ids of object
Class ilStudyProgrammeAssignment.
getInstanceByModel(\ilStudyProgrammeAssignment $assignment)
__construct(ilStudyProgrammeUserProgressDB $sp_user_progress_db, ilStudyProgrammeAssignmentRepository $assignment_repository, ilTree $tree, ilStudyProgrammeEvents $sp_events)
Represents one assignment of a user to a study programme.
Storage implementation for ilStudyProgrammeUserProgress.
Tree class data representation in hierachical trees using the Nested Set Model with Gaps by Joe Celco...
$ret
Definition: parser.php:6