ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
class.ilExcIndividualDeadline.php
Go to the documentation of this file.
1 <?php
2 
25 {
26  protected int $participant_id;
27  protected bool $is_team;
28  protected int $ass_id;
29  protected ilDBInterface $db;
30  protected int $starting_timestamp = 0;
31  protected int $individual_deadline = 0;
32 
33  protected function __construct(
34  int $a_ass_id,
35  int $a_participant_id,
36  bool $a_is_team
37  ) {
38  global $DIC;
39  $this->participant_id = $a_participant_id;
40  $this->is_team = $a_is_team;
41  $this->ass_id = $a_ass_id;
42  $this->db = $DIC->database();
43  $this->read();
44  }
45 
46  public static function getInstance(
47  int $a_ass_id,
48  int $a_participant_id,
49  bool $a_is_team = false
51  return new self($a_ass_id, $a_participant_id, $a_is_team);
52  }
53 
54  public function setStartingTimestamp(int $a_val): void
55  {
56  $this->starting_timestamp = $a_val;
57  }
58 
59  public function getStartingTimestamp(): int
60  {
62  }
63 
64  public function setIndividualDeadline(int $a_val): void
65  {
66  $this->individual_deadline = $a_val;
67  }
68 
69  public function getIndividualDeadline(): int
70  {
72  }
73 
74  public function read(): void
75  {
76  $ilDB = $this->db;
77 
78  $set = $ilDB->query(
79  "SELECT * FROM exc_idl " .
80  " WHERE ass_id = " . $this->db->quote($this->ass_id, "integer") .
81  " AND member_id = " . $this->db->quote($this->participant_id, "integer") .
82  " AND is_team = " . $this->db->quote($this->is_team, "integer")
83  );
84  if ($rec = $this->db->fetchAssoc($set)) {
85  $this->setIndividualDeadline((int) $rec["tstamp"]);
86  $this->setStartingTimestamp((int) $rec["starting_ts"]);
87  }
88  }
89 
90  public function save(): void
91  {
92  $ilDB = $this->db;
93 
94  $ilDB->replace(
95  "exc_idl",
96  array(
97  "ass_id" => array("integer", $this->ass_id),
98  "member_id" => array("integer", $this->participant_id),
99  "is_team" => array("integer", $this->is_team)
100  ),
101  array(
102  "tstamp" => array("integer", $this->getIndividualDeadline()),
103  "starting_ts" => array("integer", $this->getStartingTimestamp())
104  )
105  );
106  }
107 
108  public function delete(): void
109  {
110  $ilDB = $this->db;
111 
112  $ilDB->manipulate(
113  "DELETE FROM exc_idl " .
114  " WHERE ass_id = " . $this->db->quote($this->ass_id, "integer") .
115  " AND member_id = " . $this->db->quote($this->participant_id, "integer") .
116  " AND is_team = " . $this->db->quote($this->is_team, "integer")
117  );
118  }
119 
120 
127  public static function getStartingTimestamps(int $a_ass_id): array
128  {
129  global $DIC;
130 
131  $ilDB = $DIC->database();
132  $res = array();
133 
134  $set = $ilDB->query("SELECT * FROM exc_idl" .
135  " WHERE ass_id = " . $ilDB->quote($a_ass_id, "integer"));
136  while ($row = $ilDB->fetchAssoc($set)) {
137  $res[] = array("member_id" => $row["member_id"],
138  "is_team" => $row["is_team"],
139  "starting_ts" => $row["starting_ts"]);
140  }
141 
142  return $res;
143  }
144 }
$res
Definition: ltiservices.php:69
global $DIC
Definition: feed.php:28
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)