Passed
Push — master ( 6ab346...5089a3 )
by Angel Fernando Quiroz
07:31
created

CLpItem::getDisplayOrder()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
rs 10
c 0
b 0
f 0
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(name: 'lp_id', columns: ['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
    public function __construct()
118
    {
119
        $this->children = new ArrayCollection();
120
        $this->path = '';
121
        $this->ref = '';
122
        $this->lvl = 0;
123
        $this->launchData = '';
124
        $this->description = '';
125
        $this->displayOrder = 0;
126
        $this->minScore = 0;
127
        $this->maxScore = 100.0;
128
    }
129
130
    public function __toString(): string
131
    {
132
        return $this->getIid().' '.$this->getTitle();
133
    }
134
135
    public function getIid(): ?int
136
    {
137
        return $this->iid;
138
    }
139
140
    public function setLp(CLp $lp): self
141
    {
142
        $this->lp = $lp;
143
144
        return $this;
145
    }
146
147
    public function getLp(): CLp
148
    {
149
        return $this->lp;
150
    }
151
152
    public function setItemType(string $itemType): self
153
    {
154
        $this->itemType = $itemType;
155
156
        return $this;
157
    }
158
159
    public function getItemType(): string
160
    {
161
        return $this->itemType;
162
    }
163
164
    public function setRef(string $ref): self
165
    {
166
        $this->ref = $ref;
167
168
        return $this;
169
    }
170
171
    public function getRef(): string
172
    {
173
        return $this->ref;
174
    }
175
176
    public function setTitle(string $title): self
177
    {
178
        $this->title = $title;
179
180
        return $this;
181
    }
182
183
    public function getTitle(): string
184
    {
185
        return $this->title;
186
    }
187
188
    public function setDescription(string $description): self
189
    {
190
        $this->description = $description;
191
192
        return $this;
193
    }
194
195
    public function getDescription(): ?string
196
    {
197
        return $this->description;
198
    }
199
200
    public function setPath(string $path): self
201
    {
202
        $this->path = $path;
203
204
        return $this;
205
    }
206
207
    /**
208
     * Get path.
209
     *
210
     * @return string
211
     */
212
    public function getPath()
213
    {
214
        return $this->path;
215
    }
216
217
    public function setMinScore(float $minScore): self
218
    {
219
        $this->minScore = $minScore;
220
221
        return $this;
222
    }
223
224
    /**
225
     * Get minScore.
226
     *
227
     * @return float
228
     */
229
    public function getMinScore()
230
    {
231
        return $this->minScore;
232
    }
233
234
    public function setMaxScore(float $maxScore): self
235
    {
236
        $this->maxScore = $maxScore;
237
238
        return $this;
239
    }
240
241
    /**
242
     * Get maxScore.
243
     *
244
     * @return float
245
     */
246
    public function getMaxScore()
247
    {
248
        return $this->maxScore;
249
    }
250
251
    public function setMasteryScore(float $masteryScore): self
252
    {
253
        $this->masteryScore = $masteryScore;
254
255
        return $this;
256
    }
257
258
    /**
259
     * Get masteryScore.
260
     *
261
     * @return float
262
     */
263
    public function getMasteryScore()
264
    {
265
        return $this->masteryScore;
266
    }
267
268
    public function setPreviousItemId(?int $previousItemId): self
269
    {
270
        $this->previousItemId = $previousItemId;
271
272
        return $this;
273
    }
274
275
    /**
276
     * Get previousItemId.
277
     *
278
     * @return int
279
     */
280
    public function getPreviousItemId()
281
    {
282
        return $this->previousItemId;
283
    }
284
285
    public function setNextItemId(?int $nextItemId): self
286
    {
287
        $this->nextItemId = $nextItemId;
288
289
        return $this;
290
    }
291
292
    /**
293
     * Get nextItemId.
294
     *
295
     * @return int
296
     */
297
    public function getNextItemId()
298
    {
299
        return $this->nextItemId;
300
    }
301
302
    public function setDisplayOrder(int $displayOrder): self
303
    {
304
        $this->displayOrder = $displayOrder;
305
306
        return $this;
307
    }
308
309
    /**
310
     * Get displayOrder.
311
     *
312
     * @return int
313
     */
314
    public function getDisplayOrder()
315
    {
316
        return $this->displayOrder;
317
    }
318
319
    public function setPrerequisite(string $prerequisite): self
320
    {
321
        $this->prerequisite = $prerequisite;
322
323
        return $this;
324
    }
325
326
    /**
327
     * Get prerequisite.
328
     *
329
     * @return string
330
     */
331
    public function getPrerequisite()
332
    {
333
        return $this->prerequisite;
334
    }
335
336
    public function setParameters(string $parameters): self
337
    {
338
        $this->parameters = $parameters;
339
340
        return $this;
341
    }
342
343
    /**
344
     * Get parameters.
345
     *
346
     * @return string
347
     */
348
    public function getParameters()
349
    {
350
        return $this->parameters;
351
    }
352
353
    public function setLaunchData(string $launchData): self
354
    {
355
        $this->launchData = $launchData;
356
357
        return $this;
358
    }
359
360
    /**
361
     * Get launchData.
362
     *
363
     * @return string
364
     */
365
    public function getLaunchData()
366
    {
367
        return $this->launchData;
368
    }
369
370
    public function setMaxTimeAllowed(string $maxTimeAllowed): self
371
    {
372
        $this->maxTimeAllowed = $maxTimeAllowed;
373
374
        return $this;
375
    }
376
377
    /**
378
     * Get maxTimeAllowed.
379
     *
380
     * @return string
381
     */
382
    public function getMaxTimeAllowed()
383
    {
384
        return $this->maxTimeAllowed;
385
    }
386
387
    public function setTerms(string $terms): self
388
    {
389
        $this->terms = $terms;
390
391
        return $this;
392
    }
393
394
    /**
395
     * Get terms.
396
     *
397
     * @return string
398
     */
399
    public function getTerms()
400
    {
401
        return $this->terms;
402
    }
403
404
    public function setSearchDid(int $searchDid): self
405
    {
406
        $this->searchDid = $searchDid;
407
408
        return $this;
409
    }
410
411
    /**
412
     * Get searchDid.
413
     *
414
     * @return int
415
     */
416
    public function getSearchDid()
417
    {
418
        return $this->searchDid;
419
    }
420
421
    public function setAudio(string $audio): self
422
    {
423
        $this->audio = $audio;
424
425
        return $this;
426
    }
427
428
    /**
429
     * Get audio.
430
     *
431
     * @return string
432
     */
433
    public function getAudio()
434
    {
435
        return $this->audio;
436
    }
437
438
    public function setPrerequisiteMinScore(float $prerequisiteMinScore): self
439
    {
440
        $this->prerequisiteMinScore = $prerequisiteMinScore;
441
442
        return $this;
443
    }
444
445
    /**
446
     * Get prerequisiteMinScore.
447
     *
448
     * @return float
449
     */
450
    public function getPrerequisiteMinScore()
451
    {
452
        return $this->prerequisiteMinScore;
453
    }
454
455
    public function setPrerequisiteMaxScore(float $prerequisiteMaxScore): self
456
    {
457
        $this->prerequisiteMaxScore = $prerequisiteMaxScore;
458
459
        return $this;
460
    }
461
462
    /**
463
     * Get prerequisiteMaxScore.
464
     *
465
     * @return float
466
     */
467
    public function getPrerequisiteMaxScore()
468
    {
469
        return $this->prerequisiteMaxScore;
470
    }
471
472
    public function getParentItemId(): int
473
    {
474
        if (null === $this->parent) {
475
            return 0;
476
        }
477
478
        return $this->getParent()->getIid();
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->getParent()->getIid() could return the type null which is incompatible with the type-hinted return integer. Consider adding an additional type-check to rule them out.
Loading history...
479
    }
480
481
    public function getParent(): ?self
482
    {
483
        return $this->parent;
484
    }
485
486
    public function setParent(?self $parent): self
487
    {
488
        $this->parent = $parent;
489
490
        return $this;
491
    }
492
493
    /**
494
     * @return CLpItem[]|Collection
495
     */
496
    public function getChildren(): array|Collection
497
    {
498
        return $this->children;
499
    }
500
501
    /**
502
     * @param CLpItem[]|Collection $children
503
     */
504
    public function setChildren(array|Collection $children): self
505
    {
506
        $this->children = $children;
507
508
        return $this;
509
    }
510
511
    public function getLvl(): ?int
512
    {
513
        return $this->lvl;
514
    }
515
516
    public function setLvl(int $lvl): self
517
    {
518
        $this->lvl = $lvl;
519
520
        return $this;
521
    }
522
523
    public function getRoot(): ?CLpItem
524
    {
525
        return $this->root;
526
    }
527
528
    public function setRoot(?CLpItem $root): CLpItem
529
    {
530
        $this->root = $root;
531
532
        return $this;
533
    }
534
}
535