|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
|
4
|
|
|
|
|
5
|
|
|
/* For licensing terms, see /license.txt */ |
|
6
|
|
|
|
|
7
|
|
|
namespace Chamilo\CoreBundle\Entity; |
|
8
|
|
|
|
|
9
|
|
|
use Chamilo\CoreBundle\Traits\UserTrait; |
|
10
|
|
|
use DateTime; |
|
11
|
|
|
use Doctrine\Common\Collections\ArrayCollection; |
|
12
|
|
|
use Doctrine\Common\Collections\Collection; |
|
13
|
|
|
use Doctrine\ORM\Mapping as ORM; |
|
14
|
|
|
use Symfony\Component\Validator\Constraints as Assert; |
|
15
|
|
|
|
|
16
|
|
|
/** |
|
17
|
|
|
* Questions per quiz user attempts. |
|
18
|
|
|
* |
|
19
|
|
|
* @ORM\Table( |
|
20
|
|
|
* name="track_e_attempt", |
|
21
|
|
|
* indexes={ |
|
22
|
|
|
* @ORM\Index(name="exe_id", columns={"exe_id"}), |
|
23
|
|
|
* @ORM\Index(name="user_id", columns={"user_id"}), |
|
24
|
|
|
* @ORM\Index(name="question_id", columns={"question_id"}), |
|
25
|
|
|
* @ORM\Index(name="idx_track_e_attempt_tms", columns={"tms"}), |
|
26
|
|
|
* } |
|
27
|
|
|
* ) |
|
28
|
|
|
* @ORM\Entity |
|
29
|
|
|
*/ |
|
30
|
|
|
class TrackEAttempt |
|
31
|
|
|
{ |
|
32
|
|
|
use UserTrait; |
|
33
|
|
|
|
|
34
|
|
|
/** |
|
35
|
|
|
* @ORM\Column(name="id", type="integer") |
|
36
|
|
|
* @ORM\Id |
|
37
|
|
|
* @ORM\GeneratedValue(strategy="IDENTITY") |
|
38
|
|
|
*/ |
|
39
|
|
|
protected int $id; |
|
40
|
|
|
|
|
41
|
|
|
/** |
|
42
|
|
|
* @ORM\ManyToOne(targetEntity="Chamilo\CoreBundle\Entity\TrackExercise", inversedBy="attempts") |
|
43
|
|
|
* @ORM\JoinColumn(name="exe_id", referencedColumnName="exe_id", nullable=false) |
|
44
|
|
|
*/ |
|
45
|
|
|
#[Assert\NotNull] |
|
46
|
|
|
protected TrackExercise $trackExercise; |
|
47
|
|
|
|
|
48
|
|
|
/** |
|
49
|
|
|
* @ORM\ManyToOne(targetEntity="Chamilo\CoreBundle\Entity\User", inversedBy="trackEAttempts") |
|
50
|
|
|
* @ORM\JoinColumn(name="user_id", referencedColumnName="id", onDelete="CASCADE") |
|
51
|
|
|
*/ |
|
52
|
|
|
#[Assert\NotNull] |
|
53
|
|
|
protected User $user; |
|
54
|
|
|
|
|
55
|
|
|
/** |
|
56
|
|
|
* @ORM\Column(name="question_id", type="integer", nullable=false) |
|
57
|
|
|
*/ |
|
58
|
|
|
#[Assert\NotBlank] |
|
59
|
|
|
protected ?int $questionId = null; |
|
60
|
|
|
|
|
61
|
|
|
/** |
|
62
|
|
|
* @ORM\Column(name="answer", type="text", nullable=false) |
|
63
|
|
|
*/ |
|
64
|
|
|
protected string $answer; |
|
65
|
|
|
|
|
66
|
|
|
/** |
|
67
|
|
|
* @ORM\Column(name="teacher_comment", type="text", nullable=false) |
|
68
|
|
|
*/ |
|
69
|
|
|
protected string $teacherComment; |
|
70
|
|
|
|
|
71
|
|
|
/** |
|
72
|
|
|
* @ORM\Column(name="marks", type="float", precision=6, scale=2, nullable=false) |
|
73
|
|
|
*/ |
|
74
|
|
|
protected float $marks; |
|
75
|
|
|
|
|
76
|
|
|
/** |
|
77
|
|
|
* @ORM\Column(name="position", type="integer", nullable=true) |
|
78
|
|
|
*/ |
|
79
|
|
|
protected ?int $position = null; |
|
80
|
|
|
|
|
81
|
|
|
/** |
|
82
|
|
|
* @ORM\Column(name="tms", type="datetime", nullable=false) |
|
83
|
|
|
*/ |
|
84
|
|
|
#[Assert\NotNull] |
|
85
|
|
|
protected DateTime $tms; |
|
86
|
|
|
|
|
87
|
|
|
/** |
|
88
|
|
|
* @ORM\Column(name="filename", type="string", length=255, nullable=true) |
|
89
|
|
|
*/ |
|
90
|
|
|
protected ?string $filename = null; |
|
91
|
|
|
|
|
92
|
|
|
/** |
|
93
|
|
|
* @ORM\Column(name="seconds_spent", type="integer") |
|
94
|
|
|
*/ |
|
95
|
|
|
protected int $secondsSpent; |
|
96
|
|
|
|
|
97
|
|
|
/** |
|
98
|
|
|
* @var Collection|AttemptFile[] |
|
99
|
|
|
* |
|
100
|
|
|
* @ORM\OneToMany(targetEntity="AttemptFile", mappedBy="attempt", cascade={"persist"}, orphanRemoval=true) |
|
101
|
|
|
*/ |
|
102
|
|
|
protected Collection $attemptFiles; |
|
103
|
|
|
|
|
104
|
|
|
/** |
|
105
|
|
|
* @var Collection|AttemptFeedback[] |
|
106
|
|
|
* |
|
107
|
|
|
* @ORM\OneToMany(targetEntity="AttemptFeedback", mappedBy="attempt", cascade={"persist"}, orphanRemoval=true) |
|
108
|
|
|
*/ |
|
109
|
|
|
protected Collection $attemptFeedbacks; |
|
110
|
|
|
|
|
111
|
|
|
public function __construct() |
|
112
|
|
|
{ |
|
113
|
|
|
$this->attemptFiles = new ArrayCollection(); |
|
114
|
|
|
$this->attemptFeedbacks = new ArrayCollection(); |
|
115
|
|
|
$this->teacherComment = ''; |
|
116
|
|
|
$this->secondsSpent = 0; |
|
117
|
|
|
} |
|
118
|
|
|
|
|
119
|
|
|
public function setQuestionId(int $questionId): self |
|
120
|
|
|
{ |
|
121
|
|
|
$this->questionId = $questionId; |
|
122
|
|
|
|
|
123
|
|
|
return $this; |
|
124
|
|
|
} |
|
125
|
|
|
|
|
126
|
|
|
/** |
|
127
|
|
|
* Get questionId. |
|
128
|
|
|
* |
|
129
|
|
|
* @return int |
|
130
|
|
|
*/ |
|
131
|
|
|
public function getQuestionId() |
|
132
|
|
|
{ |
|
133
|
|
|
return $this->questionId; |
|
134
|
|
|
} |
|
135
|
|
|
|
|
136
|
|
|
public function setAnswer(string $answer): self |
|
137
|
|
|
{ |
|
138
|
|
|
$this->answer = $answer; |
|
139
|
|
|
|
|
140
|
|
|
return $this; |
|
141
|
|
|
} |
|
142
|
|
|
|
|
143
|
|
|
/** |
|
144
|
|
|
* Get answer. |
|
145
|
|
|
* |
|
146
|
|
|
* @return string |
|
147
|
|
|
*/ |
|
148
|
|
|
public function getAnswer() |
|
149
|
|
|
{ |
|
150
|
|
|
return $this->answer; |
|
151
|
|
|
} |
|
152
|
|
|
|
|
153
|
|
|
public function setTeacherComment(string $teacherComment): self |
|
154
|
|
|
{ |
|
155
|
|
|
$this->teacherComment = $teacherComment; |
|
156
|
|
|
|
|
157
|
|
|
return $this; |
|
158
|
|
|
} |
|
159
|
|
|
|
|
160
|
|
|
/** |
|
161
|
|
|
* Get teacherComment. |
|
162
|
|
|
* |
|
163
|
|
|
* @return string |
|
164
|
|
|
*/ |
|
165
|
|
|
public function getTeacherComment() |
|
166
|
|
|
{ |
|
167
|
|
|
return $this->teacherComment; |
|
168
|
|
|
} |
|
169
|
|
|
|
|
170
|
|
|
public function setMarks(float $marks): self |
|
171
|
|
|
{ |
|
172
|
|
|
$this->marks = $marks; |
|
173
|
|
|
|
|
174
|
|
|
return $this; |
|
175
|
|
|
} |
|
176
|
|
|
|
|
177
|
|
|
/** |
|
178
|
|
|
* Get marks. |
|
179
|
|
|
* |
|
180
|
|
|
* @return float |
|
181
|
|
|
*/ |
|
182
|
|
|
public function getMarks() |
|
183
|
|
|
{ |
|
184
|
|
|
return $this->marks; |
|
185
|
|
|
} |
|
186
|
|
|
|
|
187
|
|
|
public function setPosition(int $position): self |
|
188
|
|
|
{ |
|
189
|
|
|
$this->position = $position; |
|
190
|
|
|
|
|
191
|
|
|
return $this; |
|
192
|
|
|
} |
|
193
|
|
|
|
|
194
|
|
|
/** |
|
195
|
|
|
* Get position. |
|
196
|
|
|
* |
|
197
|
|
|
* @return int |
|
198
|
|
|
*/ |
|
199
|
|
|
public function getPosition() |
|
200
|
|
|
{ |
|
201
|
|
|
return $this->position; |
|
202
|
|
|
} |
|
203
|
|
|
|
|
204
|
|
|
public function setTms(DateTime $tms): self |
|
205
|
|
|
{ |
|
206
|
|
|
$this->tms = $tms; |
|
207
|
|
|
|
|
208
|
|
|
return $this; |
|
209
|
|
|
} |
|
210
|
|
|
|
|
211
|
|
|
/** |
|
212
|
|
|
* Get tms. |
|
213
|
|
|
* |
|
214
|
|
|
* @return DateTime |
|
215
|
|
|
*/ |
|
216
|
|
|
public function getTms() |
|
217
|
|
|
{ |
|
218
|
|
|
return $this->tms; |
|
219
|
|
|
} |
|
220
|
|
|
|
|
221
|
|
|
/** |
|
222
|
|
|
* Set filename. |
|
223
|
|
|
* |
|
224
|
|
|
* @return TrackEAttempt |
|
225
|
|
|
*/ |
|
226
|
|
|
public function setFilename(string $filename) |
|
227
|
|
|
{ |
|
228
|
|
|
$this->filename = $filename; |
|
229
|
|
|
|
|
230
|
|
|
return $this; |
|
231
|
|
|
} |
|
232
|
|
|
|
|
233
|
|
|
/** |
|
234
|
|
|
* Get filename. |
|
235
|
|
|
* |
|
236
|
|
|
* @return string |
|
237
|
|
|
*/ |
|
238
|
|
|
public function getFilename() |
|
239
|
|
|
{ |
|
240
|
|
|
return $this->filename; |
|
241
|
|
|
} |
|
242
|
|
|
|
|
243
|
|
|
/** |
|
244
|
|
|
* Get id. |
|
245
|
|
|
* |
|
246
|
|
|
* @return int |
|
247
|
|
|
*/ |
|
248
|
|
|
public function getId() |
|
249
|
|
|
{ |
|
250
|
|
|
return $this->id; |
|
251
|
|
|
} |
|
252
|
|
|
|
|
253
|
|
|
public function getUser(): User |
|
254
|
|
|
{ |
|
255
|
|
|
return $this->user; |
|
256
|
|
|
} |
|
257
|
|
|
|
|
258
|
|
|
public function setUser(User $user): self |
|
259
|
|
|
{ |
|
260
|
|
|
$this->user = $user; |
|
261
|
|
|
|
|
262
|
|
|
return $this; |
|
263
|
|
|
} |
|
264
|
|
|
|
|
265
|
|
|
public function getTrackExercise(): TrackExercise |
|
266
|
|
|
{ |
|
267
|
|
|
return $this->trackExercise; |
|
268
|
|
|
} |
|
269
|
|
|
|
|
270
|
|
|
public function setTrackExercise(TrackExercise $trackExercise): self |
|
271
|
|
|
{ |
|
272
|
|
|
$this->trackExercise = $trackExercise; |
|
273
|
|
|
|
|
274
|
|
|
return $this; |
|
275
|
|
|
} |
|
276
|
|
|
|
|
277
|
|
|
public function getSecondsSpent(): int |
|
278
|
|
|
{ |
|
279
|
|
|
return $this->secondsSpent; |
|
280
|
|
|
} |
|
281
|
|
|
|
|
282
|
|
|
public function setSecondsSpent(int $secondsSpent): self |
|
283
|
|
|
{ |
|
284
|
|
|
$this->secondsSpent = $secondsSpent; |
|
285
|
|
|
|
|
286
|
|
|
return $this; |
|
287
|
|
|
} |
|
288
|
|
|
|
|
289
|
|
|
/** |
|
290
|
|
|
* @return AttemptFile[]|Collection |
|
291
|
|
|
*/ |
|
292
|
|
|
public function getAttemptFiles() |
|
293
|
|
|
{ |
|
294
|
|
|
return $this->attemptFiles; |
|
295
|
|
|
} |
|
296
|
|
|
|
|
297
|
|
|
/** |
|
298
|
|
|
* @param AttemptFile[]|Collection $attemptFiles |
|
299
|
|
|
*/ |
|
300
|
|
|
public function setAttemptFiles($attemptFiles): self |
|
301
|
|
|
{ |
|
302
|
|
|
$this->attemptFiles = $attemptFiles; |
|
303
|
|
|
|
|
304
|
|
|
return $this; |
|
305
|
|
|
} |
|
306
|
|
|
|
|
307
|
|
|
/** |
|
308
|
|
|
* @return AttemptFeedback[]|Collection |
|
309
|
|
|
*/ |
|
310
|
|
|
public function getAttemptFeedbacks() |
|
311
|
|
|
{ |
|
312
|
|
|
return $this->attemptFeedbacks; |
|
313
|
|
|
} |
|
314
|
|
|
|
|
315
|
|
|
/** |
|
316
|
|
|
* @param AttemptFeedback[]|Collection $attemptFeedbacks |
|
317
|
|
|
*/ |
|
318
|
|
|
public function setAttemptFeedbacks($attemptFeedbacks): self |
|
319
|
|
|
{ |
|
320
|
|
|
$this->attemptFeedbacks = $attemptFeedbacks; |
|
321
|
|
|
|
|
322
|
|
|
return $this; |
|
323
|
|
|
} |
|
324
|
|
|
|
|
325
|
|
|
public function addAttemptFeedback(AttemptFeedback $attemptFeedback): self |
|
326
|
|
|
{ |
|
327
|
|
|
if (!$this->attemptFeedbacks->contains($attemptFeedback)) { |
|
328
|
|
|
$this->attemptFeedbacks[] = $attemptFeedback; |
|
329
|
|
|
$attemptFeedback->setAttempt($this); |
|
330
|
|
|
} |
|
331
|
|
|
|
|
332
|
|
|
return $this; |
|
333
|
|
|
} |
|
334
|
|
|
|
|
335
|
|
|
public function addAttemptFile(AttemptFile $attemptFile): self |
|
336
|
|
|
{ |
|
337
|
|
|
if (!$this->attemptFiles->contains($attemptFile)) { |
|
338
|
|
|
$this->attemptFiles[] = $attemptFile; |
|
339
|
|
|
$attemptFile->setAttempt($this); |
|
340
|
|
|
} |
|
341
|
|
|
|
|
342
|
|
|
return $this; |
|
343
|
|
|
} |
|
344
|
|
|
} |
|
345
|
|
|
|