ILIAS  trunk Revision v11.0_alpha-1761-g6dbbfa7b760
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
GeneralQuestionProperties.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
22 
24 
26 {
27  public function __construct(
28  private readonly \ilComponentFactory $component_factory,
29  private readonly int $question_id,
30  private ?int $original_id = null,
31  private ?string $external_id = null,
32  private int $parent_object_id = 0,
33  private ?int $origin_object_id = null,
34  private readonly int $type_id = 0,
35  private readonly string $class_name = '',
36  private int $owner = 0,
37  private string $title = '',
38  private string $description = '',
39  private string $question_text = '',
40  private float $available_points = 0.0,
41  private int $number_of_tries = 0,
42  private string $lifecycle = 'draft',
43  private ?string $author = null,
44  private int $updated_timestamp = 0,
45  private int $created_timestamp = 0,
46  private bool $complete = true,
47  private readonly ?string $additional_content_editing_mode = null
48  ) {
49  }
50 
51  public function getQuestionId(): int
52  {
53  return $this->question_id;
54  }
55 
56  public function getOriginalId(): ?int
57  {
58  return $this->original_id;
59  }
60 
61  public function withOriginalId(int $original_id): self
62  {
63  $clone = clone $this;
64  $clone->original_id = $original_id;
65  return $clone;
66  }
67 
68  public function getExternalId(): ?string
69  {
70  return $this->external_id;
71  }
72 
73  public function withExternalId(string $external_id): self
74  {
75  $clone = clone $this;
76  $clone->external_id = $external_id;
77  return $clone;
78  }
79 
80  public function getParentObjectId(): int
81  {
82  return $this->parent_object_id;
83  }
84 
85  public function withParentObjectId(int $parent_id): self
86  {
87  $clone = clone $this;
88  $clone->parent_object_id = $parent_id;
89  return $clone;
90  }
91 
92  public function getOriginObjectId(): ?int
93  {
94  return $this->origin_object_id;
95  }
96 
97  public function withOriginObjectId(int $origin_object_id): self
98  {
99  $clone = clone $this;
100  $clone->origin_object_id = $origin_object_id;
101  return $clone;
102  }
103 
104  public function getTypeId(): int
105  {
106  return $this->type_id;
107  }
108 
109  public function getClassName(): string
110  {
111  return $this->class_name;
112  }
113 
114  public function getGuiClassName(): string
115  {
116  return $this->class_name . 'GUI';
117  }
118 
119  public function getTypeName(Language $lng): string
120  {
121  if ($this->class_name === '') {
122  return '';
123  }
124 
125  if (file_exists(ILIAS_ABSOLUTE_PATH . '/components/ILIAS/TestQuestionPool/classes/class.' . $this->class_name . '.php')) {
126  return $lng->txt($this->class_name);
127  }
128 
129  foreach ($this->component_factory->getActivePluginsInSlot('qst') as $pl) {
130  if ($pl->getQuestionType() === $this->class_name) {
131  return $pl->getQuestionTypeTranslation();
132  }
133  }
134  return '';
135  }
136 
137  public function getOwner(): int
138  {
139  return $this->owner;
140  }
141 
142  public function withOwner(int $owner): self
143  {
144  $clone = clone $this;
145  $clone->owner = $owner;
146  return $clone;
147  }
148 
149  public function getTitle(): string
150  {
151  return $this->title;
152  }
153 
154  public function withTitle(string $title): self
155  {
156  $clone = clone $this;
157  $clone->title = $title;
158  return $clone;
159  }
160 
161  public function getDescription(): string
162  {
163  return $this->description;
164  }
165 
166  public function withDescription(string $description): self
167  {
168  $clone = clone $this;
169  $clone->description = $description;
170  return $clone;
171  }
172 
173  public function getQuestionText(): string
174  {
175  return $this->question_text;
176  }
177 
178  public function withQuestionText(string $question_text): self
179  {
180  $clone = clone $this;
181  $clone->question_text = $question_text;
182  return $clone;
183  }
184 
185  public function getAvailablePoints(): float
186  {
187  return $this->available_points;
188  }
189 
190  public function withMaximumPoints(float $reachable_points): self
191  {
192  $clone = clone $this;
193  $clone->reachable_points = $reachable_points;
194  return $clone;
195  }
196 
197  public function getNumberOfTries(): int
198  {
199  return $this->number_of_tries;
200  }
201 
202  public function withNumberOfTries(int $number_of_tries): self
203  {
204  $clone = clone $this;
205  $clone->number_of_tries = $number_of_tries;
206  return $clone;
207  }
208 
209  public function getLifecycle(): string
210  {
211  return $this->lifecycle;
212  }
213 
214  public function withLifecycle(string $lifecycle): self
215  {
216  $clone = clone $this;
217  $clone->lifecycle = $lifecycle;
218  return $clone;
219  }
220 
221  public function getAuthor(): ?string
222  {
223  return $this->author;
224  }
225 
226  public function withAuthor(string $author): self
227  {
228  $clone = clone $this;
229  $clone->author = $author;
230  return $clone;
231  }
232 
233  public function getUpdatedTimestamp(): int
234  {
235  return $this->updated_timestamp;
236  }
237 
238  public function withUpdatedTimestamp(int $updated_timestamp): self
239  {
240  $clone = clone $this;
241  $clone->updated_timestamp = $updated_timestamp;
242  return $clone;
243  }
244 
245  public function getCreatedTimestamp(): int
246  {
247  return $this->created_timestamp;
248  }
249 
250  public function withCreatedTimestamp(int $created_timestamp): self
251  {
252  $clone = clone $this;
253  $clone->created_timestamp = $created_timestamp;
254  return $clone;
255  }
256 
257  public function isRequiredInformationComplete(): bool
258  {
259  return $this->complete;
260  }
261 
262  public function withCompletionStatus(bool $complete): self
263  {
264  $clone = clone $this;
265  $clone->complete = $complete;
266  return $clone;
267  }
268 
269  public function getAdditionalContentEditingMode(): ?string
270  {
271  return $this->additional_content_editing_mode;
272  }
273 
277  public function isClone(): bool
278  {
279  return $this->original_id !== null;
280  }
281 
285  public function toStorage(): array
286  {
287  return [
288  'question_id' => [\ilDBConstants::T_INTEGER, $this->getQuestionId()],
289  'question_type_fi' => [\ilDBConstants::T_INTEGER, $this->getTypeId()],
290  'obj_fi' => [\ilDBConstants::T_INTEGER, $this->getParentObjectId()],
291  'title' => [\ilDBConstants::T_TEXT, $this->getTitle()],
292  'description' => [\ilDBConstants::T_TEXT, $this->getDescription()],
293  'author' => [\ilDBConstants::T_TEXT, $this->getAuthor()],
294  'owner' => [\ilDBConstants::T_INTEGER, $this->getOwner()],
295  'points' => [\ilDBConstants::T_FLOAT, $this->getAvailablePoints()],
296  'complete' => [\ilDBConstants::T_TEXT, $this->isRequiredInformationComplete()],
297  'original_id' => [\ilDBConstants::T_INTEGER, $this->getOriginalId()],
298  'tstamp' => [\ilDBConstants::T_INTEGER, $this->getUpdatedTimestamp()],
299  'created' => [\ilDBConstants::T_INTEGER, $this->getCreatedTimestamp()],
300  'nr_of_tries' => [\ilDBConstants::T_INTEGER, $this->getNumberOfTries()],
301  'question_text' => [\ilDBConstants::T_TEXT, $this->getQuestionText()],
302  'add_content_edit_mode' => [\ilDBConstants::T_TEXT, $this->getAdditionalContentEditingMode()],
303  'external_id' => [\ilDBConstants::T_TEXT, $this->getExternalId()],
304  'lifecycle' => [\ilDBConstants::T_TEXT, $this->getLifecycle()]
305  ];
306  }
307 
308 }
isClone()
Checks whether the question is a clone of another question or not.
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return 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="")
$lifecycle
global $lng
Definition: privfeed.php:31
__construct(private readonly \ilComponentFactory $component_factory, private readonly int $question_id, private ?int $original_id=null, private ?string $external_id=null, private int $parent_object_id=0, private ?int $origin_object_id=null, private readonly int $type_id=0, private readonly string $class_name='', private int $owner=0, private string $title='', private string $description='', private string $question_text='', private float $available_points=0.0, private int $number_of_tries=0, private string $lifecycle='draft', private ?string $author=null, private int $updated_timestamp=0, private int $created_timestamp=0, private bool $complete=true, private readonly ?string $additional_content_editing_mode=null)