Completed
Push — master ( 76b5db...d28136 )
by Julito
13:35
created

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