Passed
Push — master ( de0fbe...d2acd0 )
by Julito
13:32
created

GradebookLink::setCategory()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 1
dl 0
loc 5
rs 10
c 0
b 0
f 0
1
<?php
2
3
/* For licensing terms, see /license.txt */
4
5
namespace Chamilo\CoreBundle\Entity;
6
7
use Chamilo\CoreBundle\Traits\CourseTrait;
8
use Chamilo\CoreBundle\Traits\UserTrait;
9
use Doctrine\ORM\Mapping as ORM;
10
use Gedmo\Mapping\Annotation as Gedmo;
11
use Symfony\Component\Validator\Constraints as Assert;
12
13
/**
14
 * GradebookLink.
15
 *
16
 * @ORM\Table(name="gradebook_link",
17
 *  indexes={
18
 *     @ORM\Index(name="idx_gl_cat", columns={"category_id"}),
19
 *  }
20
 * )
21
 * @ORM\Entity
22
 */
23
class GradebookLink
24
{
25
    use CourseTrait;
26
    use UserTrait;
27
28
    /**
29
     * @var int
30
     *
31
     * @ORM\Column(name="id", type="integer")
32
     * @ORM\Id
33
     * @ORM\GeneratedValue
34
     */
35
    protected $id;
36
37
    /**
38
     * @Assert\NotBlank()
39
     * @ORM\Column(name="type", type="integer", nullable=false)
40
     */
41
    protected int $type;
42
43
    /**
44
     * @var int
45
     *
46
     * @ORM\Column(name="ref_id", type="integer", nullable=false)
47
     */
48
    protected $refId;
49
50
    /**
51
     * @ORM\ManyToOne(targetEntity="Chamilo\CoreBundle\Entity\User", inversedBy="gradeBookLinks")
52
     * @ORM\JoinColumn(name="user_id", referencedColumnName="id", onDelete="CASCADE")
53
     */
54
    protected User $user;
55
56
    /**
57
     * @ORM\ManyToOne(targetEntity="Chamilo\CoreBundle\Entity\Course", inversedBy="gradebookLinks")
58
     * @ORM\JoinColumn(name="c_id", referencedColumnName="id")
59
     */
60
    protected Course $course;
61
62
    /**
63
     * @ORM\ManyToOne(targetEntity="Chamilo\CoreBundle\Entity\GradebookCategory")
64
     * @ORM\JoinColumn(name="category_id", referencedColumnName="id")
65
     */
66
    protected GradebookCategory $category;
67
68
    /**
69
     * @var \DateTime
70
     *
71
     * @Gedmo\Timestampable(on="create")
72
     * @ORM\Column(name="created_at", type="datetime", nullable=false)
73
     */
74
    protected $createdAt;
75
76
    /**
77
     * @var float
78
     *
79
     * @ORM\Column(name="weight", type="float", precision=10, scale=0, nullable=false)
80
     */
81
    protected $weight;
82
83
    /**
84
     * @var int
85
     *
86
     * @ORM\Column(name="visible", type="integer", nullable=false)
87
     */
88
    protected $visible;
89
90
    /**
91
     * @var int
92
     *
93
     * @ORM\Column(name="locked", type="integer", nullable=false)
94
     */
95
    protected $locked;
96
97
    /**
98
     * @var float
99
     *
100
     * @ORM\Column(name="best_score", type="float", precision=6, scale=2, nullable=true)
101
     */
102
    protected $bestScore;
103
104
    /**
105
     * @var float
106
     *
107
     * @ORM\Column(name="average_score", type="float", precision=6, scale=2, nullable=true)
108
     */
109
    protected $averageScore;
110
111
    /**
112
     * @var float
113
     *
114
     * @ORM\Column(name="score_weight", type="float", precision=6, scale=2, nullable=true)
115
     */
116
    protected $scoreWeight;
117
118
    /**
119
     * @var array
120
     *
121
     * @ORM\Column(name="user_score_list", type="array", nullable=true)
122
     */
123
    protected $userScoreList;
124
125
    public function __construct()
126
    {
127
        $this->locked = 0;
128
    }
129
130
    /**
131
     * Set type.
132
     *
133
     * @param int $type
134
     *
135
     * @return GradebookLink
136
     */
137
    public function setType($type)
138
    {
139
        $this->type = $type;
140
141
        return $this;
142
    }
143
144
    /**
145
     * Get type.
146
     *
147
     * @return int
148
     */
149
    public function getType()
150
    {
151
        return $this->type;
152
    }
153
154
    /**
155
     * Set refId.
156
     *
157
     * @param int $refId
158
     *
159
     * @return GradebookLink
160
     */
161
    public function setRefId($refId)
162
    {
163
        $this->refId = $refId;
164
165
        return $this;
166
    }
167
168
    /**
169
     * Get refId.
170
     *
171
     * @return int
172
     */
173
    public function getRefId()
174
    {
175
        return $this->refId;
176
    }
177
178
    /**
179
     * Set createdAt.
180
     *
181
     * @param \DateTime $createdAt
182
     *
183
     * @return GradebookLink
184
     */
185
    public function setCreatedAt($createdAt)
186
    {
187
        $this->createdAt = $createdAt;
188
189
        return $this;
190
    }
191
192
    /**
193
     * Get createdAt.
194
     *
195
     * @return \DateTime
196
     */
197
    public function getCreatedAt()
198
    {
199
        return $this->createdAt;
200
    }
201
202
    /**
203
     * Set weight.
204
     *
205
     * @param float $weight
206
     *
207
     * @return GradebookLink
208
     */
209
    public function setWeight($weight)
210
    {
211
        $this->weight = $weight;
212
213
        return $this;
214
    }
215
216
    /**
217
     * Get weight.
218
     *
219
     * @return float
220
     */
221
    public function getWeight()
222
    {
223
        return $this->weight;
224
    }
225
226
    /**
227
     * Set visible.
228
     *
229
     * @param int $visible
230
     *
231
     * @return GradebookLink
232
     */
233
    public function setVisible($visible)
234
    {
235
        $this->visible = $visible;
236
237
        return $this;
238
    }
239
240
    /**
241
     * Get visible.
242
     *
243
     * @return int
244
     */
245
    public function getVisible()
246
    {
247
        return $this->visible;
248
    }
249
250
    /**
251
     * Set locked.
252
     *
253
     * @param int $locked
254
     *
255
     * @return GradebookLink
256
     */
257
    public function setLocked($locked)
258
    {
259
        $this->locked = $locked;
260
261
        return $this;
262
    }
263
264
    /**
265
     * Get locked.
266
     *
267
     * @return int
268
     */
269
    public function getLocked()
270
    {
271
        return $this->locked;
272
    }
273
274
    /**
275
     * Get id.
276
     *
277
     * @return int
278
     */
279
    public function getId()
280
    {
281
        return $this->id;
282
    }
283
284
    /**
285
     * @return float
286
     */
287
    public function getBestScore()
288
    {
289
        return $this->bestScore;
290
    }
291
292
    /**
293
     * @param float $bestScore
294
     */
295
    public function setBestScore($bestScore): self
296
    {
297
        $this->bestScore = $bestScore;
298
299
        return $this;
300
    }
301
302
    /**
303
     * @return float
304
     */
305
    public function getAverageScore()
306
    {
307
        return $this->averageScore;
308
    }
309
310
    /**
311
     * @param float $averageScore
312
     */
313
    public function setAverageScore($averageScore): self
314
    {
315
        $this->averageScore = $averageScore;
316
317
        return $this;
318
    }
319
320
    /**
321
     * @return array
322
     */
323
    public function getUserScoreList()
324
    {
325
        if (empty($this->userScoreList)) {
326
            return [];
327
        }
328
329
        return $this->userScoreList;
330
    }
331
332
    /**
333
     * @param array $userScoreList
334
     */
335
    public function setUserScoreList($userScoreList): self
336
    {
337
        $this->userScoreList = $userScoreList;
338
339
        return $this;
340
    }
341
342
    /**
343
     * @return float
344
     */
345
    public function getScoreWeight()
346
    {
347
        return $this->scoreWeight;
348
    }
349
350
    /**
351
     * @param float $scoreWeight
352
     */
353
    public function setScoreWeight($scoreWeight): self
354
    {
355
        $this->scoreWeight = $scoreWeight;
356
357
        return $this;
358
    }
359
360
    public function getCategory(): GradebookCategory
361
    {
362
        return $this->category;
363
    }
364
365
    public function setCategory(GradebookCategory $category): self
366
    {
367
        $this->category = $category;
368
369
        return $this;
370
    }
371
}
372