1
|
|
|
<?php |
2
|
|
|
namespace PlaygroundGame\Entity; |
3
|
|
|
|
4
|
|
|
use Doctrine\ORM\Mapping as ORM; |
5
|
|
|
use Doctrine\ORM\Mapping\HasLifecycleCallbacks; |
6
|
|
|
use Doctrine\ORM\Mapping\PrePersist; |
7
|
|
|
use Doctrine\ORM\Mapping\PreUpdate; |
8
|
|
|
use Zend\InputFilter\InputFilter; |
9
|
|
|
use Zend\InputFilter\Factory as InputFactory; |
10
|
|
|
use Zend\InputFilter\InputFilterAwareInterface; |
11
|
|
|
use Zend\InputFilter\InputFilterInterface; |
12
|
|
|
|
13
|
|
|
/** |
14
|
|
|
* @ORM\Entity @HasLifecycleCallbacks |
15
|
|
|
* @ORM\Table(name="game_quiz_answer") |
16
|
|
|
*/ |
17
|
|
|
class QuizAnswer implements InputFilterAwareInterface |
18
|
|
|
{ |
19
|
|
|
protected $inputFilter; |
20
|
|
|
|
21
|
|
|
/** |
22
|
|
|
* @ORM\Id |
23
|
|
|
* @ORM\Column(type="integer"); |
24
|
|
|
* @ORM\GeneratedValue(strategy="AUTO") |
25
|
|
|
*/ |
26
|
|
|
protected $id; |
27
|
|
|
|
28
|
|
|
/** |
29
|
|
|
* @ORM\ManyToOne(targetEntity="QuizQuestion", inversedBy="answers") |
30
|
|
|
* |
31
|
|
|
**/ |
32
|
|
|
protected $question; |
33
|
|
|
|
34
|
|
|
/** |
35
|
|
|
* @ORM\Column(type="text", nullable=true) |
36
|
|
|
*/ |
37
|
|
|
protected $answer; |
38
|
|
|
|
39
|
|
|
/** |
40
|
|
|
* Explanation of the answer |
41
|
|
|
* @ORM\Column(type="text", nullable=true) |
42
|
|
|
*/ |
43
|
|
|
protected $explanation; |
44
|
|
|
|
45
|
|
|
/** |
46
|
|
|
* @ORM\Column(name="json_data", type="text", nullable=true) |
47
|
|
|
*/ |
48
|
|
|
protected $jsonData; |
49
|
|
|
|
50
|
|
|
/** |
51
|
|
|
* @ORM\Column(type="string", nullable=true) |
52
|
|
|
*/ |
53
|
|
|
protected $video; |
54
|
|
|
|
55
|
|
|
/** |
56
|
|
|
* @ORM\Column(type="string", nullable=true) |
57
|
|
|
*/ |
58
|
|
|
protected $image; |
59
|
|
|
|
60
|
|
|
/** |
61
|
|
|
* The answer score in the game |
62
|
|
|
* @ORM\Column(type="integer", nullable=true) |
63
|
|
|
*/ |
64
|
|
|
protected $points = 0; |
65
|
|
|
|
66
|
|
|
/** |
67
|
|
|
* @ORM\Column(type="integer", nullable=false) |
68
|
|
|
*/ |
69
|
|
|
protected $position = 0; |
70
|
|
|
|
71
|
|
|
/** |
72
|
|
|
* |
73
|
|
|
* @ORM\Column(type="boolean", nullable=true) |
74
|
|
|
*/ |
75
|
|
|
protected $correct = 0; |
76
|
|
|
|
77
|
|
|
/** |
78
|
|
|
* @ORM\Column(type="datetime") |
79
|
|
|
*/ |
80
|
|
|
protected $created_at; |
81
|
|
|
|
82
|
|
|
/** |
83
|
|
|
* @ORM\Column(type="datetime") |
84
|
|
|
*/ |
85
|
|
|
protected $updated_at; |
86
|
|
|
|
87
|
|
|
/** @PrePersist */ |
88
|
|
|
public function createChrono() |
89
|
|
|
{ |
90
|
|
|
$this->created_at = new \DateTime("now"); |
91
|
|
|
$this->updated_at = new \DateTime("now"); |
92
|
|
|
} |
93
|
|
|
|
94
|
|
|
/** @PreUpdate */ |
95
|
|
|
public function updateChrono() |
96
|
|
|
{ |
97
|
|
|
$this->updated_at = new \DateTime("now"); |
98
|
|
|
} |
99
|
|
|
|
100
|
|
|
/** |
101
|
|
|
* @return the unknown_type |
102
|
|
|
*/ |
103
|
|
|
public function getId() |
104
|
|
|
{ |
105
|
|
|
return $this->id; |
106
|
|
|
} |
107
|
|
|
|
108
|
|
|
/** |
109
|
|
|
* @param unknown_type $id |
110
|
|
|
*/ |
111
|
|
|
public function setId($id) |
112
|
|
|
{ |
113
|
|
|
$this->id = $id; |
114
|
|
|
|
115
|
|
|
return $this; |
116
|
|
|
} |
117
|
|
|
|
118
|
|
|
/** |
119
|
|
|
* @return the unknown_type |
120
|
|
|
*/ |
121
|
|
|
public function getQuestion() |
122
|
|
|
{ |
123
|
|
|
return $this->question; |
124
|
|
|
} |
125
|
|
|
|
126
|
|
|
/** |
127
|
|
|
* @param unknown_type $question |
128
|
|
|
*/ |
129
|
|
|
public function setQuestion($question) |
130
|
|
|
{ |
131
|
|
|
$this->question = $question; |
132
|
|
|
|
133
|
|
|
return $this; |
134
|
|
|
} |
135
|
|
|
|
136
|
|
|
/** |
137
|
|
|
* @return the unknown_type |
138
|
|
|
*/ |
139
|
|
|
public function getAnswer() |
140
|
|
|
{ |
141
|
|
|
return $this->answer; |
142
|
|
|
} |
143
|
|
|
|
144
|
|
|
/** |
145
|
|
|
* @param unknown_type $answer |
146
|
|
|
*/ |
147
|
|
|
public function setAnswer($answer) |
148
|
|
|
{ |
149
|
|
|
$this->answer = $answer; |
150
|
|
|
|
151
|
|
|
return $this; |
152
|
|
|
} |
153
|
|
|
|
154
|
|
|
/** |
155
|
|
|
* @return the unknown_type |
156
|
|
|
*/ |
157
|
|
|
public function getExplanation() |
158
|
|
|
{ |
159
|
|
|
return $this->explanation; |
160
|
|
|
} |
161
|
|
|
|
162
|
|
|
/** |
163
|
|
|
* @param unknown_type $explanation |
164
|
|
|
*/ |
165
|
|
|
public function setExplanation($explanation) |
166
|
|
|
{ |
167
|
|
|
$this->explanation = $explanation; |
168
|
|
|
|
169
|
|
|
return $this; |
170
|
|
|
} |
171
|
|
|
|
172
|
|
|
/** |
173
|
|
|
* @return the string |
174
|
|
|
*/ |
175
|
|
|
public function getJsonData() |
176
|
|
|
{ |
177
|
|
|
return $this->jsonData; |
178
|
|
|
} |
179
|
|
|
|
180
|
|
|
/** |
181
|
|
|
* @param string $hint |
|
|
|
|
182
|
|
|
*/ |
183
|
|
|
public function setJsonData($jsonData) |
184
|
|
|
{ |
185
|
|
|
$this->jsonData = $jsonData; |
186
|
|
|
|
187
|
|
|
return $this; |
188
|
|
|
} |
189
|
|
|
|
190
|
|
|
/** |
191
|
|
|
* @return the unknown_type |
192
|
|
|
*/ |
193
|
|
|
public function getVideo() |
194
|
|
|
{ |
195
|
|
|
return $this->video; |
196
|
|
|
} |
197
|
|
|
|
198
|
|
|
/** |
199
|
|
|
* @param unknown_type $video |
200
|
|
|
*/ |
201
|
|
|
public function setVideo($video) |
202
|
|
|
{ |
203
|
|
|
$this->video = $video; |
204
|
|
|
|
205
|
|
|
return $this; |
206
|
|
|
} |
207
|
|
|
|
208
|
|
|
/** |
209
|
|
|
* @return the unknown_type |
210
|
|
|
*/ |
211
|
|
|
public function getImage() |
212
|
|
|
{ |
213
|
|
|
return $this->image; |
214
|
|
|
} |
215
|
|
|
|
216
|
|
|
/** |
217
|
|
|
* @param unknown_type $image |
218
|
|
|
*/ |
219
|
|
|
public function setImage($image) |
220
|
|
|
{ |
221
|
|
|
$this->image = $image; |
222
|
|
|
|
223
|
|
|
return $this; |
224
|
|
|
} |
225
|
|
|
|
226
|
|
|
/** |
227
|
|
|
* @return integer unknown_type |
228
|
|
|
*/ |
229
|
|
|
public function getPoints() |
230
|
|
|
{ |
231
|
|
|
return $this->points; |
232
|
|
|
} |
233
|
|
|
|
234
|
|
|
/** |
235
|
|
|
* @param unknown_type $points |
236
|
|
|
*/ |
237
|
|
|
public function setPoints($points) |
238
|
|
|
{ |
239
|
|
|
$this->points = $points; |
|
|
|
|
240
|
|
|
|
241
|
|
|
return $this; |
242
|
|
|
} |
243
|
|
|
|
244
|
|
|
/** |
245
|
|
|
* @return integer unknown_type |
246
|
|
|
*/ |
247
|
|
|
public function getPosition() |
248
|
|
|
{ |
249
|
|
|
return $this->position; |
250
|
|
|
} |
251
|
|
|
|
252
|
|
|
/** |
253
|
|
|
* @param unknown_type $position |
254
|
|
|
*/ |
255
|
|
|
public function setPosition($position) |
256
|
|
|
{ |
257
|
|
|
$this->position = $position; |
|
|
|
|
258
|
|
|
|
259
|
|
|
return $this; |
260
|
|
|
} |
261
|
|
|
|
262
|
|
|
/** |
263
|
|
|
* @return integer unknown_type |
264
|
|
|
*/ |
265
|
|
|
public function getCorrect() |
266
|
|
|
{ |
267
|
|
|
return $this->correct; |
268
|
|
|
} |
269
|
|
|
|
270
|
|
|
/** |
271
|
|
|
* @param unknown_type $correct |
272
|
|
|
*/ |
273
|
|
|
public function setCorrect($correct) |
274
|
|
|
{ |
275
|
|
|
$this->correct = $correct; |
|
|
|
|
276
|
|
|
|
277
|
|
|
return $this; |
278
|
|
|
} |
279
|
|
|
|
280
|
|
|
/** |
281
|
|
|
* @return the unknown_type |
282
|
|
|
*/ |
283
|
|
|
public function getCreatedAt() |
284
|
|
|
{ |
285
|
|
|
return $this->created_at; |
286
|
|
|
} |
287
|
|
|
|
288
|
|
|
/** |
289
|
|
|
* @param unknown_type $created_at |
290
|
|
|
*/ |
291
|
|
|
public function setCreatedAt($created_at) |
292
|
|
|
{ |
293
|
|
|
$this->created_at = $created_at; |
294
|
|
|
|
295
|
|
|
return $this; |
296
|
|
|
} |
297
|
|
|
|
298
|
|
|
/** |
299
|
|
|
* @return the unknown_type |
300
|
|
|
*/ |
301
|
|
|
public function getUpdatedAt() |
302
|
|
|
{ |
303
|
|
|
return $this->updated_at; |
304
|
|
|
} |
305
|
|
|
|
306
|
|
|
/** |
307
|
|
|
* @param unknown_type $updated_at |
308
|
|
|
*/ |
309
|
|
|
public function setUpdatedAt($updated_at) |
310
|
|
|
{ |
311
|
|
|
$this->updated_at = $updated_at; |
312
|
|
|
|
313
|
|
|
return $this; |
314
|
|
|
} |
315
|
|
|
|
316
|
|
|
/** |
317
|
|
|
* Convert the object to an array. |
318
|
|
|
* |
319
|
|
|
* @return array |
320
|
|
|
*/ |
321
|
|
|
public function getArrayCopy() |
322
|
|
|
{ |
323
|
|
|
$obj_vars = get_object_vars($this); |
324
|
|
|
|
325
|
|
|
return $obj_vars; |
326
|
|
|
} |
327
|
|
|
|
328
|
|
|
/** |
329
|
|
|
* Populate from an array. |
330
|
|
|
* |
331
|
|
|
* @param array $data |
332
|
|
|
*/ |
333
|
|
|
public function populate($data = array()) |
334
|
|
|
{ |
335
|
|
|
if (isset($data['answer']) && $data['answer'] !== null) { |
336
|
|
|
$this->answer = $data['answer']; |
337
|
|
|
} |
338
|
|
|
|
339
|
|
|
if (isset($data['explanation']) && $data['explanation'] !== null) { |
340
|
|
|
$this->explanation = $data['explanation']; |
341
|
|
|
} |
342
|
|
|
|
343
|
|
View Code Duplication |
if (isset($data['jsonData']) && $data['jsonData'] !== null) { |
|
|
|
|
344
|
|
|
$this->jsonData = $data['jsonData']; |
345
|
|
|
} |
346
|
|
|
|
347
|
|
View Code Duplication |
if (isset($data['type']) && $data['type'] !== null) { |
|
|
|
|
348
|
|
|
$this->type = $data['type']; |
|
|
|
|
349
|
|
|
} |
350
|
|
|
|
351
|
|
View Code Duplication |
if (isset($data['position']) && $data['position'] !== null) { |
|
|
|
|
352
|
|
|
$this->position = $data['position']; |
353
|
|
|
} |
354
|
|
|
|
355
|
|
View Code Duplication |
if (isset($data['image']) && $data['image'] !== null) { |
|
|
|
|
356
|
|
|
$this->image = $data['image']; |
357
|
|
|
} |
358
|
|
|
|
359
|
|
View Code Duplication |
if (isset($data['video']) && $data['video'] !== null) { |
|
|
|
|
360
|
|
|
$this->video = $data['video']; |
361
|
|
|
} |
362
|
|
|
|
363
|
|
|
if (isset($data['points']) && $data['points'] !== null) { |
364
|
|
|
$this->points = $data['points']; |
365
|
|
|
} |
366
|
|
|
|
367
|
|
|
if (isset($data['correct']) && $data['correct'] !== null) { |
368
|
|
|
$this->correct = $data['correct']; |
369
|
|
|
} |
370
|
|
|
} |
371
|
|
|
|
372
|
|
|
public function setInputFilter(InputFilterInterface $inputFilter) |
373
|
|
|
{ |
374
|
|
|
throw new \Exception("Not used"); |
375
|
|
|
} |
376
|
|
|
|
377
|
|
|
public function getInputFilter() |
378
|
|
|
{ |
379
|
|
|
if (!$this->inputFilter) { |
380
|
|
|
$inputFilter = new InputFilter(); |
381
|
|
|
$factory = new InputFactory(); |
382
|
|
|
|
383
|
|
|
$inputFilter->add($factory->createInput(array( |
384
|
|
|
'name' => 'id', |
385
|
|
|
'required' => true, |
386
|
|
|
'filters' => array( |
387
|
|
|
array('name' => 'Int'), |
388
|
|
|
), |
389
|
|
|
))); |
390
|
|
|
|
391
|
|
|
$inputFilter->add($factory->createInput(array( |
392
|
|
|
'name' => 'answer', |
393
|
|
|
'required' => true, |
394
|
|
|
))); |
395
|
|
|
|
396
|
|
|
$inputFilter->add($factory->createInput(array( |
397
|
|
|
'name' => 'position', |
398
|
|
|
'required' => true, |
399
|
|
|
))); |
400
|
|
|
|
401
|
|
|
$inputFilter->add($factory->createInput(array( |
402
|
|
|
'name' => 'explanation', |
403
|
|
|
'required' => false, |
404
|
|
|
))); |
405
|
|
|
|
406
|
|
|
$inputFilter->add($factory->createInput(array( |
407
|
|
|
'name' => 'correct', |
408
|
|
|
'required' => true, |
409
|
|
|
'validators' => array( |
410
|
|
|
array( |
411
|
|
|
'name' => 'Between', |
412
|
|
|
'options' => array( |
413
|
|
|
'min' => 0, |
414
|
|
|
'max' => 1, |
415
|
|
|
), |
416
|
|
|
), |
417
|
|
|
), |
418
|
|
|
))); |
419
|
|
|
|
420
|
|
|
$inputFilter->add($factory->createInput(array( |
421
|
|
|
'name' => 'video', |
422
|
|
|
'required' => false, |
423
|
|
|
))); |
424
|
|
|
|
425
|
|
|
$inputFilter->add($factory->createInput(array( |
426
|
|
|
'name' => 'image', |
427
|
|
|
'required' => false, |
428
|
|
|
))); |
429
|
|
|
|
430
|
|
|
$inputFilter->add($factory->createInput(array( |
431
|
|
|
'name' => 'jsonData', |
432
|
|
|
'required' => false, |
433
|
|
|
'allowEmpty' => true, |
434
|
|
|
))); |
435
|
|
|
|
436
|
|
|
$this->inputFilter = $inputFilter; |
437
|
|
|
} |
438
|
|
|
|
439
|
|
|
return $this->inputFilter; |
440
|
|
|
} |
441
|
|
|
} |
442
|
|
|
|
This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.
Consider the following example. The parameter
$italy
is not defined by the methodfinale(...)
.The most likely cause is that the parameter was removed, but the annotation was not.