ILIAS  release_8 Revision v8.23
ilExcCriteria Class Reference

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V. More...

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

Public Member Functions

 __construct ()
 
 getTranslatedType ()
 
 getId ()
 
 getType ()
 
 setParent (?int $a_value)
 
 getParent ()
 
 setTitle (?string $a_value)
 
 getTitle ()
 
 setDescription (?string $a_value)
 
 getDescription ()
 
 setRequired (bool $a_value)
 
 isRequired ()
 
 setPosition (int $a_value)
 
 getPosition ()
 
 importDefinition (string $a_def, string $a_def_json)
 
 save ()
 
 update ()
 
 delete ()
 
 cloneObject (int $a_target_parent_id)
 
 initCustomForm (ilPropertyFormGUI $a_form)
 
 exportCustomForm (ilPropertyFormGUI $a_form)
 
 importCustomForm (ilPropertyFormGUI $a_form)
 
 setPeerReviewContext (ilExAssignment $a_ass, int $a_giver_id, int $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 (int $a_id)
 
static getInstancesByParentId (int $a_parent_id)
 
static getTypesMap ()
 
static getInstanceByType (string $a_type)
 
static deleteByParent (int $a_parent_id)
 

Protected Member Functions

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

Protected Attributes

ilLanguage $lng
 
ilCtrl $ctrl
 
ilDBInterface $db
 
int $id = null
 
int $parent = null
 
string $title = ""
 
string $desc = ""
 
bool $required = false
 
int $pos = 0
 
array $def = null
 
ilPropertyFormGUI $form = null
 
ilExAssignment $ass
 
int $giver_id = 0
 
int $peer_id = 0
 

Detailed Description

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V.

ILIAS is licensed with the GPL-3.0, see https://www.gnu.org/licenses/gpl-3.0.en.html You should have received a copy of said license along with the source code, too.

If this is not the case or you just want to try ILIAS, you'll find us at: https://www.ilias.de https://github.com/ILIAS-eLearning Class ilExcCriteria.

Note: This class does stuff on application and gui layer and should be divided in multiple interfaces.

Author
Jörg Lützenkirchen luetz.nosp@m.enki.nosp@m.rchen.nosp@m.@lei.nosp@m.fos.c.nosp@m.om
Alexander Killing killi.nosp@m.ng@l.nosp@m.eifos.nosp@m..de

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

Constructor & Destructor Documentation

◆ __construct()

ilExcCriteria::__construct ( )

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

References $DIC, ILIAS\Repository\ctrl(), and ILIAS\Repository\lng().

46  {
47  global $DIC;
48 
49  $this->db = $DIC->database();
50  $this->lng = $DIC->language();
51  $this->ctrl = $DIC->ctrl();
52  }
global $DIC
Definition: feed.php:28
+ Here is the call graph for this function:

Member Function Documentation

◆ addToPeerReviewForm()

ilExcCriteria::addToPeerReviewForm (   $a_value = null)
abstract

Referenced by setPeerReviewContext().

+ Here is the caller graph for this function:

◆ cloneObject()

ilExcCriteria::cloneObject ( int  $a_target_parent_id)

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

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

334  : ?int
335  {
336  $new_obj = ilExcCriteria::getInstanceByType($this->getType());
337  $new_obj->setParent($a_target_parent_id);
338  $new_obj->setTitle($this->getTitle());
339  $new_obj->setDescription($this->getDescription());
340  $new_obj->setRequired($this->isRequired());
341  $new_obj->setPosition($this->getPosition());
342  $new_obj->setDefinition($this->getDefinition());
343  $new_obj->save();
344 
345  return $new_obj->getId();
346  }
static getInstanceByType(string $a_type)
+ Here is the call graph for this function:

◆ delete()

ilExcCriteria::delete ( )

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

References $db, and $ilDB.

308  : void
309  {
310  $ilDB = $this->db;
311 
312  if (!$this->id) {
313  return;
314  }
315 
316  $ilDB->manipulate("DELETE FROM exc_crit" .
317  " WHERE id = " . $ilDB->quote($this->id, "integer"));
318  }
ilDBInterface $db

◆ deleteByParent()

static ilExcCriteria::deleteByParent ( int  $a_parent_id)
static

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

References $DIC, and $ilDB.

Referenced by ilExcCriteriaCatalogue\delete().

320  : void
321  {
322  global $DIC;
323 
324  $ilDB = $DIC->database();
325 
326  if (!$a_parent_id) {
327  return;
328  }
329 
330  $ilDB->manipulate("DELETE FROM exc_crit" .
331  " WHERE parent = " . $ilDB->quote($a_parent_id, "integer"));
332  }
global $DIC
Definition: feed.php:28
+ Here is the caller graph for this function:

◆ exportCustomForm()

ilExcCriteria::exportCustomForm ( ilPropertyFormGUI  $a_form)

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

Referenced by ilExcCriteriaGUI\exportForm().

358  : void
359  {
360  // type-specific
361  }
+ Here is the caller graph for this function:

◆ getDBProperties()

ilExcCriteria::getDBProperties ( )
protected

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

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

Referenced by save(), and update().

245  : array
246  {
247  return array(
248  "type" => array("text", $this->getType())
249  ,"title" => array("text", $this->getTitle())
250  ,"descr" => array("text", $this->getDescription())
251  ,"required" => array("integer", $this->isRequired())
252  ,"pos" => array("integer", $this->getPosition())
253  ,"def" => array("text", is_array($this->getDefinition())
254  ? serialize($this->getDefinition())
255  : null)
256  );
257  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getDefinition()

ilExcCriteria::getDefinition ( )
protected

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

References $def.

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

201  : ?array
202  {
203  return $this->def;
204  }
+ Here is the caller graph for this function:

◆ getDescription()

ilExcCriteria::getDescription ( )

◆ getHTML()

ilExcCriteria::getHTML (   $a_value)
abstract

Referenced by validate().

+ Here is the caller graph for this function:

◆ getId()

◆ getInstanceById()

static ilExcCriteria::getInstanceById ( int  $a_id)
static

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

References $DIC, and $ilDB.

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

54  : ?ilExcCriteria
55  {
56  global $DIC;
57 
58  $ilDB = $DIC->database();
59 
60  $set = $ilDB->query("SELECT *" .
61  " FROM exc_crit" .
62  " WHERE id = " . $ilDB->quote($a_id, "integer"));
63  if ($ilDB->numRows($set)) {
64  $row = $ilDB->fetchAssoc($set);
65  $obj = self::getInstanceByType($row["type"]);
66  $obj->importFromDB($row);
67  return $obj;
68  }
69 
70  return null;
71  }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
global $DIC
Definition: feed.php:28
+ Here is the caller graph for this function:

◆ getInstanceByType()

static ilExcCriteria::getInstanceByType ( string  $a_type)
static

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

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

123  : ilExcCriteria
124  {
125  $class = "ilExcCriteria" . ucfirst($a_type);
126  return new $class();
127  }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
+ Here is the caller graph for this function:

◆ getInstancesByParentId()

static ilExcCriteria::getInstancesByParentId ( int  $a_parent_id)
static
Parameters
int$a_parent_id
Returns
ilExcCriteria[]

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

References $DIC, $ilDB, and $res.

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

77  : array
78  {
79  global $DIC;
80 
81  $ilDB = $DIC->database();
82 
83  $res = array();
84 
85  $set = $ilDB->query("SELECT *" .
86  " FROM exc_crit" .
87  " WHERE parent = " . $ilDB->quote($a_parent_id, "integer") .
88  " ORDER BY pos");
89  while ($row = $ilDB->fetchAssoc($set)) {
90  $obj = self::getInstanceByType($row["type"]);
91  $obj->importFromDB($row);
92  $res[$obj->getId()] = $obj;
93  }
94 
95  return $res;
96  }
$res
Definition: ltiservices.php:69
global $DIC
Definition: feed.php:28
+ Here is the caller graph for this function:

◆ getLastPosition()

ilExcCriteria::getLastPosition ( )
protected

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

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

Referenced by save().

259  : int
260  {
261  $ilDB = $this->db;
262 
263  if (!$this->getParent()) {
264  return 0;
265  }
266 
267  $set = $ilDB->query("SELECT MAX(pos) pos" .
268  " FROM exc_crit" .
269  " WHERE parent = " . $ilDB->quote($this->getParent(), "integer"));
270  $row = $ilDB->fetchAssoc($set);
271  return (int) $row["pos"];
272  }
ilDBInterface $db
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getParent()

ilExcCriteria::getParent ( )

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

References $parent.

Referenced by getLastPosition(), and save().

151  : ?int
152  {
153  return $this->parent;
154  }
+ Here is the caller graph for this function:

◆ getPosition()

ilExcCriteria::getPosition ( )

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

References $pos.

Referenced by cloneObject(), and getDBProperties().

191  : int
192  {
193  return $this->pos;
194  }
+ Here is the caller graph for this function:

◆ getTitle()

ilExcCriteria::getTitle ( )

◆ getTranslatedType()

ilExcCriteria::getTranslatedType ( )

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

References getType(), and getTypesMap().

Referenced by ilExcCriteriaGUI\initForm().

117  : string
118  {
119  $map = $this->getTypesMap();
120  return $map[$this->getType()];
121  }
+ 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 103 of file class.ilExcCriteria.php.

References $DIC, and ilLanguage\txt().

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

103  : array
104  {
105  global $DIC;
106 
107  $lng = $DIC->language();
108 
109  return array(
110  "bool" => $lng->txt("exc_criteria_type_bool")
111  ,"rating" => $lng->txt("exc_criteria_type_rating")
112  ,"text" => $lng->txt("exc_criteria_type_text")
113  ,"file" => $lng->txt("exc_criteria_type_file")
114  );
115  }
txt(string $a_topic, string $a_default_lang_fallback_mod="")
gets the text for a given topic if the topic is not in the list, the topic itself with "-" will be re...
global $DIC
Definition: feed.php:28
+ Here is the call graph for this function:
+ 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 363 of file class.ilExcCriteria.php.

Referenced by ilExcCriteriaGUI\importForm().

363  : void
364  {
365  // type-specific
366  }
+ Here is the caller graph for this function:

◆ importDefinition()

ilExcCriteria::importDefinition ( string  $a_def,
string  $a_def_json 
)

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

References setDefinition().

206  : void
207  {
208  // see #23711
209  // use json, if given
210  if ($a_def_json != "") {
211  $def = json_decode($a_def_json, true);
212  if (is_array($def)) {
213  $this->setDefinition($def);
214  }
215  return;
216  }
217 
218  // use unserialize only if php > 7
219  if ($a_def != "" && version_compare(PHP_VERSION, '7.0.0') >= 0) {
220  $a_def = unserialize($a_def, ['allowed_classes' => false]);
221  if (is_array($a_def)) {
222  $this->setDefinition($a_def);
223  }
224  }
225  }
setDefinition(?array $a_value=null)
+ Here is the call graph for this function:

◆ importFromDB()

ilExcCriteria::importFromDB ( array  $a_row)
protected

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

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

233  {
234  $this->setId((int) $a_row["id"]);
235  $this->setParent((int) $a_row["parent"]);
236  $this->setTitle((string) $a_row["title"]);
237  $this->setDescription((string) $a_row["descr"]);
238  $this->setRequired((bool) $a_row["required"]);
239  $this->setPosition((int) $a_row["pos"]);
240  $this->setDefinition((string) $a_row["def"]
241  ? unserialize($a_row["def"], ['allowed_classes' => false])
242  : null);
243  }
setDescription(?string $a_value)
setRequired(bool $a_value)
setDefinition(?array $a_value=null)
setPosition(int $a_value)
setTitle(?string $a_value)
setParent(?int $a_value)
+ 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 353 of file class.ilExcCriteria.php.

Referenced by ilExcCriteriaGUI\initForm().

353  : void
354  {
355  // type-specific
356  }
+ Here is the caller graph for this function:

◆ isRequired()

◆ resetReview()

ilExcCriteria::resetReview ( )

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

402  {
403  // type-specific (only needed for data not kept in exc_assignment_peer)
404  }

◆ save()

ilExcCriteria::save ( )

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

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

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

274  : void
275  {
276  $ilDB = $this->db;
277 
278  if ($this->id) {
279  $this->update();
280  return;
281  }
282 
283  $this->id = $ilDB->nextId("exc_crit");
284 
285  $fields = $this->getDBProperties();
286 
287  $fields["id"] = array("integer", $this->id);
288  $fields["type"] = array("text", $this->getType());
289  $fields["parent"] = array("integer", $this->getParent());
290  $fields["pos"] = array("integer", $this->getLastPosition() + 10);
291 
292  $ilDB->insert("exc_crit", $fields);
293  }
ilDBInterface $db
+ 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 196 of file class.ilExcCriteria.php.

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

197  {
198  $this->def = $a_value;
199  }
+ Here is the caller graph for this function:

◆ setDescription()

ilExcCriteria::setDescription ( ?string  $a_value)

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

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

166  : void
167  {
168  $this->desc = $a_value;
169  }
+ Here is the caller graph for this function:

◆ setId()

ilExcCriteria::setId ( ?int  $a_id)
protected

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

References getType().

Referenced by importFromDB().

139  : void
140  {
141  $this->id = $a_id;
142  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setParent()

ilExcCriteria::setParent ( ?int  $a_value)

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

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

146  : void
147  {
148  $this->parent = $a_value;
149  }
+ Here is the caller graph for this function:

◆ setPeerReviewContext()

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

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

References addToPeerReviewForm(), ILIAS\Repository\form(), and importFromPeerReviewForm().

376  {
377  $this->form = $a_form;
378  $this->ass = $a_ass;
379  $this->giver_id = $a_giver_id;
380  $this->peer_id = $a_peer_id;
381  }
form( $class_path, string $cmd)
+ Here is the call graph for this function:

◆ setPosition()

ilExcCriteria::setPosition ( int  $a_value)

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

Referenced by importFromDB().

186  : void
187  {
188  $this->pos = $a_value;
189  }
+ Here is the caller graph for this function:

◆ setRequired()

ilExcCriteria::setRequired ( bool  $a_value)

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

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

176  : void
177  {
178  $this->required = $a_value;
179  }
+ Here is the caller graph for this function:

◆ setTitle()

ilExcCriteria::setTitle ( ?string  $a_value)

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

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

156  : void
157  {
158  $this->title = $a_value;
159  }
+ Here is the caller graph for this function:

◆ update()

ilExcCriteria::update ( )

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

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

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

295  : void
296  {
297  $ilDB = $this->db;
298 
299  if (!$this->id) {
300  $this->save();
301  return;
302  }
303 
304  $primary = array("id" => array("integer", $this->id));
305  $ilDB->update("exc_crit", $this->getDBProperties(), $primary);
306  }
ilDBInterface $db
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ updateFromAjax()

ilExcCriteria::updateFromAjax ( )

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

387  : string
388  {
389  return "";
390  }

◆ validate()

ilExcCriteria::validate (   $a_value)

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

References getHTML(), and hasValue().

392  : bool
393  {
394  return true;
395  }
+ Here is the call graph for this function:

Field Documentation

◆ $ass

ilExAssignment ilExcCriteria::$ass
protected

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

◆ $ctrl

ilCtrl ilExcCriteria::$ctrl
protected

◆ $db

ilDBInterface ilExcCriteria::$db
protected

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

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

◆ $def

array ilExcCriteria::$def = null
protected

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

Referenced by getDefinition(), and ilExcCriteriaText\getMinChars().

◆ $desc

string ilExcCriteria::$desc = ""
protected

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

Referenced by getDescription().

◆ $form

ilPropertyFormGUI ilExcCriteria::$form = null
protected

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

◆ $giver_id

int ilExcCriteria::$giver_id = 0
protected

◆ $id

int ilExcCriteria::$id = null
protected

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

Referenced by getId().

◆ $lng

◆ $parent

int ilExcCriteria::$parent = null
protected

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

Referenced by getParent().

◆ $peer_id

◆ $pos

int ilExcCriteria::$pos = 0
protected

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

Referenced by getPosition().

◆ $required

bool ilExcCriteria::$required = false
protected

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

Referenced by isRequired().

◆ $title

string ilExcCriteria::$title = ""
protected

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

Referenced by getTitle().


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