ILIAS  trunk Revision v11.0_alpha-1731-gff9cd7e2bd3
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
class.ilExcIndividualDeadline.php
Go to the documentation of this file.
1 <?php
2 
25 {
26  protected bool $requested = false;
27  protected int $participant_id;
28  protected bool $is_team;
29  protected int $ass_id;
30  protected ilDBInterface $db;
31  protected int $starting_timestamp = 0;
32  protected int $individual_deadline = 0;
33 
34  protected function __construct(
35  int $a_ass_id,
36  int $a_participant_id,
37  bool $a_is_team
38  ) {
39  global $DIC;
40  $this->participant_id = $a_participant_id;
41  $this->is_team = $a_is_team;
42  $this->ass_id = $a_ass_id;
43  $this->db = $DIC->database();
44  $this->read();
45  }
46 
47  public static function getInstance(
48  int $a_ass_id,
49  int $a_participant_id,
50  bool $a_is_team = false
52  return new self($a_ass_id, $a_participant_id, $a_is_team);
53  }
54 
55  public function setStartingTimestamp(int $a_val): void
56  {
57  $this->starting_timestamp = $a_val;
58  }
59 
60  public function getStartingTimestamp(): int
61  {
63  }
64 
65  public function setIndividualDeadline(int $a_val): void
66  {
67  $this->individual_deadline = $a_val;
68  }
69 
70  public function getIndividualDeadline(): int
71  {
73  }
74 
75  public function setRequested(bool $a_val): void
76  {
77  $this->requested = $a_val;
78  }
79 
80  public function getRequested(): bool
81  {
82  return $this->requested;
83  }
84 
85  public function read(): void
86  {
87  $ilDB = $this->db;
88 
89  $set = $ilDB->query(
90  "SELECT * FROM exc_idl " .
91  " WHERE ass_id = " . $this->db->quote($this->ass_id, "integer") .
92  " AND member_id = " . $this->db->quote($this->participant_id, "integer") .
93  " AND is_team = " . $this->db->quote($this->is_team, "integer")
94  );
95  if ($rec = $this->db->fetchAssoc($set)) {
96  $this->setIndividualDeadline((int) $rec["tstamp"]);
97  $this->setStartingTimestamp((int) $rec["starting_ts"]);
98  $this->setRequested((bool) $rec["requested"]);
99  }
100  }
101 
102  public function save(): void
103  {
104  $ilDB = $this->db;
105 
106  $ilDB->replace(
107  "exc_idl",
108  array(
109  "ass_id" => array("integer", $this->ass_id),
110  "member_id" => array("integer", $this->participant_id),
111  "is_team" => array("integer", $this->is_team)
112  ),
113  array(
114  "tstamp" => array("integer", $this->getIndividualDeadline()),
115  "starting_ts" => array("integer", $this->getStartingTimestamp()),
116  "requested" => array("integer", (int) $this->getRequested())
117  )
118  );
119  }
120 
121  public function delete(): void
122  {
123  $ilDB = $this->db;
124 
125  $ilDB->manipulate(
126  "DELETE FROM exc_idl " .
127  " WHERE ass_id = " . $this->db->quote($this->ass_id, "integer") .
128  " AND member_id = " . $this->db->quote($this->participant_id, "integer") .
129  " AND is_team = " . $this->db->quote($this->is_team, "integer")
130  );
131  }
132 
133  public static function deleteForAssignment(int $ass_id): void
134  {
135  global $DIC;
136 
137  $ilDB = $DIC->database();
138 
139  $ilDB->manipulate(
140  "DELETE FROM exc_idl " .
141  " WHERE ass_id = " . $ilDB->quote($ass_id, "integer")
142  );
143  }
144 
145 
152  public static function getStartingTimestamps(int $a_ass_id): array
153  {
154  global $DIC;
155 
156  $ilDB = $DIC->database();
157  $res = array();
158 
159  $set = $ilDB->query("SELECT * FROM exc_idl" .
160  " WHERE ass_id = " . $ilDB->quote($a_ass_id, "integer"));
161  while ($row = $ilDB->fetchAssoc($set)) {
162  $res[] = array("member_id" => $row["member_id"],
163  "is_team" => $row["is_team"],
164  "starting_ts" => $row["starting_ts"]);
165  }
166 
167  return $res;
168  }
169 }
$res
Definition: ltiservices.php:66
global $DIC
Definition: shib_login.php:22
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
__construct(int $a_ass_id, int $a_participant_id, bool $a_is_team)
static getStartingTimestamps(int $a_ass_id)
Get starting timestamp data for an assignment.
static getInstance(int $a_ass_id, int $a_participant_id, bool $a_is_team=false)