ILIAS  trunk Revision v11.0_alpha-2638-g80c1d007f79
ilPRGAssignmentDBRepository Class Reference

Assignments are relations of users to a PRG; They hold progress-information for (sub-)nodes of the PRG-tree. More...

+ Inheritance diagram for ilPRGAssignmentDBRepository:
+ Collaboration diagram for ilPRGAssignmentDBRepository:

Public Member Functions

 __construct (protected ilDBInterface $db, protected ilTree $tree, protected ilStudyProgrammeSettingsRepository $settings_repo, protected PRGEventsDelayed $events, ilExportFieldsInfo $user_field_info)
 
 getDashboardInstancesforUser (int $usr_id)
 
 createFor (int $prg_obj_id, int $usr_id, int $assigning_usr_id)
 
 store (ilPRGAssignment $assignment)
 
 delete (ilPRGAssignment $assignment)
 
 deleteAllAssignmentsForProgrammeId (int $prg_obj_id)
 
 get (int $id)
 
 getForUser (int $usr_id)
 get all assignments for a user More...
 
 getForUserOnNode (int $usr_id, int $root_prg_obj_id)
 
 getAllForNodeIsContained (int $prg_obj_id, ?array $user_filter=null, ?ilPRGAssignmentFilter $custom_filters=null)
 get all assignments for all (or given) users, where the given node is part of the assignment More...
 
 countAllForNodeIsContained (int $prg_obj_id, ?array $user_filter=null, ?ilPRGAssignmentFilter $custom_filters=null)
 Count all assignments for all (or given) users, where the given node is part of the assignment. More...
 
 getAllForSpecificNode (int $prg_obj_id, ?array $user_filter=null)
 get all assignments for all (or given) users, where the given node is the root-node of the assignment More...
 
 getPassedDeadline (\DateTimeImmutable $deadline)
 
 getAboutToExpire (array $programmes_and_due, bool $discard_formerly_notified=true)
 
 getExpiredAndNotInvalidated ()
 
 getRiskyToFail (array $programmes_and_due, bool $discard_formerly_notified=true)
 
 storeExpiryInfoSentFor (ilPRGAssignment $ass)
 
 resetExpiryInfoSentFor (ilPRGAssignment $ass)
 
 storeRiskyToFailSentFor (ilPRGAssignment $ass)
 
 resetRiskyToFailSentFor (ilPRGAssignment $ass)
 
 getLatestAssignment (int $root_prg_obj_id, int $usr_id)
 Get the user's assignment on a prg that was created last. More...
 
 getLongestValidAssignment (int $root_prg_obj_id, int $usr_id)
 Get the user's assignment on a prg with the longest lasting qualification. More...
 
 getCertificateRelevantAssignmentIds (int $prg_obj_id, int ... $usr_id)
 

Data Fields

const ASSIGNMENT_TABLE = 'prg_usr_assignments'
 
const ASSIGNMENT_FIELD_ID = 'id'
 
const ASSIGNMENT_FIELD_USR_ID = 'usr_id'
 
const ASSIGNMENT_FIELD_ROOT_PRG_ID = 'root_prg_id'
 
const ASSIGNMENT_FIELD_LAST_CHANGE = 'last_change'
 
const ASSIGNMENT_FIELD_LAST_CHANGE_BY = 'last_change_by'
 
const ASSIGNMENT_FIELD_RESTART_DATE = 'restart_date'
 
const ASSIGNMENT_FIELD_RESTARTED_ASSIGNMENT_ID = 'restarted_assignment_id'
 
const ASSIGNMENT_FIELD_RESTART_MAIL = 'restart_mail_send'
 
const ASSIGNMENT_FIELD_MANUALLY_ASSIGNED = 'assigned_manually'
 
const PROGRESS_TABLE = 'prg_usr_progress'
 
const PROGRESS_FIELD_ASSIGNMENT_ID = 'assignment_id'
 
const PROGRESS_FIELD_USR_ID = 'usr_id'
 
const PROGRESS_FIELD_PRG_ID = 'prg_id'
 
const PROGRESS_FIELD_POINTS = 'points'
 
const PROGRESS_FIELD_POINTS_CUR = 'points_cur'
 
const PROGRESS_FIELD_STATUS = 'status'
 
const PROGRESS_FIELD_COMPLETION_BY = 'completion_by'
 
const PROGRESS_FIELD_ASSIGNMENT_DATE = 'assignment_date'
 
const PROGRESS_FIELD_LAST_CHANGE = 'last_change'
 
const PROGRESS_FIELD_LAST_CHANGE_BY = 'last_change_by'
 
const PROGRESS_FIELD_COMPLETION_DATE = 'completion_date'
 
const PROGRESS_FIELD_DEADLINE = 'deadline'
 
const PROGRESS_FIELD_VQ_DATE = 'vq_date'
 
const PROGRESS_FIELD_INVALIDATED = 'invalidated'
 
const PROGRESS_FIELD_MAIL_SENT_RISKYTOFAIL = 'sent_mail_risky_to_fail'
 
const PROGRESS_FIELD_MAIL_SENT_WILLEXPIRE = 'sent_mail_expires'
 
const PROGRESS_FIELD_IS_INDIVIDUAL = 'individual'
 
const DATE_FORMAT_ENDOFDAY = 'Y-m-d 23:59:59'
 

Protected Member Functions

 deleteAllOrphanedProgresses ()
 
 query ($filter)
 
 nextId ()
 
 count (array $filter)
 
 read (array $filter)
 
 prebuildProgressesForAssingment (int $assignment_id)
 
 assignmentByRow (array $row)
 
 buildProgressTreeFor (int $node_obj_id)
 
 getRefIdFor (int $obj_id)
 
 getObjIdFor (int $ref_id)
 
 buildProgressByRow (array $row)
 
 interimOrguLookup (int $usr_id)
 
 buildUserInformation (array $row)
 
 insertAssignmentRowDB (array $row)
 
 updateAssignmentRowDB (array $values)
 
 storeProgressRow (int $assignment_id, int $usr_id, ilPRGProgress $pgs)
 

Protected Attributes

array $user_data_fields
 
array $progresses = []
 <id => ilPRGProgress> More...
 

Detailed Description

Assignments are relations of users to a PRG; They hold progress-information for (sub-)nodes of the PRG-tree.

Definition at line 25 of file class.ilPRGAssignmentDBRepository.php.

Constructor & Destructor Documentation

◆ __construct()

ilPRGAssignmentDBRepository::__construct ( protected ilDBInterface  $db,
protected ilTree  $tree,
protected ilStudyProgrammeSettingsRepository  $settings_repo,
protected PRGEventsDelayed  $events,
ilExportFieldsInfo  $user_field_info 
)

Definition at line 66 of file class.ilPRGAssignmentDBRepository.php.

References ilExportFieldsInfo\getSelectableFieldsInfo(), and ilPRGUserInformation\MANDATORY_FIELDS.

72  {
73  $this->user_data_fields = array_merge(
74  array_keys($user_field_info->getSelectableFieldsInfo()),
76  );
77  }
getSelectableFieldsInfo(?int $a_obj_id=null)
Get selectable fields.
+ Here is the call graph for this function:

Member Function Documentation

◆ assignmentByRow()

ilPRGAssignmentDBRepository::assignmentByRow ( array  $row)
protected

Definition at line 481 of file class.ilPRGAssignmentDBRepository.php.

References buildProgressTreeFor(), buildUserInformation(), ilPRGAssignment\DATE_TIME_FORMAT, ILIAS\Repository\int(), and null.

Referenced by createFor(), and read().

482  {
483  $ass = new ilPRGAssignment(
484  (int) $row[self::ASSIGNMENT_FIELD_ID],
485  (int) $row[self::ASSIGNMENT_FIELD_USR_ID]
486  );
487  $ass = $ass
488  ->withEvents($this->events)
489  ->withLastChange(
490  (int) $row[self::ASSIGNMENT_FIELD_LAST_CHANGE_BY],
491  \DateTimeImmutable::createFromFormat(
493  $row[self::ASSIGNMENT_FIELD_LAST_CHANGE]
494  )
495  )
496  ->withRestarted(
497  (int) $row[self::ASSIGNMENT_FIELD_RESTARTED_ASSIGNMENT_ID],
498  $row[self::ASSIGNMENT_FIELD_RESTART_DATE] ?
499  \DateTimeImmutable::createFromFormat(ilPRGAssignment::DATE_TIME_FORMAT, $row[self::ASSIGNMENT_FIELD_RESTART_DATE]) :
500  null
501  )
502  ->withManuallyAssigned((bool) $row[self::ASSIGNMENT_FIELD_MANUALLY_ASSIGNED]);
503 
504 
505  $root_pgs_id = (int) $row[self::ASSIGNMENT_FIELD_ROOT_PRG_ID];
506  $pgs = $this->buildProgressTreeFor($root_pgs_id);
507 
508  $user_information = $this->buildUserInformation($row);
509 
510  $ass = $ass
511  ->withProgressTree($pgs)
512  ->withUserInformation($user_information);
513  return $ass;
514  }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
Assignments are relations of users to a PRG; They hold progress-information for (sub-)nodes of the PR...
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ buildProgressByRow()

ilPRGAssignmentDBRepository::buildProgressByRow ( array  $row)
protected

Definition at line 554 of file class.ilPRGAssignmentDBRepository.php.

References ilPRGProgress\DATE_FORMAT, ilPRGProgress\DATE_TIME_FORMAT, and null.

Referenced by prebuildProgressesForAssingment().

554  : ilPRGProgress
555  {
556  $pgs = new ilPRGProgress(
557  (int) $row[self::PROGRESS_FIELD_PRG_ID],
558  (int) $row[self::PROGRESS_FIELD_STATUS]
559  );
560 
561  $pgs = $pgs
562  ->withAmountOfPoints((int) $row[self::PROGRESS_FIELD_POINTS])
563  ->withCurrentAmountOfPoints((int) $row[self::PROGRESS_FIELD_POINTS_CUR])
564  ->withAssignmentDate(
565  $row[self::PROGRESS_FIELD_ASSIGNMENT_DATE] ?
566  \DateTimeImmutable::createFromFormat(ilPRGProgress::DATE_TIME_FORMAT, $row[self::PROGRESS_FIELD_ASSIGNMENT_DATE]) :
567  null
568  )
569  ->withDeadline(
570  $row[self::PROGRESS_FIELD_DEADLINE] ?
571  \DateTimeImmutable::createFromFormat(ilPRGProgress::DATE_FORMAT, $row[self::PROGRESS_FIELD_DEADLINE]) :
572  null
573  )
574  ->withCompletion(
575  (int) $row[self::PROGRESS_FIELD_COMPLETION_BY],
576  $row[self::PROGRESS_FIELD_COMPLETION_DATE] ?
577  \DateTimeImmutable::createFromFormat(ilPRGProgress::DATE_TIME_FORMAT, $row[self::PROGRESS_FIELD_COMPLETION_DATE]) :
578  null
579  )
580  ->withLastChange(
581  (int) $row[self::PROGRESS_FIELD_LAST_CHANGE_BY],
582  $row[self::PROGRESS_FIELD_LAST_CHANGE] ?
583  \DateTimeImmutable::createFromFormat(ilPRGProgress::DATE_TIME_FORMAT, $row[self::PROGRESS_FIELD_LAST_CHANGE]) :
584  null
585  )
586  ->withValidityOfQualification(
587  $row[self::PROGRESS_FIELD_VQ_DATE] ?
588  \DateTimeImmutable::createFromFormat(ilPRGProgress::DATE_TIME_FORMAT, $row[self::PROGRESS_FIELD_VQ_DATE]) :
589  null
590  )
591  ->withIndividualModifications((bool) $row[self::PROGRESS_FIELD_IS_INDIVIDUAL])
592  ->withInvalidated((bool) $row[self::PROGRESS_FIELD_INVALIDATED]);
593 
594  return $pgs;
595  }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
A Progress is the status of a user on a single node of an assignment; it is unique by assignment_id:u...
+ Here is the caller graph for this function:

◆ buildProgressTreeFor()

ilPRGAssignmentDBRepository::buildProgressTreeFor ( int  $node_obj_id)
protected

Definition at line 516 of file class.ilPRGAssignmentDBRepository.php.

References $c, and ilContainerReference\_lookupTargetId().

Referenced by assignmentByRow().

516  : ilPRGProgress
517  {
518  $children = array_filter(
519  $this->tree->getChilds($this->getRefIdFor($node_obj_id)),
520  fn($c) => in_array($c['type'], ['prg', 'prgr']),
521  );
522  $children = array_map(
523  fn($c) => $c['type'] === 'prg' ? (int) $c['obj_id'] : ilContainerReference::_lookupTargetId((int) $c['obj_id']),
524  $children
525  );
526 
527  $pgss = [];
528  foreach ($children as $child_obj_id) {
529  $pgss[] = $this->buildProgressTreeFor($child_obj_id);
530  }
531 
532  if (!array_key_exists($node_obj_id, $this->progresses)) {
533  $pgs = new ilPRGProgress((int) $node_obj_id);
534  } else {
535  $pgs = $this->progresses[$node_obj_id];
536  }
537  $pgs->setSubnodes($pgss);
538  return $pgs;
539  }
$c
Definition: deliver.php:25
A Progress is the status of a user on a single node of an assignment; it is unique by assignment_id:u...
static _lookupTargetId(int $a_obj_id)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ buildUserInformation()

ilPRGAssignmentDBRepository::buildUserInformation ( array  $row)
protected

Definition at line 617 of file class.ilPRGAssignmentDBRepository.php.

References interimOrguLookup().

Referenced by assignmentByRow().

618  {
619  $udf_data = new ilUserDefinedData((int) $row[self::ASSIGNMENT_FIELD_USR_ID]);
620  $user_data_values = [];
621  foreach ($this->user_data_fields as $field) {
622  switch ($field) {
623  case 'active':
624  $user_data_values[$field] = (bool) $row[$field];
625  break;
626  case 'org_units':
627  //$user_data_values[$field] = ilObjUser::lookupOrgUnitsRepresentation((int) $row[self::ASSIGNMENT_FIELD_USR_ID]);
628  $user_data_values[$field] = $this->interimOrguLookup((int) $row[self::ASSIGNMENT_FIELD_USR_ID]);
629  break;
630  case str_starts_with($field, 'udf_'):
631  $udf_field_id = str_replace('udf_', 'f_', $field);
632  $user_data_values[$field] = $udf_data->get($udf_field_id);
633  break;
634  default:
635  $user_data_values[$field] = $row[$field];
636  }
637  }
638  return new ilPRGUserInformation(
639  $user_data_values
640  );
641  }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Additional information about a user, used in context of assignments.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ count()

ilPRGAssignmentDBRepository::count ( array  $filter)
protected

Definition at line 443 of file class.ilPRGAssignmentDBRepository.php.

References $res, and query().

Referenced by countAllForNodeIsContained(), getAboutToExpire(), getRefIdFor(), and getRiskyToFail().

443  : int
444  {
445  $res = $this->query($filter);
446  return $this->db->numRows($res);
447  }
$res
Definition: ltiservices.php:66
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ countAllForNodeIsContained()

ilPRGAssignmentDBRepository::countAllForNodeIsContained ( int  $prg_obj_id,
?array  $user_filter = null,
?ilPRGAssignmentFilter  $custom_filters = null 
)

Count all assignments for all (or given) users, where the given node is part of the assignment.

Implements PRGAssignmentRepository.

Definition at line 226 of file class.ilPRGAssignmentDBRepository.php.

References count().

230  : int {
231  $conditions = [
232  'pgs.' . self::PROGRESS_FIELD_PRG_ID . ' = ' . $this->db->quote($prg_obj_id, 'integer')
233  ];
234  if ($user_filter) {
235  $conditions[] = $this->db->in('ass.' . self::ASSIGNMENT_FIELD_USR_ID, $user_filter, false, 'integer');
236  }
237  if ($custom_filters) {
238  $conditions = array_merge($conditions, $custom_filters->toConditions());
239  }
240  return $this->count($conditions);
241  }
+ Here is the call graph for this function:

◆ createFor()

ilPRGAssignmentDBRepository::createFor ( int  $prg_obj_id,
int  $usr_id,
int  $assigning_usr_id 
)

Implements PRGAssignmentRepository.

Definition at line 86 of file class.ilPRGAssignmentDBRepository.php.

References $res, ilObject\_lookupType(), assignmentByRow(), insertAssignmentRowDB(), nextId(), ilPRGAssignment\NO_RESTARTED_ASSIGNMENT, ilUtil\now(), and null.

90  : ilPRGAssignment {
91  $manually = false;
92  if (ilObject::_lookupType($assigning_usr_id) === "usr") {
93  $manually = true;
94  }
95  $row = [
96  self::ASSIGNMENT_FIELD_ID => $this->nextId(),
97  self::ASSIGNMENT_FIELD_USR_ID => $usr_id,
98  self::ASSIGNMENT_FIELD_ROOT_PRG_ID => $prg_obj_id,
99  self::ASSIGNMENT_FIELD_LAST_CHANGE_BY => $assigning_usr_id,
100  self::ASSIGNMENT_FIELD_LAST_CHANGE => ilUtil::now(),
101  self::ASSIGNMENT_FIELD_RESTART_DATE => null,
102  self::ASSIGNMENT_FIELD_RESTARTED_ASSIGNMENT_ID => ilPRGAssignment::NO_RESTARTED_ASSIGNMENT,
103  self::ASSIGNMENT_FIELD_MANUALLY_ASSIGNED => $manually
104  ];
105  $this->insertAssignmentRowDB($row);
106  $this->progresses = [];
107 
108  $user_data_fields = array_filter(
109  $this->user_data_fields,
110  static fn($field) => !str_starts_with($field, 'udf_') && $field !== 'org_units'
111  );
112  $query = 'SELECT ' . implode(',', $user_data_fields) . PHP_EOL
113  . 'FROM usr_data WHERE usr_id = ' . $this->db->quote($usr_id, 'integer');
114  $res = $this->db->query($query);
115  $row = array_merge($row, $this->db->fetchAssoc($res));
116 
117  $ass = $this->assignmentByRow($row);
118  return $ass;
119  }
$res
Definition: ltiservices.php:66
static now()
Return current timestamp in Y-m-d H:i:s format.
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
Assignments are relations of users to a PRG; They hold progress-information for (sub-)nodes of the PR...
static _lookupType(int $id, bool $reference=false)
+ Here is the call graph for this function:

◆ delete()

ilPRGAssignmentDBRepository::delete ( ilPRGAssignment  $assignment)

Implements PRGAssignmentRepository.

Definition at line 145 of file class.ilPRGAssignmentDBRepository.php.

References $ass_id.

Referenced by ilObjStudyProgramme\removeMemberFromProgrammes().

145  : void
146  {
147  $ass_id = $assignment->getId();
148  $query = 'DELETE FROM ' . self::ASSIGNMENT_TABLE . PHP_EOL
149  . 'WHERE ' . self::ASSIGNMENT_FIELD_ID . ' = ' . $ass_id;
150  $this->db->manipulate($query);
151 
152  $query = 'DELETE FROM ' . self::PROGRESS_TABLE . PHP_EOL
153  . 'WHERE ' . self::PROGRESS_FIELD_ASSIGNMENT_ID . ' = ' . $ass_id;
154  $this->db->manipulate($query);
155  }
+ Here is the caller graph for this function:

◆ deleteAllAssignmentsForProgrammeId()

ilPRGAssignmentDBRepository::deleteAllAssignmentsForProgrammeId ( int  $prg_obj_id)

Implements PRGAssignmentRepository.

Definition at line 157 of file class.ilPRGAssignmentDBRepository.php.

References deleteAllOrphanedProgresses().

157  : void
158  {
159  $query = 'DELETE FROM ' . self::ASSIGNMENT_TABLE . PHP_EOL
160  . 'WHERE ' . self::ASSIGNMENT_FIELD_ROOT_PRG_ID . '=' . $this->db->quote($prg_obj_id, 'integer');
161  $this->db->manipulate($query);
163  }
+ Here is the call graph for this function:

◆ deleteAllOrphanedProgresses()

ilPRGAssignmentDBRepository::deleteAllOrphanedProgresses ( )
protected

Definition at line 164 of file class.ilPRGAssignmentDBRepository.php.

Referenced by deleteAllAssignmentsForProgrammeId().

164  : void
165  {
166  $query = 'DELETE FROM ' . self::PROGRESS_TABLE . PHP_EOL
167  . 'WHERE ' . self::PROGRESS_FIELD_ASSIGNMENT_ID . PHP_EOL
168  . 'NOT IN (' . PHP_EOL
169  . 'SELECT ' . $this->db->quoteIdentifier(self::ASSIGNMENT_FIELD_ID)
170  . ' FROM ' . $this->db->quoteIdentifier(self::ASSIGNMENT_TABLE) . PHP_EOL
171  . ');' . PHP_EOL;
172  $this->db->manipulate($query);
173  }
+ Here is the caller graph for this function:

◆ get()

ilPRGAssignmentDBRepository::get ( int  $id)

Implements PRGAssignmentRepository.

Definition at line 175 of file class.ilPRGAssignmentDBRepository.php.

References $id, and read().

176  {
177  $ass = $this->read([
178  'ass.' . self::ASSIGNMENT_FIELD_ID . ' = ' . $this->db->quote($id, 'integer')
179  ]);
180 
181  return $ass->current();
182  }
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
Assignments are relations of users to a PRG; They hold progress-information for (sub-)nodes of the PR...
+ Here is the call graph for this function:

◆ getAboutToExpire()

ilPRGAssignmentDBRepository::getAboutToExpire ( array  $programmes_and_due,
bool  $discard_formerly_notified = true 
)
Parameters
array<int $prg_obj_id, DateTimeImmutable $due>
Returns
ilPRGAssignment[]

Implements PRGAssignmentRepository.

Definition at line 285 of file class.ilPRGAssignmentDBRepository.php.

References count(), and read().

288  : array {
289  $ret = [];
290  if (count($programmes_and_due) == 0) {
291  return $ret;
292  }
293 
294  $where = [];
295  foreach ($programmes_and_due as $prg_obj_id => $due) {
296  $due = $due->format(self::DATE_FORMAT_ENDOFDAY);
297 
298  $where_clause = '('
299  . self::PROGRESS_FIELD_VQ_DATE . '<=' . $this->db->quote($due, 'text')
300  . ' AND (pgs.' . self::PROGRESS_FIELD_PRG_ID . '=' . $prg_obj_id
301  . ' OR ' . self::ASSIGNMENT_FIELD_ROOT_PRG_ID . '=' . $prg_obj_id . ')';
302 
303  if ($discard_formerly_notified) {
304  $where_clause .= ' AND ' . self::PROGRESS_FIELD_MAIL_SENT_WILLEXPIRE . ' IS NULL';
305  }
306 
307  $where_clause .= ')';
308  $where[] = $where_clause;
309  }
310 
311  $conditions = [
312  implode(' OR ', $where)
313  ];
314  $assignments = array_filter(iterator_to_array(
315  $this->read($conditions)
316  ));
317  return $assignments;
318  }
+ Here is the call graph for this function:

◆ getAllForNodeIsContained()

ilPRGAssignmentDBRepository::getAllForNodeIsContained ( int  $prg_obj_id,
?array  $user_filter = null,
?ilPRGAssignmentFilter  $custom_filters = null 
)

get all assignments for all (or given) users, where the given node is part of the assignment

Returns
ilPRGAssignment[]

Implements PRGAssignmentRepository.

Definition at line 205 of file class.ilPRGAssignmentDBRepository.php.

References read().

209  : array {
210  $conditions = [
211  'pgs.' . self::PROGRESS_FIELD_PRG_ID . ' = ' . $this->db->quote($prg_obj_id, 'integer')
212  ];
213  if ($user_filter) {
214  $conditions[] = $this->db->in('ass.' . self::ASSIGNMENT_FIELD_USR_ID, $user_filter, false, 'integer');
215  }
216  if ($custom_filters) {
217  $conditions = array_merge($conditions, $custom_filters->toConditions());
218  }
219 
220  $assignments = array_filter(iterator_to_array(
221  $this->read($conditions)
222  ));
223  return $assignments;
224  }
+ Here is the call graph for this function:

◆ getAllForSpecificNode()

ilPRGAssignmentDBRepository::getAllForSpecificNode ( int  $prg_obj_id,
?array  $user_filter = null 
)

get all assignments for all (or given) users, where the given node is the root-node of the assignment

Returns
ilPRGAssignment[]

Implements PRGAssignmentRepository.

Definition at line 243 of file class.ilPRGAssignmentDBRepository.php.

References read().

243  : array
244  {
245  $conditions = [
246  self::ASSIGNMENT_FIELD_ROOT_PRG_ID . ' = ' . $this->db->quote($prg_obj_id, 'integer')
247  ];
248  if ($user_filter) {
249  $conditions[] = $this->db->in('ass.' . self::ASSIGNMENT_FIELD_USR_ID, $user_filter, false, 'integer');
250  }
251 
252  $assignments = array_filter(iterator_to_array(
253  $this->read($conditions)
254  ));
255  return $assignments;
256  }
+ Here is the call graph for this function:

◆ getCertificateRelevantAssignmentIds()

ilPRGAssignmentDBRepository::getCertificateRelevantAssignmentIds ( int  $prg_obj_id,
int ...  $usr_id 
)

Definition at line 850 of file class.ilPRGAssignmentDBRepository.php.

References $r, $res, ilPRGProgress\STATUS_ACCREDITED, and ilPRGProgress\STATUS_COMPLETED.

850  : array
851  {
852  $query = 'SELECT assignment_id FROM (' . PHP_EOL
853  . 'SELECT usr_id, assignment_id, ROW_NUMBER() OVER (' . PHP_EOL
854  . 'PARTITION BY usr_id' . PHP_EOL
855  . 'ORDER BY' . PHP_EOL
856  . 'CASE WHEN vq_date IS NULL THEN 1 ELSE 0 END DESC,' . PHP_EOL
857  . 'vq_date DESC,' . PHP_EOL
858  . 'completion_date DESC' . PHP_EOL
859  . ') AS row_numbers' . PHP_EOL
860  . 'FROM prg_usr_progress' . PHP_EOL
861  . 'WHERE prg_id = ' . $this->db->quote($prg_obj_id, 'integer') . PHP_EOL
862  . 'AND ' . $this->db->in('usr_id', $usr_id, false, 'integer') . PHP_EOL
863  . 'AND ' . $this->db->in('status', [ilPRGProgress::STATUS_COMPLETED, ilPRGProgress::STATUS_ACCREDITED], false, 'integer') . PHP_EOL
864  . ') ranked ' . PHP_EOL
865  . 'WHERE row_numbers = 1';
866 
867  $res = $this->db->query($query);
868  $row = array_map(
869  fn($r) => $r['assignment_id'],
870  $this->db->fetchAll($res)
871  );
872 
873  return $row;
874  }
$res
Definition: ltiservices.php:66
$r

◆ getDashboardInstancesforUser()

ilPRGAssignmentDBRepository::getDashboardInstancesforUser ( int  $usr_id)
Returns
ilPRGAssignment[]

Implements PRGAssignmentRepository.

Definition at line 79 of file class.ilPRGAssignmentDBRepository.php.

References getForUser().

79  : array
80  {
81  $assignments = $this->getForUser($usr_id);
82  //TODO: decide, which ones are relevant for the dashboard
83  return $assignments;
84  }
getForUser(int $usr_id)
get all assignments for a user
+ Here is the call graph for this function:

◆ getExpiredAndNotInvalidated()

ilPRGAssignmentDBRepository::getExpiredAndNotInvalidated ( )
Returns
ilPRGAssignment[]

Implements PRGAssignmentRepository.

Definition at line 320 of file class.ilPRGAssignmentDBRepository.php.

References read(), ilPRGProgress\STATUS_ACCREDITED, and ilPRGProgress\STATUS_COMPLETED.

320  : array
321  {
322  $now = (new \DateTimeImmutable())->format(self::DATE_FORMAT_ENDOFDAY);
323  $conditions = [
324  $this->db->in(
325  self::PROGRESS_FIELD_STATUS,
326  [
329  ],
330  false,
331  'integer'
332  ),
333  self::PROGRESS_FIELD_VQ_DATE . ' IS NOT NULL',
334  self::PROGRESS_FIELD_VQ_DATE . ' < ' . $this->db->quote($now, 'text'),
335  self::PROGRESS_FIELD_INVALIDATED . ' = 0 ',
336  ];
337 
338  $assignments = array_filter(iterator_to_array(
339  $this->read($conditions)
340  ));
341  return $assignments;
342  }
+ Here is the call graph for this function:

◆ getForUser()

ilPRGAssignmentDBRepository::getForUser ( int  $usr_id)

get all assignments for a user

Returns
ilPRGAssignment[]

Implements PRGAssignmentRepository.

Definition at line 184 of file class.ilPRGAssignmentDBRepository.php.

References read().

Referenced by getDashboardInstancesforUser().

184  : array
185  {
186  $assignments = array_filter(iterator_to_array(
187  $this->read([
188  'ass.' . self::ASSIGNMENT_FIELD_USR_ID . ' = ' . $this->db->quote($usr_id, 'integer')
189  ])
190  ));
191  return $assignments;
192  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getForUserOnNode()

ilPRGAssignmentDBRepository::getForUserOnNode ( int  $usr_id,
int  $root_prg_obj_id 
)

Definition at line 194 of file class.ilPRGAssignmentDBRepository.php.

References read().

Referenced by getLatestAssignment(), and getLongestValidAssignment().

194  : array
195  {
196  $assignments = array_filter(iterator_to_array(
197  $this->read([
198  'ass.' . self::ASSIGNMENT_FIELD_USR_ID . ' = ' . $this->db->quote($usr_id, 'integer'),
199  self::ASSIGNMENT_FIELD_ROOT_PRG_ID . ' = ' . $this->db->quote($root_prg_obj_id, 'integer')
200  ])
201  ));
202  return $assignments;
203  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getLatestAssignment()

ilPRGAssignmentDBRepository::getLatestAssignment ( int  $root_prg_obj_id,
int  $usr_id 
)

Get the user's assignment on a prg that was created last.

Implements PRGAssignmentRepository.

Definition at line 802 of file class.ilPRGAssignmentDBRepository.php.

References Vendor\Package\$a, Vendor\Package\$b, getForUserOnNode(), ilPRGAssignment\getProgressTree(), and null.

802  : ?ilPRGAssignment
803  {
804  $assignments = $this->getForUserOnNode($usr_id, $root_prg_obj_id);
805  if ($assignments === []) {
806  return null;
807  }
808  usort(
809  $assignments,
811  => $a->getProgressTree()->getAssignmentDate() <=> $b->getProgressTree()->getAssignmentDate()
812  );
813  $assignments = array_reverse($assignments);
814  return current($assignments);
815  }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
getForUserOnNode(int $usr_id, int $root_prg_obj_id)
$a
thx to https://mlocati.github.io/php-cs-fixer-configurator for the examples
Assignments are relations of users to a PRG; They hold progress-information for (sub-)nodes of the PR...
+ Here is the call graph for this function:

◆ getLongestValidAssignment()

ilPRGAssignmentDBRepository::getLongestValidAssignment ( int  $root_prg_obj_id,
int  $usr_id 
)

Get the user's assignment on a prg with the longest lasting qualification.

If there is more than one assignment with e.g. unlimited qualification, the valid assignment that was created (not finished) last is returned.

Implements PRGAssignmentRepository.

Definition at line 817 of file class.ilPRGAssignmentDBRepository.php.

References Vendor\Package\$a, Vendor\Package\$b, $valid, getForUserOnNode(), ilPRGAssignment\getProgressTree(), and null.

817  : ?ilPRGAssignment
818  {
819  $assignments = $this->getForUserOnNode($usr_id, $root_prg_obj_id);
820  if ($assignments === []) {
821  return null;
822  }
823 
824  $now = new \DateTimeImmutable();
825  $valid = array_filter($assignments, fn($ass) => $ass->getProgressTree()->hasValidQualification($now));
826  if ($valid === []) {
827  return null;
828  }
829 
830  $unlimited = array_filter($valid, fn($ass) => $ass->getProgressTree()->getValidityOfQualification() === null);
831  if ($unlimited !== []) {
832  usort(
833  $unlimited,
835  => $a->getProgressTree()->getAssignmentDate() <=> $b->getProgressTree()->getAssignmentDate()
836  );
837  $unlimited = array_reverse($unlimited);
838  return current($unlimited);
839  }
840 
841  usort(
842  $valid,
844  => $a->getProgressTree()->getValidityOfQualification() <=> $b->getProgressTree()->getValidityOfQualification()
845  );
846  $valid = array_reverse($valid);
847  return current($valid);
848  }
$valid
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
getForUserOnNode(int $usr_id, int $root_prg_obj_id)
$a
thx to https://mlocati.github.io/php-cs-fixer-configurator for the examples
Assignments are relations of users to a PRG; They hold progress-information for (sub-)nodes of the PR...
+ Here is the call graph for this function:

◆ getObjIdFor()

ilPRGAssignmentDBRepository::getObjIdFor ( int  $ref_id)
protected

Definition at line 549 of file class.ilPRGAssignmentDBRepository.php.

References ilObject\_lookupObjectId().

549  : int
550  {
551  return (int) ilObject::_lookupObjectId($ref_id);
552  }
$ref_id
Definition: ltiauth.php:65
static _lookupObjectId(int $ref_id)
+ Here is the call graph for this function:

◆ getPassedDeadline()

ilPRGAssignmentDBRepository::getPassedDeadline ( \DateTimeImmutable  $deadline)
Returns
ilPRGAssignment[]

Implements PRGAssignmentRepository.

Definition at line 258 of file class.ilPRGAssignmentDBRepository.php.

References ilPRGProgress\DATE_FORMAT, read(), ilPRGProgress\STATUS_ACCREDITED, and ilPRGProgress\STATUS_IN_PROGRESS.

258  : array
259  {
260  $deadline = $this->db->quote(
261  $deadline->format(ilPRGProgress::DATE_FORMAT),
262  'text'
263  );
264 
265  $conditions = [
266  $this->db->in(
267  self::PROGRESS_FIELD_STATUS,
268  [
271  ],
272  false,
273  'integer'
274  ),
275  self::PROGRESS_FIELD_DEADLINE . ' IS NOT NULL',
276  self::PROGRESS_FIELD_DEADLINE . ' < ' . $deadline
277  ];
278 
279  $assignments = array_filter(iterator_to_array(
280  $this->read($conditions)
281  ));
282  return $assignments;
283  }
+ Here is the call graph for this function:

◆ getRefIdFor()

ilPRGAssignmentDBRepository::getRefIdFor ( int  $obj_id)
protected

Definition at line 541 of file class.ilPRGAssignmentDBRepository.php.

References ilObject\_getAllReferences(), and count().

541  : int
542  {
543  $refs = ilObject::_getAllReferences($obj_id);
544  if (count($refs) < 1) {
545  throw new ilException("Could not find ref_id for programme with obj_id $obj_id");
546  }
547  return (int) array_shift($refs);
548  }
static _getAllReferences(int $id)
get all reference ids for object ID
+ Here is the call graph for this function:

◆ getRiskyToFail()

ilPRGAssignmentDBRepository::getRiskyToFail ( array  $programmes_and_due,
bool  $discard_formerly_notified = true 
)

Definition at line 344 of file class.ilPRGAssignmentDBRepository.php.

References count(), ilPRGProgress\DATE_FORMAT, read(), ilPRGProgress\STATUS_ACCREDITED, ilPRGProgress\STATUS_COMPLETED, and ilPRGProgress\STATUS_NOT_RELEVANT.

347  : array {
348  $ret = [];
349  if (count($programmes_and_due) == 0) {
350  return $ret;
351  }
352 
353  $where = [];
354  foreach ($programmes_and_due as $prg_obj_id => $due) {
355  $due = $due->format(ilPRGProgress::DATE_FORMAT);
356 
357  $where_clause = '('
358  . self::PROGRESS_FIELD_DEADLINE . '<=' . $this->db->quote($due, 'text')
359  . 'AND (pgs.' . self::PROGRESS_FIELD_PRG_ID . '=' . $prg_obj_id
360  . ' OR ' . self::ASSIGNMENT_FIELD_ROOT_PRG_ID . '=' . $prg_obj_id . ')'
361  . ' AND ' . $this->db->in(
362  self::PROGRESS_FIELD_STATUS,
363  [
367  ],
368  true,
369  'integer'
370  );
371 
372  if ($discard_formerly_notified) {
373  $where_clause .= ' AND ' . self::PROGRESS_FIELD_MAIL_SENT_RISKYTOFAIL . ' IS NULL';
374  }
375 
376  $where_clause .= ')';
377  $where[] = $where_clause;
378  }
379 
380  $conditions = [
381  implode(' OR ', $where)
382  ];
383  $assignments = array_filter(iterator_to_array(
384  $this->read($conditions)
385  ));
386  return $assignments;
387  }
+ Here is the call graph for this function:

◆ insertAssignmentRowDB()

ilPRGAssignmentDBRepository::insertAssignmentRowDB ( array  $row)
protected

Definition at line 643 of file class.ilPRGAssignmentDBRepository.php.

Referenced by createFor().

644  {
645  $this->db->insert(
646  self::ASSIGNMENT_TABLE,
647  [
648  self::ASSIGNMENT_FIELD_ID => ['integer', $row[self::ASSIGNMENT_FIELD_ID]]
649  , self::ASSIGNMENT_FIELD_USR_ID => ['integer', $row[self::ASSIGNMENT_FIELD_USR_ID]]
650  , self::ASSIGNMENT_FIELD_ROOT_PRG_ID => ['integer', $row[self::ASSIGNMENT_FIELD_ROOT_PRG_ID]]
651  , self::ASSIGNMENT_FIELD_LAST_CHANGE => ['text', $row[self::ASSIGNMENT_FIELD_LAST_CHANGE]]
652  , self::ASSIGNMENT_FIELD_LAST_CHANGE_BY => ['integer', $row[self::ASSIGNMENT_FIELD_LAST_CHANGE_BY]]
653  , self::ASSIGNMENT_FIELD_RESTART_DATE => ['timestamp', $row[self::ASSIGNMENT_FIELD_RESTART_DATE]]
654  , self::ASSIGNMENT_FIELD_RESTARTED_ASSIGNMENT_ID => ['integer', $row[self::ASSIGNMENT_FIELD_RESTARTED_ASSIGNMENT_ID]]
655  , self::ASSIGNMENT_FIELD_MANUALLY_ASSIGNED => ['integer', $row[self::ASSIGNMENT_FIELD_MANUALLY_ASSIGNED]]
656  ]
657  );
658  }
+ Here is the caller graph for this function:

◆ interimOrguLookup()

ilPRGAssignmentDBRepository::interimOrguLookup ( int  $usr_id)
protected
Deprecated:
; fix ilObjUser::lookupOrgUnitsRepresentation

Definition at line 600 of file class.ilPRGAssignmentDBRepository.php.

References ilObject\_lookupObjId(), ilObject\_lookupTitle(), and OrgUnit\Positions\UserAssignment\ilOrgUnitUserAssignmentRepository\getInstance().

Referenced by buildUserInformation().

600  : string
601  {
603  $orgus = array_values($orgu_repo->findAllUserAssingmentsByUserIds([$usr_id]));
604  if ($orgus) {
605  $orgu_ref_ids = array_map(
606  fn($orgu_assignment) => $orgu_assignment->getOrguId(),
607  $orgus[0]
608  );
609  $orgus = array_map(
610  fn($orgu_ref_id) => ilObject::_lookupTitle(ilObject::_lookupObjId($orgu_ref_id)),
611  $orgu_ref_ids
612  );
613  }
614  return implode(', ', $orgus);
615  }
static _lookupObjId(int $ref_id)
static _lookupTitle(int $obj_id)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ nextId()

ilPRGAssignmentDBRepository::nextId ( )
protected

Definition at line 438 of file class.ilPRGAssignmentDBRepository.php.

Referenced by createFor().

439  {
440  return $this->db->nextId(self::ASSIGNMENT_TABLE);
441  }
+ Here is the caller graph for this function:

◆ prebuildProgressesForAssingment()

ilPRGAssignmentDBRepository::prebuildProgressesForAssingment ( int  $assignment_id)
protected

Definition at line 470 of file class.ilPRGAssignmentDBRepository.php.

References $q, $res, and buildProgressByRow().

Referenced by read().

470  : array
471  {
472  $q = 'SELECT * FROM ' . self::PROGRESS_TABLE
473  . ' WHERE ' . self::PROGRESS_FIELD_ASSIGNMENT_ID . ' = ' . $assignment_id;
474  $res = $this->db->query($q);
475  while ($row = $this->db->fetchAssoc($res)) {
476  $ret[$row[self::PROGRESS_FIELD_PRG_ID]] = $this->buildProgressByRow($row);
477  }
478  return $ret;
479  }
$res
Definition: ltiservices.php:66
$q
Definition: shib_logout.php:23
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ query()

ilPRGAssignmentDBRepository::query (   $filter)
protected

Definition at line 389 of file class.ilPRGAssignmentDBRepository.php.

References $q, and $res.

Referenced by count(), and read().

389  : ilDBStatement
390  {
391  $user_fields_without_udf = array_filter(
392  $this->user_data_fields,
393  static fn($field) => !str_starts_with($field, 'udf_') && $field !== 'org_units'
394  );
395 
396  $q = 'SELECT'
397  . ' ass.' . self::ASSIGNMENT_FIELD_ID . ' AS ' . self::ASSIGNMENT_FIELD_ID
398  . ', ass.' . self::ASSIGNMENT_FIELD_USR_ID . ' AS ' . self::ASSIGNMENT_FIELD_USR_ID
399  . ',' . self::ASSIGNMENT_FIELD_ROOT_PRG_ID
400  . ', ass.' . self::ASSIGNMENT_FIELD_LAST_CHANGE
401  . ', ass.' . self::ASSIGNMENT_FIELD_LAST_CHANGE_BY
402  . ',' . self::ASSIGNMENT_FIELD_RESTART_DATE
403  . ',' . self::ASSIGNMENT_FIELD_RESTARTED_ASSIGNMENT_ID
404  . ',' . self::ASSIGNMENT_FIELD_MANUALLY_ASSIGNED
405  . ',' . self::PROGRESS_FIELD_PRG_ID
406  . ',' . self::PROGRESS_FIELD_POINTS
407  . ',' . self::PROGRESS_FIELD_POINTS_CUR
408  . ',' . self::PROGRESS_FIELD_STATUS
409  . ',' . self::PROGRESS_FIELD_COMPLETION_BY
410  . ',' . self::PROGRESS_FIELD_ASSIGNMENT_DATE
411  . ', pgs.' . self::PROGRESS_FIELD_LAST_CHANGE . ' AS p_' . self::PROGRESS_FIELD_LAST_CHANGE
412  . ', pgs.' . self::PROGRESS_FIELD_LAST_CHANGE_BY . ' AS p_' . self::PROGRESS_FIELD_LAST_CHANGE_BY
413  . ',' . self::PROGRESS_FIELD_COMPLETION_DATE
414  . ',' . self::PROGRESS_FIELD_DEADLINE
415  . ',' . self::PROGRESS_FIELD_VQ_DATE
416  . ',' . self::PROGRESS_FIELD_INVALIDATED
417  . ',' . self::PROGRESS_FIELD_MAIL_SENT_RISKYTOFAIL
418  . ',' . self::PROGRESS_FIELD_MAIL_SENT_WILLEXPIRE
419  . ',' . self::PROGRESS_FIELD_IS_INDIVIDUAL
420 
421  . ', ' . implode(', ', $user_fields_without_udf)
422 
423  . ' FROM ' . self::ASSIGNMENT_TABLE . ' ass '
424  . ' JOIN ' . self::PROGRESS_TABLE . ' pgs '
425  . ' ON ass.' . self::ASSIGNMENT_FIELD_ID . ' = pgs.' . self::PROGRESS_FIELD_ASSIGNMENT_ID
426 
427 
428  . ' JOIN usr_data memberdata ON ass.usr_id = memberdata.usr_id '
429 
430  . ' WHERE TRUE AND ';
431  $q = $q . implode(' AND ', $filter);
432  $q = $q . ' ORDER BY assignment_id, ass.usr_id';
433 
434  $res = $this->db->query($q);
435  return $res;
436  }
$res
Definition: ltiservices.php:66
$q
Definition: shib_logout.php:23
+ Here is the caller graph for this function:

◆ read()

ilPRGAssignmentDBRepository::read ( array  $filter)
protected

Definition at line 449 of file class.ilPRGAssignmentDBRepository.php.

References $res, assignmentByRow(), null, prebuildProgressesForAssingment(), and query().

Referenced by get(), getAboutToExpire(), getAllForNodeIsContained(), getAllForSpecificNode(), getExpiredAndNotInvalidated(), getForUser(), getForUserOnNode(), getPassedDeadline(), and getRiskyToFail().

449  : Generator
450  {
451  $res = $this->query($filter);
452 
453  $current_ass = -1;
454  $ass = null;
455 
456  while ($row = $this->db->fetchAssoc($res)) {
457  if ($row[self::ASSIGNMENT_FIELD_ID] !== $current_ass) {
458  $current_ass = $row[self::ASSIGNMENT_FIELD_ID];
459  if (!is_null($ass)) {
460  yield $ass;
461  }
462  $this->progresses = $this->prebuildProgressesForAssingment((int) $row[self::ASSIGNMENT_FIELD_ID]);
463  $ass = $this->assignmentByRow($row); //amend all progresses based on tree
464  }
465  }
466 
467  yield $ass;
468  }
$res
Definition: ltiservices.php:66
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ resetExpiryInfoSentFor()

ilPRGAssignmentDBRepository::resetExpiryInfoSentFor ( ilPRGAssignment  $ass)

Definition at line 760 of file class.ilPRGAssignmentDBRepository.php.

References ilPRGAssignment\getId(), ilPRGAssignment\getRootId(), and null.

760  : void
761  {
762  $where = [
763  self::PROGRESS_FIELD_ASSIGNMENT_ID => ['integer', $ass->getId()],
764  self::PROGRESS_FIELD_PRG_ID => ['integer', $ass->getRootId()]
765  ];
766 
767  $values = [
768  self::PROGRESS_FIELD_MAIL_SENT_WILLEXPIRE => ['null', null]
769  ];
770  $this->db->update(self::PROGRESS_TABLE, $values, $where);
771  }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
+ Here is the call graph for this function:

◆ resetRiskyToFailSentFor()

ilPRGAssignmentDBRepository::resetRiskyToFailSentFor ( ilPRGAssignment  $ass)

Definition at line 789 of file class.ilPRGAssignmentDBRepository.php.

References ilPRGAssignment\getId(), ilPRGAssignment\getRootId(), and null.

789  : void
790  {
791  $where = [
792  self::PROGRESS_FIELD_ASSIGNMENT_ID => ['integer', $ass->getId()],
793  self::PROGRESS_FIELD_PRG_ID => ['integer', $ass->getRootId()]
794  ];
795 
796  $values = [
797  self::PROGRESS_FIELD_MAIL_SENT_RISKYTOFAIL => ['null', null]
798  ];
799  $this->db->update(self::PROGRESS_TABLE, $values, $where);
800  }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
+ Here is the call graph for this function:

◆ store()

ilPRGAssignmentDBRepository::store ( ilPRGAssignment  $assignment)

Implements PRGAssignmentRepository.

Definition at line 121 of file class.ilPRGAssignmentDBRepository.php.

References ilPRGAssignment\DATE_TIME_FORMAT, ilPRGAssignment\getId(), ilPRGAssignment\getLastChange(), ilPRGAssignment\getLastChangeBy(), ilPRGAssignment\getProgresses(), ilPRGAssignment\getRestartDate(), ilPRGAssignment\getRestartedAssignmentId(), ilPRGAssignment\getRootId(), ilPRGAssignment\getUserId(), ilPRGAssignment\isManuallyAssigned(), null, storeProgressRow(), and updateAssignmentRowDB().

Referenced by ilObjStudyProgramme\removeMemberFromProgrammes().

121  : void
122  {
123  $row = [
124  self::ASSIGNMENT_FIELD_ID => $assignment->getId(),
125  self::ASSIGNMENT_FIELD_USR_ID => $assignment->getUserId(),
126  self::ASSIGNMENT_FIELD_ROOT_PRG_ID => $assignment->getRootId(),
127  self::ASSIGNMENT_FIELD_LAST_CHANGE_BY => $assignment->getLastChangeBy(),
128  self::ASSIGNMENT_FIELD_LAST_CHANGE => $assignment->getLastChange()->format(ilPRGAssignment::DATE_TIME_FORMAT),
129  self::ASSIGNMENT_FIELD_RESTART_DATE => $assignment->getRestartDate() ? $assignment->getRestartDate()->format(ilPRGAssignment::DATE_TIME_FORMAT) : null,
130  self::ASSIGNMENT_FIELD_RESTARTED_ASSIGNMENT_ID => $assignment->getRestartedAssignmentId(),
131  self::ASSIGNMENT_FIELD_MANUALLY_ASSIGNED => $assignment->isManuallyAssigned()
132  ];
133  $this->updateAssignmentRowDB($row);
134  foreach ($assignment->getProgresses() as $pgs) {
135  $this->storeProgressRow(
136  $assignment->getId(),
137  $assignment->getUserId(),
138  $pgs
139  );
140  }
141 
142  $this->events->raiseCollected();
143  }
getProgresses(array &$ret=[], ?ilPRGProgress $pgs=null)
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
storeProgressRow(int $assignment_id, int $usr_id, ilPRGProgress $pgs)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ storeExpiryInfoSentFor()

ilPRGAssignmentDBRepository::storeExpiryInfoSentFor ( ilPRGAssignment  $ass)

Definition at line 744 of file class.ilPRGAssignmentDBRepository.php.

References ilPRGAssignment\getId(), and ilPRGAssignment\getRootId().

744  : void
745  {
746  $where = [
747  self::PROGRESS_FIELD_ASSIGNMENT_ID => ['integer', $ass->getId()],
748  self::PROGRESS_FIELD_PRG_ID => ['integer', $ass->getRootId()]
749  ];
750 
751  $values = [
752  self::PROGRESS_FIELD_MAIL_SENT_WILLEXPIRE => [
753  'timestamp',
754  date('Y-m-d H:i:s')
755  ]
756  ];
757  $this->db->update(self::PROGRESS_TABLE, $values, $where);
758  }
+ Here is the call graph for this function:

◆ storeProgressRow()

ilPRGAssignmentDBRepository::storeProgressRow ( int  $assignment_id,
int  $usr_id,
ilPRGProgress  $pgs 
)
protected

Definition at line 675 of file class.ilPRGAssignmentDBRepository.php.

References $q, ilPRGProgress\DATE_FORMAT, ilPRGProgress\DATE_TIME_FORMAT, ilPRGProgress\getAmountOfPoints(), ilPRGProgress\getAssignmentDate(), ilPRGProgress\getCompletionBy(), ilPRGProgress\getCompletionDate(), ilPRGProgress\getCurrentAmountOfPoints(), ilPRGProgress\getDeadline(), ilPRGProgress\getLastChange(), ilPRGProgress\getLastChangeBy(), ilPRGProgress\getNodeId(), ilPRGProgress\getStatus(), ilPRGProgress\getValidityOfQualification(), ilPRGProgress\hasIndividualModifications(), and ilPRGProgress\isInvalidated().

Referenced by store().

679  {
680  //TODO: move into type?
681  $lastchange = is_null($pgs->getLastChange()) ? 'NULL' : $this->db->quote($pgs->getLastChange()->format(ilPRGProgress::DATE_TIME_FORMAT), 'text');
682  $assign_date = is_null($pgs->getAssignmentDate()) ? 'NULL' : $this->db->quote($pgs->getAssignmentDate()->format(ilPRGProgress::DATE_TIME_FORMAT), 'text');
683  $completion_date = is_null($pgs->getCompletionDate()) ? 'NULL' : $this->db->quote($pgs->getCompletionDate()->format(ilPRGProgress::DATE_TIME_FORMAT), 'text');
684  $deadline = is_null($pgs->getDeadline()) ? 'NULL' : $this->db->quote($pgs->getDeadline()->format(ilPRGProgress::DATE_FORMAT), 'text');
685  $validity = is_null($pgs->getValidityOfQualification()) ? 'NULL' : $this->db->quote($pgs->getValidityOfQualification()->format(ilPRGProgress::DATE_FORMAT), 'text');
686  $invalidated = $pgs->isInvalidated() ? 1 : 0;
687  $individual = $pgs->hasIndividualModifications() ? 1 : 0;
688  $completion = $pgs->getCompletionBy() ?? 'NULL';
689 
690  $q = 'INSERT INTO ' . self::PROGRESS_TABLE
691  . '('
692  . self::PROGRESS_FIELD_ASSIGNMENT_ID . ','
693  . self::PROGRESS_FIELD_USR_ID . ','
694  . self::PROGRESS_FIELD_PRG_ID . ','
695 
696  . self::PROGRESS_FIELD_STATUS . ','
697  . self::PROGRESS_FIELD_POINTS . ','
698  . self::PROGRESS_FIELD_POINTS_CUR . ','
699  . self::PROGRESS_FIELD_COMPLETION_BY . ','
700  . self::PROGRESS_FIELD_LAST_CHANGE_BY . ','
701  . self::PROGRESS_FIELD_LAST_CHANGE . ','
702  . self::PROGRESS_FIELD_ASSIGNMENT_DATE . ','
703  . self::PROGRESS_FIELD_COMPLETION_DATE . ','
704  . self::PROGRESS_FIELD_DEADLINE . ','
705  . self::PROGRESS_FIELD_VQ_DATE . ','
706  . self::PROGRESS_FIELD_INVALIDATED . ','
707  . self::PROGRESS_FIELD_IS_INDIVIDUAL
708 
709  . PHP_EOL . ') VALUES (' . PHP_EOL
710  . $assignment_id
711  . ' ,' . $usr_id
712  . ' ,' . $pgs->getNodeId()
713 
714  . ' ,' . $pgs->getStatus()
715  . ' ,' . $pgs->getAmountOfPoints()
716  . ' ,' . $pgs->getCurrentAmountOfPoints()
717  . ' ,' . $completion
718  . ' ,' . $pgs->getLastChangeBy()
719  . ' ,' . $lastchange
720  . ' ,' . $assign_date
721  . ' ,' . $completion_date
722  . ' ,' . $deadline
723  . ' ,' . $validity
724  . ' ,' . $invalidated
725  . ' ,' . $individual
726  . ')' . PHP_EOL
727  . 'ON DUPLICATE KEY UPDATE' . PHP_EOL
728  . self::PROGRESS_FIELD_STATUS . '=' . $pgs->getStatus() . ','
729  . self::PROGRESS_FIELD_POINTS . '=' . $pgs->getAmountOfPoints() . ','
730  . self::PROGRESS_FIELD_POINTS_CUR . '=' . $pgs->getCurrentAmountOfPoints() . ','
731  . self::PROGRESS_FIELD_COMPLETION_BY . '=' . $completion . ','
732  . self::PROGRESS_FIELD_LAST_CHANGE_BY . '=' . $pgs->getLastChangeBy() . ','
733  . self::PROGRESS_FIELD_LAST_CHANGE . '=' . $lastchange . ','
734  . self::PROGRESS_FIELD_ASSIGNMENT_DATE . '=' . $assign_date . ','
735  . self::PROGRESS_FIELD_COMPLETION_DATE . '=' . $completion_date . ','
736  . self::PROGRESS_FIELD_DEADLINE . '=' . $deadline . ','
737  . self::PROGRESS_FIELD_VQ_DATE . '=' . $validity . ','
738  . self::PROGRESS_FIELD_INVALIDATED . '=' . $invalidated . ','
739  . self::PROGRESS_FIELD_IS_INDIVIDUAL . '=' . $individual
740  ;
741  $this->db->manipulate($q);
742  }
$q
Definition: shib_logout.php:23
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ storeRiskyToFailSentFor()

ilPRGAssignmentDBRepository::storeRiskyToFailSentFor ( ilPRGAssignment  $ass)

Definition at line 773 of file class.ilPRGAssignmentDBRepository.php.

References ilPRGAssignment\getId(), and ilPRGAssignment\getRootId().

773  : void
774  {
775  $where = [
776  self::PROGRESS_FIELD_ASSIGNMENT_ID => ['integer', $ass->getId()],
777  self::PROGRESS_FIELD_PRG_ID => ['integer', $ass->getRootId()]
778  ];
779 
780  $values = [
781  self::PROGRESS_FIELD_MAIL_SENT_RISKYTOFAIL => [
782  'timestamp',
783  date('Y-m-d H:i:s')
784  ]
785  ];
786  $this->db->update(self::PROGRESS_TABLE, $values, $where);
787  }
+ Here is the call graph for this function:

◆ updateAssignmentRowDB()

ilPRGAssignmentDBRepository::updateAssignmentRowDB ( array  $values)
protected

Definition at line 660 of file class.ilPRGAssignmentDBRepository.php.

References $q.

Referenced by store().

661  {
662  $q = 'UPDATE ' . self::ASSIGNMENT_TABLE
663  . ' SET'
664  . ' ' . self::ASSIGNMENT_FIELD_USR_ID . ' = ' . $this->db->quote($values[self::ASSIGNMENT_FIELD_USR_ID], 'integer')
665  . ' ,' . self::ASSIGNMENT_FIELD_ROOT_PRG_ID . ' = ' . $this->db->quote($values[self::ASSIGNMENT_FIELD_ROOT_PRG_ID], 'integer')
666  . ' ,' . self::ASSIGNMENT_FIELD_LAST_CHANGE . ' = ' . $this->db->quote($values[self::ASSIGNMENT_FIELD_LAST_CHANGE], 'text')
667  . ' ,' . self::ASSIGNMENT_FIELD_LAST_CHANGE_BY . ' = ' . $this->db->quote($values[self::ASSIGNMENT_FIELD_LAST_CHANGE_BY], 'integer')
668  . ' ,' . self::ASSIGNMENT_FIELD_RESTART_DATE . ' = ' . $this->db->quote($values[self::ASSIGNMENT_FIELD_RESTART_DATE], 'timestamp')
669  . ' ,' . self::ASSIGNMENT_FIELD_RESTARTED_ASSIGNMENT_ID . ' = ' . $this->db->quote($values[self::ASSIGNMENT_FIELD_RESTARTED_ASSIGNMENT_ID], 'integer')
670  . ' ,' . self::ASSIGNMENT_FIELD_MANUALLY_ASSIGNED . ' = ' . $this->db->quote($values[self::ASSIGNMENT_FIELD_MANUALLY_ASSIGNED], 'integer')
671  . ' WHERE ' . self::ASSIGNMENT_FIELD_ID . ' = ' . $this->db->quote($values[self::ASSIGNMENT_FIELD_ID], 'integer');
672  $this->db->manipulate($q);
673  }
$q
Definition: shib_logout.php:23
+ Here is the caller graph for this function:

Field Documentation

◆ $progresses

array ilPRGAssignmentDBRepository::$progresses = []
protected

<id => ilPRGProgress>

Definition at line 64 of file class.ilPRGAssignmentDBRepository.php.

◆ $user_data_fields

array ilPRGAssignmentDBRepository::$user_data_fields
protected

Definition at line 59 of file class.ilPRGAssignmentDBRepository.php.

◆ ASSIGNMENT_FIELD_ID

const ilPRGAssignmentDBRepository::ASSIGNMENT_FIELD_ID = 'id'

Definition at line 28 of file class.ilPRGAssignmentDBRepository.php.

◆ ASSIGNMENT_FIELD_LAST_CHANGE

const ilPRGAssignmentDBRepository::ASSIGNMENT_FIELD_LAST_CHANGE = 'last_change'

Definition at line 31 of file class.ilPRGAssignmentDBRepository.php.

◆ ASSIGNMENT_FIELD_LAST_CHANGE_BY

const ilPRGAssignmentDBRepository::ASSIGNMENT_FIELD_LAST_CHANGE_BY = 'last_change_by'

Definition at line 32 of file class.ilPRGAssignmentDBRepository.php.

◆ ASSIGNMENT_FIELD_MANUALLY_ASSIGNED

const ilPRGAssignmentDBRepository::ASSIGNMENT_FIELD_MANUALLY_ASSIGNED = 'assigned_manually'

Definition at line 36 of file class.ilPRGAssignmentDBRepository.php.

◆ ASSIGNMENT_FIELD_RESTART_DATE

const ilPRGAssignmentDBRepository::ASSIGNMENT_FIELD_RESTART_DATE = 'restart_date'

Definition at line 33 of file class.ilPRGAssignmentDBRepository.php.

◆ ASSIGNMENT_FIELD_RESTART_MAIL

const ilPRGAssignmentDBRepository::ASSIGNMENT_FIELD_RESTART_MAIL = 'restart_mail_send'

Definition at line 35 of file class.ilPRGAssignmentDBRepository.php.

◆ ASSIGNMENT_FIELD_RESTARTED_ASSIGNMENT_ID

const ilPRGAssignmentDBRepository::ASSIGNMENT_FIELD_RESTARTED_ASSIGNMENT_ID = 'restarted_assignment_id'

Definition at line 34 of file class.ilPRGAssignmentDBRepository.php.

◆ ASSIGNMENT_FIELD_ROOT_PRG_ID

const ilPRGAssignmentDBRepository::ASSIGNMENT_FIELD_ROOT_PRG_ID = 'root_prg_id'

Definition at line 30 of file class.ilPRGAssignmentDBRepository.php.

◆ ASSIGNMENT_FIELD_USR_ID

const ilPRGAssignmentDBRepository::ASSIGNMENT_FIELD_USR_ID = 'usr_id'

Definition at line 29 of file class.ilPRGAssignmentDBRepository.php.

◆ ASSIGNMENT_TABLE

const ilPRGAssignmentDBRepository::ASSIGNMENT_TABLE = 'prg_usr_assignments'

Definition at line 27 of file class.ilPRGAssignmentDBRepository.php.

◆ DATE_FORMAT_ENDOFDAY

const ilPRGAssignmentDBRepository::DATE_FORMAT_ENDOFDAY = 'Y-m-d 23:59:59'

Definition at line 57 of file class.ilPRGAssignmentDBRepository.php.

◆ PROGRESS_FIELD_ASSIGNMENT_DATE

const ilPRGAssignmentDBRepository::PROGRESS_FIELD_ASSIGNMENT_DATE = 'assignment_date'

Definition at line 46 of file class.ilPRGAssignmentDBRepository.php.

◆ PROGRESS_FIELD_ASSIGNMENT_ID

const ilPRGAssignmentDBRepository::PROGRESS_FIELD_ASSIGNMENT_ID = 'assignment_id'

Definition at line 39 of file class.ilPRGAssignmentDBRepository.php.

◆ PROGRESS_FIELD_COMPLETION_BY

const ilPRGAssignmentDBRepository::PROGRESS_FIELD_COMPLETION_BY = 'completion_by'

Definition at line 45 of file class.ilPRGAssignmentDBRepository.php.

◆ PROGRESS_FIELD_COMPLETION_DATE

const ilPRGAssignmentDBRepository::PROGRESS_FIELD_COMPLETION_DATE = 'completion_date'

Definition at line 49 of file class.ilPRGAssignmentDBRepository.php.

◆ PROGRESS_FIELD_DEADLINE

const ilPRGAssignmentDBRepository::PROGRESS_FIELD_DEADLINE = 'deadline'

◆ PROGRESS_FIELD_INVALIDATED

const ilPRGAssignmentDBRepository::PROGRESS_FIELD_INVALIDATED = 'invalidated'

◆ PROGRESS_FIELD_IS_INDIVIDUAL

const ilPRGAssignmentDBRepository::PROGRESS_FIELD_IS_INDIVIDUAL = 'individual'

Definition at line 55 of file class.ilPRGAssignmentDBRepository.php.

◆ PROGRESS_FIELD_LAST_CHANGE

const ilPRGAssignmentDBRepository::PROGRESS_FIELD_LAST_CHANGE = 'last_change'

Definition at line 47 of file class.ilPRGAssignmentDBRepository.php.

◆ PROGRESS_FIELD_LAST_CHANGE_BY

const ilPRGAssignmentDBRepository::PROGRESS_FIELD_LAST_CHANGE_BY = 'last_change_by'

Definition at line 48 of file class.ilPRGAssignmentDBRepository.php.

◆ PROGRESS_FIELD_MAIL_SENT_RISKYTOFAIL

const ilPRGAssignmentDBRepository::PROGRESS_FIELD_MAIL_SENT_RISKYTOFAIL = 'sent_mail_risky_to_fail'

Definition at line 53 of file class.ilPRGAssignmentDBRepository.php.

◆ PROGRESS_FIELD_MAIL_SENT_WILLEXPIRE

const ilPRGAssignmentDBRepository::PROGRESS_FIELD_MAIL_SENT_WILLEXPIRE = 'sent_mail_expires'

Definition at line 54 of file class.ilPRGAssignmentDBRepository.php.

◆ PROGRESS_FIELD_POINTS

const ilPRGAssignmentDBRepository::PROGRESS_FIELD_POINTS = 'points'

Definition at line 42 of file class.ilPRGAssignmentDBRepository.php.

◆ PROGRESS_FIELD_POINTS_CUR

const ilPRGAssignmentDBRepository::PROGRESS_FIELD_POINTS_CUR = 'points_cur'

Definition at line 43 of file class.ilPRGAssignmentDBRepository.php.

◆ PROGRESS_FIELD_PRG_ID

const ilPRGAssignmentDBRepository::PROGRESS_FIELD_PRG_ID = 'prg_id'

Definition at line 41 of file class.ilPRGAssignmentDBRepository.php.

◆ PROGRESS_FIELD_STATUS

const ilPRGAssignmentDBRepository::PROGRESS_FIELD_STATUS = 'status'

◆ PROGRESS_FIELD_USR_ID

const ilPRGAssignmentDBRepository::PROGRESS_FIELD_USR_ID = 'usr_id'

Definition at line 40 of file class.ilPRGAssignmentDBRepository.php.

◆ PROGRESS_FIELD_VQ_DATE

const ilPRGAssignmentDBRepository::PROGRESS_FIELD_VQ_DATE = 'vq_date'

◆ PROGRESS_TABLE

const ilPRGAssignmentDBRepository::PROGRESS_TABLE = 'prg_usr_progress'

Definition at line 38 of file class.ilPRGAssignmentDBRepository.php.


The documentation for this class was generated from the following file: