Passed
Push — master ( 727abb...ceefce )
by Yannick
07:55 queued 14s
created

CLp::getModifiedOn()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

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