ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
AssignmentsDBRepository.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22
24
26{
27 protected \ilDBInterface $db;
29
30 public function __construct(
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"],
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.
Interface ilDBInterface.