ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
ilExcCriteria Class Reference

Class ilExcCriteria. More...

+ Inheritance diagram for ilExcCriteria:
+ Collaboration diagram for ilExcCriteria:

Public Member Functions

 getTranslatedType ()
 
 getId ()
 
 getType ()
 
 setParent ($a_value)
 
 getParent ()
 
 setTitle ($a_value)
 
 getTitle ()
 
 setDescription ($a_value)
 
 getDescription ()
 
 setRequired ($a_value)
 
 isRequired ()
 
 setPosition ($a_value)
 
 getPosition ()
 
 importDefinition ($a_def, $a_def_json)
 
 save ()
 
 update ()
 
 delete ()
 
 cloneObject ($a_target_parent_id)
 
 initCustomForm (ilPropertyFormGUI $a_form)
 
 exportCustomForm (ilPropertyFormGUI $a_form)
 
 importCustomForm (ilPropertyFormGUI $a_form)
 
 setPeerReviewContext (ilExAssignment $a_ass, $a_giver_id, $a_peer_id, ilPropertyFormGUI $a_form=null)
 
 addToPeerReviewForm ($a_value=null)
 
 importFromPeerReviewForm ()
 
 updateFromAjax ()
 
 validate ($a_value)
 
 hasValue ($a_value)
 
 getHTML ($a_value)
 
 resetReview ()
 

Static Public Member Functions

static getInstanceById ($a_id)
 
static getInstancesByParentId ($a_parent_id)
 
static getTypesMap ()
 
static getInstanceByType ($a_type)
 
static deleteByParent ($a_parent_id)
 

Protected Member Functions

 __construct ()
 
 setId ($a_id)
 
 setDefinition (array $a_value=null)
 
 getDefinition ()
 
 importFromDB (array $a_row)
 
 getDBProperties ()
 
 getLastPosition ()
 

Protected Attributes

 $db
 
 $id
 
 $parent
 
 $title
 
 $desc
 
 $required
 
 $pos
 
 $def
 
 $form
 
 $ass
 
 $giver_id
 
 $peer_id
 

Detailed Description

Constructor & Destructor Documentation

◆ __construct()

ilExcCriteria::__construct ( )
protected

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

References $DIC.

32  {
33  global $DIC;
34 
35  $this->db = $DIC->database();
36  }
global $DIC
Definition: saml.php:7

Member Function Documentation

◆ addToPeerReviewForm()

ilExcCriteria::addToPeerReviewForm (   $a_value = null)
abstract

Referenced by setPeerReviewContext().

+ Here is the caller graph for this function:

◆ cloneObject()

ilExcCriteria::cloneObject (   $a_target_parent_id)

Definition at line 316 of file class.ilExcCriteria.php.

References getDefinition(), getDescription(), getInstanceByType(), getPosition(), getTitle(), getType(), and isRequired().

317  {
318  $new_obj = ilExcCriteria::getInstanceByType($this->getType());
319  $new_obj->setParent($a_target_parent_id);
320  $new_obj->setTitle($this->getTitle());
321  $new_obj->setDescription($this->getDescription());
322  $new_obj->setRequired($this->isRequired());
323  $new_obj->setPosition($this->getPosition());
324  $new_obj->setDefinition($this->getDefinition());
325  $new_obj->save();
326 
327  return $new_obj->getId();
328  }
static getInstanceByType($a_type)
+ Here is the call graph for this function:

◆ delete()

ilExcCriteria::delete ( )

Definition at line 290 of file class.ilExcCriteria.php.

References $db, and $ilDB.

291  {
292  $ilDB = $this->db;
293 
294  if (!$this->id) {
295  return;
296  }
297 
298  $ilDB->manipulate("DELETE FROM exc_crit" .
299  " WHERE id = " . $ilDB->quote($this->id, "integer"));
300  }
global $ilDB

◆ deleteByParent()

static ilExcCriteria::deleteByParent (   $a_parent_id)
static

Definition at line 302 of file class.ilExcCriteria.php.

References $DIC, and $ilDB.

Referenced by ilExcCriteriaCatalogue\delete().

303  {
304  global $DIC;
305 
306  $ilDB = $DIC->database();
307 
308  if (!(int) $a_parent_id) {
309  return;
310  }
311 
312  $ilDB->manipulate("DELETE FROM exc_crit" .
313  " WHERE parent = " . $ilDB->quote($a_parent_id, "integer"));
314  }
global $DIC
Definition: saml.php:7
global $ilDB
+ Here is the caller graph for this function:

◆ exportCustomForm()

ilExcCriteria::exportCustomForm ( ilPropertyFormGUI  $a_form)

Definition at line 340 of file class.ilExcCriteria.php.

Referenced by ilExcCriteriaGUI\exportForm().

341  {
342  // type-specific
343  }
+ Here is the caller graph for this function:

◆ getDBProperties()

ilExcCriteria::getDBProperties ( )
protected

Definition at line 230 of file class.ilExcCriteria.php.

References array, getDefinition(), getDescription(), getPosition(), getTitle(), getType(), and isRequired().

Referenced by save(), and update().

231  {
232  return array(
233  "type" => array("text", $this->getType())
234  ,"title" => array("text", $this->getTitle())
235  ,"descr" => array("text", $this->getDescription())
236  ,"required" => array("integer", $this->isRequired())
237  ,"pos" => array("integer", $this->getPosition())
238  ,"def" => array("text", is_array($this->getDefinition())
239  ? serialize($this->getDefinition())
240  : null)
241  );
242  }
Create styles array
The data for the language used.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getDefinition()

ilExcCriteria::getDefinition ( )
protected

Definition at line 186 of file class.ilExcCriteria.php.

References $def.

Referenced by cloneObject(), getDBProperties(), and ilExcCriteriaText\getMinChars().

187  {
188  return $this->def;
189  }
+ Here is the caller graph for this function:

◆ getDescription()

◆ getHTML()

ilExcCriteria::getHTML (   $a_value)
abstract

Referenced by validate().

+ Here is the caller graph for this function:

◆ getId()

◆ getInstanceById()

static ilExcCriteria::getInstanceById (   $a_id)
static

Definition at line 38 of file class.ilExcCriteria.php.

References $DIC, $ilDB, and $row.

Referenced by ilExPeerReviewGUI\downloadPeerReviewObject(), ilExcCriteriaGUI\getCurrentCritera(), and ilExPeerReviewGUI\updateCritAjaxObject().

39  {
40  global $DIC;
41 
42  $ilDB = $DIC->database();
43 
44  $set = $ilDB->query("SELECT *" .
45  " FROM exc_crit" .
46  " WHERE id = " . $ilDB->quote($a_id, "integer"));
47  if ($ilDB->numRows($set)) {
48  $row = $ilDB->fetchAssoc($set);
49  $obj = self::getInstanceByType($row["type"]);
50  $obj->importFromDB($row);
51  return $obj;
52  }
53  }
global $DIC
Definition: saml.php:7
global $ilDB
+ Here is the caller graph for this function:

◆ getInstanceByType()

static ilExcCriteria::getInstanceByType (   $a_type)
static

Definition at line 101 of file class.ilExcCriteria.php.

References $a_type.

Referenced by ilExcCriteriaGUI\add(), cloneObject(), ilExcCriteriaGUI\create(), ilExPeerReviewGUI\downloadPeerReviewObject(), ilExAssignment\getPeerReviewCriteriaCatalogueItems(), ilExerciseDataSet\importRecord(), and ilExPeerReviewGUI\updateCritAjaxObject().

102  {
103  $class = "ilExcCriteria" . ucfirst($a_type);
104  include_once "Modules/Exercise/classes/class." . $class . ".php";
105  return new $class;
106  }
$a_type
Definition: workflow.php:92
+ Here is the caller graph for this function:

◆ getInstancesByParentId()

static ilExcCriteria::getInstancesByParentId (   $a_parent_id)
static

Definition at line 55 of file class.ilExcCriteria.php.

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

Referenced by ilExcCriteriaCatalogue\cloneObject(), ilExcCriteriaGUI\confirmDeletion(), ilExcCriteriaGUI\delete(), ilExcCriteriaTableGUI\getItems(), ilExcCriteriaCatalogueTableGUI\getItems(), ilExAssignment\getPeerReviewCriteriaCatalogueItems(), ilExAssignmentEditorGUI\initPeerReviewForm(), and ilExcCriteriaGUI\saveOrder().

56  {
57  global $DIC;
58 
59  $ilDB = $DIC->database();
60 
61  $res = array();
62 
63  $set = $ilDB->query("SELECT *" .
64  " FROM exc_crit" .
65  " WHERE parent = " . $ilDB->quote($a_parent_id, "integer") .
66  " ORDER BY pos");
67  while ($row = $ilDB->fetchAssoc($set)) {
68  $obj = self::getInstanceByType($row["type"]);
69  $obj->importFromDB($row);
70  $res[$obj->getId()] = $obj;
71  }
72 
73  return $res;
74  }
global $DIC
Definition: saml.php:7
foreach($_POST as $key=> $value) $res
Create styles array
The data for the language used.
global $ilDB
+ Here is the caller graph for this function:

◆ getLastPosition()

ilExcCriteria::getLastPosition ( )
protected

Definition at line 243 of file class.ilExcCriteria.php.

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

Referenced by save().

244  {
245  $ilDB = $this->db;
246 
247  if (!$this->getParent()) {
248  return;
249  }
250 
251  $set = $ilDB->query("SELECT MAX(pos) pos" .
252  " FROM exc_crit" .
253  " WHERE parent = " . $ilDB->quote($this->getParent(), "integer"));
254  $row = $ilDB->fetchAssoc($set);
255  return (int) $row["pos"];
256  }
global $ilDB
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getParent()

ilExcCriteria::getParent ( )

Definition at line 132 of file class.ilExcCriteria.php.

References $parent.

Referenced by getLastPosition(), and save().

133  {
134  return $this->parent;
135  }
+ Here is the caller graph for this function:

◆ getPosition()

ilExcCriteria::getPosition ( )

Definition at line 176 of file class.ilExcCriteria.php.

References $pos.

Referenced by cloneObject(), and getDBProperties().

177  {
178  return $this->pos;
179  }
+ Here is the caller graph for this function:

◆ getTitle()

◆ getTranslatedType()

ilExcCriteria::getTranslatedType ( )

Definition at line 95 of file class.ilExcCriteria.php.

References getType(), and getTypesMap().

Referenced by ilExcCriteriaGUI\initForm().

96  {
97  $map = $this->getTypesMap();
98  return $map[$this->getType()];
99  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getType()

ilExcCriteria::getType ( )
abstract

Referenced by cloneObject(), getDBProperties(), getTranslatedType(), save(), and setId().

+ Here is the caller graph for this function:

◆ getTypesMap()

static ilExcCriteria::getTypesMap ( )
static

Definition at line 81 of file class.ilExcCriteria.php.

References $DIC, $lng, and array.

Referenced by getTranslatedType(), and ilExcCriteriaGUI\view().

82  {
83  global $DIC;
84 
85  $lng = $DIC->language();
86 
87  return array(
88  "bool" => $lng->txt("exc_criteria_type_bool")
89  ,"rating" => $lng->txt("exc_criteria_type_rating")
90  ,"text" => $lng->txt("exc_criteria_type_text")
91  ,"file" => $lng->txt("exc_criteria_type_file")
92  );
93  }
global $DIC
Definition: saml.php:7
Create styles array
The data for the language used.
global $lng
Definition: privfeed.php:17
+ Here is the caller graph for this function:

◆ hasValue()

ilExcCriteria::hasValue (   $a_value)
abstract

Referenced by validate().

+ Here is the caller graph for this function:

◆ importCustomForm()

ilExcCriteria::importCustomForm ( ilPropertyFormGUI  $a_form)

Definition at line 345 of file class.ilExcCriteria.php.

Referenced by ilExcCriteriaGUI\importForm().

346  {
347  // type-specific
348  }
+ Here is the caller graph for this function:

◆ importDefinition()

ilExcCriteria::importDefinition (   $a_def,
  $a_def_json 
)

Definition at line 191 of file class.ilExcCriteria.php.

References $def, and setDefinition().

192  {
193  // see #23711
194  // use json, if given
195  if ($a_def_json != "") {
196  $def = json_decode($a_def_json, true);
197  if (is_array($def)) {
198  $this->setDefinition($def);
199  }
200  return;
201  }
202 
203  // use unserialize only if php > 7
204  if ($a_def != "" && version_compare(PHP_VERSION, '7.0.0') >= 0) {
205  $a_def = @unserialize($a_def, false);
206  if (is_array($a_def)) {
207  $this->setDefinition($a_def);
208  }
209  }
210  }
setDefinition(array $a_value=null)
+ Here is the call graph for this function:

◆ importFromDB()

ilExcCriteria::importFromDB ( array  $a_row)
protected

Definition at line 217 of file class.ilExcCriteria.php.

References setDefinition(), setDescription(), setId(), setParent(), setPosition(), setRequired(), and setTitle().

218  {
219  $this->setId($a_row["id"]);
220  $this->setParent($a_row["parent"]);
221  $this->setTitle($a_row["title"]);
222  $this->setDescription($a_row["descr"]);
223  $this->setRequired($a_row["required"]);
224  $this->setPosition($a_row["pos"]);
225  $this->setDefinition($a_row["def"]
226  ? unserialize($a_row["def"])
227  : null);
228  }
setDefinition(array $a_value=null)
+ Here is the call graph for this function:

◆ importFromPeerReviewForm()

ilExcCriteria::importFromPeerReviewForm ( )
abstract

Referenced by setPeerReviewContext().

+ Here is the caller graph for this function:

◆ initCustomForm()

ilExcCriteria::initCustomForm ( ilPropertyFormGUI  $a_form)

Definition at line 335 of file class.ilExcCriteria.php.

Referenced by ilExcCriteriaGUI\initForm().

336  {
337  // type-specific
338  }
+ Here is the caller graph for this function:

◆ isRequired()

◆ resetReview()

ilExcCriteria::resetReview ( )

Definition at line 379 of file class.ilExcCriteria.php.

380  {
381  // type-specific (only needed for data not kept in exc_assignment_peer)
382  }

◆ save()

ilExcCriteria::save ( )

Definition at line 258 of file class.ilExcCriteria.php.

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

Referenced by ilExcCriteriaGUI\importForm(), and update().

259  {
260  $ilDB = $this->db;
261 
262  if ($this->id) {
263  return $this->update();
264  }
265 
266  $this->id = $ilDB->nextId("exc_crit");
267 
268  $fields = $this->getDBProperties();
269 
270  $fields["id"] = array("integer", $this->id);
271  $fields["type"] = array("text", $this->getType());
272  $fields["parent"] = array("integer", $this->getParent());
273  $fields["pos"] = array("integer", $this->getLastPosition()+10);
274 
275  $ilDB->insert("exc_crit", $fields);
276  }
Create styles array
The data for the language used.
global $ilDB
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setDefinition()

ilExcCriteria::setDefinition ( array  $a_value = null)
protected

Definition at line 181 of file class.ilExcCriteria.php.

Referenced by ilExcCriteriaText\importCustomForm(), importDefinition(), importFromDB(), and ilExcCriteriaText\setMinChars().

182  {
183  $this->def = $a_value;
184  }
+ Here is the caller graph for this function:

◆ setDescription()

ilExcCriteria::setDescription (   $a_value)

Definition at line 149 of file class.ilExcCriteria.php.

Referenced by ilExcCriteriaGUI\importForm(), and importFromDB().

150  {
151  $this->desc = ($a_value !== null)
152  ? trim($a_value)
153  : null;
154  }
+ Here is the caller graph for this function:

◆ setId()

ilExcCriteria::setId (   $a_id)
protected

Definition at line 118 of file class.ilExcCriteria.php.

References getType().

Referenced by importFromDB().

119  {
120  $this->id = (int) $a_id;
121  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setParent()

ilExcCriteria::setParent (   $a_value)

Definition at line 125 of file class.ilExcCriteria.php.

Referenced by ilExcCriteriaGUI\importForm(), and importFromDB().

126  {
127  $this->parent = ($a_value !== null)
128  ? (int) $a_value
129  : null;
130  }
+ Here is the caller graph for this function:

◆ setPeerReviewContext()

ilExcCriteria::setPeerReviewContext ( ilExAssignment  $a_ass,
  $a_giver_id,
  $a_peer_id,
ilPropertyFormGUI  $a_form = null 
)

Definition at line 353 of file class.ilExcCriteria.php.

References addToPeerReviewForm(), and importFromPeerReviewForm().

354  {
355  $this->form = $a_form;
356  $this->ass = $a_ass;
357  $this->giver_id = $a_giver_id;
358  $this->peer_id = $a_peer_id;
359  }
+ Here is the call graph for this function:

◆ setPosition()

ilExcCriteria::setPosition (   $a_value)

Definition at line 171 of file class.ilExcCriteria.php.

Referenced by importFromDB().

172  {
173  $this->pos = (int) $a_value;
174  }
+ Here is the caller graph for this function:

◆ setRequired()

ilExcCriteria::setRequired (   $a_value)

Definition at line 161 of file class.ilExcCriteria.php.

Referenced by ilExcCriteriaGUI\importForm(), and importFromDB().

162  {
163  $this->required = (bool) $a_value;
164  }
+ Here is the caller graph for this function:

◆ setTitle()

ilExcCriteria::setTitle (   $a_value)

Definition at line 137 of file class.ilExcCriteria.php.

Referenced by ilExcCriteriaGUI\importForm(), and importFromDB().

138  {
139  $this->title = ($a_value !== null)
140  ? trim($a_value)
141  : null;
142  }
+ Here is the caller graph for this function:

◆ update()

ilExcCriteria::update ( )

Definition at line 278 of file class.ilExcCriteria.php.

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

Referenced by ilExcCriteriaGUI\importForm(), and save().

279  {
280  $ilDB = $this->db;
281 
282  if (!$this->id) {
283  return $this->save();
284  }
285 
286  $primary = array("id"=>array("integer", $this->id));
287  $ilDB->update("exc_crit", $this->getDBProperties(), $primary);
288  }
Create styles array
The data for the language used.
global $ilDB
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ updateFromAjax()

ilExcCriteria::updateFromAjax ( )

Definition at line 365 of file class.ilExcCriteria.php.

366  {
367  // type-specific
368  }

◆ validate()

ilExcCriteria::validate (   $a_value)

Definition at line 370 of file class.ilExcCriteria.php.

References getHTML(), and hasValue().

371  {
372  return true;
373  }
+ Here is the call graph for this function:

Field Documentation

◆ $ass

ilExcCriteria::$ass
protected

Definition at line 27 of file class.ilExcCriteria.php.

◆ $db

ilExcCriteria::$db
protected

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

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

◆ $def

ilExcCriteria::$def
protected

◆ $desc

ilExcCriteria::$desc
protected

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

Referenced by getDescription().

◆ $form

ilExcCriteria::$form
protected

Definition at line 26 of file class.ilExcCriteria.php.

◆ $giver_id

ilExcCriteria::$giver_id
protected

◆ $id

ilExcCriteria::$id
protected

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

Referenced by getId().

◆ $parent

ilExcCriteria::$parent
protected

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

Referenced by getParent().

◆ $peer_id

◆ $pos

ilExcCriteria::$pos
protected

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

Referenced by getPosition().

◆ $required

ilExcCriteria::$required
protected

Definition at line 22 of file class.ilExcCriteria.php.

Referenced by isRequired().

◆ $title

ilExcCriteria::$title
protected

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

Referenced by getTitle().


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