Passed
Push — master ( 49b9ea...848f15 )
by Julito
10:24
created

CStudentPublication::setViewProperties()   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
/* 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="description", type="text", nullable=true)
63
     */
64
    protected $description;
65
66
    /**
67
     * @var string
68
     *
69
     * @ORM\Column(name="author", type="string", length=255, nullable=true)
70
     */
71
    protected $author;
72
73
    /**
74
     * @var bool
75
     *
76
     * @ORM\Column(name="active", type="integer", nullable=true)
77
     */
78
    protected $active;
79
80
    /**
81
     * @var bool
82
     *
83
     * @ORM\Column(name="accepted", type="boolean", nullable=true)
84
     */
85
    protected $accepted;
86
87
    /**
88
     * @var int
89
     *
90
     * @ORM\Column(name="post_group_id", type="integer", nullable=false)
91
     */
92
    protected $postGroupId;
93
94
    /**
95
     * @var \DateTime
96
     *
97
     * @ORM\Column(name="sent_date", type="datetime", nullable=true)
98
     */
99
    protected $sentDate;
100
101
    /**
102
     * @var string
103
     *
104
     * @ORM\Column(name="filetype", type="string", length=10, nullable=false)
105
     */
106
    protected $filetype;
107
108
    /**
109
     * @var int
110
     *
111
     * @ORM\Column(name="has_properties", type="integer", nullable=false)
112
     */
113
    protected $hasProperties;
114
115
    /**
116
     * @var bool
117
     *
118
     * @ORM\Column(name="view_properties", type="boolean", nullable=true)
119
     */
120
    protected $viewProperties;
121
122
    /**
123
     * @var float
124
     *
125
     * @ORM\Column(name="qualification", type="float", precision=6, scale=2, nullable=false)
126
     */
127
    protected $qualification;
128
129
    /**
130
     * @var \DateTime
131
     *
132
     * @ORM\Column(name="date_of_qualification", type="datetime", nullable=true)
133
     */
134
    protected $dateOfQualification;
135
136
    /**
137
     * @var int
138
     *
139
     * @ORM\Column(name="parent_id", type="integer", nullable=false)
140
     */
141
    protected $parentId;
142
143
    /**
144
     * @var int
145
     *
146
     * @ORM\Column(name="qualificator_id", type="integer", nullable=false)
147
     */
148
    protected $qualificatorId;
149
150
    /**
151
     * @var float
152
     *
153
     * @ORM\Column(name="weight", type="float", precision=6, scale=2, nullable=false)
154
     */
155
    protected $weight;
156
157
    /**
158
     * @var Session
159
     * @ORM\ManyToOne(targetEntity="Chamilo\CoreBundle\Entity\Session", inversedBy="studentPublications")
160
     * @ORM\JoinColumn(name="session_id", referencedColumnName="id")
161
     */
162
    protected $session;
163
164
    /**
165
     * @var int
166
     *
167
     * @ORM\Column(name="user_id", type="integer", nullable=false)
168
     */
169
    protected $userId;
170
171
    /**
172
     * @var int
173
     *
174
     * @ORM\Column(name="allow_text_assignment", type="integer", nullable=false)
175
     */
176
    protected $allowTextAssignment;
177
178
    /**
179
     * @var int
180
     *
181
     * @ORM\Column(name="contains_file", type="integer", nullable=false)
182
     */
183
    protected $containsFile;
184
185
    /**
186
     * @var int
187
     *
188
     * @ORM\Column(name="document_id", type="integer", nullable=false)
189
     */
190
    protected $documentId;
191
192
    /**
193
     * @var int
194
     *
195
     * @ORM\Column(name="filesize", type="integer", nullable=true)
196
     */
197
    protected $fileSize;
198
199
    public function __construct()
200
    {
201
        $this->documentId = 0;
202
        $this->hasProperties = 0;
203
        $this->containsFile = 0;
204
        $this->parentId = 0;
205
        $this->qualificatorId = 0;
206
        $this->qualification = 0;
207
        $this->sentDate = new \DateTime();
208
    }
209
210
    public function __toString(): string
211
    {
212
        return (string) $this->getTitle();
213
    }
214
215
    /**
216
     * Set url.
217
     *
218
     * @param string $url
219
     *
220
     * @return CStudentPublication
221
     */
222
    public function setUrl($url)
223
    {
224
        $this->url = $url;
225
226
        return $this;
227
    }
228
229
    /**
230
     * Get url.
231
     *
232
     * @return string
233
     */
234
    public function getUrl()
235
    {
236
        return $this->url;
237
    }
238
239
    /**
240
     * Set title.
241
     *
242
     * @param string $title
243
     *
244
     * @return CStudentPublication
245
     */
246
    public function setTitle($title)
247
    {
248
        $this->title = $title;
249
250
        return $this;
251
    }
252
253
    /**
254
     * Get title.
255
     *
256
     * @return string
257
     */
258
    public function getTitle()
259
    {
260
        return $this->title;
261
    }
262
263
    /**
264
     * Set description.
265
     *
266
     * @param string $description
267
     *
268
     * @return CStudentPublication
269
     */
270
    public function setDescription($description)
271
    {
272
        $this->description = $description;
273
274
        return $this;
275
    }
276
277
    /**
278
     * Get description.
279
     *
280
     * @return string
281
     */
282
    public function getDescription()
283
    {
284
        return $this->description;
285
    }
286
287
    /**
288
     * Set author.
289
     *
290
     * @param string $author
291
     *
292
     * @return CStudentPublication
293
     */
294
    public function setAuthor($author)
295
    {
296
        $this->author = $author;
297
298
        return $this;
299
    }
300
301
    /**
302
     * Get author.
303
     *
304
     * @return string
305
     */
306
    public function getAuthor()
307
    {
308
        return $this->author;
309
    }
310
311
    /**
312
     * Set active.
313
     *
314
     * @param int $active
315
     *
316
     * @return CStudentPublication
317
     */
318
    public function setActive($active)
319
    {
320
        $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...
321
322
        return $this;
323
    }
324
325
    /**
326
     * Get active.
327
     *
328
     * @return bool
329
     */
330
    public function getActive()
331
    {
332
        return $this->active;
333
    }
334
335
    /**
336
     * Set accepted.
337
     *
338
     * @param bool $accepted
339
     *
340
     * @return CStudentPublication
341
     */
342
    public function setAccepted($accepted)
343
    {
344
        $this->accepted = $accepted;
345
346
        return $this;
347
    }
348
349
    /**
350
     * Get accepted.
351
     *
352
     * @return bool
353
     */
354
    public function getAccepted()
355
    {
356
        return $this->accepted;
357
    }
358
359
    /**
360
     * Set postGroupId.
361
     *
362
     * @param int $postGroupId
363
     *
364
     * @return CStudentPublication
365
     */
366
    public function setPostGroupId($postGroupId)
367
    {
368
        $this->postGroupId = $postGroupId;
369
370
        return $this;
371
    }
372
373
    /**
374
     * Get postGroupId.
375
     *
376
     * @return int
377
     */
378
    public function getPostGroupId()
379
    {
380
        return $this->postGroupId;
381
    }
382
383
    /**
384
     * Set sentDate.
385
     *
386
     * @param \DateTime $sentDate
387
     *
388
     * @return CStudentPublication
389
     */
390
    public function setSentDate($sentDate)
391
    {
392
        $this->sentDate = $sentDate;
393
394
        return $this;
395
    }
396
397
    /**
398
     * Get sentDate.
399
     *
400
     * @return \DateTime
401
     */
402
    public function getSentDate()
403
    {
404
        return $this->sentDate;
405
    }
406
407
    /**
408
     * Set filetype.
409
     *
410
     * @param string $filetype
411
     *
412
     * @return CStudentPublication
413
     */
414
    public function setFiletype($filetype)
415
    {
416
        $this->filetype = $filetype;
417
418
        return $this;
419
    }
420
421
    /**
422
     * Get filetype.
423
     *
424
     * @return string
425
     */
426
    public function getFiletype()
427
    {
428
        return $this->filetype;
429
    }
430
431
    /**
432
     * Set hasProperties.
433
     *
434
     * @param int $hasProperties
435
     *
436
     * @return CStudentPublication
437
     */
438
    public function setHasProperties($hasProperties)
439
    {
440
        $this->hasProperties = $hasProperties;
441
442
        return $this;
443
    }
444
445
    /**
446
     * Get hasProperties.
447
     *
448
     * @return int
449
     */
450
    public function getHasProperties()
451
    {
452
        return $this->hasProperties;
453
    }
454
455
    /**
456
     * Set viewProperties.
457
     *
458
     * @param bool $viewProperties
459
     *
460
     * @return CStudentPublication
461
     */
462
    public function setViewProperties($viewProperties)
463
    {
464
        $this->viewProperties = $viewProperties;
465
466
        return $this;
467
    }
468
469
    /**
470
     * Get viewProperties.
471
     *
472
     * @return bool
473
     */
474
    public function getViewProperties()
475
    {
476
        return $this->viewProperties;
477
    }
478
479
    /**
480
     * Set qualification.
481
     *
482
     * @param float $qualification
483
     *
484
     * @return CStudentPublication
485
     */
486
    public function setQualification($qualification)
487
    {
488
        $this->qualification = $qualification;
489
490
        return $this;
491
    }
492
493
    /**
494
     * Get qualification.
495
     *
496
     * @return float
497
     */
498
    public function getQualification()
499
    {
500
        return $this->qualification;
501
    }
502
503
    /**
504
     * Set dateOfQualification.
505
     *
506
     * @param \DateTime $dateOfQualification
507
     *
508
     * @return CStudentPublication
509
     */
510
    public function setDateOfQualification($dateOfQualification)
511
    {
512
        $this->dateOfQualification = $dateOfQualification;
513
514
        return $this;
515
    }
516
517
    /**
518
     * Get dateOfQualification.
519
     *
520
     * @return \DateTime
521
     */
522
    public function getDateOfQualification()
523
    {
524
        return $this->dateOfQualification;
525
    }
526
527
    /**
528
     * Set parentId.
529
     *
530
     * @param int $parentId
531
     *
532
     * @return CStudentPublication
533
     */
534
    public function setParentId($parentId)
535
    {
536
        $this->parentId = $parentId;
537
538
        return $this;
539
    }
540
541
    /**
542
     * Get parentId.
543
     *
544
     * @return int
545
     */
546
    public function getParentId()
547
    {
548
        return $this->parentId;
549
    }
550
551
    /**
552
     * Set qualificatorId.
553
     *
554
     * @param int $qualificatorId
555
     *
556
     * @return CStudentPublication
557
     */
558
    public function setQualificatorId($qualificatorId)
559
    {
560
        $this->qualificatorId = $qualificatorId;
561
562
        return $this;
563
    }
564
565
    /**
566
     * Get qualificatorId.
567
     */
568
    public function getQualificatorId(): int
569
    {
570
        return (int) $this->qualificatorId;
571
    }
572
573
    /**
574
     * Set weight.
575
     *
576
     * @param float $weight
577
     *
578
     * @return CStudentPublication
579
     */
580
    public function setWeight($weight)
581
    {
582
        $this->weight = $weight;
583
584
        return $this;
585
    }
586
587
    /**
588
     * Get weight.
589
     *
590
     * @return float
591
     */
592
    public function getWeight()
593
    {
594
        return $this->weight;
595
    }
596
597
    /**
598
     * Set session.
599
     *
600
     * @param Session $session
601
     *
602
     * @return CStudentPublication
603
     */
604
    public function setSession(Session $session = null)
605
    {
606
        $this->session = $session;
607
608
        return $this;
609
    }
610
611
    /**
612
     * Get session.
613
     *
614
     * @return Session
615
     */
616
    public function getSession()
617
    {
618
        return $this->session;
619
    }
620
621
    /**
622
     * Set userId.
623
     *
624
     * @param int $userId
625
     *
626
     * @return CStudentPublication
627
     */
628
    public function setUserId($userId)
629
    {
630
        $this->userId = $userId;
631
632
        return $this;
633
    }
634
635
    /**
636
     * Get userId.
637
     *
638
     * @return int
639
     */
640
    public function getUserId()
641
    {
642
        return $this->userId;
643
    }
644
645
    /**
646
     * Set allowTextAssignment.
647
     *
648
     * @param int $allowTextAssignment
649
     *
650
     * @return CStudentPublication
651
     */
652
    public function setAllowTextAssignment($allowTextAssignment)
653
    {
654
        $this->allowTextAssignment = $allowTextAssignment;
655
656
        return $this;
657
    }
658
659
    /**
660
     * Get allowTextAssignment.
661
     *
662
     * @return int
663
     */
664
    public function getAllowTextAssignment()
665
    {
666
        return $this->allowTextAssignment;
667
    }
668
669
    /**
670
     * Set containsFile.
671
     *
672
     * @param int $containsFile
673
     *
674
     * @return CStudentPublication
675
     */
676
    public function setContainsFile($containsFile)
677
    {
678
        $this->containsFile = $containsFile;
679
680
        return $this;
681
    }
682
683
    /**
684
     * Get containsFile.
685
     *
686
     * @return int
687
     */
688
    public function getContainsFile()
689
    {
690
        return $this->containsFile;
691
    }
692
693
    public function setCId(int $cId)
694
    {
695
        $this->cId = $cId;
696
697
        return $this;
698
    }
699
700
    /**
701
     * Get cId.
702
     *
703
     * @return int
704
     */
705
    public function getCId()
706
    {
707
        return $this->cId;
708
    }
709
710
    /**
711
     * @return int
712
     */
713
    public function getDocumentId()
714
    {
715
        return $this->documentId;
716
    }
717
718
    /**
719
     * @param int $documentId
720
     */
721
    public function setDocumentId($documentId)
722
    {
723
        $this->documentId = $documentId;
724
725
        return $this;
726
    }
727
728
    /**
729
     * Get iid.
730
     *
731
     * @return int
732
     */
733
    public function getIid()
734
    {
735
        return $this->iid;
736
    }
737
738
    public function getFileSize(): int
739
    {
740
        return $this->fileSize;
741
    }
742
743
    public function setFileSize(int $fileSize): self
744
    {
745
        $this->fileSize = $fileSize;
746
747
        return $this;
748
    }
749
750
    public function getCorrection(): ?ResourceNode
751
    {
752
        if ($this->hasResourceNode()) {
753
            $children = $this->getResourceNode()->getChildren();
754
            foreach ($children as $child) {
755
                $name = $child->getResourceType()->getName();
756
                if ('student_publications_corrections' === $name) {
757
                    return $child;
758
                }
759
            }
760
        }
761
762
        return null;
763
    }
764
765
    public function getResourceIdentifier(): int
766
    {
767
        return $this->getIid();
768
    }
769
770
    public function getResourceName(): string
771
    {
772
        return $this->getTitle();
773
    }
774
775
    public function setResourceName(string $name): self
776
    {
777
        return $this->setTitle($name);
778
    }
779
}
780