ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
class.ilIndividualAssessmentSettingsStorageDB.php
Go to the documentation of this file.
1 <?php
2 
3 require_once 'Modules/IndividualAssessment/interfaces/Settings/interface.ilIndividualAssessmentSettingsStorage.php';
4 require_once 'Modules/IndividualAssessment/classes/Settings/class.ilIndividualAssessmentSettings.php';
5 require_once 'Modules/IndividualAssessment/classes/Settings/class.ilIndividualAssessmentInfoSettings.php';
6 require_once 'Modules/IndividualAssessment/classes/class.ilObjIndividualAssessment.php';
7 
14 {
15  const IASS_SETTINGS_TABLE = "iass_settings";
16  const IASS_SETTINGS_INFO_TABLE = "iass_info_settings";
17 
18  protected $db;
19  public function __construct($db)
20  {
21  $this->db = $db;
22  }
23 
28  {
29  $values = array( "obj_id" => array("integer", $settings->getId())
30  , "content" => array("text", $settings->content())
31  , "record_template" => array("text", $settings->recordTemplate())
32  , "event_time_place_required" => array("integer", $settings->eventTimePlaceRequired())
33  , "file_required" => array("integer", $settings->fileRequired())
34  );
35 
36  $this->db->insert(self::IASS_SETTINGS_TABLE, $values);
37 
38  $values = array("obj_id" => array("integer", $settings->getId()));
39  $this->db->insert(self::IASS_SETTINGS_INFO_TABLE, $values);
40  }
41 
46  {
47  if (ilObjIndividualAssessment::_exists($obj->getId(), false, 'iass')) {
48  $obj_id = $obj->getId();
49  assert(is_numeric($obj_id));
50  $sql = "SELECT content, record_template, event_time_place_required, file_required\n"
51  . " FROM " . self::IASS_SETTINGS_TABLE . "\n"
52  . " WHERE obj_id = " . $this->db->quote($obj_id, 'integer');
53 
54  if ($res = $this->db->fetchAssoc($this->db->query($sql))) {
56  $obj,
57  $res["content"],
58  $res["record_template"],
59  (bool) $res["event_time_place_required"],
60  (bool) $res['file_required']
61  );
62  }
63  throw new ilIndividualAssessmentException("$obj_id not in database");
64  } else {
65  return new ilIndividualAssessmentSettings($obj);
66  }
67  }
68 
73  {
74  $where = array( "obj_id" => array("integer", $settings->getId()));
75 
76  $values = array( "content" => array("text", $settings->content())
77  , "record_template" => array("text", $settings->recordTemplate())
78  , "event_time_place_required" => array("integer", $settings->eventTimePlaceRequired())
79  , "file_required" => array("integer", $settings->fileRequired())
80  );
81 
82  $this->db->update(self::IASS_SETTINGS_TABLE, $values, $where);
83  }
84 
92  {
93  if (ilObjIndividualAssessment::_exists($obj->getId(), false, 'iass')) {
94  $obj_id = $obj->getId();
95  assert(is_numeric($obj_id));
96  $sql = "SELECT contact, responsibility, phone, mails, consultation_hours"
97  . " FROM " . self::IASS_SETTINGS_INFO_TABLE . " WHERE obj_id = " . $this->db->quote($obj_id, 'integer');
98 
99  if ($res = $this->db->fetchAssoc($this->db->query($sql))) {
101  $obj,
102  $res["contact"],
103  $res["responsibility"],
104  $res['phone'],
105  $res['mails'],
106  $res['consultation_hours']
107  );
108  }
109  throw new ilIndividualAssessmentException("$obj_id not in database");
110  } else {
111  return new ilIndividualAssessmentInfoSettings($obj);
112  }
113  }
114 
121  {
122  $where = array("obj_id" => array("integer", $settings->id()));
123 
124  $values = array( "contact" => array("text", $settings->contact())
125  , "responsibility" => array("text", $settings->responsibility())
126  , "phone" => array("text", $settings->phone())
127  , "mails" => array("text", $settings->mails())
128  , "consultation_hours" => array("text", $settings->consultationHours())
129  );
130 
131  $this->db->update(self::IASS_SETTINGS_INFO_TABLE, $values, $where);
132  }
133 
138  {
139  $sql = "DELETE FROM " . self::IASS_SETTINGS_TABLE . " WHERE obj_id = %s";
140  $this->db->manipulateF($sql, array("integer"), array($obj->getId()));
141 
142  $sql = "DELETE FROM " . self::IASS_SETTINGS_INFO_TABLE . " WHERE obj_id = %s";
143  $this->db->manipulateF($sql, array("integer"), array($obj->getId()));
144  }
145 }
loadInfoSettings(ilObjIndividualAssessment $obj)
Load info-screen settings corresponding to obj.
For the purpose of streamlining the grading and learning-process status definition outside of tests...
A settings storage handler to write iass settings to db.
static _exists($a_id, $a_reference=false, $a_type=null)
checks if an object exists in object_data
An object carrying settings of an Individual Assessment obj beyond the standart information.
eventTimePlaceRequired()
Get the value of the checkbox event_time_place_require.
A general storage interface for Individual assessment settings.
recordTemplate()
Get the record template to be used as default record with corresponding object.
foreach($_POST as $key=> $value) $res
getId()
get object id public
$values
updateSettings(ilIndividualAssessmentSettings $settings)
Update settings entry.
content()
Get the content of this assessment, e.g.
loadSettings(ilObjIndividualAssessment $obj)
Load settings corresponding to obj.ilIndividualAssessmentSettings $settings
getId()
Get the id of corrwsponding iass-object.
fileRequired()
Get the value of the checkbox file_required.
deleteSettings(ilObjIndividualAssessment $obj)
Delete settings entry corresponding to obj.ilIndividualAssessmentSettings $settings ...
createSettings(ilIndividualAssessmentSettings $settings)
Create a entry corresponding to $settings.
updateInfoSettings(ilIndividualAssessmentInfoSettings $settings)
Update info-screen settings entry.