Passed
Push — master ( 5299ad...064cf0 )
by Yannick
16:41 queued 06:10
created

CQuizAnswer::setCorrect()   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
declare(strict_types=1);
6
7
namespace Chamilo\CourseBundle\Entity;
8
9
use Doctrine\ORM\Mapping as ORM;
10
use Symfony\Component\Validator\Constraints as Assert;
11
12
/**
13
 * CQuizAnswer.
14
 */
15
#[ORM\Table(name: 'c_quiz_answer')]
16
#[ORM\Index(columns: ['question_id'], name: 'idx_cqa_q')]
17
#[ORM\Entity]
18
class CQuizAnswer
19
{
20
    #[ORM\Column(name: 'iid', type: 'integer', options: ['unsigned' => true])]
21
    #[ORM\Id]
22
    #[ORM\GeneratedValue]
23
    protected ?int $iid = null;
24
25
    #[Assert\NotBlank]
26
    #[ORM\ManyToOne(targetEntity: CQuizQuestion::class, cascade: ['persist'], inversedBy: 'answers')]
27
    #[ORM\JoinColumn(name: 'question_id', referencedColumnName: 'iid', onDelete: 'CASCADE')]
28
    protected CQuizQuestion $question;
29
30
    #[Assert\NotBlank]
31
    #[ORM\Column(name: 'answer', type: 'text', nullable: false)]
32
    protected string $answer;
33
34
    #[ORM\Column(name: 'correct', type: 'integer', nullable: true)]
35
    protected ?int $correct;
36
37
    #[ORM\Column(name: 'comment', type: 'text', nullable: true)]
38
    protected ?string $comment;
39
40
    #[ORM\Column(name: 'ponderation', type: 'float', precision: 6, scale: 2, nullable: false, options: ['default' => 0])]
41
    protected float $ponderation;
42
43
    #[ORM\Column(name: 'position', type: 'integer', nullable: false)]
44
    protected int $position;
45
46
    #[ORM\Column(name: 'hotspot_coordinates', type: 'text', nullable: true)]
47
    protected ?string $hotspotCoordinates;
48
49
    #[ORM\Column(name: 'hotspot_type', type: 'string', length: 40, nullable: true)]
50
    protected ?string $hotspotType;
51
52
    #[ORM\Column(name: 'answer_code', type: 'string', length: 10, nullable: true)]
53
    protected ?string $answerCode;
54
55
    public function __construct()
56
    {
57
        $this->answer = '';
58
        $this->correct = null;
59
        $this->comment = null;
60
        $this->ponderation = 0.0;
61
        $this->hotspotCoordinates = null;
62
        $this->hotspotType = null;
63
        $this->destination = null;
64
        $this->answerCode = null;
65
    }
66
67
    public function setAnswer(string $answer): self
68
    {
69
        $this->answer = $answer;
70
71
        return $this;
72
    }
73
74
    public function getAnswer(): string
75
    {
76
        return $this->answer;
77
    }
78
79
    public function setCorrect(int $correct): self
80
    {
81
        $this->correct = $correct;
82
83
        return $this;
84
    }
85
86
    public function getCorrect(): ?int
87
    {
88
        return $this->correct;
89
    }
90
91
    public function setComment(string $comment): self
92
    {
93
        $this->comment = $comment;
94
95
        return $this;
96
    }
97
98
    public function getComment(): ?string
99
    {
100
        return $this->comment;
101
    }
102
103
    public function setPonderation(float|string $weight): self
104
    {
105
        $this->ponderation = empty($weight) ? 0.0 : (float) $weight;
106
107
        return $this;
108
    }
109
110
    public function getPonderation(): float
111
    {
112
        return $this->ponderation;
113
    }
114
115
    public function setPosition(int $position): self
116
    {
117
        $this->position = $position;
118
119
        return $this;
120
    }
121
122
    public function getPosition(): int
123
    {
124
        return $this->position;
125
    }
126
127
    public function setHotspotCoordinates(?string $hotspotCoordinates): self
128
    {
129
        $this->hotspotCoordinates = $hotspotCoordinates;
130
131
        return $this;
132
    }
133
134
    public function getHotspotCoordinates(): ?string
135
    {
136
        return $this->hotspotCoordinates;
137
    }
138
139
    public function setHotspotType(?string $hotspotType): self
140
    {
141
        $this->hotspotType = $hotspotType;
142
143
        return $this;
144
    }
145
146
    public function getHotspotType(): ?string
147
    {
148
        return $this->hotspotType;
149
    }
150
151
    public function setAnswerCode(string $answerCode): self
152
    {
153
        $this->answerCode = $answerCode;
154
155
        return $this;
156
    }
157
158
    /**
159
     * Get answerCode.
160
     */
161
    public function getAnswerCode(): ?string
162
    {
163
        return $this->answerCode;
164
    }
165
166
    /**
167
     * Get iid.
168
     */
169
    public function getIid(): ?int
170
    {
171
        return $this->iid;
172
    }
173
174
    public function getQuestion(): CQuizQuestion
175
    {
176
        return $this->question;
177
    }
178
179
    public function setQuestion(CQuizQuestion $question): self
180
    {
181
        $this->question = $question;
182
183
        return $this;
184
    }
185
}
186