Passed
Push — master ( 2cb959...2b5b03 )
by Julito
11:13 queued 10s
created

TrackExercise::getUser()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
rs 10
c 0
b 0
f 0
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 DateTime;
10
use Doctrine\Common\Collections\ArrayCollection;
11
use Doctrine\Common\Collections\Collection;
12
use Doctrine\ORM\Mapping as ORM;
13
use Symfony\Component\Validator\Constraints as Assert;
14
15
/**
16
 * Quiz user attempts.
17
 *
18
 * @ORM\Table(name="track_e_exercises", indexes={
19
 *     @ORM\Index(name="idx_tee_user_id", columns={"exe_user_id"}),
20
 *     @ORM\Index(name="idx_tee_c_id", columns={"c_id"}),
21
 *     @ORM\Index(name="session_id", columns={"session_id"})
22
 * })
23
 * @ORM\Entity
24
 */
25
class TrackExercise
26
{
27
    /**
28
     * @ORM\Column(name="exe_id", type="integer")
29
     * @ORM\Id
30
     * @ORM\GeneratedValue(strategy="IDENTITY")
31
     */
32
    protected int $exeId;
33
34
    /**
35
     * @ORM\ManyToOne(targetEntity="Chamilo\CoreBundle\Entity\User")
36
     * @ORM\JoinColumn(name="exe_user_id", referencedColumnName="id", nullable=false)
37
     */
38
    #[Assert\NotNull]
39
    protected User $user;
40
41
    /**
42
     * @ORM\ManyToOne(targetEntity="Chamilo\CoreBundle\Entity\Course")
43
     * @ORM\JoinColumn(name="c_id", referencedColumnName="id", nullable=false)
44
     */
45
    #[Assert\NotNull]
46
    protected Course $course;
47
48
    /**
49
     * @ORM\ManyToOne(targetEntity="Chamilo\CoreBundle\Entity\Session")
50
     * @ORM\JoinColumn(name="session_id", referencedColumnName="id")
51
     */
52
    protected ?Session $session = null;
53
54
    /**
55
     * @ORM\Column(name="exe_date", type="datetime", nullable=false)
56
     */
57
    #[Assert\NotBlank]
58
    protected DateTime $exeDate;
59
60
    /**
61
     * @ORM\Column(name="exe_exo_id", type="integer", nullable=false)
62
     */
63
    #[Assert\NotBlank]
64
    protected int $exeExoId;
65
66
    /**
67
     * @ORM\Column(name="score", type="float", precision=6, scale=2, nullable=false)
68
     */
69
    #[Assert\NotNull]
70
    protected float $score;
71
72
    /**
73
     * @ORM\Column(name="max_score", type="float", precision=6, scale=2, nullable=false)
74
     */
75
    #[Assert\NotNull]
76
    protected float $maxScore;
77
78
    /**
79
     * @ORM\Column(name="user_ip", type="string", length=39, nullable=false)
80
     */
81
    #[Assert\NotBlank]
82
    protected string $userIp;
83
84
    /**
85
     * @ORM\Column(name="status", type="string", length=20, nullable=false)
86
     */
87
    #[Assert\NotNull]
88
    protected string $status;
89
90
    /**
91
     * @ORM\Column(name="data_tracking", type="text", nullable=false)
92
     */
93
    #[Assert\NotNull]
94
    protected string $dataTracking;
95
96
    /**
97
     * @ORM\Column(name="start_date", type="datetime", nullable=false)
98
     */
99
    protected DateTime $startDate;
100
101
    /**
102
     * @ORM\Column(name="steps_counter", type="smallint", nullable=false)
103
     */
104
    #[Assert\NotNull]
105
    protected int $stepsCounter;
106
107
    /**
108
     * @ORM\Column(name="orig_lp_id", type="integer", nullable=false)
109
     */
110
    protected int $origLpId;
111
112
    /**
113
     * @ORM\Column(name="orig_lp_item_id", type="integer", nullable=false)
114
     */
115
    protected int $origLpItemId;
116
117
    /**
118
     * @ORM\Column(name="exe_duration", type="integer", nullable=false)
119
     */
120
    #[Assert\NotNull]
121
    protected int $exeDuration;
122
123
    /**
124
     * @ORM\Column(name="expired_time_control", type="datetime", nullable=true)
125
     */
126
    protected ?DateTime $expiredTimeControl = null;
127
128
    /**
129
     * @ORM\Column(name="orig_lp_item_view_id", type="integer", nullable=false)
130
     */
131
    protected int $origLpItemViewId;
132
133
    /**
134
     * @ORM\Column(name="questions_to_check", type="text", nullable=false)
135
     */
136
    #[Assert\NotNull]
137
    protected string $questionsToCheck;
138
139
    /**
140
     * @ORM\Column(name="blocked_categories", type="text", nullable=true)
141
     */
142
    protected ?string $blockedCategories;
143
144
    /**
145
     * @var Collection|TrackEAttempt[]
146
     *
147
     * @ORM\OneToMany(targetEntity="Chamilo\CoreBundle\Entity\TrackEAttempt", mappedBy="trackExercise", cascade={"persist"})
148
     */
149
    protected Collection $attempts;
150
151
    public function __construct()
152
    {
153
        $this->attempts = new ArrayCollection();
154
        $this->questionsToCheck = '';
155
        $this->blockedCategories = '';
156
        $this->dataTracking = '';
157
        $this->exeDuration = 0;
158
        $this->score = 0;
159
        $this->status = 'incomplete';
160
        $this->stepsCounter = 0;
161
        $this->exeDate = new DateTime();
162
        $this->startDate = new DateTime();
163
    }
164
165
    public function setExeDate(DateTime $exeDate): self
166
    {
167
        $this->exeDate = $exeDate;
168
169
        return $this;
170
    }
171
172
    /**
173
     * Get exeDate.
174
     *
175
     * @return DateTime
176
     */
177
    public function getExeDate()
178
    {
179
        return $this->exeDate;
180
    }
181
182
    public function setExeExoId(int $exeExoId): self
183
    {
184
        $this->exeExoId = $exeExoId;
185
186
        return $this;
187
    }
188
189
    public function getExeExoId(): int
190
    {
191
        return $this->exeExoId;
192
    }
193
194
    public function setUserIp(string $userIp): self
195
    {
196
        $this->userIp = $userIp;
197
198
        return $this;
199
    }
200
201
    /**
202
     * Get userIp.
203
     *
204
     * @return string
205
     */
206
    public function getUserIp()
207
    {
208
        return $this->userIp;
209
    }
210
211
    public function setStatus(string $status): self
212
    {
213
        $this->status = $status;
214
215
        return $this;
216
    }
217
218
    /**
219
     * Get status.
220
     *
221
     * @return string
222
     */
223
    public function getStatus()
224
    {
225
        return $this->status;
226
    }
227
228
    public function setDataTracking(string $dataTracking): self
229
    {
230
        $this->dataTracking = $dataTracking;
231
232
        return $this;
233
    }
234
235
    /**
236
     * Get dataTracking.
237
     *
238
     * @return string
239
     */
240
    public function getDataTracking()
241
    {
242
        return $this->dataTracking;
243
    }
244
245
    public function setStartDate(DateTime $startDate): self
246
    {
247
        $this->startDate = $startDate;
248
249
        return $this;
250
    }
251
252
    /**
253
     * Get startDate.
254
     *
255
     * @return DateTime
256
     */
257
    public function getStartDate()
258
    {
259
        return $this->startDate;
260
    }
261
262
    public function setStepsCounter(int $stepsCounter): self
263
    {
264
        $this->stepsCounter = $stepsCounter;
265
266
        return $this;
267
    }
268
269
    /**
270
     * Get stepsCounter.
271
     *
272
     * @return int
273
     */
274
    public function getStepsCounter()
275
    {
276
        return $this->stepsCounter;
277
    }
278
279
    public function setOrigLpId(int $origLpId): self
280
    {
281
        $this->origLpId = $origLpId;
282
283
        return $this;
284
    }
285
286
    /**
287
     * Get origLpId.
288
     *
289
     * @return int
290
     */
291
    public function getOrigLpId()
292
    {
293
        return $this->origLpId;
294
    }
295
296
    public function setOrigLpItemId(int $origLpItemId): self
297
    {
298
        $this->origLpItemId = $origLpItemId;
299
300
        return $this;
301
    }
302
303
    /**
304
     * Get origLpItemId.
305
     *
306
     * @return int
307
     */
308
    public function getOrigLpItemId()
309
    {
310
        return $this->origLpItemId;
311
    }
312
313
    public function setExeDuration(int $exeDuration): self
314
    {
315
        $this->exeDuration = $exeDuration;
316
317
        return $this;
318
    }
319
320
    /**
321
     * Get exeDuration.
322
     *
323
     * @return int
324
     */
325
    public function getExeDuration()
326
    {
327
        return $this->exeDuration;
328
    }
329
330
    public function setExpiredTimeControl(?DateTime $expiredTimeControl): self
331
    {
332
        $this->expiredTimeControl = $expiredTimeControl;
333
334
        return $this;
335
    }
336
337
    public function getExpiredTimeControl(): ?DateTime
338
    {
339
        return $this->expiredTimeControl;
340
    }
341
342
    public function setOrigLpItemViewId(int $origLpItemViewId): self
343
    {
344
        $this->origLpItemViewId = $origLpItemViewId;
345
346
        return $this;
347
    }
348
349
    /**
350
     * Get origLpItemViewId.
351
     *
352
     * @return int
353
     */
354
    public function getOrigLpItemViewId()
355
    {
356
        return $this->origLpItemViewId;
357
    }
358
359
    public function setQuestionsToCheck(string $questionsToCheck): self
360
    {
361
        $this->questionsToCheck = $questionsToCheck;
362
363
        return $this;
364
    }
365
366
    /**
367
     * Get questionsToCheck.
368
     *
369
     * @return string
370
     */
371
    public function getQuestionsToCheck()
372
    {
373
        return $this->questionsToCheck;
374
    }
375
376
    /**
377
     * Get exeId.
378
     *
379
     * @return int
380
     */
381
    public function getExeId()
382
    {
383
        return $this->exeId;
384
    }
385
386
    public function getScore(): float
387
    {
388
        return $this->score;
389
    }
390
391
    public function setScore(float $score): self
392
    {
393
        $this->score = $score;
394
395
        return $this;
396
    }
397
398
    public function getMaxScore(): float
399
    {
400
        return $this->maxScore;
401
    }
402
403
    public function setMaxScore(float $maxScore): self
404
    {
405
        $this->maxScore = $maxScore;
406
407
        return $this;
408
    }
409
410
    public function getUser(): User
411
    {
412
        return $this->user;
413
    }
414
415
    public function setUser(User $user): self
416
    {
417
        $this->user = $user;
418
419
        return $this;
420
    }
421
422
    public function getCourse(): Course
423
    {
424
        return $this->course;
425
    }
426
427
    public function setCourse(Course $course): self
428
    {
429
        $this->course = $course;
430
431
        return $this;
432
    }
433
434
    /**
435
     * @return TrackEAttempt[]|Collection
436
     */
437
    public function getAttempts()
438
    {
439
        return $this->attempts;
440
    }
441
442
    /**
443
     * @param TrackEAttempt[]|Collection $attempts
444
     */
445
    public function setAttempts($attempts): self
446
    {
447
        $this->attempts = $attempts;
448
449
        return $this;
450
    }
451
452
    public function addAttempt(TrackEAttempt $attempt): self
453
    {
454
        if (!$this->attempts->contains($attempt)) {
455
            $this->attempts[] = $attempt;
456
            $attempt->setTrackExercise($this);
457
        }
458
459
        return $this;
460
    }
461
462
    public function getSession(): ?Session
463
    {
464
        return $this->session;
465
    }
466
467
    public function setSession(?Session $session): self
468
    {
469
        $this->session = $session;
470
471
        return $this;
472
    }
473
}
474