Passed
Push — master ( 995eb2...f02a22 )
by Yannick
07:05 queued 43s
created

CLp::setPrerequisite()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 1
dl 0
loc 5
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\CoreBundle\Entity\AbstractResource;
10
use Chamilo\CoreBundle\Entity\Asset;
11
use Chamilo\CoreBundle\Entity\ResourceInterface;
12
use Chamilo\CoreBundle\Entity\ResourceShowCourseResourcesInSessionInterface;
13
use DateTime;
14
use Doctrine\Common\Collections\ArrayCollection;
15
use Doctrine\Common\Collections\Collection;
16
use Doctrine\ORM\Mapping as ORM;
17
use Gedmo\Mapping\Annotation as Gedmo;
18
use Symfony\Component\Validator\Constraints as Assert;
19
20
/**
21
 * Course learning paths (LPs).
22
 *
23
 * @ORM\Table(
24
 *     name="c_lp"
25
 * )
26
 * @ORM\Entity(repositoryClass="Chamilo\CourseBundle\Repository\CLpRepository")
27
 */
28
class CLp extends AbstractResource implements ResourceInterface, ResourceShowCourseResourcesInSessionInterface
29
{
30
    public const LP_TYPE = 1;
31
    public const SCORM_TYPE = 2;
32
    public const AICC_TYPE = 3;
33
34
    /**
35
     * @ORM\Column(name="iid", type="integer")
36
     * @ORM\Id
37
     * @ORM\GeneratedValue
38
     */
39
    protected int $iid;
40
41
    /**
42
     * @ORM\Column(name="lp_type", type="integer", nullable=false)
43
     */
44
    #[Assert\NotBlank]
45
    protected int $lpType;
46
47
    /**
48
     * @ORM\Column(name="name", type="string", length=255, nullable=false)
49
     */
50
    #[Assert\NotBlank]
51
    protected string $name;
52
53
    /**
54
     * @ORM\Column(name="ref", type="text", nullable=true)
55
     */
56
    protected ?string $ref = null;
57
58
    /**
59
     * @ORM\Column(name="description", type="text", nullable=true)
60
     */
61
    protected ?string $description;
62
63
    /**
64
     * @ORM\Column(name="path", type="text", nullable=false)
65
     */
66
    protected string $path;
67
68
    /**
69
     * @ORM\Column(name="force_commit", type="boolean", nullable=false)
70
     */
71
    protected bool $forceCommit;
72
73
    /**
74
     * @ORM\Column(name="default_view_mod", type="string", length=32, nullable=false, options={"default":"embedded"})
75
     */
76
    protected string $defaultViewMod;
77
78
    /**
79
     * @ORM\Column(name="default_encoding", type="string", length=32, nullable=false, options={"default":"UTF-8"})
80
     */
81
    protected string $defaultEncoding;
82
83
    /**
84
     * @ORM\Column(name="display_order", type="integer", nullable=false, options={"default":"0"})
85
     */
86
    protected int $displayOrder;
87
88
    /**
89
     * @ORM\Column(name="content_maker", type="text", nullable=false)
90
     */
91
    protected string $contentMaker;
92
93
    /**
94
     * @ORM\Column(name="content_local", type="string", length=32, nullable=false, options={"default":"local"})
95
     */
96
    protected string $contentLocal;
97
98
    /**
99
     * @ORM\Column(name="content_license", type="text", nullable=false)
100
     */
101
    protected string $contentLicense;
102
103
    /**
104
     * @ORM\Column(name="prevent_reinit", type="boolean", nullable=false, options={"default":"1"})
105
     */
106
    protected bool $preventReinit;
107
108
    /**
109
     * @ORM\Column(name="js_lib", type="text", nullable=false)
110
     */
111
    protected string $jsLib;
112
113
    /**
114
     * @ORM\Column(name="debug", type="boolean", nullable=false)
115
     */
116
    protected bool $debug;
117
118
    /**
119
     * @ORM\Column(name="theme", type="string", length=255, nullable=false)
120
     */
121
    #[Assert\NotBlank]
122
    protected string $theme;
123
124
    /**
125
     * @ORM\Column(name="author", type="text", nullable=false)
126
     */
127
    #[Assert\NotBlank]
128
    protected string $author;
129
130
    /**
131
     * @ORM\Column(name="prerequisite", type="integer", nullable=false)
132
     */
133
    protected int $prerequisite;
134
135
    /**
136
     * @ORM\Column(name="hide_toc_frame", type="boolean", nullable=false)
137
     */
138
    protected bool $hideTocFrame;
139
140
    /**
141
     * @ORM\Column(name="seriousgame_mode", type="boolean", nullable=false)
142
     */
143
    protected bool $seriousgameMode;
144
145
    /**
146
     * @ORM\Column(name="use_max_score", type="integer", nullable=false, options={"default":"1"})
147
     */
148
    protected int $useMaxScore;
149
150
    /**
151
     * @ORM\Column(name="autolaunch", type="integer", nullable=false)
152
     */
153
    protected int $autolaunch;
154
155
    /**
156
     * @ORM\ManyToOne(targetEntity="Chamilo\CourseBundle\Entity\CLpCategory", inversedBy="lps")
157
     * @ORM\JoinColumn(name="category_id", referencedColumnName="iid")
158
     */
159
    protected ?CLpCategory $category = null;
160
161
    /**
162
     * @ORM\Column(name="max_attempts", type="integer", nullable=false)
163
     */
164
    protected int $maxAttempts;
165
166
    /**
167
     * @ORM\Column(name="subscribe_users", type="integer", nullable=false)
168
     */
169
    protected int $subscribeUsers;
170
171
    /**
172
     * @Gedmo\Timestampable(on="create")
173
     *
174
     * @ORM\Column(name="created_on", type="datetime", nullable=false)
175
     */
176
    protected DateTime $createdOn;
177
178
    /**
179
     * @Gedmo\Timestampable(on="update")
180
     *
181
     * @ORM\Column(name="modified_on", type="datetime", nullable=false)
182
     */
183
    protected DateTime $modifiedOn;
184
185
    /**
186
     * @ORM\Column(name="published_on", type="datetime", nullable=true)
187
     */
188
    protected ?DateTime $publishedOn;
189
190
    /**
191
     * @ORM\Column(name="expired_on", type="datetime", nullable=true)
192
     */
193
    protected ?DateTime $expiredOn = null;
194
195
    /**
196
     * @ORM\Column(name="accumulate_scorm_time", type="integer", nullable=false, options={"default":1})
197
     */
198
    protected int $accumulateScormTime;
199
200
    /**
201
     * @ORM\Column(name="accumulate_work_time", type="integer", nullable=false, options={"default":0})
202
     */
203
    protected int $accumulateWorkTime;
204
205
    /**
206
     * @ORM\OneToMany(targetEntity="Chamilo\CourseBundle\Entity\CLpItem", mappedBy="lp", cascade={"persist", "remove"}, orphanRemoval=true)
207
     */
208
    protected Collection $items;
209
210
    /**
211
     * @var Collection|CForum[]
212
     *
213
     * @ORM\OneToMany(targetEntity="Chamilo\CourseBundle\Entity\CForum", mappedBy="lp", cascade={"persist", "remove"})
214
     */
215
    protected Collection $forums;
216
217
    /**
218
     * @ORM\ManyToOne(targetEntity="Chamilo\CoreBundle\Entity\Asset", cascade={"persist", "remove"})
219
     * @ORM\JoinColumn(name="asset_id", referencedColumnName="id")
220
     */
221
    protected ?Asset $asset = null;
222
223
    public function __construct()
224
    {
225
        $now = new DateTime();
226
        $this->createdOn = $now;
227
        $this->modifiedOn = $now;
228
        $this->publishedOn = $now;
229
        $this->accumulateScormTime = 1;
230
        $this->accumulateWorkTime = 0;
231
        $this->author = '';
232
        $this->autolaunch = 0;
233
        $this->contentLocal = 'local';
234
        $this->contentMaker = 'chamilo';
235
        $this->contentLicense = '';
236
        $this->defaultEncoding = 'UTF-8';
237
        $this->defaultViewMod = 'embedded';
238
        $this->description = '';
239
        $this->displayOrder = 0;
240
        $this->debug = false;
241
        $this->forceCommit = false;
242
        $this->hideTocFrame = false;
243
        $this->jsLib = '';
244
        $this->maxAttempts = 0;
245
        $this->preventReinit = true;
246
        $this->path = '';
247
        $this->prerequisite = 0;
248
        $this->seriousgameMode = false;
249
        $this->subscribeUsers = 0;
250
        $this->useMaxScore = 1;
251
        $this->theme = '';
252
        $this->items = new ArrayCollection();
253
        $this->forums = new ArrayCollection();
254
    }
255
256
    public function __toString(): string
257
    {
258
        return $this->getName();
259
    }
260
261
    public function setLpType(int $lpType): self
262
    {
263
        $this->lpType = $lpType;
264
265
        return $this;
266
    }
267
268
    /**
269
     * Get lpType.
270
     *
271
     * @return int
272
     */
273
    public function getLpType()
274
    {
275
        return $this->lpType;
276
    }
277
278
    public function setName(string $name): self
279
    {
280
        $this->name = $name;
281
282
        return $this;
283
    }
284
285
    public function getName(): string
286
    {
287
        return $this->name;
288
    }
289
290
    public function setRef(string $ref): self
291
    {
292
        $this->ref = $ref;
293
294
        return $this;
295
    }
296
297
    /**
298
     * Get ref.
299
     *
300
     * @return string
301
     */
302
    public function getRef()
303
    {
304
        return $this->ref;
305
    }
306
307
    public function setDescription(string $description): self
308
    {
309
        $this->description = $description;
310
311
        return $this;
312
    }
313
314
    public function getDescription(): ?string
315
    {
316
        return $this->description;
317
    }
318
319
    public function setPath(string $path): self
320
    {
321
        $this->path = $path;
322
323
        return $this;
324
    }
325
326
    /**
327
     * Get path.
328
     *
329
     * @return string
330
     */
331
    public function getPath()
332
    {
333
        return $this->path;
334
    }
335
336
    public function setForceCommit(bool $forceCommit): self
337
    {
338
        $this->forceCommit = $forceCommit;
339
340
        return $this;
341
    }
342
343
    /**
344
     * Get forceCommit.
345
     *
346
     * @return bool
347
     */
348
    public function getForceCommit()
349
    {
350
        return $this->forceCommit;
351
    }
352
353
    public function setDefaultViewMod(string $defaultViewMod): self
354
    {
355
        $this->defaultViewMod = $defaultViewMod;
356
357
        return $this;
358
    }
359
360
    /**
361
     * Get defaultViewMod.
362
     *
363
     * @return string
364
     */
365
    public function getDefaultViewMod()
366
    {
367
        return $this->defaultViewMod;
368
    }
369
370
    public function setDefaultEncoding(string $defaultEncoding): self
371
    {
372
        $this->defaultEncoding = $defaultEncoding;
373
374
        return $this;
375
    }
376
377
    /**
378
     * Get defaultEncoding.
379
     *
380
     * @return string
381
     */
382
    public function getDefaultEncoding()
383
    {
384
        return $this->defaultEncoding;
385
    }
386
387
    public function setDisplayOrder(int $displayOrder): self
388
    {
389
        $this->displayOrder = $displayOrder;
390
391
        return $this;
392
    }
393
394
    /**
395
     * Get displayOrder.
396
     *
397
     * @return int
398
     */
399
    public function getDisplayOrder()
400
    {
401
        return $this->displayOrder;
402
    }
403
404
    public function setContentMaker(string $contentMaker): self
405
    {
406
        $this->contentMaker = $contentMaker;
407
408
        return $this;
409
    }
410
411
    /**
412
     * Get contentMaker.
413
     *
414
     * @return string
415
     */
416
    public function getContentMaker()
417
    {
418
        return $this->contentMaker;
419
    }
420
421
    public function setContentLocal(string $contentLocal): self
422
    {
423
        $this->contentLocal = $contentLocal;
424
425
        return $this;
426
    }
427
428
    /**
429
     * Get contentLocal.
430
     *
431
     * @return string
432
     */
433
    public function getContentLocal()
434
    {
435
        return $this->contentLocal;
436
    }
437
438
    public function setContentLicense(string $contentLicense): self
439
    {
440
        $this->contentLicense = $contentLicense;
441
442
        return $this;
443
    }
444
445
    /**
446
     * Get contentLicense.
447
     *
448
     * @return string
449
     */
450
    public function getContentLicense()
451
    {
452
        return $this->contentLicense;
453
    }
454
455
    public function setPreventReinit(bool $preventReinit): self
456
    {
457
        $this->preventReinit = $preventReinit;
458
459
        return $this;
460
    }
461
462
    /**
463
     * Get preventReinit.
464
     *
465
     * @return bool
466
     */
467
    public function getPreventReinit()
468
    {
469
        return $this->preventReinit;
470
    }
471
472
    public function setJsLib(string $jsLib): self
473
    {
474
        $this->jsLib = $jsLib;
475
476
        return $this;
477
    }
478
479
    /**
480
     * Get jsLib.
481
     *
482
     * @return string
483
     */
484
    public function getJsLib()
485
    {
486
        return $this->jsLib;
487
    }
488
489
    public function setDebug(bool $debug): self
490
    {
491
        $this->debug = $debug;
492
493
        return $this;
494
    }
495
496
    /**
497
     * Get debug.
498
     *
499
     * @return bool
500
     */
501
    public function getDebug()
502
    {
503
        return $this->debug;
504
    }
505
506
    public function setTheme(string $theme): self
507
    {
508
        $this->theme = $theme;
509
510
        return $this;
511
    }
512
513
    public function getTheme(): string
514
    {
515
        return $this->theme;
516
    }
517
518
    public function setAuthor(string $author): self
519
    {
520
        $this->author = $author;
521
522
        return $this;
523
    }
524
525
    public function getAuthor(): string
526
    {
527
        return $this->author;
528
    }
529
530
    public function setPrerequisite(int $prerequisite): self
531
    {
532
        $this->prerequisite = $prerequisite;
533
534
        return $this;
535
    }
536
537
    /**
538
     * Get prerequisite.
539
     *
540
     * @return int
541
     */
542
    public function getPrerequisite()
543
    {
544
        return $this->prerequisite;
545
    }
546
547
    public function setHideTocFrame(bool $hideTocFrame): self
548
    {
549
        $this->hideTocFrame = $hideTocFrame;
550
551
        return $this;
552
    }
553
554
    public function getHideTocFrame(): bool
555
    {
556
        return $this->hideTocFrame;
557
    }
558
559
    public function setSeriousgameMode(bool $seriousgameMode): self
560
    {
561
        $this->seriousgameMode = $seriousgameMode;
562
563
        return $this;
564
    }
565
566
    /**
567
     * Get seriousgameMode.
568
     *
569
     * @return bool
570
     */
571
    public function getSeriousgameMode()
572
    {
573
        return $this->seriousgameMode;
574
    }
575
576
    public function setUseMaxScore(int $useMaxScore): self
577
    {
578
        $this->useMaxScore = $useMaxScore;
579
580
        return $this;
581
    }
582
583
    /**
584
     * Get useMaxScore.
585
     *
586
     * @return int
587
     */
588
    public function getUseMaxScore()
589
    {
590
        return $this->useMaxScore;
591
    }
592
593
    public function setAutolaunch(int $autolaunch): self
594
    {
595
        $this->autolaunch = $autolaunch;
596
597
        return $this;
598
    }
599
600
    /**
601
     * Get autolaunch.
602
     *
603
     * @return int
604
     */
605
    public function getAutolaunch()
606
    {
607
        return $this->autolaunch;
608
    }
609
610
    public function setCreatedOn(DateTime $createdOn): self
611
    {
612
        $this->createdOn = $createdOn;
613
614
        return $this;
615
    }
616
617
    /**
618
     * Get createdOn.
619
     *
620
     * @return DateTime
621
     */
622
    public function getCreatedOn()
623
    {
624
        return $this->createdOn;
625
    }
626
627
    public function setModifiedOn(DateTime $modifiedOn): self
628
    {
629
        $this->modifiedOn = $modifiedOn;
630
631
        return $this;
632
    }
633
634
    /**
635
     * Get modifiedOn.
636
     *
637
     * @return DateTime
638
     */
639
    public function getModifiedOn()
640
    {
641
        return $this->modifiedOn;
642
    }
643
644
    public function setPublishedOn(DateTime $publishedOn): self
645
    {
646
        $this->publishedOn = $publishedOn;
647
648
        return $this;
649
    }
650
651
    public function getPublishedOn(): ?DateTime
652
    {
653
        return $this->publishedOn;
654
    }
655
656
    public function setExpiredOn(?DateTime $expiredOn): self
657
    {
658
        $this->expiredOn = $expiredOn;
659
660
        return $this;
661
    }
662
663
    public function getExpiredOn(): ?DateTime
664
    {
665
        return $this->expiredOn;
666
    }
667
668
    public function getCategory(): ?CLpCategory
669
    {
670
        return $this->category;
671
    }
672
673
    public function hasCategory(): bool
674
    {
675
        return null !== $this->category;
676
    }
677
678
    public function setCategory(CLpCategory $category = null): self
679
    {
680
        $this->category = $category;
681
682
        return $this;
683
    }
684
685
    public function getAccumulateScormTime(): int
686
    {
687
        return $this->accumulateScormTime;
688
    }
689
690
    public function setAccumulateScormTime(int $accumulateScormTime): self
691
    {
692
        $this->accumulateScormTime = $accumulateScormTime;
693
694
        return $this;
695
    }
696
697
    public function getAccumulateWorkTime(): int
698
    {
699
        return $this->accumulateWorkTime;
700
    }
701
702
    public function setAccumulateWorkTime(int $accumulateWorkTime): self
703
    {
704
        $this->accumulateWorkTime = $accumulateWorkTime;
705
706
        return $this;
707
    }
708
709
    public function getMaxAttempts(): int
710
    {
711
        return $this->maxAttempts;
712
    }
713
714
    /**
715
     * @return CLpItem[]|Collection
716
     */
717
    public function getItems()
718
    {
719
        return $this->items;
720
    }
721
722
    /**
723
     * Get iid.
724
     *
725
     * @return int
726
     */
727
    public function getIid()
728
    {
729
        return $this->iid;
730
    }
731
732
    /**
733
     * Get subscribeUsers.
734
     *
735
     * @return int
736
     */
737
    public function getSubscribeUsers()
738
    {
739
        return $this->subscribeUsers;
740
    }
741
742
    public function setSubscribeUsers(int $value): self
743
    {
744
        $this->subscribeUsers = $value;
745
746
        return $this;
747
    }
748
749
    /**
750
     * @return ArrayCollection|Collection|CForum[]
751
     */
752
    public function getForums()
753
    {
754
        return $this->forums;
755
    }
756
757
    /**
758
     * @param ArrayCollection|Collection $forums
759
     *
760
     * @return CLp
761
     */
762
    public function setForums($forums): self
763
    {
764
        $this->forums = $forums;
765
766
        return $this;
767
    }
768
769
    public function getAsset(): ?Asset
770
    {
771
        return $this->asset;
772
    }
773
774
    public function hasAsset(): bool
775
    {
776
        return null !== $this->asset;
777
    }
778
779
    public function setAsset(?Asset $asset): self
780
    {
781
        $this->asset = $asset;
782
783
        return $this;
784
    }
785
786
    public function getResourceIdentifier(): int
787
    {
788
        return $this->getIid();
789
    }
790
791
    public function getResourceName(): string
792
    {
793
        return $this->getName();
794
    }
795
796
    public function setResourceName(string $name): self
797
    {
798
        return $this->setName($name);
799
    }
800
}
801