ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.assFormulaQuestionUnit.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
27{
28 private int $id = 0;
29 private string $unit = '';
30 private float $factor = 0.0;
31 private int $category = 0;
32 private int $sequence = 0;
33 private int $baseunit = 0;
34 private ?string $baseunit_title = null;
35
36 public function initFormArray(array $data): void
37 {
38 $this->id = (int) $data['unit_id'];
39 $this->unit = $data['unit'];
40 $this->factor = (float) $data['factor'];
41 $this->baseunit = (int) $data['baseunit_fi'];
42 $this->baseunit_title = $data['baseunit_title'] ?? null;
43 $this->category = (int) $data['category'];
44 $this->sequence = (int) $data['sequence'];
45 }
46
47 public function setId(int $id): void
48 {
49 $this->id = $id;
50 }
51
52 public function getId(): int
53 {
54 return $this->id;
55 }
56
57 public function setUnit(string $unit): void
58 {
59 $this->unit = $unit;
60 }
61
62 public function getUnit(): string
63 {
64 return $this->unit;
65 }
66
67 public function setSequence(int $sequence): void
68 {
69 $this->sequence = $sequence;
70 }
71
72 public function getSequence(): int
73 {
74 return $this->sequence;
75 }
76
77 public function setFactor(float $factor): void
78 {
79 $this->factor = $factor;
80 }
81
82 public function getFactor(): float
83 {
84 return $this->factor;
85 }
86
87 public function setBaseUnit(int $baseunit): void
88 {
89 $this->baseunit = $baseunit;
90 }
91
92 public function getBaseUnit(): int
93 {
94 if ($this->baseunit > 0) {
95 return $this->baseunit;
96 }
97
98 return $this->id;
99 }
100
101 public function setBaseunitTitle(?string $baseunit_title): void
102 {
103 $this->baseunit_title = $baseunit_title;
104 }
105
106 public function getBaseunitTitle(): ?string
107 {
109 }
110
111 public function setCategory(int $category): void
112 {
113 $this->category = $category;
114 }
115
116 public function getCategory(): int
117 {
118 return $this->category;
119 }
120
121 public function getDisplayString(): string
122 {
123 global $DIC;
124
125 $lng = $DIC->language();
126
127 $unit = $this->getUnit();
128 if (strcmp('-qpl_qst_formulaquestion_' . $unit . '-', $lng->txt('qpl_qst_formulaquestion_' . $unit)) !== 0) {
129 $unit = $lng->txt('qpl_qst_formulaquestion_' . $unit);
130 }
131
132 return $unit;
133 }
134
135 public static function lookupUnitFactor(int $a_unit_id): float
136 {
137 global $DIC;
138 $ilDB = $DIC['ilDB'];
139
140 $res = $ilDB->queryF(
141 'SELECT factor FROM il_qpl_qst_fq_unit WHERE unit_id = %s',
142 ['integer'],
143 [$a_unit_id]
144 );
145
146 $row = $ilDB->fetchAssoc($res);
147
148 return (float) $row['factor'];
149 }
150}
setBaseunitTitle(?string $baseunit_title)
static lookupUnitFactor(int $a_unit_id)
$res
Definition: ltiservices.php:69
global $lng
Definition: privfeed.php:31
global $DIC
Definition: shib_login.php:26