ILIAS  release_10 Revision v10.1-43-ga1241a92c2f
AssignmentsDBRepository.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
22 
24 
26 {
27  protected \ilDBInterface $db;
29 
30  public function __construct(
31  InternalDataService $data,
32  \ilDBInterface $db
33  ) {
34  $this->db = $db;
35  $this->data = $data;
36  }
37 
38  protected function getAssignmentFromRecord(array $rec): Assignment
39  {
40  return $this->data->assignment(
41  (int) $rec["id"],
42  (int) $rec["exc_id"],
43  (string) $rec["title"],
44  (int) $rec["order_nr"],
45  (int) $rec["type"],
46  (string) $rec["instruction"],
47  (bool) $rec["mandatory"],
48  (int) $rec["deadline_mode"],
49  (int) $rec["time_stamp"],
50  (int) $rec["deadline2"],
51  (int) $rec["relative_deadline"],
52  (int) $rec["rel_deadline_last_subm"]
53  );
54  }
55 
59  public function getList(int $exc_id): \Iterator
60  {
61  $set = $this->db->query("SELECT * FROM exc_assignment " .
62  " WHERE exc_id = " . $this->db->quote($exc_id, "integer") .
63  " ORDER BY order_nr");
64  $order_val = 10;
65  while ($rec = $this->db->fetchAssoc($set)) {
66  $rec["order_nr"] = $order_val;
67  $order_val += 10;
68  yield $this->getAssignmentFromRecord($rec);
69  }
70  }
71 
72  public function get(int $exc_id, int $ass_id): ?Assignment
73  {
74  $set = $this->db->queryF(
75  "SELECT * FROM exc_assignment " .
76  " WHERE exc_id = %s AND id = %s",
77  ["integer", "integer"],
78  [$exc_id, $ass_id]
79  );
80  if ($rec = $this->db->fetchAssoc($set)) {
81  return $this->getAssignmentFromRecord($rec);
82  }
83  return null;
84  }
85 
86 }
__construct(InternalDataService $data, \ilDBInterface $db)
Internal factory for data objects.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Definition: Assignment.php:21