1
|
|
|
<?php declare(strict_types=1); |
2
|
|
|
|
3
|
|
|
namespace VSV\GVQ_API\Question\Forms; |
4
|
|
|
|
5
|
|
|
use Ramsey\Uuid\UuidFactoryInterface; |
6
|
|
|
use Symfony\Component\HttpFoundation\File\UploadedFile; |
7
|
|
|
use VSV\GVQ_API\Common\ValueObjects\Language; |
8
|
|
|
use VSV\GVQ_API\Common\ValueObjects\NotEmptyString; |
9
|
|
|
use VSV\GVQ_API\Question\Models\Answer; |
10
|
|
|
use VSV\GVQ_API\Question\Models\Answers; |
11
|
|
|
use VSV\GVQ_API\Question\Models\Category; |
12
|
|
|
use VSV\GVQ_API\Question\Models\Question; |
13
|
|
|
use VSV\GVQ_API\Question\ValueObjects\Year; |
14
|
|
|
|
15
|
|
|
class QuestionFormDTO |
16
|
|
|
{ |
17
|
|
|
/** |
18
|
|
|
* @var Language |
19
|
|
|
*/ |
20
|
|
|
public $language; |
21
|
|
|
|
22
|
|
|
/** |
23
|
|
|
* @var int |
24
|
|
|
*/ |
25
|
|
|
public $year; |
26
|
|
|
|
27
|
|
|
/** |
28
|
|
|
* @var Category |
29
|
|
|
*/ |
30
|
|
|
public $category; |
31
|
|
|
|
32
|
|
|
/** |
33
|
|
|
* @var UploadedFile |
34
|
|
|
*/ |
35
|
|
|
public $image; |
36
|
|
|
|
37
|
|
|
/** |
38
|
|
|
* @var string |
39
|
|
|
*/ |
40
|
|
|
public $answer1; |
41
|
|
|
|
42
|
|
|
/** |
43
|
|
|
* @var string |
44
|
|
|
*/ |
45
|
|
|
public $answer2; |
46
|
|
|
|
47
|
|
|
/** |
48
|
|
|
* @var string |
49
|
|
|
*/ |
50
|
|
|
public $answer3; |
51
|
|
|
|
52
|
|
|
/** |
53
|
|
|
* @var int |
54
|
|
|
*/ |
55
|
|
|
public $correctAnswer; |
56
|
|
|
|
57
|
|
|
/** |
58
|
|
|
* @var string |
59
|
|
|
*/ |
60
|
|
|
public $text; |
61
|
|
|
|
62
|
|
|
/** |
63
|
|
|
* @var string |
64
|
|
|
*/ |
65
|
|
|
public $feedback; |
66
|
|
|
|
67
|
|
|
/** |
68
|
|
|
* QuestionForm constructor. |
69
|
|
|
*/ |
70
|
|
|
public function __construct() |
71
|
|
|
{ |
72
|
|
|
$this->year = 2018; |
73
|
|
|
} |
74
|
|
|
|
75
|
|
|
/** |
76
|
|
|
* @param UuidFactoryInterface $uuidFactory |
77
|
|
|
* @param NotEmptyString $fileName |
78
|
|
|
* @return Question |
79
|
|
|
*/ |
80
|
|
|
public function toQuestion( |
81
|
|
|
UuidFactoryInterface $uuidFactory, |
82
|
|
|
NotEmptyString $fileName |
83
|
|
|
): Question { |
84
|
|
|
// TODO: Take into account the correct number of answers, can be 2 or 3. |
85
|
|
|
$answers = new Answers( |
86
|
|
|
new Answer( |
87
|
|
|
$uuidFactory->uuid4(), |
88
|
|
|
new NotEmptyString($this->answer1), |
89
|
|
|
$this->correctAnswer === 1 ? true : false |
90
|
|
|
), |
91
|
|
|
new Answer( |
92
|
|
|
$uuidFactory->uuid4(), |
93
|
|
|
new NotEmptyString($this->answer2), |
94
|
|
|
$this->correctAnswer === 2 ? true : false |
95
|
|
|
), |
96
|
|
|
new Answer( |
97
|
|
|
$uuidFactory->uuid4(), |
98
|
|
|
new NotEmptyString($this->answer3), |
99
|
|
|
$this->correctAnswer === 3 ? true : false |
100
|
|
|
) |
101
|
|
|
); |
102
|
|
|
|
103
|
|
|
return new Question( |
104
|
|
|
$uuidFactory->uuid4(), |
105
|
|
|
$this->language, |
106
|
|
|
new Year($this->year), |
107
|
|
|
$this->category, |
108
|
|
|
new NotEmptyString($this->text), |
109
|
|
|
$fileName, |
110
|
|
|
$answers, |
111
|
|
|
new NotEmptyString($this->feedback) |
112
|
|
|
); |
113
|
|
|
} |
114
|
|
|
} |
115
|
|
|
|