ILIAS  trunk Revision v12.0_alpha-1221-g4e438232683
class.ilRatingGUI.php
Go to the documentation of this file.
1<?php
2
26{
27 protected ilLanguage $lng;
28 protected ilCtrl $ctrl;
29 protected ilObjUser $user;
30 protected string $id = "rtg_";
32 protected string $export_subobj_title = "";
33 protected array $ctrl_path = [];
34 protected bool $enable_categories = false;
35 protected string $your_rating_text = "";
36 protected \ILIAS\DI\UIServices $ui;
37
38 protected int $obj_id;
39 protected string $obj_type;
40 protected ?int $sub_obj_id;
41 protected ?string $sub_obj_type;
42 protected int $userid;
43 protected $update_callback = null;
44 protected ?array $requested_ratings = null;
45 protected int $requested_rating;
46
47 public function __construct()
48 {
49 global $DIC;
50
51 $this->lng = $DIC->language();
52 $this->ctrl = $DIC->ctrl();
53 $this->user = $DIC->user();
54 $lng = $DIC->language();
55
56 $this->ui = $DIC->ui();
57
58 $params = $DIC->http()->request()->getQueryParams();
59 $body = $DIC->http()->request()->getParsedBody();
60
61 if (isset($body['rating'])) {
62 if (is_array($body['rating'])) {
63 $this->requested_ratings = ($body['rating'] ?? null);
64 } else {
65 $this->requested_rating = (int) ($body['rating'] ?? 0);
66 }
67 } else {
68 $this->requested_rating = (int) ($params['rating'] ?? 0);
69 }
70
71 $lng->loadLanguageModule("rating");
72 }
73
77 public function executeCommand(): void
78 {
79 $ilCtrl = $this->ctrl;
80
81 $next_class = $ilCtrl->getNextClass($this);
82 $cmd = $ilCtrl->getCmd();
83
84 switch ($next_class) {
85 case "ilratingcategorygui":
86 $gui = new ilRatingCategoryGUI($this->obj_id, $this->export_callback, $this->export_subobj_title);
87 $ilCtrl->forwardCommand($gui);
88 break;
89
90 default:
91 $this->$cmd();
92 break;
93 }
94 }
95
96 public function getUnsafeGetCommands(): array
97 {
98 return ['saveRating'];
99 }
100
101 public function getSafePostCommands(): array
102 {
103 return [];
104 }
105
114 public function setObject(
115 int $a_obj_id,
116 string $a_obj_type,
117 ?int $a_sub_obj_id = 0,
118 ?string $a_sub_obj_type = ""
119 ): void {
120 $ilUser = $this->user;
121
122 if (!trim((string) $a_sub_obj_type)) {
123 $a_sub_obj_type = "-";
124 }
125
126 $this->obj_id = $a_obj_id;
127 $this->obj_type = $a_obj_type;
128 $this->sub_obj_id = $a_sub_obj_id;
129 $this->sub_obj_type = $a_sub_obj_type;
130 $this->id = "rtg_" . $this->obj_id . "_" . $this->obj_type . "_" . $this->sub_obj_id . "_" .
132
133 $this->setUserId($ilUser->getId());
134 }
135
136 public function setUserId(int $a_userid): void
137 {
138 $this->userid = $a_userid;
139 }
140
141 public function getUserId(): int
142 {
143 return $this->userid;
144 }
145
146 public function setYourRatingText(string $a_val): void
147 {
148 $this->your_rating_text = $a_val;
149 }
150
151 public function getYourRatingText(): string
152 {
153 return $this->your_rating_text;
154 }
155
156 public function enableCategories(bool $a_value): void
157 {
158 $this->enable_categories = $a_value;
159 }
160
161 public function setCtrlPath(array $a_value): void
162 {
163 $this->ctrl_path = $a_value;
164 }
165
166 // Render rating details
167 protected function renderDetails(
168 string $a_js_id,
169 bool $a_may_rate,
170 ?array $a_categories = null,
171 ?string $a_onclick = null,
172 bool $a_average = false,
173 bool $add_tooltip = false
174 ): string {
175 $lng = $this->lng;
176 $ilCtrl = $this->ctrl;
177 $f = $this->ui->factory();
178 $r = $this->ui->renderer();
179
180 $ttpl = new ilTemplate("tpl.rating_details.html", true, true, "components/ILIAS/Rating");
181
182 $rate_text = null;
183 if ($this->getYourRatingText() != "#") {
184 $rate_text = ($this->getYourRatingText() != "")
185 ? $this->getYourRatingText()
186 : $lng->txt("rating_your_rating");
187 }
188
189 // no categories: 1 simple rating (link)
190 if (!$a_categories) {
191 if ($a_may_rate) {
193 $this->obj_id,
194 $this->obj_type,
195 $this->sub_obj_id,
196 $this->sub_obj_type,
197 $this->getUserId(),
198 0
199 );
200 $overall_rating = [
201 "avg" => 0,
202 "cnt" => 0
203 ];
204 if ($a_average) {
205 $overall_rating = ilRating::getOverallRatingForObject(
206 $this->obj_id,
207 $this->obj_type,
208 $this->sub_obj_id,
209 $this->sub_obj_type
210 );
211 }
212
213 // user rating links
214 for ($i = 1; $i <= 5; $i++) {
215 $star_tpl = new ilTemplate("tpl.rating_star.html", true, true, "components/ILIAS/Rating");
216 if ($a_average &&
217 $i == $rating) {
218 $star_tpl->setCurrentBlock("rating_mark_simple");
219 $star_tpl->setVariable(
220 "SRC_MARK_SIMPLE",
221 ilUtil::getImagePath("standard/icon_rate_marker.svg")
222 );
223 $star_tpl->parseCurrentBlock();
224 }
225
226 $ttpl->setCurrentBlock("rating_link_simple");
227 if (stristr((string) $a_onclick, "%rating%")) {
228 $url_save = "#";
229 } else {
230 $ilCtrl->setParameter($this, "rating", $i);
231 if (!$this->ctrl_path) {
232 $url_save = $ilCtrl->getLinkTarget($this, "saveRating");
233 } else {
234 $url_save = $ilCtrl->getLinkTargetByClass($this->ctrl_path, "saveRating");
235 }
236 }
237 $b = $this->ui->factory()->button()->shy("###star###", $url_save);
238
239 if ($a_onclick) {
240 $onclick = str_replace("%rating%", $i, $a_onclick);
241 $b = $b->withOnLoadCode(function ($id) use ($onclick) {
242 return
243 "$('#" . $id . "').click(function() { $onclick; return false;});";
244 });
245 }
246
247 if ($a_average) {
248 $ref_rating = $overall_rating["avg"];
249 } else {
250 $ref_rating = $rating;
251 }
252
253 if ($ref_rating >= $i) {
254 $star_tpl->setVariable(
255 "SRC_ICON",
256 ilUtil::getImagePath("standard/icon_rate_on.svg")
257 );
258 } else {
259 $star_tpl->setVariable(
260 "SRC_ICON",
261 ilUtil::getImagePath("standard/icon_rate_off.svg")
262 );
263 }
264 $star_tpl->setVariable(
265 "ALT_ICON",
266 sprintf($lng->txt("rating_rate_x_of_5"), $i)
267 );
268
269 if ($add_tooltip) {
270 $topics = $this->getTooltipTopics(
271 (int) ($overall_rating["cnt"] ?? 0),
272 (float) ($overall_rating["avg"] ?? 0),
273 (int) ($rating ?? 0)
274 );
275 $b = $b->withHelpTopics(...$f->helpTopics(...$topics));
276 }
277
278 $star_html = $this->ui->renderer()->render($b);
279 $star_html = str_replace("###star###", $star_tpl->get(), $star_html);
280
281 $ttpl->setVariable("STAR_BUTTON", $star_html);
282
283 $ttpl->parseCurrentBlock();
284 }
285
286 // remove
287 if ($rating) {
288 $ttpl->setCurrentBlock("rating_simple_del_bl");
289 $ttpl->setVariable("CAPTION_RATING_DEL", $lng->txt("rating_remove"));
290
291 if (stristr((string) $a_onclick, "%rating%")) {
292 $url_save = "#";
293 } else {
294 $ilCtrl->setParameter($this, "rating", 0);
295 if (!$this->ctrl_path) {
296 $url_save = $ilCtrl->getLinkTarget($this, "saveRating");
297 } else {
298 $url_save = $ilCtrl->getLinkTargetByClass($this->ctrl_path, "saveRating");
299 }
300 }
301 $ttpl->setVariable("HREF_RATING_DEL", $url_save);
302
303 if ($a_onclick) {
304 $onclick = str_replace("%rating%", 0, $a_onclick);
305 $ttpl->setVariable("ONCLICK_RATING_DEL", ' onclick="' . $onclick . '"');
306 }
307
308 $ttpl->parseCurrentBlock();
309 }
310
311 if ($rate_text) {
312 $ttpl->setCurrentBlock("rating_simple_title");
313 $ttpl->setVariable("TXT_RATING_SIMPLE", $rate_text);
314 $ttpl->parseCurrentBlock();
315 }
316
317 if ($a_average &&
318 $overall_rating["cnt"]) {
319 $ttpl->setCurrentBlock("number_votes_simple");
320 $ttpl->setVariable("NUMBER_VOTES_SIMPLE", $overall_rating["cnt"]);
321 $ttpl->parseCurrentBlock();
322 }
323
324 // user rating text
325 $ttpl->setCurrentBlock("user_rating_simple");
326 $ttpl->parseCurrentBlock();
327 }
328 }
329 // categories: overall & user (form)
330 else {
331 $has_user_rating = false;
332 $overall_rating = [
333 "avg" => 0,
334 "cnt" => 0
335 ];
336
337 // Collect all category IDs
338 $category_ids = array_column($a_categories, "id");
340 $this->obj_id,
341 $this->sub_obj_id,
342 $this->sub_obj_type,
343 $category_ids
344 );
345
346 foreach ($a_categories as $category) {
347 $user_rating = round(ilRating::getRatingForUserAndObject(
348 $this->obj_id,
349 $this->obj_type,
350 $this->sub_obj_id,
351 $this->sub_obj_type,
352 $this->getUserId(),
353 $category["id"]
354 ));
355
356 $overall_rating = ilRating::getOverallRatingForObject(
357 $this->obj_id,
358 $this->obj_type,
359 $this->sub_obj_id,
360 $this->sub_obj_type,
361 $category["id"]
362 );
363
364 for ($i = 1; $i <= 5; $i++) {
365 $star_tpl = new ilTemplate("tpl.js_rating_star.html", true, true, "components/ILIAS/Rating");
366 if ($a_may_rate && $i == $user_rating) {
367 $has_user_rating = true;
368
369 $star_tpl->setCurrentBlock("rating_mark");
370 $star_tpl->setVariable(
371 "SRC_MARK",
372 ilUtil::getImagePath("standard/icon_rate_marker.svg")
373 );
374 $star_tpl->parseCurrentBlock();
375 }
376
377 $ttpl->setCurrentBlock("user_rating_icon");
378 if ($overall_rating["avg"] >= $i) {
379 $star_tpl->setVariable(
380 "SRC_ICON",
381 ilUtil::getImagePath("standard/icon_rate_on.svg")
382 );
383 $star_tpl->setVariable('RATING_FRACTION', 10);
384 } elseif ($overall_rating["avg"] + 1 <= $i) {
385 $star_tpl->setVariable(
386 "SRC_ICON",
387 ilUtil::getImagePath("standard/icon_rate_off.svg")
388 );
389 $star_tpl->setVariable('RATING_FRACTION', 0);
390 } else {
391 $nr = round(($overall_rating["avg"] + 1 - $i) * 10);
392 $star_tpl->setVariable(
393 "SRC_ICON",
394 ilUtil::getImagePath("standard/icon_rate_$nr.svg")
395 );
396 $star_tpl->setVariable("RATING_FRACTION", $nr);
397 }
398 $star_tpl->setVariable(
399 "ALT_ICON",
400 sprintf($lng->txt("rating_rate_x_of_5"), $i)
401 );
402
403 $b = $f->button()->shy("###star###", "#");
404 if ($a_may_rate) {
405 $ttpl->setVariable("HREF_RATING", "il.Rating.setValue(" . $category["id"] . "," . $i . ", '" . $a_js_id . "')");
406 $star_tpl->setVariable("CATEGORY_ID", $category["id"]);
407 $star_tpl->setVariable("ICON_VALUE", $i);
408 $star_tpl->setVariable("JS_ID", $a_js_id);
409 $b = $b->withOnLoadCode(function ($id) use ($category, $i, $a_js_id) {
410 return
411 "$('#" . $id . "').click(function() { il.Rating.setValue(" . $category["id"] . "," . $i . ", '" . $a_js_id . "'); return false;});";
412 });
413
414 /*
415 $ttpl->setVariable("ICON_MOUSEACTION", " onmouseover=\"il.Rating.toggleIcon(this," . $i . ")\"" .
416 " onmouseout=\"il.Rating.toggleIcon(this," . $i . ",1)\"");*/
417 }
418 if ($add_tooltip) {
419 $topics = $this->getTooltipTopics(
420 (int) ($overall_rating["cnt"] ?? 0),
421 (float) ($overall_rating["avg"] ?? 0),
422 (int) ($user_rating ?? 0)
423 );
424 $b = $b->withHelpTopics(...$f->helpTopics(...$topics));
425 }
426 $button_html = $r->render($b);
427 $button_html = str_replace("###star###", $star_tpl->get(), $button_html);
428 $ttpl->setVariable("RATE_BUTTON", $button_html);
429 $ttpl->parseCurrentBlock();
430 }
431
432 if ($a_may_rate) {
433 $ttpl->setCurrentBlock("user_rating_category_column");
434 $ttpl->setVariable("JS_ID", $a_js_id);
435 $ttpl->setVariable("CATEGORY_ID", $category["id"]);
436 $ttpl->setVariable("CATEGORY_VALUE", $user_rating);
437 $ttpl->parseCurrentBlock();
438 }
439
440
441 // category title
442 $ttpl->setCurrentBlock("user_rating_category");
443 $ttpl->setVariable("TXT_RATING_CATEGORY", $category["title"]);
444 $ttpl->parseCurrentBlock();
445 }
446
447 if ($overall_count > 0) {
448 $ttpl->setCurrentBlock("votes_number_bl");
449 $ttpl->setVariable("NUMBER_VOTES", sprintf($lng->txt("rating_number_votes"), $overall_count));
450 $ttpl->parseCurrentBlock();
451 }
452
453 if ($a_may_rate) {
454 // remove
455 if ($has_user_rating) {
456 $ttpl->setCurrentBlock("user_rating_categories_del_bl");
457 $ttpl->setVariable("CAPTION_RATING_DEL_CAT", $lng->txt("rating_remove"));
458
459 $ilCtrl->setParameter($this, "rating", 0);
460 if (!$this->ctrl_path) {
461 $url_save = $ilCtrl->getLinkTarget($this, "resetUserRating");
462 } else {
463 $url_save = $ilCtrl->getLinkTargetByClass($this->ctrl_path, "resetUserRating");
464 }
465 $ttpl->setVariable("HREF_RATING_DEL_CAT", $url_save);
466
467 $ttpl->parseCurrentBlock();
468 }
469
470 if (!$this->ctrl_path) {
471 $url_form = $ilCtrl->getFormAction($this, "saveRating");
472 } else {
473 $url_form = $ilCtrl->getFormActionByClass($this->ctrl_path, "saveRating");
474 }
475 $ttpl->setVariable("FORM_ACTION", $url_form);
476 $ttpl->setVariable("TXT_SUBMIT", $lng->txt("rating_overlay_submit"));
477 $ttpl->setVariable("CMD_SUBMIT", "saveRating");
478 $ttpl->touchBlock("user_rating_categories_form_out");
479 }
480 }
481
482 return $ttpl->get();
483 }
484
485 // Get HTML for rating of an object (and a user)
486 public function getHTML(
487 bool $a_show_overall = true,
488 bool $a_may_rate = true,
489 ?string $a_onclick = null,
490 ?string $a_additional_id = null
491 ): string {
492 $f = $this->ui->factory();
493 $r = $this->ui->renderer();
494 $lng = $this->lng;
495 $unique_id = $this->id;
496 if ($a_additional_id) {
497 $unique_id .= "_" . $a_additional_id;
498 }
499
500 $categories = array();
501 if ($this->enable_categories) {
502 $categories = ilRatingCategory::getAllForObject($this->obj_id);
503 }
504
505 $may_rate = ($this->getUserId() != ANONYMOUS_USER_ID);
506 if ($may_rate && !$a_may_rate) {
507 $may_rate = false;
508 }
509
510 $has_overlay = false;
511 if ($may_rate || $categories) {
512 $has_overlay = true;
513 }
514
515 $ttpl = new ilTemplate("tpl.rating_input.html", true, true, "components/ILIAS/Rating");
516
517 // user rating
518 $user_rating = 0;
519 if ($may_rate || !$a_show_overall) {
520 $user_rating = round(ilRating::getRatingForUserAndObject(
521 $this->obj_id,
522 $this->obj_type,
523 $this->sub_obj_id,
524 $this->sub_obj_type,
525 $this->getUserId()
526 ));
527 }
528
529 // (1) overall rating
530 if ($a_show_overall) {
532 $this->obj_id,
533 $this->obj_type,
534 $this->sub_obj_id,
535 $this->sub_obj_type
536 );
537 } else {
538 $rating = array("avg" => $user_rating);
539 }
540
541 for ($i = 1; $i <= 5; $i++) {
542 if ($a_show_overall &&
543 $i == $user_rating) {
544 $ttpl->setCurrentBlock("rating_mark");
545 $ttpl->setVariable(
546 "SRC_MARK",
547 ilUtil::getImagePath("standard/icon_rate_marker.svg")
548 );
549 $ttpl->parseCurrentBlock();
550 }
551
552 $ttpl->setCurrentBlock("rating_icon");
553 if ($rating["avg"] >= $i) {
554 $ttpl->setVariable(
555 "SRC_ICON",
556 ilUtil::getImagePath("standard/icon_rate_on.svg")
557 );
558 } elseif ($rating["avg"] + 1 <= $i) {
559 $ttpl->setVariable(
560 "SRC_ICON",
561 ilUtil::getImagePath("standard/icon_rate_off.svg")
562 );
563 } else {
564 $nr = round(($rating["avg"] + 1 - $i) * 10);
565 $ttpl->setVariable(
566 "SRC_ICON",
567 ilUtil::getImagePath("standard/icon_rate_$nr.svg")
568 );
569 }
570 $ttpl->setVariable("ALT_ICON", "");
571 $ttpl->parseCurrentBlock();
572 }
573 $ttpl->setCurrentBlock("rating_icon");
574
575 if ($a_show_overall) {
576 if ($rating["cnt"] > 0) {
577 $ttpl->setCurrentBlock("rat_nr");
578 $ttpl->setVariable("RT_NR", $rating["cnt"]);
579 $ttpl->parseCurrentBlock();
580 }
581 }
582
583 // add overlay (trigger)
584 if ($has_overlay) {
585 $ttpl->setCurrentBlock("act_rat_start");
586 $ttpl->setVariable("ID", $unique_id);
587 $ttpl->setVariable("TXT_OPEN_DIALOG", $lng->txt("rating_open_dialog"));
588 $ttpl->parseCurrentBlock();
589
590 $ttpl->touchBlock("act_rat_end");
591 }
592
593 $ttpl->parseCurrentBlock();
594
595
596 // (2) user rating
597
598 $ttpl->setVariable("TTID", $unique_id);
599 $rating_html = $ttpl->get();
600
601 $tt_topics = $this->getTooltipTopics(
602 (int) ($rating["cnt"] ?? 0),
603 (float) ($rating["avg"] ?? 0),
604 (int) ($user_rating ?? 0)
605 );
606
607
608 $button = $f->button()->shy('###button###', '#')
609 ->withOnLoadCode(function (string $id): string {
610 return "document.getElementById('$id').classList.add('ilRating');";
611 });
612 if ($has_overlay) {
613 $ttpl->setVariable(
614 "RATING_DETAILS",
615 $this->renderDetails("rtov_", $may_rate, $categories, $a_onclick)
616 );
617
618 $popover = $f->popover()->standard(
619 $f->legacy()->content($this->renderDetails("rtov_", $may_rate, $categories, $a_onclick))
620 );
621 $button = $button->withOnClick($popover->getShowSignal());
622 $button = $button->withHelpTopics(
623 ...$f->helpTopics(...$tt_topics)
624 );
625 $elements = [$popover, $button];
626 } else {
627 /*$button = $button->withOnLoadCode(function ($id) {
628 return "";
629 });*/
630 $button = $button->withHelpTopics(
631 ...$f->helpTopics(...$tt_topics)
632 );
633 $elements = [$button];
634 }
635 $html = $r->render($elements);
636 $html = str_replace("###button###", $rating_html, $html);
637
638 return $html;
639 }
640
641 protected function getTooltipTopics(
642 int $cnt = 0,
643 float $avg = 0,
644 int $user = 0
645 ): array {
646 $topics = [];
648
649 if ($cnt == 0) {
650 $topics[] = $lng->txt("rat_not_rated_yet");
651 } else {
652 if ($cnt == 1) {
653 $topics[] = $lng->txt("rat_one_rating");
654 } else {
655 $topics[] = sprintf($lng->txt("rat_nr_ratings"), $cnt);
656 }
657 $topics[] = $lng->txt("rating_avg_rating") . ": " . round($avg, 1);
658 }
659
660 if ($user > 0) {
661 $topics[] = $lng->txt("rating_personal_rating") . ": " . $user;
662 }
663 return $topics;
664 }
665
666 public function getBlockHTML(string $a_title): string
667 {
668 $ui = $this->ui;
669
670 $categories = array();
671 if ($this->enable_categories) {
672 $categories = ilRatingCategory::getAllForObject($this->obj_id);
673 }
674
675 $may_rate = ($this->getUserId() != ANONYMOUS_USER_ID);
676
677
678 $panel = $ui->factory()->panel()->secondary()->legacy(
679 $a_title,
680 $ui->factory()->legacy()->content(
681 $this->renderDetails("rtsb_", $may_rate, $categories, null, true, true)
682 )
683 );
684
685 return $ui->renderer()->render($panel);
686 }
687
691 public function saveRating(): void
692 {
693 $ilCtrl = $this->ctrl;
694
695 if (!is_array($this->requested_ratings)) {
696 $rating = $this->requested_rating;
697 if ($rating == 0) {
698 $this->resetUserRating();
699 } else {
701 $this->obj_id,
702 $this->obj_type,
703 $this->sub_obj_id,
704 $this->sub_obj_type,
705 $this->getUserId(),
706 $rating
707 );
708 }
709 } else {
710 foreach ($this->requested_ratings as $cat_id => $rating) {
712 $this->obj_id,
713 $this->obj_type,
714 $this->sub_obj_id,
715 $this->sub_obj_type,
716 $this->getUserId(),
717 $rating,
718 $cat_id
719 );
720 }
721 }
722
723 if ($this->update_callback) {
724 call_user_func(
725 $this->update_callback,
726 $this->obj_id,
727 $this->obj_type,
728 $this->sub_obj_id,
729 $this->sub_obj_type
730 );
731 }
732
733 if ($ilCtrl->isAsynch()) {
734 exit();
735 }
736 }
737
738 public function setUpdateCallback($a_callback): void
739 {
740 $this->update_callback = $a_callback;
741 }
742
743 public function resetUserRating(): void
744 {
746 $this->obj_id,
747 $this->obj_type,
748 (int) $this->sub_obj_id,
749 $this->sub_obj_type,
750 $this->getUserId()
751 );
752 }
753
754 public function setExportCallback($a_callback, string $a_subobj_title): void
755 {
756 $this->export_callback = $a_callback;
757 $this->export_subobj_title = $a_subobj_title;
758 }
759
760 // Build list gui property for object
761 public function getListGUIProperty(
762 int $a_ref_id,
763 bool $a_may_rate,
764 string $a_ajax_hash,
765 int $parent_ref_id
766 ): string {
767 return $this->getHTML(
768 true,
769 $a_may_rate,
770 "il.Object.saveRatingFromListGUI(" . $a_ref_id . ", '" . $a_ajax_hash . "', %rating%);",
771 $parent_ref_id
772 );
773 }
774}
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
factory()
return true
Class ilCtrl provides processing control methods.
getNextClass($a_gui_class=null)
@inheritDoc
language handling
loadLanguageModule(string $a_module)
Load language module.
User class.
Class ilRatingCategoryGUI.
static getAllForObject(int $a_parent_obj_id)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
setObject(int $a_obj_id, string $a_obj_type, ?int $a_sub_obj_id=0, ?string $a_sub_obj_type="")
Set Object.
getUnsafeGetCommands()
This method must return a list of unsafe GET commands.
string $your_rating_text
setUserId(int $a_userid)
setCtrlPath(array $a_value)
getBlockHTML(string $a_title)
executeCommand()
execute command
getSafePostCommands()
This method must return a list of safe POST commands.
getHTML(bool $a_show_overall=true, bool $a_may_rate=true, ?string $a_onclick=null, ?string $a_additional_id=null)
renderDetails(string $a_js_id, bool $a_may_rate, ?array $a_categories=null, ?string $a_onclick=null, bool $a_average=false, bool $add_tooltip=false)
setUpdateCallback($a_callback)
setYourRatingText(string $a_val)
getListGUIProperty(int $a_ref_id, bool $a_may_rate, string $a_ajax_hash, int $parent_ref_id)
saveRating()
Save Rating.
getTooltipTopics(int $cnt=0, float $avg=0, int $user=0)
ILIAS DI UIServices $ui
setExportCallback($a_callback, string $a_subobj_title)
enableCategories(bool $a_value)
ilLanguage $lng
array $requested_ratings
string $export_subobj_title
static getNumberOfFinishedCategoryRatingsForWikis(int $a_obj_id, int $sub_obj_id, string $sub_obj_type, array $all_category_ids)
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.
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.
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.
static getOverallRatingForObject(int $a_obj_id, string $a_obj_type, ?int $a_sub_obj_id=null, ?string $a_sub_obj_type=null, ?int $a_category_id=null)
Get overall rating for an object.
special template class to simplify handling of ITX/PEAR
static getImagePath(string $image_name, string $module_path="", string $mode="output", bool $offline=false)
get image path (for images located in a template directory)
const ANONYMOUS_USER_ID
Definition: constants.php:27
return['delivery_method'=> 'php',]
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
exit
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
if(! $DIC->user() ->getId()||!ilLTIConsumerAccess::hasCustomProviderCreationAccess()) $params
Definition: ltiregstart.php:31
global $lng
Definition: privfeed.php:31
global $DIC
Definition: shib_login.php:26