ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
ilExcCriteriaCatalogue Class Reference

Class ilExcCriteriaCatalogue. More...

+ Collaboration diagram for ilExcCriteriaCatalogue:

Public Member Functions

 __construct ($a_id=null)
 
 getId ()
 
 setParent ($a_value)
 
 getParent ()
 
 setTitle ($a_value)
 
 getTitle ()
 
 setPosition ($a_value)
 
 getPosition ()
 
 save ()
 
 update ()
 
 delete ()
 
 cloneObject ($a_target_parent_id)
 

Static Public Member Functions

static getInstancesByParentId ($a_parent_id)
 
static deleteByParent ($a_parent_id)
 

Protected Member Functions

 setId ($a_id)
 
 importFromDB (array $a_row)
 
 getDBProperties ()
 
 getLastPosition ()
 
 read ($a_id)
 

Protected Attributes

 $db
 
 $id
 
 $parent
 
 $title
 
 $pos
 

Detailed Description

Constructor & Destructor Documentation

◆ __construct()

ilExcCriteriaCatalogue::__construct (   $a_id = null)

Definition at line 23 of file class.ilExcCriteriaCatalogue.php.

References $DIC, and read().

24  {
25  global $DIC;
26 
27  $this->db = $DIC->database();
28  $this->read($a_id);
29  }
global $DIC
Definition: saml.php:7
+ Here is the call graph for this function:

Member Function Documentation

◆ cloneObject()

ilExcCriteriaCatalogue::cloneObject (   $a_target_parent_id)

Definition at line 211 of file class.ilExcCriteriaCatalogue.php.

References getId(), ilExcCriteria\getInstancesByParentId(), getPosition(), and getTitle().

212  {
213  $new_obj = new self();
214  $new_obj->setParent($a_target_parent_id);
215  $new_obj->setTitle($this->getTitle());
216  $new_obj->setPosition($this->getPosition());
217  $new_obj->save();
218 
219  include_once "Modules/Exercise/classes/class.ilExcCriteria.php";
220  foreach (ilExcCriteria::getInstancesByParentId($this->getId()) as $crit) {
221  $crit->cloneObject($new_obj->getId());
222  }
223 
224  return $new_obj->getId();
225  }
static getInstancesByParentId($a_parent_id)
+ Here is the call graph for this function:

◆ delete()

ilExcCriteriaCatalogue::delete ( )

Definition at line 182 of file class.ilExcCriteriaCatalogue.php.

References $db, $ilDB, and ilExcCriteria\deleteByParent().

183  {
184  $ilDB = $this->db;
185 
186  if (!$this->id) {
187  return;
188  }
189 
190  include_once "Modules/Exercise/classes/class.ilExcCriteria.php";
192 
193  $ilDB->manipulate("DELETE FROM exc_crit_cat" .
194  " WHERE id = " . $ilDB->quote($this->id, "integer"));
195  }
static deleteByParent($a_parent_id)
global $ilDB
+ Here is the call graph for this function:

◆ deleteByParent()

static ilExcCriteriaCatalogue::deleteByParent (   $a_parent_id)
static

Definition at line 197 of file class.ilExcCriteriaCatalogue.php.

References $DIC, and $ilDB.

Referenced by ilObjExercise\delete().

198  {
199  global $DIC;
200 
201  $ilDB = $DIC->database();
202 
203  if (!(int) $a_parent_id) {
204  return;
205  }
206 
207  $ilDB->manipulate("DELETE FROM exc_crit" .
208  " WHERE parent = " . $ilDB->quote($a_parent_id, "integer"));
209  }
global $DIC
Definition: saml.php:7
global $ilDB
+ Here is the caller graph for this function:

◆ getDBProperties()

ilExcCriteriaCatalogue::getDBProperties ( )
protected

Definition at line 114 of file class.ilExcCriteriaCatalogue.php.

References getPosition(), and getTitle().

Referenced by save(), and update().

115  {
116  return array(
117  "title" => array("text", $this->getTitle())
118  ,"pos" => array("integer", $this->getPosition())
119  );
120  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getId()

ilExcCriteriaCatalogue::getId ( )

Definition at line 57 of file class.ilExcCriteriaCatalogue.php.

References $id.

Referenced by cloneObject().

+ Here is the caller graph for this function:

◆ getInstancesByParentId()

static ilExcCriteriaCatalogue::getInstancesByParentId (   $a_parent_id)
static

Definition at line 31 of file class.ilExcCriteriaCatalogue.php.

References $DIC, $ilDB, $res, and $row.

Referenced by ilObjExercise\cloneObject(), ilExcCriteriaCatalogueGUI\confirmDeletion(), ilExcCriteriaCatalogueGUI\delete(), ilExcCriteriaCatalogueTableGUI\getItems(), ilExAssignmentEditorGUI\initPeerReviewForm(), and ilExcCriteriaCatalogueGUI\saveOrder().

32  {
33  global $DIC;
34 
35  $ilDB = $DIC->database();
36 
37  $res = array();
38 
39  $set = $ilDB->query("SELECT *" .
40  " FROM exc_crit_cat" .
41  " WHERE parent = " . $ilDB->quote($a_parent_id, "integer") .
42  " ORDER BY pos");
43  while ($row = $ilDB->fetchAssoc($set)) {
44  $obj = new self();
45  $obj->importFromDB($row);
46  $res[$obj->getId()] = $obj;
47  }
48 
49  return $res;
50  }
global $DIC
Definition: saml.php:7
foreach($_POST as $key=> $value) $res
$row
global $ilDB
+ Here is the caller graph for this function:

◆ getLastPosition()

ilExcCriteriaCatalogue::getLastPosition ( )
protected

Definition at line 121 of file class.ilExcCriteriaCatalogue.php.

References $db, $ilDB, $row, and getParent().

Referenced by save().

122  {
123  $ilDB = $this->db;
124 
125  if (!$this->getParent()) {
126  return;
127  }
128 
129  $set = $ilDB->query("SELECT MAX(pos) pos" .
130  " FROM exc_crit_cat" .
131  " WHERE parent = " . $ilDB->quote($this->getParent(), "integer"));
132  $row = $ilDB->fetchAssoc($set);
133  return (int) $row["pos"];
134  }
$row
global $ilDB
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getParent()

ilExcCriteriaCatalogue::getParent ( )

Definition at line 74 of file class.ilExcCriteriaCatalogue.php.

References $parent.

Referenced by getLastPosition(), and save().

+ Here is the caller graph for this function:

◆ getPosition()

ilExcCriteriaCatalogue::getPosition ( )

Definition at line 96 of file class.ilExcCriteriaCatalogue.php.

References $pos.

Referenced by cloneObject(), and getDBProperties().

+ Here is the caller graph for this function:

◆ getTitle()

ilExcCriteriaCatalogue::getTitle ( )

Definition at line 86 of file class.ilExcCriteriaCatalogue.php.

References $title.

Referenced by cloneObject(), ilExcCriteriaCatalogueGUI\exportForm(), and getDBProperties().

+ Here is the caller graph for this function:

◆ importFromDB()

ilExcCriteriaCatalogue::importFromDB ( array  $a_row)
protected

Definition at line 106 of file class.ilExcCriteriaCatalogue.php.

References setId(), setParent(), setPosition(), and setTitle().

Referenced by read().

107  {
108  $this->setId($a_row["id"]);
109  $this->setParent($a_row["parent"]);
110  $this->setTitle($a_row["title"]);
111  $this->setPosition($a_row["pos"]);
112  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ read()

ilExcCriteriaCatalogue::read (   $a_id)
protected

Definition at line 136 of file class.ilExcCriteriaCatalogue.php.

References $db, $ilDB, $row, and importFromDB().

Referenced by __construct().

137  {
138  $ilDB = $this->db;
139 
140  $a_id = (int) $a_id;
141  if ($a_id) {
142  $set = $ilDB->query("SELECT *" .
143  " FROM exc_crit_cat" .
144  " WHERE id = " . $ilDB->quote($a_id, "integer"));
145  if ($ilDB->numRows($set)) {
146  $row = $ilDB->fetchAssoc($set);
147  $this->importFromDB($row);
148  }
149  }
150  }
$row
global $ilDB
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ save()

ilExcCriteriaCatalogue::save ( )

Definition at line 152 of file class.ilExcCriteriaCatalogue.php.

References $db, $ilDB, getDBProperties(), getLastPosition(), getParent(), and update().

Referenced by update().

153  {
154  $ilDB = $this->db;
155 
156  if ($this->id) {
157  return $this->update();
158  }
159 
160  $this->id = $ilDB->nextId("exc_crit_cat");
161 
162  $fields = $this->getDBProperties();
163  $fields["parent"] = array("integer", $this->getParent());
164  $fields["pos"] = array("integer", $this->getLastPosition() + 10);
165  $fields["id"] = array("integer", $this->id);
166 
167  $ilDB->insert("exc_crit_cat", $fields);
168  }
global $ilDB
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setId()

ilExcCriteriaCatalogue::setId (   $a_id)
protected

Definition at line 62 of file class.ilExcCriteriaCatalogue.php.

Referenced by importFromDB().

63  {
64  $this->id = (int) $a_id;
65  }
+ Here is the caller graph for this function:

◆ setParent()

ilExcCriteriaCatalogue::setParent (   $a_value)

Definition at line 67 of file class.ilExcCriteriaCatalogue.php.

Referenced by importFromDB().

68  {
69  $this->parent = ($a_value !== null)
70  ? (int) $a_value
71  : null;
72  }
+ Here is the caller graph for this function:

◆ setPosition()

ilExcCriteriaCatalogue::setPosition (   $a_value)

Definition at line 91 of file class.ilExcCriteriaCatalogue.php.

Referenced by importFromDB().

92  {
93  $this->pos = (int) $a_value;
94  }
+ Here is the caller graph for this function:

◆ setTitle()

ilExcCriteriaCatalogue::setTitle (   $a_value)

Definition at line 79 of file class.ilExcCriteriaCatalogue.php.

Referenced by importFromDB().

80  {
81  $this->title = ($a_value !== null)
82  ? trim($a_value)
83  : null;
84  }
+ Here is the caller graph for this function:

◆ update()

ilExcCriteriaCatalogue::update ( )

Definition at line 170 of file class.ilExcCriteriaCatalogue.php.

References $db, $ilDB, getDBProperties(), and save().

Referenced by save().

171  {
172  $ilDB = $this->db;
173 
174  if (!$this->id) {
175  return $this->save();
176  }
177 
178  $primary = array("id" => array("integer", $this->id));
179  $ilDB->update("exc_crit_cat", $this->getDBProperties(), $primary);
180  }
global $ilDB
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Field Documentation

◆ $db

ilExcCriteriaCatalogue::$db
protected

Definition at line 16 of file class.ilExcCriteriaCatalogue.php.

Referenced by delete(), getLastPosition(), read(), save(), and update().

◆ $id

ilExcCriteriaCatalogue::$id
protected

Definition at line 18 of file class.ilExcCriteriaCatalogue.php.

Referenced by getId().

◆ $parent

ilExcCriteriaCatalogue::$parent
protected

Definition at line 19 of file class.ilExcCriteriaCatalogue.php.

Referenced by getParent().

◆ $pos

ilExcCriteriaCatalogue::$pos
protected

Definition at line 21 of file class.ilExcCriteriaCatalogue.php.

Referenced by getPosition().

◆ $title

ilExcCriteriaCatalogue::$title
protected

Definition at line 20 of file class.ilExcCriteriaCatalogue.php.

Referenced by getTitle().


The documentation for this class was generated from the following file: