ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
ilExcCriteriaRating Class Reference

Class ilExcCriteriaRating. More...

+ Inheritance diagram for ilExcCriteriaRating:
+ Collaboration diagram for ilExcCriteriaRating:

Public Member Functions

 __construct ()
 Constructor. More...
 
 getType ()
 
 addToPeerReviewForm ($a_value=null)
 
 importFromPeerReviewForm ()
 
 updateFromAjax ()
 
 validate ($a_value)
 
 hasValue ($a_value)
 
 getHTML ($a_value)
 
 resetReview ()
 
- Public Member Functions inherited from ilExcCriteria
 __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 ()
 

Protected Member Functions

 getRatingSubType ()
 
 renderWidget (bool $a_read_only=false)
 
- Protected Member Functions inherited from ilExcCriteria
 setId (?int $a_id)
 
 setDefinition (?array $a_value=null)
 
 getDefinition ()
 
 importFromDB (array $a_row)
 
 getDBProperties ()
 
 getLastPosition ()
 

Protected Attributes

ILIAS HTTP Services $http
 
ilGlobalTemplateInterface $tpl
 
ilCustomInputGUI $form_item
 
GUIRequest $request
 
- Protected Attributes inherited from ilExcCriteria
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
 

Additional Inherited Members

- Static Public Member Functions inherited from ilExcCriteria
static getInstanceById (int $a_id)
 
static getInstancesByParentId (int $a_parent_id)
 
static getTypesMap ()
 
static getInstanceByType (string $a_type)
 
static deleteByParent (int $a_parent_id)
 

Detailed Description

Constructor & Destructor Documentation

◆ __construct()

ilExcCriteriaRating::__construct ( )

Constructor.

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

References $DIC, ILIAS\GlobalScreen\Provider\__construct(), and ILIAS\FileDelivery\http().

38  {
39  global $DIC;
40 
42  $this->tpl = $DIC->ui()->mainTemplate();
43  $this->request = $DIC->exercise()->internal()->gui()->request();
44  $this->http = $DIC->http();
45  }
global $DIC
Definition: feed.php:28
static http()
Fetches the global http state from ILIAS.
__construct(Container $dic, ilPlugin $plugin)
+ Here is the call graph for this function:

Member Function Documentation

◆ addToPeerReviewForm()

ilExcCriteriaRating::addToPeerReviewForm (   $a_value = null)

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

References ilExcCriteria\$ctrl, $tpl, ilGlobalTemplateInterface\addJavaScript(), ilGlobalTemplateInterface\addOnLoadCode(), ILIAS\Repository\form(), ilExcCriteria\getDescription(), ilExcCriteria\getId(), ilExcCriteria\getTitle(), hasValue(), ilExcCriteria\isRequired(), and renderWidget().

55  : void
56  {
57  $tpl = $this->tpl;
58  $ilCtrl = $this->ctrl;
59 
60  $tpl->addJavaScript("Modules/Exercise/js/ilExcPeerReview.js");
61  $tpl->addOnLoadCode("il.ExcPeerReview.setAjax('" .
62  $ilCtrl->getLinkTargetByClass("ilExPeerReviewGUI", "updateCritAjax", "", true, false) .
63  "')");
64 
65  $field_id = "prccc_rating_" . $this->getId();
66 
67  $input = new ilCustomInputGUI($this->getTitle(), $field_id);
68  $input->setInfo($this->getDescription());
69  $input->setRequired($this->isRequired());
70  $input->setHtml($this->renderWidget());
71  $this->form->addItem($input);
72 
73  // #16993 - making form checkInput() work
74  if ($this->hasValue("")) {
75  $input->setSkipRequiredCheck(true);
76  }
77 
78  $this->form_item = $input;
79  }
ilGlobalTemplateInterface $tpl
renderWidget(bool $a_read_only=false)
addJavaScript(string $a_js_file, bool $a_add_version_parameter=true, int $a_batch=2)
Add a javascript file that should be included in the header.
addOnLoadCode(string $a_code, int $a_batch=2)
Add on load code.
form( $class_path, string $cmd)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
+ Here is the call graph for this function:

◆ getHTML()

ilExcCriteriaRating::getHTML (   $a_value)

Definition at line 159 of file class.ilExcCriteriaRating.php.

References renderWidget().

159  : string
160  {
161  return $this->renderWidget(true);
162  }
renderWidget(bool $a_read_only=false)
+ Here is the call graph for this function:

◆ getRatingSubType()

ilExcCriteriaRating::getRatingSubType ( )
protected

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

References ilExcCriteria\getId().

Referenced by hasValue(), renderWidget(), resetReview(), and updateFromAjax().

81  : string
82  {
83  return $this->getId()
84  ? "peer_" . $this->getId()
85  : "peer"; // no catalogue / v1
86  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getType()

ilExcCriteriaRating::getType ( )

Definition at line 47 of file class.ilExcCriteriaRating.php.

47  : string
48  {
49  return "rating";
50  }

◆ hasValue()

ilExcCriteriaRating::hasValue (   $a_value)

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

References ilExcCriteria\$giver_id, ilExcCriteria\$peer_id, ilRating\getRatingForUserAndObject(), and getRatingSubType().

Referenced by addToPeerReviewForm(), and validate().

148  : bool
149  {
151  $this->ass->getId(),
152  "ass",
154  $this->getRatingSubType(),
156  );
157  }
static getRatingForUserAndObject(int $a_obj_id, string $a_obj_type, int $a_sub_obj_id, string $a_sub_obj_type, int $a_user_id, int $a_category_id=null)
Get rating for a user and an object.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ importFromPeerReviewForm()

ilExcCriteriaRating::importFromPeerReviewForm ( )

Definition at line 112 of file class.ilExcCriteriaRating.php.

112  : void
113  {
114  // see updateFromAjax()
115  }

◆ renderWidget()

ilExcCriteriaRating::renderWidget ( bool  $a_read_only = false)
protected

Definition at line 88 of file class.ilExcCriteriaRating.php.

References ilExcCriteria\$peer_id, ilExcCriteria\getId(), and getRatingSubType().

Referenced by addToPeerReviewForm(), getHTML(), and updateFromAjax().

88  : string
89  {
90  $rating = new ilRatingGUI();
91  $rating->setObject(
92  $this->ass->getId(),
93  "ass",
95  $this->getRatingSubType()
96  );
97  $rating->setUserId($this->giver_id);
98 
99  $ajax_id = $this->getId()
100  ?: "'rating'";
101 
102  if (!$a_read_only) {
103  $html = '<div class="crit_widget">' .
104  $rating->getHTML(false, true, "il.ExcPeerReview.saveCrit(this, " . $this->peer_id . ", " . $ajax_id . ", %rating%)") .
105  '</div>';
106  } else {
107  $html = $rating->getHTML(false, false);
108  }
109  return $html;
110  }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ resetReview()

ilExcCriteriaRating::resetReview ( )

Definition at line 164 of file class.ilExcCriteriaRating.php.

References ilExcCriteria\$giver_id, ilExcCriteria\$peer_id, getRatingSubType(), and ilRating\resetRatingForUserAndObject().

164  : void
165  {
167  $this->ass->getId(),
168  "ass",
170  $this->getRatingSubType(),
172  );
173  }
static resetRatingForUserAndObject(int $a_obj_id, string $a_obj_type, int $a_sub_obj_id, string $a_sub_obj_type, int $a_user_id)
Reset rating for a user and an object.
+ Here is the call graph for this function:

◆ updateFromAjax()

ilExcCriteriaRating::updateFromAjax ( )

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

References ilExcCriteria\$giver_id, ilExcCriteria\$peer_id, getRatingSubType(), renderWidget(), and ilRating\writeRatingForUserAndObject().

117  : string
118  {
119  // save rating
121  $this->ass->getId(),
122  "ass",
124  $this->getRatingSubType(),
126  $this->request->getRatingValue()
127  );
128 
129  // render current rating
130  return $this->renderWidget();
131  }
static writeRatingForUserAndObject(int $a_obj_id, string $a_obj_type, ?int $a_sub_obj_id, ?string $a_sub_obj_type, int $a_user_id, int $a_rating, int $a_category_id=0)
Write rating for a user and an object.
renderWidget(bool $a_read_only=false)
+ Here is the call graph for this function:

◆ validate()

ilExcCriteriaRating::validate (   $a_value)

Definition at line 133 of file class.ilExcCriteriaRating.php.

References ilExcCriteria\$lng, ILIAS\Repository\form(), ilExcCriteria\getId(), hasValue(), ilExcCriteria\isRequired(), and ilLanguage\txt().

133  : bool
134  {
135  $lng = $this->lng;
136 
137  if ($this->isRequired()) {
138  if (!$this->hasValue($a_value)) {
139  if ($this->form) {
140  $this->form->getItemByPostVar("prccc_rating_" . $this->getId())->setAlert($lng->txt("msg_input_is_required"));
141  }
142  return false;
143  }
144  }
145  return true;
146  }
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...
form( $class_path, string $cmd)
+ Here is the call graph for this function:

Field Documentation

◆ $form_item

ilCustomInputGUI ilExcCriteriaRating::$form_item
protected

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

◆ $http

ILIAS HTTP Services ilExcCriteriaRating::$http
protected

Definition at line 29 of file class.ilExcCriteriaRating.php.

◆ $request

GUIRequest ilExcCriteriaRating::$request
protected

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

◆ $tpl

ilGlobalTemplateInterface ilExcCriteriaRating::$tpl
protected

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

Referenced by addToPeerReviewForm().


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