ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
class.ilStudyProgrammeSettings.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=1);
4 
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 = [
37  self::MODE_UNDEFINED,
38  self::MODE_POINTS,
39  self::MODE_LP_COMPLETED
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 
93 
94  public function __construct(
95  int $a_id,
96  ilStudyProgrammeTypeSettings $type_settings,
97  ilStudyProgrammeAssessmentSettings $assessment_settings,
98  ilStudyProgrammeDeadlineSettings $deadline_settings,
99  ilStudyProgrammeValidityOfAchievedQualificationSettings $validity_of_qualification_settings,
100  ilStudyProgrammeAutoMailSettings $automail_settings
101  ) {
102  $this->obj_id = $a_id;
103  $this->type_settings = $type_settings;
104  $this->assessment_settings = $assessment_settings;
105  $this->deadline_settings = $deadline_settings;
106  $this->validity_of_qualification_settings = $validity_of_qualification_settings;
107  $this->automail_settings = $automail_settings;
108  }
109 
113  public function getObjId(): int
114  {
115  return $this->obj_id;
116  }
117 
121  public function getLastChange(): DateTime
122  {
123  return DateTime::createFromFormat(self::DATE_TIME_FORMAT, $this->last_change);
124  }
125 
130  {
131  $this->setLastChange(new DateTime());
132  return $this;
133  }
134 
141  public function setLastChange(DateTime $a_timestamp): ilStudyProgrammeSettings
142  {
143  $this->last_change = $a_timestamp->format(self::DATE_TIME_FORMAT);
144  return $this;
145  }
146 
154  public function setLPMode(int $a_mode): ilStudyProgrammeSettings
155  {
156  if (!in_array($a_mode, self::$MODES)) {
157  throw new ilException("ilStudyProgramme::setLPMode: No lp mode: "
158  . "'$a_mode'");
159  }
160  $this->lp_mode = $a_mode;
161  $this->updateLastChange();
162  return $this;
163  }
164 
170  public function getLPMode(): int
171  {
172  return $this->lp_mode;
173  }
174 
176  {
177  return $this->type_settings;
178  }
179 
181  {
182  $clone = clone $this;
183  $clone->type_settings = $type_settings;
184  return $clone;
185  }
186 
188  {
190  }
191 
192  public function withAssessmentSettings(
193  ilStudyProgrammeAssessmentSettings $assessment_settings
195  $clone = clone $this;
196  $clone->assessment_settings = $assessment_settings;
197  $clone->updateLastChange();
198  return $clone;
199  }
200 
202  {
204  }
205 
206  public function withDeadlineSettings(
207  ilStudyProgrammeDeadlineSettings $deadline_settings
209  $clone = clone $this;
210  $clone->deadline_settings = $deadline_settings;
211  return $clone;
212  }
213 
215  {
217  }
218 
220  ilStudyProgrammeValidityOfAchievedQualificationSettings $validity_of_qualification_settings
222  $clone = clone $this;
223  $clone->validity_of_qualification_settings = $validity_of_qualification_settings;
224  return $clone;
225  }
226 
227  public function validationExpires(): bool
228  {
229  return !is_null($this->getValidityOfQualificationSettings()->getQualificationDate()) ||
230  $this->getValidityOfQualificationSettings()->getQualificationPeriod() !== self::NO_VALIDITY_OF_QUALIFICATION_PERIOD;
231  }
232 
234  {
236  }
237 
238  public function withAutoMailSettings(
239  ilStudyProgrammeAutoMailSettings $automail_settings
241  $clone = clone $this;
242  $clone->automail_settings = $automail_settings;
243  return $clone;
244  }
245 }
withTypeSettings(ilStudyProgrammeTypeSettings $type_settings)
ilStudyProgrammeTypeSettings $type_settings
setLastChange(DateTime $a_timestamp)
Set the last change timestamp to the given time.
getLastChange()
Get the timestamp of the last change on this program or a sub program.
string $last_change
Timestamp of the moment the last change was made on this object or any object in the subtree of the p...
withDeadlineSettings(ilStudyProgrammeDeadlineSettings $deadline_settings)
withValidityOfQualificationSettings(ilStudyProgrammeValidityOfAchievedQualificationSettings $validity_of_qualification_settings)
updateLastChange()
Update the last change timestamp to the current time.
setLPMode(int $a_mode)
Set the lp mode.
ilStudyProgrammeAutoMailSettings $automail_settings
bool $access_ctrl_positions
Is the access control governed by positions?
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
ilStudyProgrammeDeadlineSettings $deadline_settings
int $lp_mode
Mode the calculation of the learning progress on this node is run in.
withAutoMailSettings(ilStudyProgrammeAutoMailSettings $automail_settings)
int $obj_id
Id of this study program and the corresponding ILIAS-object as well.
ilStudyProgrammeValidityOfAchievedQualificationSettings $validity_of_qualification_settings
getObjId()
Get the id of the study program.
withAssessmentSettings(ilStudyProgrammeAssessmentSettings $assessment_settings)
__construct(int $a_id, ilStudyProgrammeTypeSettings $type_settings, ilStudyProgrammeAssessmentSettings $assessment_settings, ilStudyProgrammeDeadlineSettings $deadline_settings, ilStudyProgrammeValidityOfAchievedQualificationSettings $validity_of_qualification_settings, ilStudyProgrammeAutoMailSettings $automail_settings)
ilStudyProgrammeAssessmentSettings $assessment_settings