ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
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

ILIAS Exercise InternalGUIService $gui
 
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 ( )

Reimplemented in ilExcCriteriaRating.

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

47 {
48 global $DIC;
49
50 $this->db = $DIC->database();
51 $this->lng = $DIC->language();
52 $this->ctrl = $DIC->ctrl();
53 $this->gui = $DIC->exercise()->internal()->gui();
54 }
global $DIC
Definition: shib_login.php:26

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

+ Here is the call graph for this function:

Member Function Documentation

◆ addToPeerReviewForm()

ilExcCriteria::addToPeerReviewForm (   $a_value = null)
abstract

◆ cloneObject()

ilExcCriteria::cloneObject ( int  $a_target_parent_id)

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

336 : ?int
337 {
338 $new_obj = ilExcCriteria::getInstanceByType($this->getType());
339 $new_obj->setParent($a_target_parent_id);
340 $new_obj->setTitle($this->getTitle());
341 $new_obj->setDescription($this->getDescription());
342 $new_obj->setRequired($this->isRequired());
343 $new_obj->setPosition($this->getPosition());
344 $new_obj->setDefinition($this->getDefinition());
345 $new_obj->save();
346
347 return $new_obj->getId();
348 }
static getInstanceByType(string $a_type)

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

+ Here is the call graph for this function:

◆ delete()

ilExcCriteria::delete ( )

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

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

References $db, and $ilDB.

◆ deleteByParent()

static ilExcCriteria::deleteByParent ( int  $a_parent_id)
static

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

322 : void
323 {
324 global $DIC;
325
326 $ilDB = $DIC->database();
327
328 if (!$a_parent_id) {
329 return;
330 }
331
332 $ilDB->manipulate("DELETE FROM exc_crit" .
333 " WHERE parent = " . $ilDB->quote($a_parent_id, "integer"));
334 }

References $DIC, and $ilDB.

Referenced by ilExcCriteriaCatalogue\delete().

+ Here is the caller graph for this function:

◆ exportCustomForm()

ilExcCriteria::exportCustomForm ( ilPropertyFormGUI  $a_form)

Reimplemented in ilExcCriteriaText.

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

360 : void
361 {
362 // type-specific
363 }

◆ getDBProperties()

ilExcCriteria::getDBProperties ( )
protected

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

247 : array
248 {
249 return array(
250 "type" => array("text", $this->getType())
251 ,"title" => array("text", $this->getTitle())
252 ,"descr" => array("text", $this->getDescription())
253 ,"required" => array("integer", $this->isRequired())
254 ,"pos" => array("integer", $this->getPosition())
255 ,"def" => array("text", is_array($this->getDefinition())
256 ? serialize($this->getDefinition())
257 : null)
258 );
259 }

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

Referenced by save(), and update().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getDefinition()

ilExcCriteria::getDefinition ( )
protected

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

203 : ?array
204 {
205 return $this->def;
206 }

References $def.

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

+ Here is the caller graph for this function:

◆ getDescription()

ilExcCriteria::getDescription ( )

◆ getHTML()

ilExcCriteria::getHTML (   $a_value)
abstract

◆ getId()

◆ getInstanceById()

static ilExcCriteria::getInstanceById ( int  $a_id)
static

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

57 {
58 global $DIC;
59
60 $ilDB = $DIC->database();
61
62 $set = $ilDB->query("SELECT *" .
63 " FROM exc_crit" .
64 " WHERE id = " . $ilDB->quote($a_id, "integer"));
65 if ($ilDB->numRows($set)) {
66 $row = $ilDB->fetchAssoc($set);
67 $obj = self::getInstanceByType($row["type"]);
68 $obj->importFromDB($row);
69 return $obj;
70 }
71
72 return null;
73 }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...

References $DIC, $ilDB, and getInstanceByType().

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

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getInstanceByType()

static ilExcCriteria::getInstanceByType ( string  $a_type)
static

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

126 {
127 $class = "ilExcCriteria" . ucfirst($a_type);
128 return new $class();
129 }

Referenced by ilExcCriteriaGUI\add(), cloneObject(), ilExcCriteriaGUI\create(), ilExPeerReviewGUI\downloadPeerReviewObject(), getInstanceById(), getInstancesByParentId(), and ilExPeerReviewGUI\updateCritAjaxObject().

+ 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 79 of file class.ilExcCriteria.php.

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

References $DIC, $ilDB, $res, and getInstanceByType().

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

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getLastPosition()

ilExcCriteria::getLastPosition ( )
protected

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

261 : int
262 {
264
265 if (!$this->getParent()) {
266 return 0;
267 }
268
269 $set = $ilDB->query("SELECT MAX(pos) pos" .
270 " FROM exc_crit" .
271 " WHERE parent = " . $ilDB->quote($this->getParent(), "integer"));
272 $row = $ilDB->fetchAssoc($set);
273 return (int) $row["pos"];
274 }

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

Referenced by save().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getParent()

ilExcCriteria::getParent ( )

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

153 : ?int
154 {
155 return $this->parent;
156 }

References $parent.

Referenced by getLastPosition(), and save().

+ Here is the caller graph for this function:

◆ getPosition()

ilExcCriteria::getPosition ( )

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

193 : int
194 {
195 return $this->pos;
196 }

References $pos.

Referenced by cloneObject(), and getDBProperties().

+ Here is the caller graph for this function:

◆ getTitle()

ilExcCriteria::getTitle ( )

◆ getTranslatedType()

ilExcCriteria::getTranslatedType ( )

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

119 : string
120 {
121 $map = $this->getTypesMap();
122 return $map[$this->getType()];
123 }

References getType(), and getTypesMap().

Referenced by ilExcCriteriaGUI\initForm().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getType()

ilExcCriteria::getType ( )
abstract

Reimplemented in ilExcCriteriaBool, ilExcCriteriaFile, ilExcCriteriaRating, and ilExcCriteriaText.

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

+ Here is the caller graph for this function:

◆ getTypesMap()

static ilExcCriteria::getTypesMap ( )
static

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

105 : array
106 {
107 global $DIC;
108
109 $lng = $DIC->language();
110
111 return array(
112 "bool" => $lng->txt("exc_criteria_type_bool")
113 ,"rating" => $lng->txt("exc_criteria_type_rating")
114 ,"text" => $lng->txt("exc_criteria_type_text")
115 ,"file" => $lng->txt("exc_criteria_type_file")
116 );
117 }
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...

References $DIC, $lng, and ilLanguage\txt().

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

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ hasValue()

ilExcCriteria::hasValue (   $a_value)
abstract

◆ importCustomForm()

ilExcCriteria::importCustomForm ( ilPropertyFormGUI  $a_form)

Reimplemented in ilExcCriteriaText.

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

365 : void
366 {
367 // type-specific
368 }

◆ importDefinition()

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

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

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

References $def, and setDefinition().

+ Here is the call graph for this function:

◆ importFromDB()

ilExcCriteria::importFromDB ( array  $a_row)
protected

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

235 {
236 $this->setId((int) $a_row["id"]);
237 $this->setParent((int) $a_row["parent"]);
238 $this->setTitle((string) $a_row["title"]);
239 $this->setDescription((string) $a_row["descr"]);
240 $this->setRequired((bool) $a_row["required"]);
241 $this->setPosition((int) $a_row["pos"]);
242 $this->setDefinition((string) $a_row["def"]
243 ? unserialize((string) $a_row["def"], ['allowed_classes' => false])
244 : null);
245 }
setRequired(bool $a_value)
setTitle(?string $a_value)
setPosition(int $a_value)
setDescription(?string $a_value)
setParent(?int $a_value)

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

+ Here is the call graph for this function:

◆ importFromPeerReviewForm()

ilExcCriteria::importFromPeerReviewForm ( )
abstract

◆ initCustomForm()

ilExcCriteria::initCustomForm ( ilPropertyFormGUI  $a_form)

Reimplemented in ilExcCriteriaText.

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

355 : void
356 {
357 // type-specific
358 }

Referenced by ilExcCriteriaGUI\initForm().

+ Here is the caller graph for this function:

◆ isRequired()

◆ resetReview()

ilExcCriteria::resetReview ( )

Reimplemented in ilExcCriteriaFile, and ilExcCriteriaRating.

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

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

◆ save()

ilExcCriteria::save ( )

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

276 : void
277 {
279
280 if ($this->id) {
281 $this->update();
282 return;
283 }
284
285 $this->id = $ilDB->nextId("exc_crit");
286
287 $fields = $this->getDBProperties();
288
289 $fields["id"] = array("integer", $this->id);
290 $fields["type"] = array("text", $this->getType());
291 $fields["parent"] = array("integer", $this->getParent());
292 $fields["pos"] = array("integer", $this->getLastPosition() + 10);
293
294 $ilDB->insert("exc_crit", $fields);
295 }

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

Referenced by update().

+ 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 198 of file class.ilExcCriteria.php.

199 {
200 $this->def = $a_value;
201 }

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

+ Here is the caller graph for this function:

◆ setDescription()

ilExcCriteria::setDescription ( ?string  $a_value)

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

168 : void
169 {
170 $this->desc = $a_value;
171 }

Referenced by importFromDB().

+ Here is the caller graph for this function:

◆ setId()

ilExcCriteria::setId ( ?int  $a_id)
protected

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

141 : void
142 {
143 $this->id = $a_id;
144 }

Referenced by importFromDB().

+ Here is the caller graph for this function:

◆ setParent()

ilExcCriteria::setParent ( ?int  $a_value)

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

148 : void
149 {
150 $this->parent = $a_value;
151 }

Referenced by importFromDB().

+ 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 373 of file class.ilExcCriteria.php.

378 {
379 $this->form = $a_form;
380 $this->ass = $a_ass;
381 $this->giver_id = $a_giver_id;
382 $this->peer_id = $a_peer_id;
383 }
form( $class_path, string $cmd, string $submit_caption="")

References ILIAS\Repository\form().

+ Here is the call graph for this function:

◆ setPosition()

ilExcCriteria::setPosition ( int  $a_value)

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

188 : void
189 {
190 $this->pos = $a_value;
191 }

Referenced by importFromDB().

+ Here is the caller graph for this function:

◆ setRequired()

ilExcCriteria::setRequired ( bool  $a_value)

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

178 : void
179 {
180 $this->required = $a_value;
181 }

Referenced by importFromDB().

+ Here is the caller graph for this function:

◆ setTitle()

ilExcCriteria::setTitle ( ?string  $a_value)

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

158 : void
159 {
160 $this->title = $a_value;
161 }

Referenced by importFromDB().

+ Here is the caller graph for this function:

◆ update()

ilExcCriteria::update ( )

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

297 : void
298 {
300
301 if (!$this->id) {
302 $this->save();
303 return;
304 }
305
306 $primary = array("id" => array("integer", $this->id));
307 $ilDB->update("exc_crit", $this->getDBProperties(), $primary);
308 }

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

Referenced by save().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ updateFromAjax()

ilExcCriteria::updateFromAjax ( )

Reimplemented in ilExcCriteriaRating.

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

389 : string
390 {
391 return "";
392 }

◆ validate()

ilExcCriteria::validate (   $a_value)

Reimplemented in ilExcCriteriaFile, ilExcCriteriaRating, and ilExcCriteriaText.

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

394 : bool
395 {
396 return true;
397 }

Field Documentation

◆ $ass

ilExAssignment ilExcCriteria::$ass
protected

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

◆ $ctrl

ilCtrl ilExcCriteria::$ctrl
protected

◆ $db

ilDBInterface ilExcCriteria::$db
protected

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

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

◆ $def

array ilExcCriteria::$def = null
protected

◆ $desc

string ilExcCriteria::$desc = ""
protected

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

Referenced by getDescription().

◆ $form

ilPropertyFormGUI ilExcCriteria::$form = null
protected

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

◆ $giver_id

int ilExcCriteria::$giver_id = 0
protected

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

◆ $gui

ILIAS Exercise InternalGUIService ilExcCriteria::$gui
protected

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

◆ $id

int ilExcCriteria::$id = null
protected

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

Referenced by getId().

◆ $lng

◆ $parent

int ilExcCriteria::$parent = null
protected

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

Referenced by getParent().

◆ $peer_id

int ilExcCriteria::$peer_id = 0
protected

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

◆ $pos

int ilExcCriteria::$pos = 0
protected

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

Referenced by getPosition().

◆ $required

bool ilExcCriteria::$required = false
protected

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

Referenced by isRequired().

◆ $title

string ilExcCriteria::$title = ""
protected

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

Referenced by getTitle().


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