Completed
Push — master ( d9adeb...430d2c )
by
unknown
01:15 queued 37s
created

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