ILIAS  release_7 Revision v7.30-3-g800a261c036
class.ilStudyProgrammeSettings.php
Go to the documentation of this file.
1<?php
2
3/* Copyright (c) 2015 Richard Klees <richard.klees@concepts-and-training.de> Extended GPL, see docs/LICENSE */
4/* Copyright (c) 2019 Stefan Hecken <stefan.hecken@concepts-and-training.de> Extended GPL, see docs/LICENSE */
5
6declare(strict_types = 1);
7
17{
18
19 // There are two different modes the programs calculation of the learning
20 // progress can run in. It is also possible, that the mode is not defined
21 // yet.
22 const MODE_UNDEFINED = 0;
23
24 // User is successful if he collected enough points in the subnodes of
25 // this node.
26 const MODE_POINTS = 1;
27
28 // User is successful if he has the "completed" learning progress in any
29 // subobject.
31
32 public static $MODES = array(
33 self::MODE_UNDEFINED,
34 self::MODE_POINTS,
35 self::MODE_LP_COMPLETED
36 );
37
38
39 // A program tree has a lifecycle during which it has three status.
40
41 // The program is a draft, that is users won't be assigned to the program
42 // already.
43 const STATUS_DRAFT = 10;
44
45 // The program is active, that is users can be assigned to it.
46 const STATUS_ACTIVE = 20;
47
48 // The program is outdated, that is users won't be assigned to it but can
49 // still complete the program.
50 const STATUS_OUTDATED = 30;
51
52 const NO_RESTART = -1;
54
55 // Defaults
56 const DEFAULT_POINTS = 100;
57 const DEFAULT_SUBTYPE = 0; // TODO: What should that be?
58
59 const DATE_TIME_FORMAT = 'Y-m-d H:i:s';
60 const DATE_FORMAT = 'Y-m-d';
61
67 protected $obj_id;
68
75 protected $last_change;
76
82 protected $lp_mode;
83
87 protected $type_settings;
88
93
98
103
110
115
116 public function __construct(
117 int $a_id,
123 ) {
124 $this->obj_id = $a_id;
125 $this->type_settings = $type_settings;
126 $this->assessment_settings = $assessment_settings;
127 $this->deadline_settings = $deadline_settings;
128 $this->validity_of_qualification_settings = $validity_of_qualification_settings;
129 $this->automail_settings = $automail_settings;
130 }
131
137 public function getObjId() : int
138 {
139 return (int) $this->obj_id;
140 }
141
147 public function getLastChange() : DateTime
148 {
149 return DateTime::createFromFormat(self::DATE_TIME_FORMAT, $this->last_change);
150 }
151
158 {
159 $this->setLastChange(new DateTime());
160 return $this;
161 }
162
171 public function setLastChange(DateTime $a_timestamp) : ilStudyProgrammeSettings
172 {
173 $this->last_change = $a_timestamp->format(self::DATE_TIME_FORMAT);
174 return $this;
175 }
176
185 public function setLPMode(int $a_mode) : ilStudyProgrammeSettings
186 {
187 $a_mode = (int) $a_mode;
188 if (!in_array($a_mode, self::$MODES)) {
189 throw new ilException("ilStudyProgramme::setLPMode: No lp mode: "
190 . "'$a_mode'");
191 }
192 $this->lp_mode = $a_mode;
193 $this->updateLastChange();
194 return $this;
195 }
196
202 public function getLPMode() : int
203 {
204 return (int) $this->lp_mode;
205 }
206
208 {
210 }
211
212 public function withTypeSettings(
215 $clone = clone $this;
216 $clone->type_settings = $type_settings;
217 return $clone;
218 }
219
221 {
222 return $this->assessment_settings;
223 }
224
225 public function withAssessmentSettings(
226 \ilStudyProgrammeAssessmentSettings $assessment_settings
228 $clone = clone $this;
229 $clone->assessment_settings = $assessment_settings;
230 $clone->updateLastChange();
231 return $clone;
232 }
233
235 {
236 return $this->deadline_settings;
237 }
238
239 public function withDeadlineSettings(
240 \ilStudyProgrammeDeadlineSettings $deadline_settings
242 $clone = clone $this;
243 $clone->deadline_settings = $deadline_settings;
244 return $clone;
245 }
246
248 {
249 return $this->validity_of_qualification_settings;
250 }
251
253 \ilStudyProgrammeValidityOfAchievedQualificationSettings $validity_of_qualification_settings
255 $clone = clone $this;
256 $clone->validity_of_qualification_settings = $validity_of_qualification_settings;
257 return $clone;
258 }
259
260 public function validationExpires() : bool
261 {
262 return !is_null($this->getValidityOfQualificationSettings()->getQualificationDate()) ||
263 $this->getValidityOfQualificationSettings()->getQualificationPeriod() != -1;
264 }
265
267 {
268 return $this->automail_settings;
269 }
270
271 public function withAutoMailSettings(
272 \ilStudyProgrammeAutoMailSettings $automail_settings
274 $clone = clone $this;
275 $clone->automail_settings = $automail_settings;
276 return $clone;
277 }
278}
An exception for terminatinating execution or to throw for unit testing.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
setLastChange(DateTime $a_timestamp)
Set the last change timestamp to the given time.
__construct(int $a_id, \ilStudyProgrammeTypeSettings $type_settings, \ilStudyProgrammeAssessmentSettings $assessment_settings, \ilStudyProgrammeDeadlineSettings $deadline_settings, \ilStudyProgrammeValidityOfAchievedQualificationSettings $validity_of_qualification_settings, \ilStudyProgrammeAutoMailSettings $automail_settings)
getLastChange()
Get the timestamp of the last change on this program or a sub program.
getObjId()
Get the id of the study program.
setLPMode(int $a_mode)
Set the lp mode.
updateLastChange()
Update the last change timestamp to the current time.
withAutoMailSettings(\ilStudyProgrammeAutoMailSettings $automail_settings)
withValidityOfQualificationSettings(\ilStudyProgrammeValidityOfAchievedQualificationSettings $validity_of_qualification_settings)
withDeadlineSettings(\ilStudyProgrammeDeadlineSettings $deadline_settings)
withTypeSettings(\ilStudyProgrammeTypeSettings $type_settings)
withAssessmentSettings(\ilStudyProgrammeAssessmentSettings $assessment_settings)