Completed
Push — master ( 38e61c...cd9a17 )
by Julito
14:03
created

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