Passed
Push — master ( b9a35c...ab20b0 )
by Julito
15:41
created

CStudentPublication::getCorrection()   A

Complexity

Conditions 4
Paths 3

Size

Total Lines 12
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 4
eloc 6
c 0
b 0
f 0
nc 3
nop 0
dl 0
loc 12
rs 10
1
<?php
2
3
/* For licensing terms, see /license.txt */
4
5
namespace Chamilo\CourseBundle\Entity;
6
7
use Chamilo\CoreBundle\Entity\AbstractResource;
8
use Chamilo\CoreBundle\Entity\ResourceInterface;
9
use Chamilo\CoreBundle\Entity\ResourceNode;
10
use Chamilo\CoreBundle\Entity\Session;
11
use Doctrine\ORM\Mapping as ORM;
12
use Symfony\Component\Validator\Constraints as Assert;
13
14
/**
15
 * CStudentPublication.
16
 *
17
 * @ORM\Table(
18
 *  name="c_student_publication",
19
 *  indexes={
20
 *      @ORM\Index(name="course", columns={"c_id"}),
21
 *      @ORM\Index(name="session_id", columns={"session_id"}),
22
 *      @ORM\Index(name="idx_csp_u", columns={"user_id"})
23
 *  }
24
 * )
25
 * @ORM\Entity()
26
 */
27
class CStudentPublication extends AbstractResource implements ResourceInterface
28
{
29
    /**
30
     * @var int
31
     *
32
     * @ORM\Column(name="iid", type="integer")
33
     * @ORM\Id
34
     * @ORM\GeneratedValue
35
     */
36
    protected $iid;
37
38
    /**
39
     * @var string
40
     * @Assert\NotBlank()
41
     * @ORM\Column(name="title", type="string", length=255, nullable=true)
42
     */
43
    protected $title;
44
45
    /**
46
     * @var int
47
     *
48
     * @ORM\Column(name="c_id", type="integer")
49
     */
50
    protected $cId;
51
52
    /**
53
     * @var string
54
     *
55
     * @ORM\Column(name="url", type="string", length=500, nullable=true)
56
     */
57
    protected $url;
58
59
    /**
60
     * @var string
61
     *
62
     * @ORM\Column(name="url_correction", type="string", length=500, nullable=true)
63
     */
64
    protected $urlCorrection;
65
66
    /**
67
     * @var string
68
     *
69
     * @ORM\Column(name="title_correction", type="string", length=255, nullable=true)
70
     */
71
    protected $titleCorrection;
72
73
    /**
74
     * @var string
75
     *
76
     * @ORM\Column(name="description", type="text", nullable=true)
77
     */
78
    protected $description;
79
80
    /**
81
     * @var string
82
     *
83
     * @ORM\Column(name="author", type="string", length=255, nullable=true)
84
     */
85
    protected $author;
86
87
    /**
88
     * @var bool
89
     *
90
     * @ORM\Column(name="active", type="integer", nullable=true)
91
     */
92
    protected $active;
93
94
    /**
95
     * @var bool
96
     *
97
     * @ORM\Column(name="accepted", type="boolean", nullable=true)
98
     */
99
    protected $accepted;
100
101
    /**
102
     * @var int
103
     *
104
     * @ORM\Column(name="post_group_id", type="integer", nullable=false)
105
     */
106
    protected $postGroupId;
107
108
    /**
109
     * @var \DateTime
110
     *
111
     * @ORM\Column(name="sent_date", type="datetime", nullable=true)
112
     */
113
    protected $sentDate;
114
115
    /**
116
     * @var string
117
     *
118
     * @ORM\Column(name="filetype", type="string", length=10, nullable=false)
119
     */
120
    protected $filetype;
121
122
    /**
123
     * @var int
124
     *
125
     * @ORM\Column(name="has_properties", type="integer", nullable=false)
126
     */
127
    protected $hasProperties;
128
129
    /**
130
     * @var bool
131
     *
132
     * @ORM\Column(name="view_properties", type="boolean", nullable=true)
133
     */
134
    protected $viewProperties;
135
136
    /**
137
     * @var float
138
     *
139
     * @ORM\Column(name="qualification", type="float", precision=6, scale=2, nullable=false)
140
     */
141
    protected $qualification;
142
143
    /**
144
     * @var \DateTime
145
     *
146
     * @ORM\Column(name="date_of_qualification", type="datetime", nullable=true)
147
     */
148
    protected $dateOfQualification;
149
150
    /**
151
     * @var int
152
     *
153
     * @ORM\Column(name="parent_id", type="integer", nullable=false)
154
     */
155
    protected $parentId;
156
157
    /**
158
     * @var int
159
     *
160
     * @ORM\Column(name="qualificator_id", type="integer", nullable=false)
161
     */
162
    protected $qualificatorId;
163
164
    /**
165
     * @var float
166
     *
167
     * @ORM\Column(name="weight", type="float", precision=6, scale=2, nullable=false)
168
     */
169
    protected $weight;
170
171
    /**
172
     * @var Session
173
     * @ORM\ManyToOne(targetEntity="Chamilo\CoreBundle\Entity\Session", inversedBy="studentPublications")
174
     * @ORM\JoinColumn(name="session_id", referencedColumnName="id")
175
     */
176
    protected $session;
177
178
    /**
179
     * @var int
180
     *
181
     * @ORM\Column(name="user_id", type="integer", nullable=false)
182
     */
183
    protected $userId;
184
185
    /**
186
     * @var int
187
     *
188
     * @ORM\Column(name="allow_text_assignment", type="integer", nullable=false)
189
     */
190
    protected $allowTextAssignment;
191
192
    /**
193
     * @var int
194
     *
195
     * @ORM\Column(name="contains_file", type="integer", nullable=false)
196
     */
197
    protected $containsFile;
198
199
    /**
200
     * @var int
201
     *
202
     * @ORM\Column(name="document_id", type="integer", nullable=false)
203
     */
204
    protected $documentId;
205
206
    /**
207
     * @var int
208
     *
209
     * @ORM\Column(name="filesize", type="integer", nullable=true)
210
     */
211
    protected $fileSize;
212
213
    public function __construct()
214
    {
215
        $this->documentId = 0;
216
        $this->hasProperties = 0;
217
        $this->containsFile = 0;
218
        $this->parentId = 0;
219
        $this->qualificatorId = 0;
220
        $this->qualification = 0;
221
        $this->sentDate = new \DateTime();
222
    }
223
224
    public function __toString(): string
225
    {
226
        return (string) $this->getTitle();
227
    }
228
229
    /**
230
     * Set url.
231
     *
232
     * @param string $url
233
     *
234
     * @return CStudentPublication
235
     */
236
    public function setUrl($url)
237
    {
238
        $this->url = $url;
239
240
        return $this;
241
    }
242
243
    /**
244
     * Get url.
245
     *
246
     * @return string
247
     */
248
    public function getUrl()
249
    {
250
        return $this->url;
251
    }
252
253
    /**
254
     * Set title.
255
     *
256
     * @param string $title
257
     *
258
     * @return CStudentPublication
259
     */
260
    public function setTitle($title)
261
    {
262
        $this->title = $title;
263
264
        return $this;
265
    }
266
267
    /**
268
     * Get title.
269
     *
270
     * @return string
271
     */
272
    public function getTitle()
273
    {
274
        return $this->title;
275
    }
276
277
    /**
278
     * Set description.
279
     *
280
     * @param string $description
281
     *
282
     * @return CStudentPublication
283
     */
284
    public function setDescription($description)
285
    {
286
        $this->description = $description;
287
288
        return $this;
289
    }
290
291
    /**
292
     * Get description.
293
     *
294
     * @return string
295
     */
296
    public function getDescription()
297
    {
298
        return $this->description;
299
    }
300
301
    /**
302
     * Set author.
303
     *
304
     * @param string $author
305
     *
306
     * @return CStudentPublication
307
     */
308
    public function setAuthor($author)
309
    {
310
        $this->author = $author;
311
312
        return $this;
313
    }
314
315
    /**
316
     * Get author.
317
     *
318
     * @return string
319
     */
320
    public function getAuthor()
321
    {
322
        return $this->author;
323
    }
324
325
    /**
326
     * Set active.
327
     *
328
     * @param int $active
329
     *
330
     * @return CStudentPublication
331
     */
332
    public function setActive($active)
333
    {
334
        $this->active = (int) $active;
0 ignored issues
show
Documentation Bug introduced by
The property $active was declared of type boolean, but (int)$active is of type integer. Maybe add a type cast?

This check looks for assignments to scalar types that may be of the wrong type.

To ensure the code behaves as expected, it may be a good idea to add an explicit type cast.

$answer = 42;

$correct = false;

$correct = (bool) $answer;
Loading history...
335
336
        return $this;
337
    }
338
339
    /**
340
     * Get active.
341
     *
342
     * @return bool
343
     */
344
    public function getActive()
345
    {
346
        return $this->active;
347
    }
348
349
    /**
350
     * Set accepted.
351
     *
352
     * @param bool $accepted
353
     *
354
     * @return CStudentPublication
355
     */
356
    public function setAccepted($accepted)
357
    {
358
        $this->accepted = $accepted;
359
360
        return $this;
361
    }
362
363
    /**
364
     * Get accepted.
365
     *
366
     * @return bool
367
     */
368
    public function getAccepted()
369
    {
370
        return $this->accepted;
371
    }
372
373
    /**
374
     * Set postGroupId.
375
     *
376
     * @param int $postGroupId
377
     *
378
     * @return CStudentPublication
379
     */
380
    public function setPostGroupId($postGroupId)
381
    {
382
        $this->postGroupId = $postGroupId;
383
384
        return $this;
385
    }
386
387
    /**
388
     * Get postGroupId.
389
     *
390
     * @return int
391
     */
392
    public function getPostGroupId()
393
    {
394
        return $this->postGroupId;
395
    }
396
397
    /**
398
     * Set sentDate.
399
     *
400
     * @param \DateTime $sentDate
401
     *
402
     * @return CStudentPublication
403
     */
404
    public function setSentDate($sentDate)
405
    {
406
        $this->sentDate = $sentDate;
407
408
        return $this;
409
    }
410
411
    /**
412
     * Get sentDate.
413
     *
414
     * @return \DateTime
415
     */
416
    public function getSentDate()
417
    {
418
        return $this->sentDate;
419
    }
420
421
    /**
422
     * Set filetype.
423
     *
424
     * @param string $filetype
425
     *
426
     * @return CStudentPublication
427
     */
428
    public function setFiletype($filetype)
429
    {
430
        $this->filetype = $filetype;
431
432
        return $this;
433
    }
434
435
    /**
436
     * Get filetype.
437
     *
438
     * @return string
439
     */
440
    public function getFiletype()
441
    {
442
        return $this->filetype;
443
    }
444
445
    /**
446
     * Set hasProperties.
447
     *
448
     * @param int $hasProperties
449
     *
450
     * @return CStudentPublication
451
     */
452
    public function setHasProperties($hasProperties)
453
    {
454
        $this->hasProperties = $hasProperties;
455
456
        return $this;
457
    }
458
459
    /**
460
     * Get hasProperties.
461
     *
462
     * @return int
463
     */
464
    public function getHasProperties()
465
    {
466
        return $this->hasProperties;
467
    }
468
469
    /**
470
     * Set viewProperties.
471
     *
472
     * @param bool $viewProperties
473
     *
474
     * @return CStudentPublication
475
     */
476
    public function setViewProperties($viewProperties)
477
    {
478
        $this->viewProperties = $viewProperties;
479
480
        return $this;
481
    }
482
483
    /**
484
     * Get viewProperties.
485
     *
486
     * @return bool
487
     */
488
    public function getViewProperties()
489
    {
490
        return $this->viewProperties;
491
    }
492
493
    /**
494
     * Set qualification.
495
     *
496
     * @param float $qualification
497
     *
498
     * @return CStudentPublication
499
     */
500
    public function setQualification($qualification)
501
    {
502
        $this->qualification = $qualification;
503
504
        return $this;
505
    }
506
507
    /**
508
     * Get qualification.
509
     *
510
     * @return float
511
     */
512
    public function getQualification()
513
    {
514
        return $this->qualification;
515
    }
516
517
    /**
518
     * Set dateOfQualification.
519
     *
520
     * @param \DateTime $dateOfQualification
521
     *
522
     * @return CStudentPublication
523
     */
524
    public function setDateOfQualification($dateOfQualification)
525
    {
526
        $this->dateOfQualification = $dateOfQualification;
527
528
        return $this;
529
    }
530
531
    /**
532
     * Get dateOfQualification.
533
     *
534
     * @return \DateTime
535
     */
536
    public function getDateOfQualification()
537
    {
538
        return $this->dateOfQualification;
539
    }
540
541
    /**
542
     * Set parentId.
543
     *
544
     * @param int $parentId
545
     *
546
     * @return CStudentPublication
547
     */
548
    public function setParentId($parentId)
549
    {
550
        $this->parentId = $parentId;
551
552
        return $this;
553
    }
554
555
    /**
556
     * Get parentId.
557
     *
558
     * @return int
559
     */
560
    public function getParentId()
561
    {
562
        return $this->parentId;
563
    }
564
565
    /**
566
     * Set qualificatorId.
567
     *
568
     * @param int $qualificatorId
569
     *
570
     * @return CStudentPublication
571
     */
572
    public function setQualificatorId($qualificatorId)
573
    {
574
        $this->qualificatorId = $qualificatorId;
575
576
        return $this;
577
    }
578
579
    /**
580
     * Get qualificatorId.
581
     */
582
    public function getQualificatorId(): int
583
    {
584
        return (int) $this->qualificatorId;
585
    }
586
587
    /**
588
     * Set weight.
589
     *
590
     * @param float $weight
591
     *
592
     * @return CStudentPublication
593
     */
594
    public function setWeight($weight)
595
    {
596
        $this->weight = $weight;
597
598
        return $this;
599
    }
600
601
    /**
602
     * Get weight.
603
     *
604
     * @return float
605
     */
606
    public function getWeight()
607
    {
608
        return $this->weight;
609
    }
610
611
    /**
612
     * Set session.
613
     *
614
     * @param Session $session
615
     *
616
     * @return CStudentPublication
617
     */
618
    public function setSession(Session $session = null)
619
    {
620
        $this->session = $session;
621
622
        return $this;
623
    }
624
625
    /**
626
     * Get session.
627
     *
628
     * @return Session
629
     */
630
    public function getSession()
631
    {
632
        return $this->session;
633
    }
634
635
    /**
636
     * Set userId.
637
     *
638
     * @param int $userId
639
     *
640
     * @return CStudentPublication
641
     */
642
    public function setUserId($userId)
643
    {
644
        $this->userId = $userId;
645
646
        return $this;
647
    }
648
649
    /**
650
     * Get userId.
651
     *
652
     * @return int
653
     */
654
    public function getUserId()
655
    {
656
        return $this->userId;
657
    }
658
659
    /**
660
     * Set allowTextAssignment.
661
     *
662
     * @param int $allowTextAssignment
663
     *
664
     * @return CStudentPublication
665
     */
666
    public function setAllowTextAssignment($allowTextAssignment)
667
    {
668
        $this->allowTextAssignment = $allowTextAssignment;
669
670
        return $this;
671
    }
672
673
    /**
674
     * Get allowTextAssignment.
675
     *
676
     * @return int
677
     */
678
    public function getAllowTextAssignment()
679
    {
680
        return $this->allowTextAssignment;
681
    }
682
683
    /**
684
     * Set containsFile.
685
     *
686
     * @param int $containsFile
687
     *
688
     * @return CStudentPublication
689
     */
690
    public function setContainsFile($containsFile)
691
    {
692
        $this->containsFile = $containsFile;
693
694
        return $this;
695
    }
696
697
    /**
698
     * Get containsFile.
699
     *
700
     * @return int
701
     */
702
    public function getContainsFile()
703
    {
704
        return $this->containsFile;
705
    }
706
707
    public function setCId(int $cId)
708
    {
709
        $this->cId = $cId;
710
711
        return $this;
712
    }
713
714
    /**
715
     * Get cId.
716
     *
717
     * @return int
718
     */
719
    public function getCId()
720
    {
721
        return $this->cId;
722
    }
723
724
    /**
725
     * @return string
726
     */
727
    public function getUrlCorrection()
728
    {
729
        return $this->urlCorrection;
730
    }
731
732
    /**
733
     * @param string $urlCorrection
734
     */
735
    public function setUrlCorrection($urlCorrection)
736
    {
737
        $this->urlCorrection = $urlCorrection;
738
739
        return $this;
740
    }
741
742
    /**
743
     * @return string
744
     */
745
    public function getTitleCorrection()
746
    {
747
        return $this->titleCorrection;
748
    }
749
750
    /**
751
     * @param string $titleCorrection
752
     */
753
    public function setTitleCorrection($titleCorrection)
754
    {
755
        $this->titleCorrection = $titleCorrection;
756
757
        return $this;
758
    }
759
760
    /**
761
     * @return int
762
     */
763
    public function getDocumentId()
764
    {
765
        return $this->documentId;
766
    }
767
768
    /**
769
     * @param int $documentId
770
     */
771
    public function setDocumentId($documentId)
772
    {
773
        $this->documentId = $documentId;
774
775
        return $this;
776
    }
777
778
    /**
779
     * Get iid.
780
     *
781
     * @return int
782
     */
783
    public function getIid()
784
    {
785
        return $this->iid;
786
    }
787
788
    public function getFileSize(): int
789
    {
790
        return $this->fileSize;
791
    }
792
793
    public function setFileSize(int $fileSize): self
794
    {
795
        $this->fileSize = $fileSize;
796
797
        return $this;
798
    }
799
800
    public function getCorrection(): ?ResourceNode
801
    {
802
        if ($this->hasResourceNode()) {
803
            $children = $this->getResourceNode()->getChildren();
804
            foreach ($children as $child) {
805
                if ($child instanceof CStudentPublicationCorrection) {
806
                    return $child;
807
                }
808
            }
809
        }
810
811
        return null;
812
    }
813
814
    public function getResourceIdentifier(): int
815
    {
816
        return $this->getIid();
817
    }
818
819
    public function getResourceName(): string
820
    {
821
        return $this->getTitle();
822
    }
823
824
    public function setResourceName(string $name): self
825
    {
826
        return $this->setTitle($name);
827
    }
828
}
829