Passed
Push — master ( f3b60f...e63ea7 )
by Yannick
09:11
created

GradebookLink::getLocked()   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 Chamilo\CoreBundle\Traits\CourseTrait;
10
use DateTime;
11
use Doctrine\ORM\Mapping as ORM;
12
use Gedmo\Mapping\Annotation as Gedmo;
13
use Symfony\Component\Validator\Constraints as Assert;
14
15
#[ORM\Table(name: 'gradebook_link')]
16
#[ORM\Index(name: 'idx_gl_cat', columns: ['category_id'])]
17
#[ORM\Entity]
18
class GradebookLink
19
{
20
    use CourseTrait;
21
22
    #[ORM\Column(name: 'id', type: 'integer')]
23
    #[ORM\Id]
24
    #[ORM\GeneratedValue]
25
    protected ?int $id = null;
26
27
    #[Assert\NotBlank]
28
    #[ORM\Column(name: 'type', type: 'integer', nullable: false)]
29
    protected int $type;
30
31
    #[Assert\NotBlank]
32
    #[ORM\Column(name: 'ref_id', type: 'integer', nullable: false)]
33
    protected int $refId;
34
35
    #[ORM\ManyToOne(targetEntity: Course::class, inversedBy: 'gradebookLinks')]
36
    #[ORM\JoinColumn(name: 'c_id', referencedColumnName: 'id', onDelete: 'CASCADE')]
37
    protected Course $course;
38
39
    #[ORM\ManyToOne(targetEntity: GradebookCategory::class, inversedBy: 'links')]
40
    #[ORM\JoinColumn(name: 'category_id', referencedColumnName: 'id', onDelete: 'CASCADE')]
41
    protected GradebookCategory $category;
42
43
    #[Gedmo\Timestampable(on: 'create')]
44
    #[ORM\Column(name: 'created_at', type: 'datetime', nullable: false)]
45
    protected DateTime $createdAt;
46
47
    #[ORM\Column(name: 'weight', type: 'float', precision: 10, scale: 0, nullable: false)]
48
    protected float $weight;
49
50
    #[Assert\NotBlank]
51
    #[ORM\Column(name: 'visible', type: 'integer', nullable: false)]
52
    protected int $visible;
53
54
    #[Assert\NotBlank]
55
    #[ORM\Column(name: 'locked', type: 'integer', nullable: false)]
56
    protected int $locked;
57
58
    #[ORM\Column(name: 'best_score', type: 'float', precision: 6, scale: 2, nullable: true)]
59
    protected ?float $bestScore = null;
60
61
    #[ORM\Column(name: 'average_score', type: 'float', precision: 6, scale: 2, nullable: true)]
62
    protected ?float $averageScore = null;
63
64
    #[ORM\Column(name: 'score_weight', type: 'float', precision: 6, scale: 2, nullable: true)]
65
    protected ?float $scoreWeight = null;
66
67
    #[ORM\Column(name: 'user_score_list', type: 'array', nullable: true)]
68
    protected ?array $userScoreList = null;
69
70
    #[ORM\Column(name: 'min_score', type: 'float', precision: 6, scale: 2, nullable: true)]
71
    protected ?float $minScore = null;
72
73
    public function __construct()
74
    {
75
        $this->locked = 0;
76
        $this->visible = 1;
77
    }
78
79
    public function setType(int $type): self
80
    {
81
        $this->type = $type;
82
83
        return $this;
84
    }
85
86
    public function getType(): int
87
    {
88
        return $this->type;
89
    }
90
91
    /**
92
     * Set refId.
93
     *
94
     * @return GradebookLink
95
     */
96
    public function setRefId(int $refId)
97
    {
98
        $this->refId = $refId;
99
100
        return $this;
101
    }
102
103
    /**
104
     * Get refId.
105
     *
106
     * @return int
107
     */
108
    public function getRefId()
109
    {
110
        return $this->refId;
111
    }
112
113
    public function setCreatedAt(DateTime $createdAt): self
114
    {
115
        $this->createdAt = $createdAt;
116
117
        return $this;
118
    }
119
120
    /**
121
     * Get createdAt.
122
     *
123
     * @return DateTime
124
     */
125
    public function getCreatedAt()
126
    {
127
        return $this->createdAt;
128
    }
129
130
    public function setWeight(float $weight): self
131
    {
132
        $this->weight = $weight;
133
134
        return $this;
135
    }
136
137
    /**
138
     * Get weight.
139
     *
140
     * @return float
141
     */
142
    public function getWeight()
143
    {
144
        return $this->weight;
145
    }
146
147
    public function setVisible(int $visible): self
148
    {
149
        $this->visible = $visible;
150
151
        return $this;
152
    }
153
154
    /**
155
     * Get visible.
156
     *
157
     * @return int
158
     */
159
    public function getVisible()
160
    {
161
        return $this->visible;
162
    }
163
164
    public function setLocked(int $locked): self
165
    {
166
        $this->locked = $locked;
167
168
        return $this;
169
    }
170
171
    /**
172
     * Get locked.
173
     *
174
     * @return int
175
     */
176
    public function getLocked()
177
    {
178
        return $this->locked;
179
    }
180
181
    /**
182
     * Get id.
183
     *
184
     * @return int
185
     */
186
    public function getId()
187
    {
188
        return $this->id;
189
    }
190
191
    /**
192
     * @return float
193
     */
194
    public function getBestScore()
195
    {
196
        return $this->bestScore;
197
    }
198
199
    public function setBestScore(float $bestScore): self
200
    {
201
        $this->bestScore = $bestScore;
202
203
        return $this;
204
    }
205
206
    /**
207
     * @return float
208
     */
209
    public function getAverageScore()
210
    {
211
        return $this->averageScore;
212
    }
213
214
    public function setAverageScore(float $averageScore): self
215
    {
216
        $this->averageScore = $averageScore;
217
218
        return $this;
219
    }
220
221
    /**
222
     * @return array
223
     */
224
    public function getUserScoreList()
225
    {
226
        if (empty($this->userScoreList)) {
227
            return [];
228
        }
229
230
        return $this->userScoreList;
231
    }
232
233
    public function setUserScoreList(array $userScoreList): self
234
    {
235
        $this->userScoreList = $userScoreList;
236
237
        return $this;
238
    }
239
240
    /**
241
     * @return float
242
     */
243
    public function getScoreWeight()
244
    {
245
        return $this->scoreWeight;
246
    }
247
248
    public function setScoreWeight(float $scoreWeight): self
249
    {
250
        $this->scoreWeight = $scoreWeight;
251
252
        return $this;
253
    }
254
255
    public function getCategory(): GradebookCategory
256
    {
257
        return $this->category;
258
    }
259
260
    public function setCategory(GradebookCategory $category): self
261
    {
262
        $this->category = $category;
263
264
        return $this;
265
    }
266
267
    public function getMinScore(): ?float
268
    {
269
        return $this->minScore;
270
    }
271
272
    public function setMinScore(?float $minScore): self
273
    {
274
        $this->minScore = $minScore;
275
276
        return $this;
277
    }
278
}
279