Completed
Push — master ( 76a038...0c6f8d )
by Julito
10:18
created

CQuiz::getExerciseCategory()   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
nop 0
dl 0
loc 3
rs 10
c 1
b 0
f 0
nc 1
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\Course;
9
use Chamilo\CoreBundle\Entity\ResourceInterface;
10
use Chamilo\CourseBundle\Traits\ShowCourseResourcesInSessionTrait;
11
use Doctrine\ORM\Event\LifecycleEventArgs;
12
use Doctrine\ORM\Mapping as ORM;
13
use Symfony\Component\Validator\Constraints as Assert;
14
15
/**
16
 * CQuiz.
17
 *
18
 * @ORM\Table(
19
 *  name="c_quiz",
20
 *  indexes={
21
 *      @ORM\Index(name="course", columns={"c_id"}),
22
 *      @ORM\Index(name="session_id", columns={"session_id"})
23
 *  }
24
 * )
25
 * @ORM\Entity
26
 */
27
class CQuiz extends AbstractResource implements ResourceInterface
28
{
29
    use ShowCourseResourcesInSessionTrait;
30
31
    /**
32
     * @var int
33
     *
34
     * @ORM\Column(name="iid", type="integer")
35
     * @ORM\Id
36
     * @ORM\GeneratedValue
37
     */
38
    protected $iid;
39
40
    /**
41
     * @var int
42
     *
43
     * @ORM\Column(name="c_id", type="integer")
44
     */
45
    protected $cId;
46
47
    /**
48
     * @var string
49
     * @Assert\NotBlank()
50
     * @ORM\Column(name="title", type="text", nullable=false)
51
     */
52
    protected $title;
53
54
    /**
55
     * @var string
56
     *
57
     * @ORM\Column(name="description", type="text", nullable=true)
58
     */
59
    protected $description;
60
61
    /**
62
     * @var string
63
     *
64
     * @ORM\Column(name="sound", type="string", length=255, nullable=true)
65
     */
66
    protected $sound;
67
68
    /**
69
     * @var bool
70
     *
71
     * @ORM\Column(name="type", type="boolean", nullable=false)
72
     */
73
    protected $type;
74
75
    /**
76
     * @var int
77
     *
78
     * @ORM\Column(name="random", type="integer", nullable=false)
79
     */
80
    protected $random;
81
82
    /**
83
     * @var bool
84
     *
85
     * @ORM\Column(name="random_answers", type="boolean", nullable=false)
86
     */
87
    protected $randomAnswers;
88
89
    /**
90
     * @var bool
91
     *
92
     * @ORM\Column(name="active", type="boolean", nullable=false)
93
     */
94
    protected $active;
95
96
    /**
97
     * @var int
98
     *
99
     * @ORM\Column(name="results_disabled", type="integer", nullable=false)
100
     */
101
    protected $resultsDisabled;
102
103
    /**
104
     * @var string
105
     *
106
     * @ORM\Column(name="access_condition", type="text", nullable=true)
107
     */
108
    protected $accessCondition;
109
110
    /**
111
     * @var int
112
     *
113
     * @ORM\Column(name="max_attempt", type="integer", nullable=false)
114
     */
115
    protected $maxAttempt;
116
117
    /**
118
     * @var \DateTime
119
     *
120
     * @ORM\Column(name="start_time", type="datetime", nullable=true)
121
     */
122
    protected $startTime;
123
124
    /**
125
     * @var \DateTime
126
     *
127
     * @ORM\Column(name="end_time", type="datetime", nullable=true)
128
     */
129
    protected $endTime;
130
131
    /**
132
     * @var int
133
     *
134
     * @ORM\Column(name="feedback_type", type="integer", nullable=false)
135
     */
136
    protected $feedbackType;
137
138
    /**
139
     * @var int
140
     *
141
     * @ORM\Column(name="expired_time", type="integer", nullable=false)
142
     */
143
    protected $expiredTime;
144
145
    /**
146
     * @var int
147
     *
148
     * @ORM\Column(name="session_id", type="integer", nullable=true)
149
     */
150
    protected $sessionId;
151
152
    /**
153
     * @var int
154
     *
155
     * @ORM\Column(name="propagate_neg", type="integer", nullable=false)
156
     */
157
    protected $propagateNeg;
158
159
    /**
160
     * @var int
161
     *
162
     * @ORm\Column(name="save_correct_answers", type="integer", nullable=true)
163
     */
164
    protected $saveCorrectAnswers;
165
166
    /**
167
     * @var int
168
     *
169
     * @ORM\Column(name="review_answers", type="integer", nullable=false)
170
     */
171
    protected $reviewAnswers;
172
173
    /**
174
     * @var int
175
     *
176
     * @ORM\Column(name="random_by_category", type="integer", nullable=false)
177
     */
178
    protected $randomByCategory;
179
180
    /**
181
     * @var string
182
     *
183
     * @ORM\Column(name="text_when_finished", type="text", nullable=true)
184
     */
185
    protected $textWhenFinished;
186
187
    /**
188
     * @var int
189
     *
190
     * @ORM\Column(name="display_category_name", type="integer", nullable=false)
191
     */
192
    protected $displayCategoryName;
193
194
    /**
195
     * @var int
196
     *
197
     * @ORM\Column(name="pass_percentage", type="integer", nullable=true)
198
     */
199
    protected $passPercentage;
200
201
    /**
202
     * @var int
203
     *
204
     * @ORM\Column(name="prevent_backwards", type="integer", nullable=false, options={"default":0})
205
     */
206
    protected $preventBackwards;
207
208
    /**
209
     * @var int
210
     *
211
     * @ORM\Column(name="question_selection_type", type="integer", nullable=true)
212
     */
213
    protected $questionSelectionType;
214
215
    /**
216
     * @var bool
217
     *
218
     * @ORM\Column(name="hide_question_title", type="boolean", nullable=true)
219
     */
220
    protected $hideQuestionTitle;
221
222
    /**
223
     * @var CExerciseCategory
224
     *
225
     * @ORM\ManyToOne(targetEntity="Chamilo\CourseBundle\Entity\CExerciseCategory", cascade={"persist"})
226
     * @ORM\JoinColumn(name="exercise_category_id", referencedColumnName="id", onDelete="SET NULL")
227
     */
228
    protected $exerciseCategory;
229
230
    /**
231
     * @var bool
232
     *
233
     * @ORM\Column(name="show_previous_button", type="boolean", nullable=true, options={"default":1})
234
     */
235
    protected $showPreviousButton;
236
237
    /**
238
     * @var string
239
     *
240
     * @ORM\Column(name="notifications", type="string", length=255, nullable=true)
241
     */
242
    protected $notifications;
243
244
    /**
245
     * @var bool
246
     *
247
     * @ORM\Column(name="autolaunch", type="boolean", nullable=true, options={"default":0})
248
     */
249
    protected $autoLaunch;
250
251
    /**
252
     * @var int
253
     *
254
     * @ORM\Column(name="page_result_configuration", type="array", nullable=true)
255
     */
256
    protected $pageResultConfiguration;
257
258
    /**
259
     * CQuiz constructor.
260
     */
261
    public function __construct()
262
    {
263
        $this->hideQuestionTitle = false;
264
        $this->showPreviousButton = true;
265
        $this->notifications = '';
266
        $this->autoLaunch = 0;
0 ignored issues
show
Documentation Bug introduced by
The property $autoLaunch was declared of type boolean, but 0 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...
267
        $this->preventBackwards = 0;
268
    }
269
270
    public function __toString(): string
271
    {
272
        return $this->getTitle();
273
    }
274
275
    /**
276
     * Set title.
277
     *
278
     * @param string $title
279
     *
280
     * @return CQuiz
281
     */
282
    public function setTitle($title)
283
    {
284
        $this->title = $title;
285
286
        return $this;
287
    }
288
289
    /**
290
     * Get title.
291
     *
292
     * @return string
293
     */
294
    public function getTitle()
295
    {
296
        return (string) $this->title;
297
    }
298
299
    /**
300
     * Set description.
301
     *
302
     * @param string $description
303
     *
304
     * @return CQuiz
305
     */
306
    public function setDescription($description)
307
    {
308
        $this->description = $description;
309
310
        return $this;
311
    }
312
313
    /**
314
     * Get description.
315
     *
316
     * @return string
317
     */
318
    public function getDescription()
319
    {
320
        return $this->description;
321
    }
322
323
    /**
324
     * Set sound.
325
     *
326
     * @param string $sound
327
     *
328
     * @return CQuiz
329
     */
330
    public function setSound($sound)
331
    {
332
        $this->sound = $sound;
333
334
        return $this;
335
    }
336
337
    /**
338
     * Get sound.
339
     *
340
     * @return string
341
     */
342
    public function getSound()
343
    {
344
        return $this->sound;
345
    }
346
347
    /**
348
     * Set type.
349
     *
350
     * @param bool $type
351
     *
352
     * @return CQuiz
353
     */
354
    public function setType($type)
355
    {
356
        $this->type = $type;
357
358
        return $this;
359
    }
360
361
    /**
362
     * Get type.
363
     *
364
     * @return bool
365
     */
366
    public function getType()
367
    {
368
        return $this->type;
369
    }
370
371
    /**
372
     * Set random.
373
     *
374
     * @param int $random
375
     *
376
     * @return CQuiz
377
     */
378
    public function setRandom($random)
379
    {
380
        $this->random = $random;
381
382
        return $this;
383
    }
384
385
    /**
386
     * Get random.
387
     *
388
     * @return int
389
     */
390
    public function getRandom()
391
    {
392
        return $this->random;
393
    }
394
395
    /**
396
     * Set randomAnswers.
397
     *
398
     * @param bool $randomAnswers
399
     *
400
     * @return CQuiz
401
     */
402
    public function setRandomAnswers($randomAnswers)
403
    {
404
        $this->randomAnswers = $randomAnswers;
405
406
        return $this;
407
    }
408
409
    /**
410
     * Get randomAnswers.
411
     *
412
     * @return bool
413
     */
414
    public function getRandomAnswers()
415
    {
416
        return $this->randomAnswers;
417
    }
418
419
    /**
420
     * Set active.
421
     *
422
     * @param bool $active
423
     *
424
     * @return CQuiz
425
     */
426
    public function setActive($active)
427
    {
428
        $this->active = $active;
429
430
        return $this;
431
    }
432
433
    /**
434
     * Get active.
435
     *
436
     * @return bool
437
     */
438
    public function getActive()
439
    {
440
        return $this->active;
441
    }
442
443
    /**
444
     * Set resultsDisabled.
445
     *
446
     * @param int $resultsDisabled
447
     *
448
     * @return CQuiz
449
     */
450
    public function setResultsDisabled($resultsDisabled)
451
    {
452
        $this->resultsDisabled = $resultsDisabled;
453
454
        return $this;
455
    }
456
457
    /**
458
     * Get resultsDisabled.
459
     *
460
     * @return int
461
     */
462
    public function getResultsDisabled()
463
    {
464
        return $this->resultsDisabled;
465
    }
466
467
    /**
468
     * Set accessCondition.
469
     *
470
     * @param string $accessCondition
471
     *
472
     * @return CQuiz
473
     */
474
    public function setAccessCondition($accessCondition)
475
    {
476
        $this->accessCondition = $accessCondition;
477
478
        return $this;
479
    }
480
481
    /**
482
     * Get accessCondition.
483
     *
484
     * @return string
485
     */
486
    public function getAccessCondition()
487
    {
488
        return $this->accessCondition;
489
    }
490
491
    /**
492
     * Set maxAttempt.
493
     *
494
     * @param int $maxAttempt
495
     *
496
     * @return CQuiz
497
     */
498
    public function setMaxAttempt($maxAttempt)
499
    {
500
        $this->maxAttempt = $maxAttempt;
501
502
        return $this;
503
    }
504
505
    /**
506
     * Get maxAttempt.
507
     *
508
     * @return int
509
     */
510
    public function getMaxAttempt()
511
    {
512
        return $this->maxAttempt;
513
    }
514
515
    /**
516
     * Set startTime.
517
     *
518
     * @param \DateTime $startTime
519
     *
520
     * @return CQuiz
521
     */
522
    public function setStartTime($startTime)
523
    {
524
        $this->startTime = $startTime;
525
526
        return $this;
527
    }
528
529
    /**
530
     * Get startTime.
531
     *
532
     * @return \DateTime
533
     */
534
    public function getStartTime()
535
    {
536
        return $this->startTime;
537
    }
538
539
    /**
540
     * Set endTime.
541
     *
542
     * @param \DateTime $endTime
543
     *
544
     * @return CQuiz
545
     */
546
    public function setEndTime($endTime)
547
    {
548
        $this->endTime = $endTime;
549
550
        return $this;
551
    }
552
553
    /**
554
     * Get endTime.
555
     *
556
     * @return \DateTime
557
     */
558
    public function getEndTime()
559
    {
560
        return $this->endTime;
561
    }
562
563
    /**
564
     * Set feedbackType.
565
     *
566
     * @param int $feedbackType
567
     *
568
     * @return CQuiz
569
     */
570
    public function setFeedbackType($feedbackType)
571
    {
572
        $this->feedbackType = $feedbackType;
573
574
        return $this;
575
    }
576
577
    /**
578
     * Get feedbackType.
579
     *
580
     * @return int
581
     */
582
    public function getFeedbackType()
583
    {
584
        return $this->feedbackType;
585
    }
586
587
    /**
588
     * Set expiredTime.
589
     *
590
     * @param int $expiredTime
591
     *
592
     * @return CQuiz
593
     */
594
    public function setExpiredTime($expiredTime)
595
    {
596
        $this->expiredTime = $expiredTime;
597
598
        return $this;
599
    }
600
601
    /**
602
     * Get expiredTime.
603
     *
604
     * @return int
605
     */
606
    public function getExpiredTime()
607
    {
608
        return $this->expiredTime;
609
    }
610
611
    /**
612
     * Set sessionId.
613
     *
614
     * @param int $sessionId
615
     *
616
     * @return CQuiz
617
     */
618
    public function setSessionId($sessionId)
619
    {
620
        $this->sessionId = $sessionId;
621
622
        return $this;
623
    }
624
625
    /**
626
     * Get sessionId.
627
     *
628
     * @return int
629
     */
630
    public function getSessionId()
631
    {
632
        return $this->sessionId;
633
    }
634
635
    /**
636
     * Set propagateNeg.
637
     *
638
     * @param int $propagateNeg
639
     *
640
     * @return CQuiz
641
     */
642
    public function setPropagateNeg($propagateNeg)
643
    {
644
        $this->propagateNeg = $propagateNeg;
645
646
        return $this;
647
    }
648
649
    /**
650
     * Get propagateNeg.
651
     *
652
     * @return int
653
     */
654
    public function getPropagateNeg()
655
    {
656
        return $this->propagateNeg;
657
    }
658
659
    /**
660
     * @param int $saveCorrectAnswers
661
     *
662
     * @return CQuiz
663
     */
664
    public function setSaveCorrectAnswers($saveCorrectAnswers)
665
    {
666
        $this->saveCorrectAnswers = $saveCorrectAnswers;
667
668
        return $this;
669
    }
670
671
    /**
672
     * @return int
673
     */
674
    public function getSaveCorrectAnswers()
675
    {
676
        return $this->saveCorrectAnswers;
677
    }
678
679
    /**
680
     * Set reviewAnswers.
681
     *
682
     * @param int $reviewAnswers
683
     *
684
     * @return CQuiz
685
     */
686
    public function setReviewAnswers($reviewAnswers)
687
    {
688
        $this->reviewAnswers = $reviewAnswers;
689
690
        return $this;
691
    }
692
693
    /**
694
     * Get reviewAnswers.
695
     *
696
     * @return int
697
     */
698
    public function getReviewAnswers()
699
    {
700
        return $this->reviewAnswers;
701
    }
702
703
    /**
704
     * Set randomByCategory.
705
     *
706
     * @param int $randomByCategory
707
     *
708
     * @return CQuiz
709
     */
710
    public function setRandomByCategory($randomByCategory)
711
    {
712
        $this->randomByCategory = $randomByCategory;
713
714
        return $this;
715
    }
716
717
    /**
718
     * Get randomByCategory.
719
     *
720
     * @return int
721
     */
722
    public function getRandomByCategory()
723
    {
724
        return $this->randomByCategory;
725
    }
726
727
    /**
728
     * Set textWhenFinished.
729
     *
730
     * @param string $textWhenFinished
731
     *
732
     * @return CQuiz
733
     */
734
    public function setTextWhenFinished($textWhenFinished)
735
    {
736
        $this->textWhenFinished = $textWhenFinished;
737
738
        return $this;
739
    }
740
741
    /**
742
     * Get textWhenFinished.
743
     *
744
     * @return string
745
     */
746
    public function getTextWhenFinished()
747
    {
748
        return $this->textWhenFinished;
749
    }
750
751
    /**
752
     * Set displayCategoryName.
753
     *
754
     * @param int $displayCategoryName
755
     *
756
     * @return CQuiz
757
     */
758
    public function setDisplayCategoryName($displayCategoryName)
759
    {
760
        $this->displayCategoryName = $displayCategoryName;
761
762
        return $this;
763
    }
764
765
    /**
766
     * Get displayCategoryName.
767
     *
768
     * @return int
769
     */
770
    public function getDisplayCategoryName()
771
    {
772
        return $this->displayCategoryName;
773
    }
774
775
    /**
776
     * Set passPercentage.
777
     *
778
     * @param int $passPercentage
779
     *
780
     * @return CQuiz
781
     */
782
    public function setPassPercentage($passPercentage)
783
    {
784
        $this->passPercentage = $passPercentage;
785
786
        return $this;
787
    }
788
789
    /**
790
     * Get passPercentage.
791
     *
792
     * @return int
793
     */
794
    public function getPassPercentage()
795
    {
796
        return $this->passPercentage;
797
    }
798
799
    /**
800
     * Set cId.
801
     *
802
     * @param int $cId
803
     *
804
     * @return CQuiz
805
     */
806
    public function setCId($cId)
807
    {
808
        $this->cId = $cId;
809
810
        return $this;
811
    }
812
813
    /**
814
     * Get cId.
815
     *
816
     * @return int
817
     */
818
    public function getCId()
819
    {
820
        return $this->cId;
821
    }
822
823
    /**
824
     * @return CExerciseCategory
825
     */
826
    public function getExerciseCategory(): ?CExerciseCategory
827
    {
828
        return $this->exerciseCategory;
829
    }
830
831
    public function setExerciseCategory(CExerciseCategory $exerciseCategory): self
832
    {
833
        $this->exerciseCategory = $exerciseCategory;
834
835
        return $this;
836
    }
837
838
    /**
839
     * @return int
840
     */
841
    public function getQuestionSelectionType()
842
    {
843
        return $this->questionSelectionType;
844
    }
845
846
    /**
847
     * @param int $questionSelectionType
848
     *
849
     * @return CQuiz
850
     */
851
    public function setQuestionSelectionType($questionSelectionType)
852
    {
853
        $this->questionSelectionType = $questionSelectionType;
854
855
        return $this;
856
    }
857
858
    /**
859
     * @return bool
860
     */
861
    public function isHideQuestionTitle()
862
    {
863
        return $this->hideQuestionTitle;
864
    }
865
866
    /**
867
     * @param bool $hideQuestionTitle
868
     *
869
     * @return CQuiz
870
     */
871
    public function setHideQuestionTitle($hideQuestionTitle)
872
    {
873
        $this->hideQuestionTitle = $hideQuestionTitle;
874
875
        return $this;
876
    }
877
878
    public function isShowPreviousButton(): bool
879
    {
880
        return $this->showPreviousButton;
881
    }
882
883
    public function setShowPreviousButton(bool $showPreviousButton): self
884
    {
885
        $this->showPreviousButton = $showPreviousButton;
886
887
        return $this;
888
    }
889
890
    public function getNotifications(): string
891
    {
892
        return $this->notifications;
893
    }
894
895
    public function setNotifications(string $notifications): self
896
    {
897
        $this->notifications = $notifications;
898
899
        return $this;
900
    }
901
902
    /**
903
     * @return int
904
     */
905
    public function getIid()
906
    {
907
        return $this->iid;
908
    }
909
910
    /**
911
     * @return int
912
     */
913
    public function getPreventBackwards(): int
914
    {
915
        return $this->preventBackwards;
916
    }
917
918
    public function setPreventBackwards(int $preventBackwards): self
919
    {
920
        $this->preventBackwards = $preventBackwards;
921
922
        return $this;
923
    }
924
925
    /**
926
     * @return bool
927
     */
928
    public function isAutoLaunch(): bool
929
    {
930
        return $this->autoLaunch;
931
    }
932
933
    public function setAutoLaunch(bool $autoLaunch): self
934
    {
935
        $this->autoLaunch = $autoLaunch;
936
937
        return $this;
938
    }
939
940
    public function getPageResultConfiguration(): int
941
    {
942
        return $this->pageResultConfiguration;
943
    }
944
945
    public function setPageResultConfiguration(int $pageResultConfiguration): self
946
    {
947
        $this->pageResultConfiguration = $pageResultConfiguration;
948
949
        return $this;
950
    }
951
952
    /**
953
     * @ORM\PostPersist()
954
     */
955
    public function postPersist(LifecycleEventArgs $args)
956
    {
957
    }
958
959
    /**
960
     * Resource identifier.
961
     */
962
    public function getResourceIdentifier(): int
963
    {
964
        return $this->getIid();
965
    }
966
967
    public function getResourceName(): string
968
    {
969
        return $this->getTitle();
970
    }
971
}
972