11 const TABLE =
'prg_usr_assignments';
35 throw new ilException(
"ilStudyProgrammeAssignment::createFor: '$usr_id' " 36 .
"is no id of a user.");
39 throw new ilException(
"ilStudyProgrammeAssignment::createFor: '$root_prg_id' " 40 .
"is no id of a prg.");
43 self::FIELD_ID => $this->
nextId(),
44 self::FIELD_USR_ID => $usr_id,
45 self::FIELD_ROOT_PRG_ID => $root_prg_id,
46 self::FIELD_LAST_CHANGE_BY => $assigning_usr_id,
48 self::FIELD_RESTART_DATE => null,
59 public function read(
int $id)
74 foreach ($this->
loadByFilterDB([self::FIELD_USR_ID => $usr_id]) as $row) {
87 foreach ($this->
loadByFilterDB([self::FIELD_ROOT_PRG_ID => $prg_id]) as $row) {
101 [self::FIELD_USR_ID => $usr_id
102 , self::FIELD_ROOT_PRG_ID => $prg_id]
134 $res = $this->db->query($q);
135 while ($rec = $this->db->fetchAssoc(
$res)) {
143 $q .=
' AND ' . self::FIELD_RESTART_MAIL .
' IS NULL';
145 $res = $this->db->query($q);
146 while ($rec = $this->db->fetchAssoc(
$res)) {
153 return 'SELECT ' . self::FIELD_ID
154 .
', ' . self::FIELD_USR_ID
155 .
', ' . self::FIELD_ROOT_PRG_ID
156 .
', ' . self::FIELD_LAST_CHANGE
157 .
', ' . self::FIELD_LAST_CHANGE_BY
158 .
', ' . self::FIELD_RESTART_DATE
159 .
', ' . self::FIELD_RESTARTED_ASSIGNMENT_ID . PHP_EOL
160 .
' FROM ' . self::TABLE . PHP_EOL;
166 .
' WHERE ' . self::FIELD_RESTARTED_ASSIGNMENT_ID
167 .
' = ' . $this->db->quote(
171 .
' AND ' . self::FIELD_RESTART_DATE .
' IS NOT NULL' . PHP_EOL
172 .
' AND DATE(' . self::FIELD_RESTART_DATE .
') <= ' 200 $date->sub(
new DateInterval(
'P' . $days_before_end .
'D'));
202 .
' WHERE ' . self::FIELD_RESTARTED_ASSIGNMENT_ID
203 .
' = ' . $this->db->quote(
207 .
' AND ' . self::FIELD_RESTART_DATE .
' IS NOT NULL' . PHP_EOL
208 .
' AND DATE(' . self::FIELD_RESTART_DATE .
') <= ' 215 $res = $this->db->query($q);
216 while ($rec = $this->db->fetchAssoc(
$res)) {
227 self::FIELD_ID => $assignment->
getId(),
228 self::FIELD_USR_ID => $assignment->
getUserId(),
229 self::FIELD_ROOT_PRG_ID => $assignment->
getRootId(),
243 $this->
deleteDB($assignment->getId());
256 self::FIELD_RESTART_MAIL => [
262 $this->db->update(self::TABLE, $values, $where);
272 $q =
'SELECT ' . self::FIELD_ID
273 .
', ' . self::FIELD_USR_ID
274 .
', ' . self::FIELD_ROOT_PRG_ID
275 .
', ' . self::FIELD_LAST_CHANGE
276 .
', ' . self::FIELD_LAST_CHANGE_BY
277 .
', ' . self::FIELD_RESTART_DATE
278 .
', ' . self::FIELD_RESTARTED_ASSIGNMENT_ID
279 .
' FROM ' . self::TABLE
280 .
' WHERE ' . self::FIELD_USR_ID .
' = ' . $usr_id
281 .
' ORDER BY ' . self::FIELD_ROOT_PRG_ID .
', ' . self::FIELD_ID
287 while ($row =
$db->fetchAssoc(
$res)) {
289 $prg = $row[
'root_prg_id'];
291 if ($prg != $row[
'root_prg_id']) {
292 $ret[$prg] = $assignments;
293 $prg = $row[
'root_prg_id'];
298 if (count($assignments) > 0) {
299 $ret[$prg] = $assignments;
310 ->
setRootId($row[self::FIELD_ROOT_PRG_ID])
311 ->setUserId($row[self::FIELD_USR_ID])
312 ->setLastChangeBy($row[self::FIELD_LAST_CHANGE_BY])
313 ->setLastChange(DateTime::createFromFormat(
315 $row[self::FIELD_LAST_CHANGE]
318 $row[self::FIELD_RESTART_DATE] ?
322 ->setRestartedAssignmentId($row[self::FIELD_RESTARTED_ASSIGNMENT_ID]);
327 $q =
'SELECT ' . self::FIELD_ID
328 .
' ,' . self::FIELD_USR_ID
329 .
' ,' . self::FIELD_ROOT_PRG_ID
330 .
' ,' . self::FIELD_LAST_CHANGE
331 .
' ,' . self::FIELD_LAST_CHANGE_BY
332 .
' ,' . self::FIELD_RESTART_DATE
333 .
' ,' . self::FIELD_RESTARTED_ASSIGNMENT_ID
334 .
' FROM ' . self::TABLE
336 foreach ($filter as $field => $value) {
337 $q .=
' AND ' . $field .
' = ' . $this->db->quote($value,
'text');
339 $res = $this->db->query($q);
340 while ($rec = $this->db->fetchAssoc(
$res)) {
350 self::FIELD_ID => [
'interger', $row[self::FIELD_ID]]
351 , self::FIELD_USR_ID => [
'interger', $row[self::FIELD_USR_ID]]
352 , self::FIELD_ROOT_PRG_ID => [
'interger', $row[self::FIELD_ROOT_PRG_ID]]
353 , self::FIELD_LAST_CHANGE => [
'interger', $row[self::FIELD_LAST_CHANGE]]
354 , self::FIELD_LAST_CHANGE_BY => [
'interger', $row[self::FIELD_LAST_CHANGE_BY]]
355 , self::FIELD_RESTART_DATE => [
'timestamp', $row[self::FIELD_RESTART_DATE]]
356 , self::FIELD_RESTARTED_ASSIGNMENT_ID => [
'integer', $row[self::FIELD_RESTARTED_ASSIGNMENT_ID]]
363 $q =
'UPDATE ' . self::TABLE
365 .
' ' . self::FIELD_USR_ID .
' = ' . $this->db->quote($values[self::FIELD_USR_ID],
'integer')
366 .
' ,' . self::FIELD_ROOT_PRG_ID .
' = ' . $this->db->quote($values[self::FIELD_ROOT_PRG_ID],
'integer')
367 .
' ,' . self::FIELD_LAST_CHANGE .
' = ' . $this->db->quote($values[self::FIELD_LAST_CHANGE],
'text')
368 .
' ,' . self::FIELD_LAST_CHANGE_BY .
' = ' . $this->db->quote($values[self::FIELD_LAST_CHANGE_BY],
'integer')
369 .
' ,' . self::FIELD_RESTART_DATE .
' = ' . $this->db->quote($values[self::FIELD_RESTART_DATE],
'timestamp')
370 .
' ,' . self::FIELD_RESTARTED_ASSIGNMENT_ID .
' = ' . $this->db->quote($values[self::FIELD_RESTARTED_ASSIGNMENT_ID],
'integer')
371 .
' WHERE ' . self::FIELD_ID .
' = ' . $this->db->quote($values[self::FIELD_ID],
'integer');
372 $this->db->manipulate($q);
377 $this->db->manipulate(
'DELETE FROM ' . self::TABLE .
' WHERE ' . self::FIELD_ID .
' = ' . $this->db->quote($id,
'integer'));
382 return $this->db->nextId(self::TABLE);
update(ilStudyProgrammeAssignment $assignment)
Update settings belonging to a SP-Object.Will throw if the record does not exist yet.
readByUsrIdAndPrgId(int $usr_id, int $prg_id)
loadDueToRestartAndMail()
getUserId()
Get the id of the user who is assigned.
const FIELD_RESTARTED_ASSIGNMENT_ID
loadDueToManuelRestart(int $days_before_end)
getRestartedAssignmentId()
Get the id of the assignment which was intiated due to expiring progress of this assignment.
createFor(int $root_prg_id, int $usr_id, int $assigning_usr_id)
Create a record corresponding to a SP-Object and return represending settings.Will throw if a record ...
getDashboardInstancesforUser(int $usr_id)
static now()
Return current timestamp in Y-m-d H:i:s format.
read(int $id)
Load settings belonging to a SP-Object.Will throw if the record does not exist yet.ilStudyProgrammeAssignment | null
getLastChange()
Get the timestamp of the last change on this program or a sub program.
reminderSendFor(int $assignment_id)
const NO_RESTARTED_ASSIGNMENT
foreach($_POST as $key=> $value) $res
readDueToRestart()
Get all assignments due to restart and not restrted yet.
updatedRowDB(array $values)
__construct(ilDBInterface $db)
readDueToRestartAndMail()
Class ilStudyProgrammeAssignment.
getRestartDate()
Get the date, at which the user is to be reassigned to the programme.
static _lookupType($a_id, $a_reference=false)
lookup object type
assignmentByRow(array $row)
getLastChangeBy()
Get the id of the user who did the last change on this assignment.
readByPrgId(int $prg_id)
Get all assignments to a prg.
readByUsrId(int $usr_id)
Get all assignments of a user.
getRootId()
Get the object id of the program the user was assigned to.
loadByFilterDB(array $filter)
const FIELD_LAST_CHANGE_BY
readDueToManuelRestart(int $days_before_end)
Get all assignments due to restart and not restrted yet.
getId()
Get the id of the assignment.