ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilStudyProgrammeSettings.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22{
23 // There are two different modes the programs' calculation of the learning
24 // progress can run in. It is also possible, that the mode is not defined
25 // yet.
26 public const MODE_UNDEFINED = 0;
27
28 // User is successful if he collected enough points in the sub nodes of
29 // this node.
30 public const MODE_POINTS = 1;
31
32 // User is successful if he has the "completed" learning progress in any
33 // sub object.
34 public const MODE_LP_COMPLETED = 2;
35
36 public static array $MODES = [
40 ];
41
42
43 // A program tree has a lifecycle during which it has three status.
44
45 // The program is a draft, that is users won't be assigned to the program
46 // already.
47 public const STATUS_DRAFT = 10;
48
49 // The program is active, that is users can be assigned to it.
50 public const STATUS_ACTIVE = 20;
51
52 // The program is outdated, that is users won't be assigned to it but can
53 // still complete the program.
54 public const STATUS_OUTDATED = 30;
55
56 public const NO_RESTART = -1;
58 public const NO_DEADLINE = -1;
59
60 // Defaults
61 public const DEFAULT_POINTS = 100;
62 public const DEFAULT_SUBTYPE = 0;
63
64 public const DATE_TIME_FORMAT = 'Y-m-d H:i:s';
65 public const DATE_FORMAT = 'Y-m-d';
66
70 protected int $obj_id;
71
76 protected string $last_change;
77
81 protected int $lp_mode;
82
86 protected bool $access_ctrl_positions;
87
88 public function __construct(
89 int $a_id,
90 protected ilStudyProgrammeTypeSettings $type_settings,
91 protected ilStudyProgrammeAssessmentSettings $assessment_settings,
92 protected ilStudyProgrammeDeadlineSettings $deadline_settings,
93 protected ilStudyProgrammeValidityOfAchievedQualificationSettings $validity_of_qualification_settings,
94 protected ilStudyProgrammeAutoMailSettings $automail_settings
95 ) {
96 $this->obj_id = $a_id;
97 $this->type_settings = $type_settings;
98 $this->assessment_settings = $assessment_settings;
99 $this->deadline_settings = $deadline_settings;
100 $this->validity_of_qualification_settings = $validity_of_qualification_settings;
101 $this->automail_settings = $automail_settings;
102 }
103
107 public function getObjId(): int
108 {
109 return $this->obj_id;
110 }
111
112 public function withObjId(int $obj_id): self
113 {
114 $clone = clone $this;
115 $clone->obj_id = $obj_id;
116 return $clone;
117 }
118
122 public function getLastChange(): DateTime
123 {
124 return DateTime::createFromFormat(self::DATE_TIME_FORMAT, $this->last_change);
125 }
126
131 {
132 $this->setLastChange(new DateTime());
133 return $this;
134 }
135
142 public function setLastChange(DateTime $a_timestamp): ilStudyProgrammeSettings
143 {
144 $this->last_change = $a_timestamp->format(self::DATE_TIME_FORMAT);
145 return $this;
146 }
147
155 public function setLPMode(int $a_mode): ilStudyProgrammeSettings
156 {
157 if (!in_array($a_mode, self::$MODES)) {
158 throw new ilException("ilStudyProgramme::setLPMode: No lp mode: "
159 . "'$a_mode'");
160 }
161 $this->lp_mode = $a_mode;
162 $this->updateLastChange();
163 return $this;
164 }
165
171 public function getLPMode(): int
172 {
173 return $this->lp_mode;
174 }
175
177 {
178 return $this->type_settings;
179 }
180
182 {
183 $clone = clone $this;
184 $clone->type_settings = $type_settings;
185 return $clone;
186 }
187
189 {
190 return $this->assessment_settings;
191 }
192
193 public function withAssessmentSettings(
194 ilStudyProgrammeAssessmentSettings $assessment_settings
196 $clone = clone $this;
197 $clone->assessment_settings = $assessment_settings;
198 $clone->updateLastChange();
199 return $clone;
200 }
201
203 {
204 return $this->deadline_settings;
205 }
206
207 public function withDeadlineSettings(
208 ilStudyProgrammeDeadlineSettings $deadline_settings
210 $clone = clone $this;
211 $clone->deadline_settings = $deadline_settings;
212 return $clone;
213 }
214
216 {
217 return $this->validity_of_qualification_settings;
218 }
219
221 ilStudyProgrammeValidityOfAchievedQualificationSettings $validity_of_qualification_settings
223 $clone = clone $this;
224 $clone->validity_of_qualification_settings = $validity_of_qualification_settings;
225 return $clone;
226 }
227
228 public function validationExpires(): bool
229 {
230 return !is_null($this->getValidityOfQualificationSettings()->getQualificationDate()) ||
231 $this->getValidityOfQualificationSettings()->getQualificationPeriod() !== self::NO_VALIDITY_OF_QUALIFICATION_PERIOD;
232 }
233
235 {
236 return $this->automail_settings;
237 }
238
239 public function withAutoMailSettings(
240 ilStudyProgrammeAutoMailSettings $automail_settings
242 $clone = clone $this;
243 $clone->automail_settings = $automail_settings;
244 return $clone;
245 }
246}
Base class for ILIAS Exception handling.
setLastChange(DateTime $a_timestamp)
Set the last change timestamp to the given time.
withValidityOfQualificationSettings(ilStudyProgrammeValidityOfAchievedQualificationSettings $validity_of_qualification_settings)
getLastChange()
Get the timestamp of the last change on this program or a sub program.
getObjId()
Get the id of the study program.
withAssessmentSettings(ilStudyProgrammeAssessmentSettings $assessment_settings)
setLPMode(int $a_mode)
Set the lp mode.
updateLastChange()
Update the last change timestamp to the current time.
string $last_change
Timestamp of the moment the last change was made on this object or any object in the subtree of the p...
int $lp_mode
Mode the calculation of the learning progress on this node is run in.
withDeadlineSettings(ilStudyProgrammeDeadlineSettings $deadline_settings)
withTypeSettings(ilStudyProgrammeTypeSettings $type_settings)
withAutoMailSettings(ilStudyProgrammeAutoMailSettings $automail_settings)
int $obj_id
Id of this study program and the corresponding ILIAS-object as well.
bool $access_ctrl_positions
Is the access control governed by positions?
__construct(int $a_id, protected ilStudyProgrammeTypeSettings $type_settings, protected ilStudyProgrammeAssessmentSettings $assessment_settings, protected ilStudyProgrammeDeadlineSettings $deadline_settings, protected ilStudyProgrammeValidityOfAchievedQualificationSettings $validity_of_qualification_settings, protected ilStudyProgrammeAutoMailSettings $automail_settings)