|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
|
4
|
|
|
|
|
5
|
|
|
/* For licensing terms, see /license.txt */ |
|
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( |
|
16
|
|
|
* name="c_quiz_answer", |
|
17
|
|
|
* indexes={ |
|
18
|
|
|
* @ORM\Index(name="idx_cqa_q", columns={"question_id"}), |
|
19
|
|
|
* } |
|
20
|
|
|
* ) |
|
21
|
|
|
* @ORM\Entity |
|
22
|
|
|
*/ |
|
23
|
|
|
class CQuizAnswer |
|
24
|
|
|
{ |
|
25
|
|
|
/** |
|
26
|
|
|
* @ORM\Column(name="iid", type="integer", options={"unsigned": true}) |
|
27
|
|
|
* @ORM\Id |
|
28
|
|
|
* @ORM\GeneratedValue |
|
29
|
|
|
*/ |
|
30
|
|
|
protected int $iid; |
|
31
|
|
|
|
|
32
|
|
|
/** |
|
33
|
|
|
* @Assert\NotBlank() |
|
34
|
|
|
* @ORM\ManyToOne(targetEntity="CQuizQuestion", inversedBy="answers", cascade={"persist"}) |
|
35
|
|
|
* @ORM\JoinColumn(name="question_id", referencedColumnName="iid", onDelete="CASCADE") |
|
36
|
|
|
*/ |
|
37
|
|
|
protected CQuizQuestion $question; |
|
38
|
|
|
|
|
39
|
|
|
/** |
|
40
|
|
|
* @Assert\NotBlank() |
|
41
|
|
|
* @ORM\Column(name="answer", type="text", nullable=false) |
|
42
|
|
|
*/ |
|
43
|
|
|
protected string $answer; |
|
44
|
|
|
|
|
45
|
|
|
/** |
|
46
|
|
|
* @ORM\Column(name="correct", type="integer", nullable=true) |
|
47
|
|
|
*/ |
|
48
|
|
|
protected ?int $correct; |
|
49
|
|
|
|
|
50
|
|
|
/** |
|
51
|
|
|
* @ORM\Column(name="comment", type="text", nullable=true) |
|
52
|
|
|
*/ |
|
53
|
|
|
protected ?string $comment; |
|
54
|
|
|
|
|
55
|
|
|
/** |
|
56
|
|
|
* @ORM\Column(name="ponderation", type="float", precision=6, scale=2, nullable=false, options={"default": 0}) |
|
57
|
|
|
*/ |
|
58
|
|
|
protected float $ponderation; |
|
59
|
|
|
|
|
60
|
|
|
/** |
|
61
|
|
|
* @ORM\Column(name="position", type="integer", nullable=false) |
|
62
|
|
|
*/ |
|
63
|
|
|
protected int $position; |
|
64
|
|
|
|
|
65
|
|
|
/** |
|
66
|
|
|
* @ORM\Column(name="hotspot_coordinates", type="text", nullable=true) |
|
67
|
|
|
*/ |
|
68
|
|
|
protected ?string $hotspotCoordinates; |
|
69
|
|
|
|
|
70
|
|
|
/** |
|
71
|
|
|
* @ORM\Column(name="hotspot_type", type="string", length=40, nullable=true) |
|
72
|
|
|
*/ |
|
73
|
|
|
protected ?string $hotspotType; |
|
74
|
|
|
|
|
75
|
|
|
/** |
|
76
|
|
|
* @ORM\Column(name="destination", type="text", nullable=true) |
|
77
|
|
|
*/ |
|
78
|
|
|
protected ?string $destination; |
|
79
|
|
|
|
|
80
|
|
|
/** |
|
81
|
|
|
* @ORM\Column(name="answer_code", type="string", length=10, nullable=true) |
|
82
|
|
|
*/ |
|
83
|
|
|
protected ?string $answerCode; |
|
84
|
|
|
|
|
85
|
|
|
public function __construct() |
|
86
|
|
|
{ |
|
87
|
|
|
$this->answer = ''; |
|
88
|
|
|
$this->correct = null; |
|
89
|
|
|
$this->comment = null; |
|
90
|
|
|
$this->ponderation = 0.0; |
|
91
|
|
|
$this->hotspotCoordinates = null; |
|
92
|
|
|
$this->hotspotType = null; |
|
93
|
|
|
$this->destination = null; |
|
94
|
|
|
$this->answerCode = null; |
|
95
|
|
|
} |
|
96
|
|
|
|
|
97
|
|
|
public function setAnswer(string $answer): self |
|
98
|
|
|
{ |
|
99
|
|
|
$this->answer = $answer; |
|
100
|
|
|
|
|
101
|
|
|
return $this; |
|
102
|
|
|
} |
|
103
|
|
|
|
|
104
|
|
|
public function getAnswer(): string |
|
105
|
|
|
{ |
|
106
|
|
|
return $this->answer; |
|
107
|
|
|
} |
|
108
|
|
|
|
|
109
|
|
|
public function setCorrect(int $correct): self |
|
110
|
|
|
{ |
|
111
|
|
|
$this->correct = $correct; |
|
112
|
|
|
|
|
113
|
|
|
return $this; |
|
114
|
|
|
} |
|
115
|
|
|
|
|
116
|
|
|
/** |
|
117
|
|
|
* Get correct. |
|
118
|
|
|
* |
|
119
|
|
|
* @return int |
|
120
|
|
|
*/ |
|
121
|
|
|
public function getCorrect() |
|
122
|
|
|
{ |
|
123
|
|
|
return $this->correct; |
|
124
|
|
|
} |
|
125
|
|
|
|
|
126
|
|
|
public function setComment(string $comment): self |
|
127
|
|
|
{ |
|
128
|
|
|
$this->comment = $comment; |
|
129
|
|
|
|
|
130
|
|
|
return $this; |
|
131
|
|
|
} |
|
132
|
|
|
|
|
133
|
|
|
/** |
|
134
|
|
|
* Get comment. |
|
135
|
|
|
* |
|
136
|
|
|
* @return string |
|
137
|
|
|
*/ |
|
138
|
|
|
public function getComment() |
|
139
|
|
|
{ |
|
140
|
|
|
return $this->comment; |
|
141
|
|
|
} |
|
142
|
|
|
|
|
143
|
|
|
public function setPonderation(float $weight): self |
|
144
|
|
|
{ |
|
145
|
|
|
$this->ponderation = empty($weight) ? 0.0 : (float) $weight; |
|
146
|
|
|
|
|
147
|
|
|
return $this; |
|
148
|
|
|
} |
|
149
|
|
|
|
|
150
|
|
|
/** |
|
151
|
|
|
* Get weight. |
|
152
|
|
|
* |
|
153
|
|
|
* @return float |
|
154
|
|
|
*/ |
|
155
|
|
|
public function getPonderation() |
|
156
|
|
|
{ |
|
157
|
|
|
return $this->ponderation; |
|
158
|
|
|
} |
|
159
|
|
|
|
|
160
|
|
|
public function setPosition(int $position): self |
|
161
|
|
|
{ |
|
162
|
|
|
$this->position = $position; |
|
163
|
|
|
|
|
164
|
|
|
return $this; |
|
165
|
|
|
} |
|
166
|
|
|
|
|
167
|
|
|
/** |
|
168
|
|
|
* Get position. |
|
169
|
|
|
* |
|
170
|
|
|
* @return int |
|
171
|
|
|
*/ |
|
172
|
|
|
public function getPosition() |
|
173
|
|
|
{ |
|
174
|
|
|
return $this->position; |
|
175
|
|
|
} |
|
176
|
|
|
|
|
177
|
|
|
public function setHotspotCoordinates(string $hotspotCoordinates): self |
|
178
|
|
|
{ |
|
179
|
|
|
$this->hotspotCoordinates = $hotspotCoordinates; |
|
180
|
|
|
|
|
181
|
|
|
return $this; |
|
182
|
|
|
} |
|
183
|
|
|
|
|
184
|
|
|
/** |
|
185
|
|
|
* Get hotspotCoordinates. |
|
186
|
|
|
* |
|
187
|
|
|
* @return string |
|
188
|
|
|
*/ |
|
189
|
|
|
public function getHotspotCoordinates() |
|
190
|
|
|
{ |
|
191
|
|
|
return $this->hotspotCoordinates; |
|
192
|
|
|
} |
|
193
|
|
|
|
|
194
|
|
|
public function setHotspotType(string $hotspotType): self |
|
195
|
|
|
{ |
|
196
|
|
|
$this->hotspotType = $hotspotType; |
|
197
|
|
|
|
|
198
|
|
|
return $this; |
|
199
|
|
|
} |
|
200
|
|
|
|
|
201
|
|
|
/** |
|
202
|
|
|
* Get hotspotType. |
|
203
|
|
|
* |
|
204
|
|
|
* @return string |
|
205
|
|
|
*/ |
|
206
|
|
|
public function getHotspotType() |
|
207
|
|
|
{ |
|
208
|
|
|
return $this->hotspotType; |
|
209
|
|
|
} |
|
210
|
|
|
|
|
211
|
|
|
public function setDestination(string $destination) |
|
212
|
|
|
{ |
|
213
|
|
|
$this->destination = empty($destination) ? null : $destination; |
|
214
|
|
|
|
|
215
|
|
|
return $this; |
|
216
|
|
|
} |
|
217
|
|
|
|
|
218
|
|
|
/** |
|
219
|
|
|
* Get destination. |
|
220
|
|
|
* |
|
221
|
|
|
* @return string |
|
222
|
|
|
*/ |
|
223
|
|
|
public function getDestination() |
|
224
|
|
|
{ |
|
225
|
|
|
return $this->destination; |
|
226
|
|
|
} |
|
227
|
|
|
|
|
228
|
|
|
public function setAnswerCode(string $answerCode): self |
|
229
|
|
|
{ |
|
230
|
|
|
$this->answerCode = $answerCode; |
|
231
|
|
|
|
|
232
|
|
|
return $this; |
|
233
|
|
|
} |
|
234
|
|
|
|
|
235
|
|
|
/** |
|
236
|
|
|
* Get answerCode. |
|
237
|
|
|
* |
|
238
|
|
|
* @return string |
|
239
|
|
|
*/ |
|
240
|
|
|
public function getAnswerCode() |
|
241
|
|
|
{ |
|
242
|
|
|
return $this->answerCode; |
|
243
|
|
|
} |
|
244
|
|
|
|
|
245
|
|
|
/** |
|
246
|
|
|
* Get iid. |
|
247
|
|
|
* |
|
248
|
|
|
* @return int |
|
249
|
|
|
*/ |
|
250
|
|
|
public function getIid() |
|
251
|
|
|
{ |
|
252
|
|
|
return $this->iid; |
|
253
|
|
|
} |
|
254
|
|
|
|
|
255
|
|
|
public function getQuestion(): CQuizQuestion |
|
256
|
|
|
{ |
|
257
|
|
|
return $this->question; |
|
258
|
|
|
} |
|
259
|
|
|
|
|
260
|
|
|
public function setQuestion(CQuizQuestion $question): self |
|
261
|
|
|
{ |
|
262
|
|
|
$this->question = $question; |
|
263
|
|
|
|
|
264
|
|
|
return $this; |
|
265
|
|
|
} |
|
266
|
|
|
} |
|
267
|
|
|
|