ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
class.ilStudyProgrammeUserProgressDB.php
Go to the documentation of this file.
1<?php
2
10{
11 public function __construct(
12 ilStudyProgrammeProgressRepository $progress_repository,
13 ilStudyProgrammeAssignmentRepository $assignment_repository,
16 ) {
17 $this->progress_repository = $progress_repository;
18 $this->assignment_repository = $assignment_repository;
19 $this->lng = $lng;
20 $this->events = $events;
21 }
22
32 public function getInstance($a_assignment_id, $a_program_id, $a_user_id)
33 {
34 $prgrs = $this->progress_repository->readByIds($a_program_id, $a_assignment_id, $a_user_id);
36 $prgrs,
37 $this->progress_repository,
38 $this->assignment_repository,
39 $this->events
40 );
41 }
42
49 public function getInstanceById($a_prgrs_id)
50 {
51 $prgrs = $this->progress_repository->read($a_prgrs_id);
52 if ($prgrs === null) {
53 throw new ilException("Unknown progress id $a_prgrs_id.");
54 }
56 $prgrs,
57 $this->progress_repository,
58 $this->assignment_repository,
59 $this->events
60 );
61 }
62
70 public function getInstancesForUser($a_program_id, $a_user_id)
71 {
72 return array_values(
73 $this->getObjectsByModels(
74 $this->progress_repository->readByPrgIdAndUserId($a_program_id, $a_user_id)
75 )
76 );
77 }
78
89 public function getInstanceForAssignment($a_program_id, $a_assignment_id)
90 {
91 $progress = $this->progress_repository->readByPrgIdAndAssignmentId($a_program_id, $a_assignment_id);
92 if (!$progress) {
93 require_once("Modules/StudyProgramme/classes/exceptions/class.ilStudyProgrammeNoProgressForAssignmentException.php");
94 throw new ilStudyProgrammeNoProgressForAssignmentException("ilStudyProgrammeUserProgress::getInstanceForAssignment: "
95 . "Assignment '$a_assignment_id' does not belong to program "
96 . "'$a_program_id'");
97 }
99 $progress,
100 $this->progress_repository,
101 $this->assignment_repository,
102 $this->events
103 );
104 }
105
116 public function getInstancesForAssignment($a_assignment_id)
117 {
118 $progresses = $this->progress_repository->readByAssignmentId($a_assignment_id);
119 if (count($progresses) == 0) {
120 require_once("Modules/StudyProgramme/classes/exceptions/class.ilStudyProgrammeNoProgressForAssignmentException.php");
121 throw new ilStudyProgrammeNoProgressForAssignmentException("ilStudyProgrammeUserProgress::getInstancesForAssignment: "
122 . "Can't find progresses for assignment '$a_assignment_id'.");
123 }
124 return $this->getObjectsByModels($progresses);
125 }
126
133 public function getInstancesForProgram($a_program_id)
134 {
135 return array_values($this->getObjectsByModels($this->progress_repository->readByPrgId($a_program_id)));
136 }
137
143 public function getExpiredSuccessfulInstances() : array
144 {
145 return $this->getObjectsByModels($this->progress_repository->readExpiredSuccessfull());
146 }
147
148 public function getPassedDeadline() : array
149 {
150 return $this->getObjectsByModels($this->progress_repository->readPassedDeadline());
151 }
152
156 public function getRiskyToFailInstances() : array
157 {
158 return $this->getObjectsByModels($this->progress_repository->readRiskyToFailInstances());
159 }
160
161 protected function getObjectsByModels(array $models) : array
162 {
163 return array_map(function ($dat) {
165 $dat,
166 $this->progress_repository,
167 $this->assignment_repository,
168 $this->events
169 );
170 }, $models);
171 }
172
176 public function statusToRepr($a_status)
177 {
179 $lng->loadLanguageModule("prg");
180
182 return $lng->txt("prg_status_in_progress");
183 }
185 return $lng->txt("prg_status_completed");
186 }
188 return $lng->txt("prg_status_accredited");
189 }
191 return $lng->txt("prg_status_not_relevant");
192 }
194 return $lng->txt("prg_status_failed");
195 }
196 throw new ilException("Unknown status: '$a_status'");
197 }
198
199 public function reminderSendFor(int $assignment_id) : void
200 {
201 $this->progress_repository->reminderSendFor($assignment_id);
202 }
203}
An exception for terminatinating execution or to throw for unit testing.
Base class for ILIAS Exception handling.
language handling
Exception is thrown when a progress for some programme node and assignment is missing.
Storage implementation for ilStudyProgrammeUserProgress.
getExpiredSuccessfulInstances()
Get all expired and successful progresses.
getInstancesForAssignment($a_assignment_id)
Get the instance for an assignment.
statusToRepr($a_status)
Get a user readable representation of a status.
getInstanceById($a_prgrs_id)
Get an instance by progress id.
getInstanceForAssignment($a_program_id, $a_assignment_id)
Get the instance for the assignment on the program.
__construct(ilStudyProgrammeProgressRepository $progress_repository, ilStudyProgrammeAssignmentRepository $assignment_repository, ilLanguage $lng, ilStudyProgrammeEvents $events)
getInstancesForUser($a_program_id, $a_user_id)
Get the instances that user has on program.
getInstancesForProgram($a_program_id)
Get the instances for a program node.
getInstance($a_assignment_id, $a_program_id, $a_user_id)
Get an instance.
Represents the progress of a user at one node of a study programme.
Covers the persistence of settings belonging to a study programme (SP).
$lng