|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* Created by PhpStorm. |
|
4
|
|
|
* User: device |
|
5
|
|
|
* Date: 23.02.16 |
|
6
|
|
|
* Time: 10:00 |
|
7
|
|
|
*/ |
|
8
|
|
|
|
|
9
|
|
|
namespace AppBundle\Entity; |
|
10
|
|
|
|
|
11
|
|
|
use Doctrine\Common\Collections\ArrayCollection; |
|
12
|
|
|
use Doctrine\ORM\Mapping as ORM; |
|
13
|
|
|
use Symfony\Component\Validator\Constraints as Assert; |
|
14
|
|
|
|
|
15
|
|
|
|
|
16
|
|
|
/** |
|
17
|
|
|
* Question |
|
18
|
|
|
* |
|
19
|
|
|
* @ORM\Table(name="question") |
|
20
|
|
|
* @ORM\Entity(repositoryClass="AppBundle\Repository\QuestionRepository") |
|
21
|
|
|
*/ |
|
22
|
|
|
class Question |
|
23
|
|
|
{ |
|
24
|
|
|
/** |
|
25
|
|
|
* @ORM\Id |
|
26
|
|
|
* @ORM\GeneratedValue |
|
27
|
|
|
* @ORM\Column(type="integer") |
|
28
|
|
|
*/ |
|
29
|
|
|
private $id; |
|
30
|
|
|
|
|
31
|
|
|
/** |
|
32
|
|
|
* @ORM\Column(name="sort", type="integer") |
|
33
|
|
|
*/ |
|
34
|
|
|
private $sort; |
|
35
|
|
|
|
|
36
|
|
|
/** |
|
37
|
|
|
* @ORM\Column(name="text_question", type="string") |
|
38
|
|
|
* @Assert\NotBlank() |
|
39
|
|
|
*/ |
|
40
|
|
|
private $textQuestion; |
|
41
|
|
|
|
|
42
|
|
|
/** |
|
43
|
|
|
* @ORM\Column(name="all_incorrect", type="boolean", nullable=true) |
|
44
|
|
|
*/ |
|
45
|
|
|
private $allIncorrect; |
|
46
|
|
|
/** |
|
47
|
|
|
* @ORM\ManyToOne(targetEntity="AppBundle\Entity\Module", inversedBy="questions") |
|
48
|
|
|
*/ |
|
49
|
|
|
private $module; |
|
50
|
|
|
|
|
51
|
|
|
/** |
|
52
|
|
|
* @ORM\OneToMany(targetEntity="AppBundle\Entity\Answer", mappedBy="question", cascade={"persist", "remove"}) |
|
53
|
|
|
* @Assert\Count( |
|
54
|
|
|
* min = "2", |
|
55
|
|
|
* minMessage = "You must specify at least two answers" |
|
56
|
|
|
* ) |
|
57
|
|
|
*/ |
|
58
|
|
|
private $answers; |
|
59
|
|
|
|
|
60
|
|
|
/** |
|
61
|
|
|
* @ORM\OneToMany(targetEntity="AppBundle\Entity\PassModule", mappedBy="currentQuestion") |
|
62
|
|
|
*/ |
|
63
|
|
|
private $passModules; |
|
|
|
|
|
|
64
|
|
|
|
|
65
|
|
|
|
|
66
|
27 |
|
public function __construct() |
|
67
|
|
|
{ |
|
68
|
27 |
|
$this->answers = new ArrayCollection(); |
|
69
|
27 |
|
} |
|
70
|
|
|
|
|
71
|
|
|
/** |
|
72
|
|
|
* @return mixed |
|
73
|
|
|
*/ |
|
74
|
3 |
|
public function getAnswers() |
|
75
|
|
|
{ |
|
76
|
3 |
|
return $this->answers; |
|
77
|
|
|
} |
|
78
|
|
|
|
|
79
|
|
|
/** |
|
80
|
|
|
* @param Answer $answer |
|
81
|
|
|
* @return $this |
|
82
|
|
|
*/ |
|
83
|
|
|
public function addAnswer(Answer $answer) |
|
84
|
|
|
{ |
|
85
|
|
|
$this->answers->add($answer); |
|
86
|
|
|
|
|
87
|
|
|
return $this; |
|
88
|
|
|
} |
|
89
|
|
|
|
|
90
|
|
|
/** |
|
91
|
|
|
* @param Answer $answer |
|
92
|
|
|
*/ |
|
93
|
|
|
public function removeAnswer(Answer $answer) |
|
94
|
|
|
{ |
|
95
|
|
|
$this->answers->removeElement($answer); |
|
96
|
|
|
} |
|
97
|
|
|
|
|
98
|
|
|
/** |
|
99
|
|
|
* @return mixed |
|
100
|
|
|
*/ |
|
101
|
2 |
|
public function getId() |
|
102
|
|
|
{ |
|
103
|
2 |
|
return $this->id; |
|
104
|
|
|
} |
|
105
|
|
|
|
|
106
|
|
|
/** |
|
107
|
|
|
* @return mixed |
|
108
|
|
|
*/ |
|
109
|
3 |
|
public function getSort() |
|
110
|
|
|
{ |
|
111
|
3 |
|
return $this->sort; |
|
112
|
|
|
} |
|
113
|
|
|
|
|
114
|
|
|
/** |
|
115
|
|
|
* @param mixed $sort |
|
116
|
|
|
*/ |
|
117
|
27 |
|
public function setSort($sort) |
|
118
|
|
|
{ |
|
119
|
27 |
|
$this->sort = $sort; |
|
120
|
27 |
|
} |
|
121
|
|
|
|
|
122
|
|
|
/** |
|
123
|
|
|
* @return mixed |
|
124
|
|
|
*/ |
|
125
|
4 |
|
public function getTextQuestion() |
|
126
|
|
|
{ |
|
127
|
4 |
|
return $this->textQuestion; |
|
128
|
|
|
} |
|
129
|
|
|
|
|
130
|
|
|
/** |
|
131
|
|
|
* @param mixed $textQuestion |
|
132
|
|
|
*/ |
|
133
|
27 |
|
public function setTextQuestion($textQuestion) |
|
134
|
|
|
{ |
|
135
|
27 |
|
$this->textQuestion = $textQuestion; |
|
136
|
27 |
|
} |
|
137
|
|
|
|
|
138
|
|
|
/** |
|
139
|
|
|
* @return mixed |
|
140
|
|
|
*/ |
|
141
|
1 |
|
public function getModule() |
|
142
|
|
|
{ |
|
143
|
1 |
|
return $this->module; |
|
144
|
|
|
} |
|
145
|
|
|
|
|
146
|
|
|
/** |
|
147
|
|
|
* @param mixed $module |
|
148
|
|
|
*/ |
|
149
|
27 |
|
public function setModule(Module $module = null) |
|
150
|
|
|
{ |
|
151
|
27 |
|
$this->module = $module; |
|
152
|
27 |
|
} |
|
153
|
|
|
|
|
154
|
|
|
/** |
|
155
|
|
|
* @return mixed |
|
156
|
|
|
*/ |
|
157
|
2 |
|
public function getAllIncorrect() |
|
158
|
|
|
{ |
|
159
|
2 |
|
return $this->allIncorrect; |
|
160
|
|
|
} |
|
161
|
|
|
|
|
162
|
|
|
/** |
|
163
|
|
|
* @param mixed $allIncorrect |
|
164
|
|
|
*/ |
|
165
|
27 |
|
public function setAllIncorrect($allIncorrect) |
|
166
|
|
|
{ |
|
167
|
27 |
|
$this->allIncorrect = $allIncorrect; |
|
168
|
27 |
|
} |
|
169
|
|
|
|
|
170
|
1 |
|
public function getCountAnswers() |
|
171
|
|
|
{ |
|
172
|
1 |
|
return count($this->answers); |
|
173
|
|
|
} |
|
174
|
|
|
|
|
175
|
|
|
} |
|
176
|
|
|
|
This check marks private properties in classes that are never used. Those properties can be removed.