6 declare(strict_types = 1);
50 $type_settings = new \ilStudyProgrammeTypeSettings(
53 $assessment_settings = new \ilStudyProgrammeAssessmentSettings(
57 $deadline_settings = new \ilStudyProgrammeDeadlineSettings(null, null);
58 $validity_of_achieved_qualification_settings =
59 new \ilStudyProgrammeValidityOfAchievedQualificationSettings(null, null, null)
61 $automail = new \ilStudyProgrammeAutoMailSettings(
false, null, null);
68 $validity_of_achieved_qualification_settings,
89 self::$cache[$obj_id] = $prg;
99 if (!array_key_exists($obj_id, self::$cache)) {
100 self::$cache[$obj_id] = $this->
loadDB($obj_id);
102 return self::$cache[$obj_id];
111 if (is_null($deadline_period)) {
112 $deadline_period = 0;
116 if (!is_null($deadline_date)) {
121 if (!is_null($vq_date)) {
153 self::$cache[$settings->
getObjId()] = $settings;
161 unset(self::$cache[$settings->getObjId()]);
162 $this->
deleteDB($settings->getObjId());
171 $q =
'SELECT ' . self::FIELD_SUBTYPE_ID
172 .
' ,' . self::FIELD_STATUS
173 .
' ,' . self::FIELD_POINTS
174 .
' ,' . self::FIELD_LP_MODE
175 .
' ,' . self::FIELD_LAST_CHANGED
176 .
' ,' . self::FIELD_OBJ_ID
177 .
' ,' . self::FIELD_DEADLINE_PERIOD
178 .
' ,' . self::FIELD_DEADLINE_DATE
179 .
' ,' . self::FIELD_VALIDITY_QUALIFICATION_PERIOD
180 .
' ,' . self::FIELD_VALIDITY_QUALIFICATION_DATE
181 .
' ,' . self::FIELD_VQ_RESTART_PERIOD
182 .
', ' . self::FIELD_SEND_RE_ASSIGNED_MAIL
183 .
', ' . self::FIELD_SEND_INFO_TO_RE_ASSIGN_MAIL
184 .
', ' . self::FIELD_SEND_RISKY_TO_FAIL_MAIL
185 .
' FROM ' . self::TABLE
186 .
' WHERE ' . self::FIELD_SUBTYPE_ID .
' = ' . $this->db->quote($type_id,
'integer');
187 $res = $this->db->query($q);
189 while ($rec = $this->db->fetchAssoc(
$res)) {
208 int $deadline_period,
210 int $vq_restart_period,
211 string $deadline_date = null,
212 string $vq_date = null,
213 int $rm_nr_by_usr_days = null,
214 int $proc_end_no_success = null,
215 bool $send_re_assigned_mail =
false,
216 bool $send_info_to_re_assign_mail =
false,
217 bool $send_risky_to_fail_mail =
false 222 self::FIELD_OBJ_ID => [
'integer', $obj_id],
223 self::FIELD_SUBTYPE_ID => [
'integer', $subtype_id],
224 self::FIELD_STATUS => [
'integer', $status],
225 self::FIELD_POINTS => [
'integer', $points],
226 self::FIELD_LP_MODE => [
'integer', $lp_mode],
227 self::FIELD_LAST_CHANGED => [
'timestamp', $last_change],
228 self::FIELD_DEADLINE_PERIOD => [
'integer', $deadline_period],
229 self::FIELD_DEADLINE_DATE => [
'timestamp', $deadline_date],
230 self::FIELD_VALIDITY_QUALIFICATION_DATE => [
'timestamp', $vq_date],
231 self::FIELD_VALIDITY_QUALIFICATION_PERIOD => [
'integer', $vq_period],
232 self::FIELD_VQ_RESTART_PERIOD => [
'integer', $vq_restart_period],
233 self::FIELD_RM_NOT_RESTARTED_BY_USER_DAY => [
'integer', $rm_nr_by_usr_days],
234 self::FIELD_PROC_ENDS_NOT_SUCCESSFUL => [
'integer', $proc_end_no_success],
235 self::FIELD_SEND_RE_ASSIGNED_MAIL => [
'integer', $send_re_assigned_mail],
236 self::FIELD_SEND_INFO_TO_RE_ASSIGN_MAIL => [
'integer', $send_info_to_re_assign_mail],
237 self::FIELD_SEND_RISKY_TO_FAIL_MAIL => [
'integer', $send_risky_to_fail_mail]
248 $rec = $this->db->fetchAssoc(
250 'SELECT ' . self::FIELD_SUBTYPE_ID
251 .
', ' . self::FIELD_STATUS
252 .
', ' . self::FIELD_POINTS
253 .
', ' . self::FIELD_LP_MODE
254 .
', ' . self::FIELD_LAST_CHANGED
255 .
', ' . self::FIELD_OBJ_ID
256 .
', ' . self::FIELD_DEADLINE_PERIOD
257 .
', ' . self::FIELD_DEADLINE_DATE
258 .
', ' . self::FIELD_VALIDITY_QUALIFICATION_PERIOD
259 .
', ' . self::FIELD_VALIDITY_QUALIFICATION_DATE
260 .
', ' . self::FIELD_VQ_RESTART_PERIOD
261 .
', ' . self::FIELD_RM_NOT_RESTARTED_BY_USER_DAY
262 .
', ' . self::FIELD_PROC_ENDS_NOT_SUCCESSFUL
263 .
', ' . self::FIELD_SEND_RE_ASSIGNED_MAIL
264 .
', ' . self::FIELD_SEND_INFO_TO_RE_ASSIGN_MAIL
265 .
', ' . self::FIELD_SEND_RISKY_TO_FAIL_MAIL
266 .
' FROM ' . self::TABLE
267 .
' WHERE ' . self::FIELD_OBJ_ID .
' = ' . $this->db->quote($obj_id,
'integer')
281 $type_settings = new \ilStudyProgrammeTypeSettings(
284 $assessment_settings = new \ilStudyProgrammeAssessmentSettings(
288 $deadline_settings = new \ilStudyProgrammeDeadlineSettings(null, null);
289 $validity_of_achieved_qualification_settings =
290 new \ilStudyProgrammeValidityOfAchievedQualificationSettings(null, null, null)
292 $automail = new \ilStudyProgrammeAutoMailSettings(
false, null, null);
295 (
int) $row[self::FIELD_OBJ_ID],
297 $assessment_settings,
299 $validity_of_achieved_qualification_settings,
304 ->setLPMode((
int) $row[self::FIELD_LP_MODE])
305 ->setLastChange(DateTime::createFromFormat(
307 $row[self::FIELD_LAST_CHANGED]
311 $type = $return->getTypeSettings();
312 $type =
$type->withTypeId((
int) $row[
'subtype_id']);
313 $return = $return->withTypeSettings(
$type);
315 $points = $return->getAssessmentSettings();
316 $points = $points->withPoints((
int) $row[
'points'])->withStatus((
int) $row[
'status']);
317 $return = $return->withAssessmentSettings($points);
319 $deadline = $return->getDeadlineSettings();
320 if ($row[self::FIELD_DEADLINE_DATE] !== null) {
321 $deadline = $deadline->withDeadlineDate(DateTime::createFromFormat(
323 $row[self::FIELD_DEADLINE_DATE]
327 $deadline_period = (int) $row[self::FIELD_DEADLINE_PERIOD];
328 if ($deadline_period == -1) {
329 $deadline_period = null;
331 $deadline = $deadline->withDeadlinePeriod($deadline_period);
333 $return = $return->withDeadlineSettings($deadline);
335 $vqs = $return->getValidityOfQualificationSettings();
336 if ($row[self::FIELD_VALIDITY_QUALIFICATION_DATE] !== null) {
337 $vqs = $vqs->withQualificationDate(
338 DateTime::createFromFormat(
340 $row[self::FIELD_VALIDITY_QUALIFICATION_DATE]
344 $qualification_period = (int) $row[self::FIELD_VALIDITY_QUALIFICATION_PERIOD];
345 if ($qualification_period == -1) {
346 $qualification_period = null;
348 $vqs = $vqs->withQualificationPeriod($qualification_period);
350 $restart_period = (int) $row[self::FIELD_VQ_RESTART_PERIOD];
351 if ($restart_period == -1) {
352 $restart_period = null;
354 $vqs = $vqs->withRestartPeriod($restart_period);
355 $return = $return->withValidityOfQualificationSettings($vqs);
357 $rm_nr_by_usr_days = $row[self::FIELD_RM_NOT_RESTARTED_BY_USER_DAY];
358 if (!is_null($rm_nr_by_usr_days)) {
359 $rm_nr_by_usr_days = (int) $rm_nr_by_usr_days;
361 $proc_end_no_success = $row[self::FIELD_PROC_ENDS_NOT_SUCCESSFUL];
362 if (!is_null($proc_end_no_success)) {
363 $proc_end_no_success = (int) $proc_end_no_success;
366 return $return->withAutoMailSettings(
368 (
bool) $row[self::FIELD_SEND_RE_ASSIGNED_MAIL],
383 $this->db->manipulate(
384 'DELETE FROM ' . self::TABLE
385 .
' WHERE ' . self::FIELD_OBJ_ID .
' = ' . $this->db->quote($obj_id,
'integer')
399 int $deadline_period,
401 int $vq_restart_period,
402 string $deadline_date = null,
403 string $vq_date = null,
404 int $rm_nr_by_usr_days = null,
405 int $proc_end_no_success = null,
406 bool $send_re_assigned_mail =
false,
407 bool $send_info_to_re_assign_mail =
false,
408 bool $send_risky_to_fail_mail =
false 414 self::FIELD_OBJ_ID => [
421 self::FIELD_SUBTYPE_ID => [
425 self::FIELD_STATUS => [
429 self::FIELD_LP_MODE => [
433 self::FIELD_POINTS => [
437 self::FIELD_LAST_CHANGED => [
441 self::FIELD_DEADLINE_PERIOD => [
445 self::FIELD_DEADLINE_DATE => [
449 self::FIELD_VALIDITY_QUALIFICATION_PERIOD => [
453 self::FIELD_VALIDITY_QUALIFICATION_DATE => [
457 self::FIELD_VQ_RESTART_PERIOD => [
461 self::FIELD_RM_NOT_RESTARTED_BY_USER_DAY => [
465 self::FIELD_PROC_ENDS_NOT_SUCCESSFUL => [
469 self::FIELD_SEND_RE_ASSIGNED_MAIL => [
471 $send_re_assigned_mail
473 self::FIELD_SEND_INFO_TO_RE_ASSIGN_MAIL => [
475 $send_info_to_re_assign_mail
477 self::FIELD_SEND_RISKY_TO_FAIL_MAIL => [
479 $send_risky_to_fail_mail
483 $this->db->update(self::TABLE, $values, $where);
488 $rec = $this->db->fetchAssoc(
490 'SELECT ' . self::FIELD_OBJ_ID
491 .
' FROM ' . self::TABLE
492 .
' WHERE ' . self::FIELD_OBJ_ID .
' = ' . $this->db->quote($obj_id,
'integer')
const FIELD_DEADLINE_DATE
createFor(int $obj_id)
Create a record corresponding to a SP-Object and return representing settings.Will throw if a record ...
const FIELD_VALIDITY_QUALIFICATION_DATE
getLastChange()
Get the timestamp of the last change on this program or a sub program.
__construct(ilDBInterface $db)
const NO_VALIDITY_OF_QUALIFICATION_PERIOD
const FIELD_RM_NOT_RESTARTED_BY_USER_DAY
insertDB(int $obj_id, int $subtype_id, int $status, int $lp_mode, int $points, string $last_change, int $deadline_period, int $vq_period, int $vq_restart_period, string $deadline_date=null, string $vq_date=null, int $rm_nr_by_usr_days=null, int $proc_end_no_success=null, bool $send_re_assigned_mail=false, bool $send_info_to_re_assign_mail=false, bool $send_risky_to_fail_mail=false)
loadByType(int $type_id)
Load SP settings by assigned type.
read(int $obj_id)
Load settings belonging to a SP-Object.Will throw if the record does not exist yet.
loadIdsByType(int $type_id)
Load SP setting-ids by assigned type.
const FIELD_SEND_INFO_TO_RE_ASSIGN_MAIL
const FIELD_VALIDITY_QUALIFICATION_PERIOD
getValidityOfQualificationSettings()
Covers the persistence of settings belonging to a study programme (SP).
foreach($_POST as $key=> $value) $res
const FIELD_SEND_RE_ASSIGNED_MAIL
getObjId()
Get the id of the study program.
update(ilStudyProgrammeSettings $settings)
Update settings belonging to a SP-Object.Will throw if the record does not exist yet.
const FIELD_SEND_RISKY_TO_FAIL_MAIL
getLPMode()
Get the lp mode.
updateDB(int $obj_id, int $subtype_id, int $status, int $lp_mode, int $points, string $last_change, int $deadline_period, int $vq_period, int $vq_restart_period, string $deadline_date=null, string $vq_date=null, int $rm_nr_by_usr_days=null, int $proc_end_no_success=null, bool $send_re_assigned_mail=false, bool $send_info_to_re_assign_mail=false, bool $send_risky_to_fail_mail=false)
LogicException
const FIELD_PROC_ENDS_NOT_SUCCESSFUL
const FIELD_VQ_RESTART_PERIOD
const FIELD_DEADLINE_PERIOD