1 | <?php |
||
2 | |||
3 | declare(strict_types=1); |
||
4 | |||
5 | /* For licensing terms, see /license.txt */ |
||
6 | |||
7 | namespace Chamilo\CourseBundle\Entity; |
||
8 | |||
9 | use Chamilo\CourseBundle\Repository\CLpItemRepository; |
||
10 | use Doctrine\Common\Collections\ArrayCollection; |
||
11 | use Doctrine\Common\Collections\Collection; |
||
12 | use Doctrine\ORM\Mapping as ORM; |
||
13 | use Gedmo\Mapping\Annotation as Gedmo; |
||
14 | use Stringable; |
||
15 | use Symfony\Component\Validator\Constraints as Assert; |
||
16 | |||
17 | /** |
||
18 | * Items from a learning path (LP). |
||
19 | */ |
||
20 | #[ORM\Table(name: 'c_lp_item')] |
||
21 | #[ORM\Index(columns: ['lp_id'], name: 'lp_id')] |
||
22 | #[Gedmo\Tree(type: 'nested')] |
||
23 | #[ORM\Entity(repositoryClass: CLpItemRepository::class)] |
||
24 | class CLpItem implements Stringable |
||
25 | { |
||
26 | #[ORM\Column(name: 'iid', type: 'integer')] |
||
27 | #[ORM\Id] |
||
28 | #[ORM\GeneratedValue] |
||
29 | protected ?int $iid = null; |
||
30 | |||
31 | #[Assert\NotBlank] |
||
32 | #[ORM\Column(name: 'title', type: 'string', length: 511, nullable: false)] |
||
33 | protected string $title; |
||
34 | |||
35 | #[Assert\NotBlank] |
||
36 | #[ORM\Column(name: 'item_type', type: 'string', length: 32, nullable: false)] |
||
37 | protected string $itemType; |
||
38 | |||
39 | #[Assert\NotBlank] |
||
40 | #[ORM\Column(name: 'ref', type: 'text', nullable: false)] |
||
41 | protected string $ref; |
||
42 | |||
43 | #[ORM\Column(name: 'description', type: 'string', length: 511, nullable: true)] |
||
44 | protected ?string $description; |
||
45 | |||
46 | #[ORM\Column(name: 'path', type: 'text', nullable: false)] |
||
47 | protected string $path; |
||
48 | |||
49 | #[ORM\Column(name: 'min_score', type: 'float', precision: 10, scale: 0, nullable: false)] |
||
50 | protected float $minScore; |
||
51 | |||
52 | #[ORM\Column(name: 'max_score', type: 'float', precision: 10, scale: 0, nullable: true, options: ['default' => 100])] |
||
53 | protected ?float $maxScore; |
||
54 | |||
55 | #[ORM\Column(name: 'mastery_score', type: 'float', precision: 10, scale: 0, nullable: true)] |
||
56 | protected ?float $masteryScore = null; |
||
57 | |||
58 | #[ORM\Column(name: 'display_order', type: 'integer', nullable: false)] |
||
59 | protected int $displayOrder; |
||
60 | |||
61 | #[ORM\Column(name: 'prerequisite', type: 'text', nullable: true)] |
||
62 | protected ?string $prerequisite = null; |
||
63 | |||
64 | #[ORM\Column(name: 'parameters', type: 'text', nullable: true)] |
||
65 | protected ?string $parameters = null; |
||
66 | |||
67 | #[ORM\Column(name: 'launch_data', type: 'text', nullable: false)] |
||
68 | protected string $launchData; |
||
69 | |||
70 | #[ORM\Column(name: 'max_time_allowed', type: 'string', length: 13, nullable: true)] |
||
71 | protected ?string $maxTimeAllowed = null; |
||
72 | |||
73 | #[ORM\Column(name: 'terms', type: 'text', nullable: true)] |
||
74 | protected ?string $terms = null; |
||
75 | |||
76 | #[ORM\Column(name: 'search_did', type: 'integer', nullable: true)] |
||
77 | protected ?int $searchDid = null; |
||
78 | |||
79 | #[ORM\Column(name: 'audio', type: 'string', length: 250, nullable: true)] |
||
80 | protected ?string $audio = null; |
||
81 | |||
82 | #[ORM\Column(name: 'prerequisite_min_score', type: 'float', precision: 10, scale: 0, nullable: true)] |
||
83 | protected ?float $prerequisiteMinScore = null; |
||
84 | |||
85 | #[ORM\Column(name: 'prerequisite_max_score', type: 'float', precision: 10, scale: 0, nullable: true)] |
||
86 | protected ?float $prerequisiteMaxScore = null; |
||
87 | |||
88 | #[ORM\ManyToOne(targetEntity: CLp::class, inversedBy: 'items', cascade: ['persist', 'remove'])] |
||
89 | #[ORM\JoinColumn(name: 'lp_id', referencedColumnName: 'iid', onDelete: 'CASCADE')] |
||
90 | protected CLp $lp; |
||
91 | |||
92 | #[Gedmo\TreeRoot] |
||
93 | #[ORM\ManyToOne(targetEntity: self::class)] |
||
94 | #[ORM\JoinColumn(name: 'item_root', referencedColumnName: 'iid', onDelete: 'CASCADE')] |
||
95 | protected ?CLpItem $root = null; |
||
96 | |||
97 | #[Gedmo\TreeParent] |
||
98 | #[ORM\ManyToOne(targetEntity: self::class, inversedBy: 'children', cascade: ['persist'])] |
||
99 | #[ORM\JoinColumn(name: 'parent_item_id', referencedColumnName: 'iid', onDelete: 'SET NULL')] |
||
100 | protected ?CLpItem $parent = null; |
||
101 | |||
102 | #[ORM\OneToMany(targetEntity: self::class, mappedBy: 'parent')] |
||
103 | protected Collection $children; |
||
104 | |||
105 | #[Gedmo\TreeLeft] |
||
106 | #[ORM\Column(name: 'previous_item_id', type: 'integer', nullable: true)] |
||
107 | protected ?int $previousItemId = null; |
||
108 | |||
109 | #[Gedmo\TreeRight] |
||
110 | #[ORM\Column(name: 'next_item_id', type: 'integer', nullable: true)] |
||
111 | protected ?int $nextItemId = null; |
||
112 | |||
113 | #[Gedmo\TreeLevel] |
||
114 | #[ORM\Column(name: 'lvl', type: 'integer')] |
||
115 | protected ?int $lvl; |
||
116 | |||
117 | #[ORM\Column(name: 'duration', type: 'integer', nullable: true)] |
||
118 | protected ?int $duration = null; |
||
119 | |||
120 | #[ORM\Column(name: 'export_allowed', type: 'boolean', options: ['default' => false])] |
||
121 | protected bool $exportAllowed = false; |
||
122 | |||
123 | public function __construct() |
||
124 | { |
||
125 | $this->children = new ArrayCollection(); |
||
126 | $this->path = ''; |
||
127 | $this->ref = ''; |
||
128 | $this->lvl = 0; |
||
129 | $this->launchData = ''; |
||
130 | $this->description = ''; |
||
131 | $this->displayOrder = 0; |
||
132 | $this->minScore = 0; |
||
133 | $this->maxScore = 100.0; |
||
134 | } |
||
135 | |||
136 | public function __toString(): string |
||
137 | { |
||
138 | return $this->getIid().' '.$this->getTitle(); |
||
139 | } |
||
140 | |||
141 | public function getIid(): ?int |
||
142 | { |
||
143 | return $this->iid; |
||
144 | } |
||
145 | |||
146 | public function setLp(CLp $lp): self |
||
147 | { |
||
148 | $this->lp = $lp; |
||
149 | |||
150 | return $this; |
||
151 | } |
||
152 | |||
153 | public function getLp(): CLp |
||
154 | { |
||
155 | return $this->lp; |
||
156 | } |
||
157 | |||
158 | public function setItemType(string $itemType): self |
||
159 | { |
||
160 | $this->itemType = $itemType; |
||
161 | |||
162 | return $this; |
||
163 | } |
||
164 | |||
165 | public function getItemType(): string |
||
166 | { |
||
167 | return $this->itemType; |
||
168 | } |
||
169 | |||
170 | public function setRef(string $ref): self |
||
171 | { |
||
172 | $this->ref = $ref; |
||
173 | |||
174 | return $this; |
||
175 | } |
||
176 | |||
177 | public function getRef(): string |
||
178 | { |
||
179 | return $this->ref; |
||
180 | } |
||
181 | |||
182 | public function setTitle(string $title): self |
||
183 | { |
||
184 | $this->title = $title; |
||
185 | |||
186 | return $this; |
||
187 | } |
||
188 | |||
189 | public function getTitle(): string |
||
190 | { |
||
191 | return $this->title; |
||
192 | } |
||
193 | |||
194 | public function setDescription(string $description): self |
||
195 | { |
||
196 | $this->description = $description; |
||
197 | |||
198 | return $this; |
||
199 | } |
||
200 | |||
201 | public function getDescription(): ?string |
||
202 | { |
||
203 | return $this->description; |
||
204 | } |
||
205 | |||
206 | public function setPath(string $path): self |
||
207 | { |
||
208 | $this->path = $path; |
||
209 | |||
210 | return $this; |
||
211 | } |
||
212 | |||
213 | /** |
||
214 | * Get path. |
||
215 | * |
||
216 | * @return string |
||
217 | */ |
||
218 | public function getPath() |
||
219 | { |
||
220 | return $this->path; |
||
221 | } |
||
222 | |||
223 | public function setMinScore(float $minScore): self |
||
224 | { |
||
225 | $this->minScore = $minScore; |
||
226 | |||
227 | return $this; |
||
228 | } |
||
229 | |||
230 | /** |
||
231 | * Get minScore. |
||
232 | * |
||
233 | * @return float |
||
234 | */ |
||
235 | public function getMinScore() |
||
236 | { |
||
237 | return $this->minScore; |
||
238 | } |
||
239 | |||
240 | public function setMaxScore(float $maxScore): self |
||
241 | { |
||
242 | $this->maxScore = $maxScore; |
||
243 | |||
244 | return $this; |
||
245 | } |
||
246 | |||
247 | /** |
||
248 | * Get maxScore. |
||
249 | * |
||
250 | * @return float |
||
251 | */ |
||
252 | public function getMaxScore() |
||
253 | { |
||
254 | return $this->maxScore; |
||
255 | } |
||
256 | |||
257 | public function setMasteryScore(float $masteryScore): self |
||
258 | { |
||
259 | $this->masteryScore = $masteryScore; |
||
260 | |||
261 | return $this; |
||
262 | } |
||
263 | |||
264 | /** |
||
265 | * Get masteryScore. |
||
266 | * |
||
267 | * @return float |
||
268 | */ |
||
269 | public function getMasteryScore() |
||
270 | { |
||
271 | return $this->masteryScore; |
||
272 | } |
||
273 | |||
274 | public function setPreviousItemId(?int $previousItemId): self |
||
275 | { |
||
276 | $this->previousItemId = $previousItemId; |
||
277 | |||
278 | return $this; |
||
279 | } |
||
280 | |||
281 | /** |
||
282 | * Get previousItemId. |
||
283 | * |
||
284 | * @return int |
||
285 | */ |
||
286 | public function getPreviousItemId() |
||
287 | { |
||
288 | return $this->previousItemId; |
||
289 | } |
||
290 | |||
291 | public function setNextItemId(?int $nextItemId): self |
||
292 | { |
||
293 | $this->nextItemId = $nextItemId; |
||
294 | |||
295 | return $this; |
||
296 | } |
||
297 | |||
298 | /** |
||
299 | * Get nextItemId. |
||
300 | * |
||
301 | * @return int |
||
302 | */ |
||
303 | public function getNextItemId() |
||
304 | { |
||
305 | return $this->nextItemId; |
||
306 | } |
||
307 | |||
308 | public function setDisplayOrder(int $displayOrder): self |
||
309 | { |
||
310 | $this->displayOrder = $displayOrder; |
||
311 | |||
312 | return $this; |
||
313 | } |
||
314 | |||
315 | /** |
||
316 | * Get displayOrder. |
||
317 | * |
||
318 | * @return int |
||
319 | */ |
||
320 | public function getDisplayOrder() |
||
321 | { |
||
322 | return $this->displayOrder; |
||
323 | } |
||
324 | |||
325 | public function setPrerequisite(string $prerequisite): self |
||
326 | { |
||
327 | $this->prerequisite = $prerequisite; |
||
328 | |||
329 | return $this; |
||
330 | } |
||
331 | |||
332 | /** |
||
333 | * Get prerequisite. |
||
334 | * |
||
335 | * @return string |
||
336 | */ |
||
337 | public function getPrerequisite() |
||
338 | { |
||
339 | return $this->prerequisite; |
||
340 | } |
||
341 | |||
342 | public function setParameters(string $parameters): self |
||
343 | { |
||
344 | $this->parameters = $parameters; |
||
345 | |||
346 | return $this; |
||
347 | } |
||
348 | |||
349 | /** |
||
350 | * Get parameters. |
||
351 | * |
||
352 | * @return string |
||
353 | */ |
||
354 | public function getParameters() |
||
355 | { |
||
356 | return $this->parameters; |
||
357 | } |
||
358 | |||
359 | public function setLaunchData(string $launchData): self |
||
360 | { |
||
361 | $this->launchData = $launchData; |
||
362 | |||
363 | return $this; |
||
364 | } |
||
365 | |||
366 | /** |
||
367 | * Get launchData. |
||
368 | * |
||
369 | * @return string |
||
370 | */ |
||
371 | public function getLaunchData() |
||
372 | { |
||
373 | return $this->launchData; |
||
374 | } |
||
375 | |||
376 | public function setMaxTimeAllowed(string $maxTimeAllowed): self |
||
377 | { |
||
378 | $this->maxTimeAllowed = $maxTimeAllowed; |
||
379 | |||
380 | return $this; |
||
381 | } |
||
382 | |||
383 | /** |
||
384 | * Get maxTimeAllowed. |
||
385 | * |
||
386 | * @return string |
||
387 | */ |
||
388 | public function getMaxTimeAllowed() |
||
389 | { |
||
390 | return $this->maxTimeAllowed; |
||
391 | } |
||
392 | |||
393 | public function setTerms(string $terms): self |
||
394 | { |
||
395 | $this->terms = $terms; |
||
396 | |||
397 | return $this; |
||
398 | } |
||
399 | |||
400 | /** |
||
401 | * Get terms. |
||
402 | * |
||
403 | * @return string |
||
404 | */ |
||
405 | public function getTerms() |
||
406 | { |
||
407 | return $this->terms; |
||
408 | } |
||
409 | |||
410 | public function setSearchDid(int $searchDid): self |
||
411 | { |
||
412 | $this->searchDid = $searchDid; |
||
413 | |||
414 | return $this; |
||
415 | } |
||
416 | |||
417 | /** |
||
418 | * Get searchDid. |
||
419 | * |
||
420 | * @return int |
||
421 | */ |
||
422 | public function getSearchDid() |
||
423 | { |
||
424 | return $this->searchDid; |
||
425 | } |
||
426 | |||
427 | public function setAudio(string $audio): self |
||
428 | { |
||
429 | $this->audio = $audio; |
||
430 | |||
431 | return $this; |
||
432 | } |
||
433 | |||
434 | /** |
||
435 | * Get audio. |
||
436 | * |
||
437 | * @return string |
||
438 | */ |
||
439 | public function getAudio() |
||
440 | { |
||
441 | return $this->audio; |
||
442 | } |
||
443 | |||
444 | public function setPrerequisiteMinScore(float $prerequisiteMinScore): self |
||
445 | { |
||
446 | $this->prerequisiteMinScore = $prerequisiteMinScore; |
||
447 | |||
448 | return $this; |
||
449 | } |
||
450 | |||
451 | /** |
||
452 | * Get prerequisiteMinScore. |
||
453 | * |
||
454 | * @return float |
||
455 | */ |
||
456 | public function getPrerequisiteMinScore() |
||
457 | { |
||
458 | return $this->prerequisiteMinScore; |
||
459 | } |
||
460 | |||
461 | public function setPrerequisiteMaxScore(float $prerequisiteMaxScore): self |
||
462 | { |
||
463 | $this->prerequisiteMaxScore = $prerequisiteMaxScore; |
||
464 | |||
465 | return $this; |
||
466 | } |
||
467 | |||
468 | /** |
||
469 | * Get prerequisiteMaxScore. |
||
470 | * |
||
471 | * @return float |
||
472 | */ |
||
473 | public function getPrerequisiteMaxScore() |
||
474 | { |
||
475 | return $this->prerequisiteMaxScore; |
||
476 | } |
||
477 | |||
478 | public function getParentItemId(): int |
||
479 | { |
||
480 | if (null === $this->parent) { |
||
481 | return 0; |
||
482 | } |
||
483 | |||
484 | return $this->getParent()->getIid(); |
||
0 ignored issues
–
show
Bug
Best Practice
introduced
by
![]() |
|||
485 | } |
||
486 | |||
487 | public function getParent(): ?self |
||
488 | { |
||
489 | return $this->parent; |
||
490 | } |
||
491 | |||
492 | public function setParent(?self $parent): self |
||
493 | { |
||
494 | $this->parent = $parent; |
||
495 | |||
496 | return $this; |
||
497 | } |
||
498 | |||
499 | /** |
||
500 | * @return CLpItem[]|Collection |
||
501 | */ |
||
502 | public function getChildren(): array|Collection |
||
503 | { |
||
504 | return $this->children; |
||
505 | } |
||
506 | |||
507 | /** |
||
508 | * @param CLpItem[]|Collection $children |
||
509 | */ |
||
510 | public function setChildren(array|Collection $children): self |
||
511 | { |
||
512 | $this->children = $children; |
||
513 | |||
514 | return $this; |
||
515 | } |
||
516 | |||
517 | public function getLvl(): ?int |
||
518 | { |
||
519 | return $this->lvl; |
||
520 | } |
||
521 | |||
522 | public function setLvl(int $lvl): self |
||
523 | { |
||
524 | $this->lvl = $lvl; |
||
525 | |||
526 | return $this; |
||
527 | } |
||
528 | |||
529 | public function getRoot(): ?self |
||
530 | { |
||
531 | return $this->root; |
||
532 | } |
||
533 | |||
534 | public function setRoot(?self $root): self |
||
535 | { |
||
536 | $this->root = $root; |
||
537 | |||
538 | return $this; |
||
539 | } |
||
540 | |||
541 | public function getDuration(): ?int |
||
542 | { |
||
543 | return $this->duration; |
||
544 | } |
||
545 | |||
546 | public function setDuration(?int $duration): self |
||
547 | { |
||
548 | $this->duration = $duration; |
||
549 | |||
550 | return $this; |
||
551 | } |
||
552 | |||
553 | public function isExportAllowed(): bool |
||
554 | { |
||
555 | return $this->exportAllowed; |
||
556 | } |
||
557 | |||
558 | public function setExportAllowed(bool $exportAllowed): self |
||
559 | { |
||
560 | $this->exportAllowed = $exportAllowed; |
||
561 | |||
562 | return $this; |
||
563 | } |
||
564 | } |
||
565 |