Completed
Push — master ( 00c715...0749eb )
by Julito
60:49 queued 31:35
created

CQuiz   D

Complexity

Total Complexity 57

Size/Duplication

Total Lines 840
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 0
loc 840
rs 4.1379
c 1
b 0
f 0
wmc 57
lcom 0
cbo 0

57 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 1
A setTitle() 0 6 1
A getTitle() 0 4 1
A setDescription() 0 6 1
A getDescription() 0 4 1
A setSound() 0 6 1
A getSound() 0 4 1
A setType() 0 6 1
A getType() 0 4 1
A setRandom() 0 6 1
A getRandom() 0 4 1
A setRandomAnswers() 0 6 1
A getRandomAnswers() 0 4 1
A setActive() 0 6 1
A getActive() 0 4 1
A setResultsDisabled() 0 6 1
A getResultsDisabled() 0 4 1
A setAccessCondition() 0 6 1
A getAccessCondition() 0 4 1
A setMaxAttempt() 0 6 1
A getMaxAttempt() 0 4 1
A setStartTime() 0 6 1
A getStartTime() 0 4 1
A setEndTime() 0 6 1
A getEndTime() 0 4 1
A setFeedbackType() 0 6 1
A getFeedbackType() 0 4 1
A setExpiredTime() 0 6 1
A getExpiredTime() 0 4 1
A setSessionId() 0 6 1
A getSessionId() 0 4 1
A setPropagateNeg() 0 6 1
A getPropagateNeg() 0 4 1
A setSaveCorrectAnswers() 0 6 1
A getSaveCorrectAnswers() 0 4 1
A setReviewAnswers() 0 6 1
A getReviewAnswers() 0 4 1
A setRandomByCategory() 0 6 1
A getRandomByCategory() 0 4 1
A setTextWhenFinished() 0 6 1
A getTextWhenFinished() 0 4 1
A setDisplayCategoryName() 0 6 1
A getDisplayCategoryName() 0 4 1
A setPassPercentage() 0 6 1
A getPassPercentage() 0 4 1
A setId() 0 6 1
A getId() 0 4 1
A setCId() 0 6 1
A getCId() 0 4 1
A getQuestionSelectionType() 0 4 1
A setQuestionSelectionType() 0 6 1
A isHideQuestionTitle() 0 4 1
A setHideQuestionTitle() 0 6 1
A isShowPreviousButton() 0 4 1
A setShowPreviousButton() 0 6 1
A getNotifications() 0 4 1
A setNotifications() 0 6 1

How to fix   Complexity   

Complex Class

Complex classes like CQuiz often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes. You can also have a look at the cohesion graph to spot any un-connected, or weakly-connected components.

Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.

While breaking up the class, it is a good idea to analyze how other classes use CQuiz, and based on these observations, apply Extract Interface, too.

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