ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilExcCriteriaBool.php
Go to the documentation of this file.
1<?php
2
26{
27 public function getType(): string
28 {
29 return "bool";
30 }
31
32
33 // PEER REVIEW
34
35 public function addToPeerReviewForm($a_value = null): void
36 {
38
39 if (!$this->isRequired()) {
40 $input = new ilCheckboxInputGUI($this->getTitle(), "prccc_bool_" . $this->getId());
41 $input->setInfo($this->getDescription());
42 $input->setRequired($this->isRequired());
43 $input->setChecked($a_value > 0);
44 } else {
45 $input = new ilSelectInputGUI($this->getTitle(), "prccc_bool_" . $this->getId());
46 $input->setInfo($this->getDescription());
47 $input->setRequired($this->isRequired());
48 $input->setValue($a_value);
49 $options = array();
50 if (!$a_value) {
51 $options[""] = $lng->txt("please_select");
52 }
53 $options[1] = $lng->txt("yes");
54 $options[-1] = $lng->txt("no");
55 $input->setOptions($options);
56 }
57 $this->form->addItem($input);
58 }
59
60 public function importFromPeerReviewForm(): int
61 {
62 return (int) $this->form->getInput("prccc_bool_" . $this->getId());
63 }
64
65 public function hasValue($a_value): int
66 {
67 // see #35695, a non required un-checked checkbox is treated as a value
68 if (!is_null($a_value) && !$this->isRequired()) {
69 return 1;
70 }
71 return (int) $a_value;
72 }
73
74 public function getHTML($a_value): string
75 {
77
78 $caption = "";
79 // see #35694, a non required un-checked checkbox is treated as a "no"
80 if (!$this->isRequired()) {
81 $caption = $lng->txt("no");
82 }
83 if ($this->isRequired() && $a_value < 0) {
84 $caption = $lng->txt("no");
85 } elseif ($a_value == 1) {
86 $caption = $lng->txt("yes");
87 }
88 return $caption;
89 }
90}
This class represents a checkbox property in a property form.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
addToPeerReviewForm($a_value=null)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
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...
This class represents a selection list property in a property form.
form( $class_path, string $cmd, string $submit_caption="")