ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilIndividualAssessmentSettingsStorageDB.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
25{
26 public const IASS_SETTINGS_TABLE = "iass_settings";
27 public const IASS_SETTINGS_INFO_TABLE = "iass_info_settings";
28
29 protected ilDBInterface $db;
30
31 public function __construct(ilDBInterface $db)
32 {
33 $this->db = $db;
34 }
35
39 public function createSettings(ilIndividualAssessmentSettings $settings): void
40 {
41 $values = [
42 "obj_id" => ["integer", $settings->getObjId()],
43 "content" => ["text", $settings->getContent()],
44 "record_template" => ["text", $settings->getRecordTemplate()],
45 "event_time_place_required" => ["integer", $settings->isEventTimePlaceRequired()],
46 "file_required" => ["integer", $settings->isFileRequired()]
47 ];
48
49 $this->db->insert(self::IASS_SETTINGS_TABLE, $values);
50
51 $values = ["obj_id" => ["integer", $settings->getObjId()]];
52 $this->db->insert(self::IASS_SETTINGS_INFO_TABLE, $values);
53 }
54
59 {
60 if (!ilObjIndividualAssessment::_exists($obj->getId(), false, 'iass')) {
62 $obj->getId(),
63 '',
64 '',
65 '',
66 '',
67 false,
68 false
69 );
70 }
71
72 $sql =
73 "SELECT content, record_template, event_time_place_required, file_required" . PHP_EOL
74 . "FROM " . self::IASS_SETTINGS_TABLE . PHP_EOL
75 . "WHERE obj_id = " . $this->db->quote($obj->getId(), 'integer') . PHP_EOL
76 ;
77
78 $result = $this->db->query($sql);
79
80 if ($this->db->numRows($result) == 0) {
81 throw new ilIndividualAssessmentException($obj->getId() . " not in database");
82 }
83
84 $row = $this->db->fetchAssoc($result);
85
87 $obj->getId(),
88 $obj->getTitle(),
89 $obj->getDescription(),
90 $row["content"],
91 $row["record_template"],
92 (bool) $row["event_time_place_required"],
93 (bool) $row['file_required']
94 );
95 }
96
100 public function updateSettings(ilIndividualAssessmentSettings $settings): void
101 {
102 $where = ["obj_id" => ["integer", $settings->getObjId()]];
103
104 $values = [
105 "content" => ["text", $settings->getContent()],
106 "record_template" => ["text", $settings->getRecordTemplate()],
107 "event_time_place_required" => ["integer", $settings->isEventTimePlaceRequired()],
108 "file_required" => ["integer", $settings->isFileRequired()]
109 ];
110
111 $this->db->update(self::IASS_SETTINGS_TABLE, $values, $where);
112 }
113
118 {
119 if (!ilObjIndividualAssessment::_exists($obj->getId(), false, 'iass')) {
120 return new ilIndividualAssessmentInfoSettings($obj->getId());
121 }
122
123 $sql =
124 "SELECT contact, responsibility, phone, mails, consultation_hours" . PHP_EOL
125 . "FROM " . self::IASS_SETTINGS_INFO_TABLE . PHP_EOL
126 . "WHERE obj_id = " . $this->db->quote($obj->getId(), 'integer') . PHP_EOL
127 ;
128
129 $result = $this->db->query($sql);
130
131 if ($this->db->numRows($result) == 0) {
132 throw new ilIndividualAssessmentException($obj->getId() . " not in database");
133 }
134
135 $row = $this->db->fetchAssoc($result);
136
138 $obj->getId(),
139 $row["contact"],
140 $row["responsibility"],
141 $row['phone'],
142 $row['mails'],
143 $row['consultation_hours']
144 );
145 }
146
151 {
152 $where = ["obj_id" => ["integer", $settings->getObjId()]];
153
154 $values = [
155 "contact" => ["text", $settings->getContact()],
156 "responsibility" => ["text", $settings->getResponsibility()],
157 "phone" => ["text", $settings->getPhone()],
158 "mails" => ["text", $settings->getMails()],
159 "consultation_hours" => ["text", $settings->getConsultationHours()]
160 ];
161
162 $this->db->update(self::IASS_SETTINGS_INFO_TABLE, $values, $where);
163 }
164
168 public function deleteSettings(ilObjIndividualAssessment $obj): void
169 {
170 $sql = "DELETE FROM " . self::IASS_SETTINGS_TABLE . " WHERE obj_id = %s";
171 $this->db->manipulateF($sql, array("integer"), array($obj->getId()));
172
173 $sql = "DELETE FROM " . self::IASS_SETTINGS_INFO_TABLE . " WHERE obj_id = %s";
174 $this->db->manipulateF($sql, array("integer"), array($obj->getId()));
175 }
176}
A settings storage handler to write iass settings to db.
updateSettings(ilIndividualAssessmentSettings $settings)
Update settings entry.
loadSettings(ilObjIndividualAssessment $obj)
Load settings corresponding to obj.
deleteSettings(ilObjIndividualAssessment $obj)
Delete settings entry corresponding to obj.
updateInfoSettings(ilIndividualAssessmentInfoSettings $settings)
Update info-screen settings entry.
loadInfoSettings(ilObjIndividualAssessment $obj)
Load info-screen settings corresponding to obj.
createSettings(ilIndividualAssessmentSettings $settings)
Create an entry corresponding to $settings.
An object carrying settings of an Individual Assessment obj beyond the standard information.
isEventTimePlaceRequired()
Get the value of the checkbox event_time_place_require.
isFileRequired()
Get the value of the checkbox file_required.
getObjId()
Get the id of corresponding iass-object.
getRecordTemplate()
Get the record template to be used as default record with corresponding object.
getContent()
Get the content of this assessment, e.g.
For the purpose of streamlining the grading and learning-process status definition outside of tests,...
static _exists(int $id, bool $reference=false, ?string $type=null)
checks if an object exists in object_data
Interface ilDBInterface.
A general storage interface for Individual assessment settings.