3declare(strict_types=1);
10 const TABLE =
'prg_usr_progress';
44 int $acting_user =
null
48 self::FIELD_ID => $id,
49 self::FIELD_ASSIGNMENT_ID => $ass->
getId(),
50 self::FIELD_PRG_ID => $prg->
getObjId(),
53 self::FIELD_POINTS_CUR => 0,
55 self::FIELD_COMPLETION_BY =>
null,
58 self::FIELD_LAST_CHANGE_BY => $acting_user,
59 self::FIELD_COMPLETION_DATE =>
null,
60 self::FIELD_DEADLINE =>
null,
61 self::FIELD_VQ_DATE =>
null,
62 self::FIELD_INVALIDATED => 0,
63 self::FIELD_IS_INDIVIDUAL => 0
76 foreach ($this->loadByFilter([self::FIELD_ID => $id]) as $row) {
77 return $this->buildByRow($row);
92 return $this->getByPrgIdAndAssignmentId($prg_id, $assignment_id);
104 $rows = $this->loadByFilter(
106 self::FIELD_PRG_ID => $prg_id,
107 self::FIELD_ASSIGNMENT_ID => $assignment_id
111 foreach (
$rows as $row) {
112 return $this->buildByRow($row);
118 $rows = $this->loadByFilter(
120 self::FIELD_PRG_ID => $assignment->
getRootId(),
121 self::FIELD_ASSIGNMENT_ID => $assignment->
getId(),
122 self::FIELD_USR_ID => $assignment->
getUserId()
126 foreach (
$rows as $row) {
127 return $this->buildByRow($row);
139 foreach ($this->loadByFilter([self::FIELD_PRG_ID => $prg_id, self::FIELD_USR_ID => $usr_id]) as $row) {
140 $return[] = $this->buildByRow($row);
153 foreach ($this->loadByFilter([self::FIELD_PRG_ID => $prg_id]) as $row) {
154 $return[] = $this->buildByRow($row);
165 foreach ($this->loadByFilter([self::FIELD_PRG_ID => $prg_id]) as $row) {
166 return $this->buildByRow($row);
178 foreach ($this->loadByFilter([self::FIELD_ASSIGNMENT_ID => $assignment_id]) as $row) {
179 $return[] = $this->buildByRow($row);
192 foreach ($this->loadExpiredSuccessful() as $row) {
193 $return[] = $this->buildByRow($row);
206 foreach ($this->loadPassedDeadline() as $row) {
207 $return[] = $this->buildByRow($row);
220 foreach ($this->loadRiskyToFailInstance() as $row) {
221 $return[] = $this->buildByRow($row);
233 self::FIELD_ID => $progress->
getId(),
235 self::FIELD_PRG_ID => $progress->
getNodeId(),
236 self::FIELD_USR_ID => $progress->
getUserId(),
237 self::FIELD_STATUS => $progress->
getStatus(),
244 self::FIELD_COMPLETION_DATE =>
249 self::FIELD_INVALIDATED => $progress->
isInvalidated() ? 1 : 0,
260 $this->deleteDB($progress->getId());
268 self::FIELD_ID => [
'integer', $row[self::FIELD_ID]]
269 , self::FIELD_ASSIGNMENT_ID => [
'integer', $row[self::FIELD_ASSIGNMENT_ID]]
270 , self::FIELD_PRG_ID => [
'integer', $row[self::FIELD_PRG_ID]]
271 , self::FIELD_USR_ID => [
'integer', $row[self::FIELD_USR_ID]]
272 , self::FIELD_STATUS => [
'integer', $row[self::FIELD_STATUS]]
273 , self::FIELD_POINTS => [
'integer', $row[self::FIELD_POINTS]]
274 , self::FIELD_POINTS_CUR => [
'integer', $row[self::FIELD_POINTS_CUR]]
275 , self::FIELD_COMPLETION_BY => [
'integer', $row[self::FIELD_COMPLETION_BY]]
276 , self::FIELD_LAST_CHANGE_BY => [
'integer', $row[self::FIELD_LAST_CHANGE_BY]]
277 , self::FIELD_LAST_CHANGE => [
'text', $row[self::FIELD_LAST_CHANGE]]
278 , self::FIELD_ASSIGNMENT_DATE => [
'timestamp', $row[self::FIELD_ASSIGNMENT_DATE]]
279 , self::FIELD_COMPLETION_DATE => [
'timestamp', $row[self::FIELD_COMPLETION_DATE]]
280 , self::FIELD_DEADLINE => [
'text', $row[self::FIELD_DEADLINE]]
281 , self::FIELD_VQ_DATE => [
'timestamp', $row[self::FIELD_VQ_DATE]]
282 , self::FIELD_INVALIDATED => [
'timestamp', $row[self::FIELD_INVALIDATED]]
283 , self::FIELD_IS_INDIVIDUAL => [
'integer', $row[self::FIELD_IS_INDIVIDUAL]]
293 $progresses = $this->getByAssignmentId($assignment_id);
295 $query =
'DELETE FROM ' . self::TABLE . PHP_EOL
296 .
' WHERE ' . self::FIELD_ASSIGNMENT_ID .
' = '
297 . $this->db->quote($assignment_id,
'integer');
299 $this->db->manipulate(
$query);
302 function ($progress) {
303 return $progress->getNodeId();
319 self::FIELD_MAIL_SENT_RISKYTOFAIL => [
325 $this->db->update(self::TABLE, $values, $where);
338 self::FIELD_MAIL_SENT_WILLEXPIRE => [
344 $this->db->update(self::TABLE, $values, $where);
354 $data[self::FIELD_ID]
359 self::FIELD_ASSIGNMENT_ID => [
361 $data[self::FIELD_ASSIGNMENT_ID]
363 self::FIELD_PRG_ID => [
365 $data[self::FIELD_PRG_ID]
367 self::FIELD_USR_ID => [
369 $data[self::FIELD_USR_ID]
371 self::FIELD_STATUS => [
373 $data[self::FIELD_STATUS]
375 self::FIELD_POINTS => [
377 $data[self::FIELD_POINTS]
379 self::FIELD_POINTS_CUR => [
381 $data[self::FIELD_POINTS_CUR]
383 self::FIELD_COMPLETION_BY => [
385 $data[self::FIELD_COMPLETION_BY]
387 self::FIELD_LAST_CHANGE_BY => [
389 $data[self::FIELD_LAST_CHANGE_BY]
391 self::FIELD_LAST_CHANGE => [
393 $data[self::FIELD_LAST_CHANGE]
395 self::FIELD_ASSIGNMENT_DATE => [
397 $data[self::FIELD_ASSIGNMENT_DATE]
399 self::FIELD_COMPLETION_DATE => [
401 $data[self::FIELD_COMPLETION_DATE]
403 self::FIELD_DEADLINE => [
405 $data[self::FIELD_DEADLINE]
407 self::FIELD_VQ_DATE => [
409 $data[self::FIELD_VQ_DATE]
411 self::FIELD_INVALIDATED => [
413 $data[self::FIELD_INVALIDATED]
415 self::FIELD_IS_INDIVIDUAL => [
417 $data[self::FIELD_IS_INDIVIDUAL]
421 $this->db->update(self::TABLE, $values, $where);
430 ->withAssignmentId((
int) $row[self::FIELD_ASSIGNMENT_ID])
431 ->withNodeId((
int) $row[self::FIELD_PRG_ID])
432 ->withUserId((
int) $row[self::FIELD_USR_ID])
433 ->withStatus((
int) $row[self::FIELD_STATUS])
434 ->withAmountOfPoints((
int) $row[self::FIELD_POINTS])
435 ->withCurrentAmountOfPoints((
int) $row[self::FIELD_POINTS_CUR])
437 $row[self::FIELD_DEADLINE] ?
441 ->withAssignmentDate(
445 (
int) $row[self::FIELD_COMPLETION_BY],
446 $row[self::FIELD_COMPLETION_DATE] ?
451 (
int) $row[self::FIELD_LAST_CHANGE_BY],
452 $row[self::FIELD_LAST_CHANGE] ?
456 ->withValidityOfQualification(
457 $row[self::FIELD_VQ_DATE] ?
461 ->withIndividualModifications((
bool) $row[self::FIELD_IS_INDIVIDUAL]);
465 if ((
int) $row[self::FIELD_INVALIDATED] === 1) {
474 $q = $this->getSQLHeader()
476 foreach ($filter as $field => $value) {
477 $q .=
' AND ' . $field .
' = ' . $this->db->quote($value,
'text');
479 $res = $this->db->query($q);
480 while ($rec = $this->db->fetchAssoc(
$res)) {
487 $q = $this->getSQLHeader()
488 .
' WHERE ' . $this->db->in(
497 .
' AND ' . self::FIELD_VQ_DATE .
' IS NOT NULL'
498 .
' AND DATE(' . self::FIELD_VQ_DATE .
') < '
503 .
' AND ' . self::FIELD_INVALIDATED .
' != 1 OR ' . self::FIELD_INVALIDATED .
' IS NULL';
505 $res = $this->db->query($q);
506 while ($rec = $this->db->fetchAssoc(
$res)) {
514 $this->getSQLHeader() . PHP_EOL
515 .
'WHERE ' . $this->db->in(
524 .
'AND ' . self::FIELD_DEADLINE .
' IS NOT NULL' . PHP_EOL
525 .
'AND DATE(' . self::FIELD_DEADLINE .
') < ' . $this->db->quote(
530 $res = $this->db->query($q);
531 while ($rec = $this->db->fetchAssoc(
$res)) {
538 $q = $this->getSQLHeader()
539 .
' WHERE ' . $this->db->in(
548 .
' AND ' . self::FIELD_DEADLINE .
' IS NOT NULL'
549 .
' AND DATE(' . self::FIELD_DEADLINE .
') < '
554 .
' AND ' . self::FIELD_MAIL_SENT_RISKYTOFAIL .
' IS NULL'
556 $res = $this->db->query($q);
557 while ($rec = $this->db->fetchAssoc(
$res)) {
564 return 'SELECT ' . self::FIELD_ID
565 .
', ' . self::FIELD_ASSIGNMENT_ID
566 .
', ' . self::FIELD_PRG_ID
567 .
', ' . self::FIELD_USR_ID
568 .
', ' . self::FIELD_STATUS
569 .
', ' . self::FIELD_POINTS
570 .
', ' . self::FIELD_POINTS_CUR
571 .
', ' . self::FIELD_COMPLETION_BY
572 .
', ' . self::FIELD_LAST_CHANGE
573 .
', ' . self::FIELD_LAST_CHANGE_BY
574 .
', ' . self::FIELD_ASSIGNMENT_DATE
575 .
', ' . self::FIELD_COMPLETION_DATE
576 .
', ' . self::FIELD_DEADLINE
577 .
', ' . self::FIELD_VQ_DATE
578 .
', ' . self::FIELD_INVALIDATED
579 .
', ' . self::FIELD_IS_INDIVIDUAL
580 .
' FROM ' . self::TABLE;
590 if (count($programmes_and_due) == 0) {
595 foreach ($programmes_and_due as $programme_obj_id => $due) {
598 . self::FIELD_PRG_ID .
'=' . $programme_obj_id
599 .
' AND ' . self::FIELD_DEADLINE .
'<=' . $this->db->quote($due,
'text')
600 .
' AND ' . self::FIELD_MAIL_SENT_RISKYTOFAIL .
' IS NULL'
603 $query = $this->getSQLHeader() .
' WHERE ' . implode(
' OR ', $where);
606 while ($rec = $this->db->fetchAssoc(
$res)) {
607 $ret[] = $this->buildByRow($rec);
617 array $programmes_and_due,
618 bool $discard_formerly_notified =
true
621 if (count($programmes_and_due) == 0) {
626 foreach ($programmes_and_due as $programme_obj_id => $due) {
629 . self::FIELD_PRG_ID .
'=' . $programme_obj_id
630 .
' AND ' . self::FIELD_VQ_DATE .
'<=' . $this->db->quote($due,
'text');
632 if ($discard_formerly_notified) {
633 $where_clause .=
' AND ' . self::FIELD_MAIL_SENT_WILLEXPIRE .
' IS NULL';
636 $where_clause .=
')';
637 $where[] = $where_clause;
640 $query = $this->getSQLHeader() .
' WHERE ' . implode(
' OR ', $where);
642 while ($rec = $this->db->fetchAssoc(
$res)) {
643 $ret[] = $this->buildByRow($rec);
650 return (
int) $this->db->nextId(self::TABLE);
654 string $assignment_table,
655 string $assignment_id_field
657 $query =
'DELETE FROM ' . self::TABLE . PHP_EOL
658 .
'WHERE ' . self::FIELD_ASSIGNMENT_ID . PHP_EOL
659 .
'NOT IN (' . PHP_EOL
660 .
'SELECT ' . $this->db->quoteIdentifier($assignment_id_field)
661 .
' FROM ' . $this->db->quoteIdentifier($assignment_table) . PHP_EOL
663 $this->db->manipulate(
$query);
668 $query =
'DELETE FROM ' . self::TABLE . PHP_EOL
669 .
' WHERE ' . self::FIELD_PRG_ID .
' = '
670 . $this->db->quote($prg_obj_id,
'integer');
672 $this->db->manipulate(
$query);
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...
Represents one assignment of the user to a program tree.
const FIELD_ASSIGNMENT_ID
deleteForAssignmentId(int $assignment_id)
getByPrgIdAndAssignmentId(int $prg_id, int $assignment_id)
Load progress belonging to a prg id and assignment.Will throw if the record does not exist yet.
const FIELD_LAST_CHANGE_BY
const FIELD_IS_INDIVIDUAL
const FIELD_COMPLETION_DATE
const FIELD_ASSIGNMENT_DATE
getFirstByPrgId(int $prg_id)
sentExpiryInfoFor(int $progress_id)
deleteAllOrphanedProgresses(string $assignment_table, string $assignment_id_field)
getByPrgIdAndUserId(int $prg_id, int $usr_id)
Load progress objects belonging to a prg id and a user id.
getByAssignmentId(int $assignment_id)
Load progress objects belonging to an assignment id.Will throw if the record does not exist yet.
const FIELD_MAIL_SENT_RISKYTOFAIL
getByPrgId(int $prg_id)
Load progress objects belonging to a prg id.
createFor(ilStudyProgrammeSettings $prg, ilStudyProgrammeAssignment $ass, int $acting_user=null)
getPassedDeadline()
@inheritDoc
getRootProgressOf(ilStudyProgrammeAssignment $assignment)
const FIELD_MAIL_SENT_WILLEXPIRE
loadRiskyToFailInstance()
__construct(ilDBInterface $db)
sentRiskyToFailFor(int $progress_id)
deleteProgressesFor(int $prg_obj_id)
getRiskyToFailInstances()
getExpiredSuccessfull()
Load all progress objects which are successfull and whose validity is expired.
getAboutToExpire(array $programmes_and_due, bool $discard_formerly_notified=true)
getByIds(int $prg_id, int $assignment_id)
Load progress belonging to a prg id and assignment.Will throw if the record does not exist yet.
loadByFilter(array $filter)
getRiskyToFail(array $programmes_and_due)
update(ilStudyProgrammeProgress $progress)
Update record corresponding to progress.Will throw if the record does not exist yet.
const FIELD_COMPLETION_BY
Class ilStudyProgrammeProgress.
getId()
Get the id of the progress.
getAssignmentId()
Get the assignment this progress belongs to.
getAmountOfPoints()
Get the amount of points the user needs to achieve on the subnodes of this node.
getStatus()
Get the status the user has on this node.
const DATE_FORMAT_ENDOFDAY
getUserId()
Get the id of the user this progress is for.
getValidityOfQualification()
getCompletionBy()
Get the id of object or user that lead to the successful completion of this node.
getLastChangeBy()
Get the id of the user/object who/which invoked the last change on this assignment.
hasIndividualModifications()
getCurrentAmountOfPoints()
getNodeId()
Get the obj_id of the program node this progress belongs to.
getObjId()
Get the id of the study program.
static now()
Return current timestamp in Y-m-d H:i:s format.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Covers the persistence of settings belonging to a study programme (SP).
foreach($_POST as $key=> $value) $res