Passed
Pull Request — master (#5834)
by
unknown
08:28
created

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