Completed
Push — master ( 0dfc19...c58ed8 )
by Julito
10:02
created

SkillRelItem::getCreatedAt()   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
/* For licensing terms, see /license.txt */
4
5
namespace Chamilo\CoreBundle\Entity;
6
7
use Doctrine\ORM\Mapping as ORM;
8
use Gedmo\Timestampable\Traits\TimestampableEntity;
9
10
/**
11
 * SkillRelItem.
12
 *
13
 * @ORM\Table(name="skill_rel_item")
14
 * @ORM\Entity
15
 */
16
class SkillRelItem
17
{
18
    use TimestampableEntity;
19
20
    /**
21
     * @var int
22
     *
23
     * @ORM\Column(name="id", type="integer")
24
     * @ORM\Id
25
     * @ORM\GeneratedValue
26
     */
27
    protected $id;
28
29
    /**
30
     * @ORM\ManyToOne(targetEntity="Chamilo\CoreBundle\Entity\Skill", inversedBy="items")
31
     * @ORM\JoinColumn(name="skill_id", referencedColumnName="id")
32
     */
33
    protected $skill;
34
35
    /**
36
     * See ITEM_TYPE_* constants in api.lib.php.
37
     *
38
     * @var int
39
     *
40
     * @ORM\Column(name="item_type", type="integer", nullable=false)
41
     */
42
    protected $itemType;
43
44
    /**
45
     * iid value.
46
     *
47
     * @var int
48
     *
49
     * @ORM\Column(name="item_id", type="integer", nullable=false)
50
     */
51
    protected $itemId;
52
53
    /**
54
     * A text expressing what has to be achieved
55
     * (view, finish, get more than X score, finishing all children skills, etc),.
56
     *
57
     * @var string
58
     *
59
     * @ORM\Column(name="obtain_conditions", type="string", length=255, nullable=true)
60
     */
61
    protected $obtainConditions;
62
63
    /**
64
     * if it requires validation by a teacher.
65
     *
66
     * @var bool
67
     *
68
     * @ORM\Column(name="requires_validation", type="boolean")
69
     */
70
    protected $requiresValidation;
71
72
    /**
73
     *  Set to false if this is a children skill used only to obtain a higher-level skill,
74
     * so a skill with is_real = false never appears in a student portfolio/backpack.
75
     *
76
     * @var bool
77
     *
78
     * @ORM\Column(name="is_real", type="boolean")
79
     */
80
    protected $isReal;
81
82
    /**
83
     * @var int
84
     *
85
     * @ORM\Column(name="c_id", type="integer", nullable=true)
86
     */
87
    protected $courseId;
88
89
    /**
90
     * @var int
91
     *
92
     * @ORM\Column(name="session_id", type="integer", nullable=true)
93
     */
94
    protected $sessionId;
95
96
    /**
97
     * @var int
98
     *
99
     * @ORM\Column(name="created_by", type="integer", nullable=false)
100
     */
101
    protected $createdBy;
102
103
    /**
104
     * @var int
105
     *
106
     * @ORM\Column(name="updated_by", type="integer", nullable=false)
107
     */
108
    protected $updatedBy;
109
110
    /**
111
     * SkillRelItem constructor.
112
     */
113
    public function __construct()
114
    {
115
        $this->createdAt = new \DateTime('now');
0 ignored issues
show
Bug Best Practice introduced by
The property createdAt does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
116
        $this->updatedAt = new \DateTime('now');
0 ignored issues
show
Bug Best Practice introduced by
The property updatedAt does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
117
        $this->isReal = false;
118
        $this->requiresValidation = false;
119
    }
120
121
    /**
122
     * @return int
123
     */
124
    public function getId()
125
    {
126
        return $this->id;
127
    }
128
129
    /**
130
     * @param int $id
131
     *
132
     * @return SkillRelItem
133
     */
134
    public function setId($id)
135
    {
136
        $this->id = $id;
137
138
        return $this;
139
    }
140
141
    /**
142
     * @return Skill
143
     */
144
    public function getSkill()
145
    {
146
        return $this->skill;
147
    }
148
149
    /**
150
     * @return SkillRelItem
151
     */
152
    public function setSkill(Skill $skill)
153
    {
154
        $this->skill = $skill;
155
156
        return $this;
157
    }
158
159
    /**
160
     * @return int
161
     */
162
    public function getItemId()
163
    {
164
        return $this->itemId;
165
    }
166
167
    /**
168
     * @param int $itemId
169
     *
170
     * @return SkillRelItem
171
     */
172
    public function setItemId($itemId)
173
    {
174
        $this->itemId = $itemId;
175
176
        return $this;
177
    }
178
179
    /**
180
     * @return string
181
     */
182
    public function getObtainConditions()
183
    {
184
        return $this->obtainConditions;
185
    }
186
187
    /**
188
     * @param string $obtainConditions
189
     *
190
     * @return SkillRelItem
191
     */
192
    public function setObtainConditions($obtainConditions)
193
    {
194
        $this->obtainConditions = $obtainConditions;
195
196
        return $this;
197
    }
198
199
    /**
200
     * @return bool
201
     */
202
    public function isRequiresValidation()
203
    {
204
        return $this->requiresValidation;
205
    }
206
207
    /**
208
     * @param bool $requiresValidation
209
     *
210
     * @return SkillRelItem
211
     */
212
    public function setRequiresValidation($requiresValidation)
213
    {
214
        $this->requiresValidation = $requiresValidation;
215
216
        return $this;
217
    }
218
219
    /**
220
     * @return bool
221
     */
222
    public function isReal()
223
    {
224
        return $this->isReal;
225
    }
226
227
    /**
228
     * @param bool $isReal
229
     *
230
     * @return SkillRelItem
231
     */
232
    public function setIsReal($isReal)
233
    {
234
        $this->isReal = $isReal;
235
236
        return $this;
237
    }
238
239
    /**
240
     * @return \DateTime
241
     */
242
    public function getCreatedAt()
243
    {
244
        return $this->createdAt;
245
    }
246
247
    /**
248
     * @param \DateTime $createdAt
249
     *
250
     * @return SkillRelItem
251
     */
252
    public function setCreatedAt($createdAt)
253
    {
254
        $this->createdAt = $createdAt;
0 ignored issues
show
Bug Best Practice introduced by
The property createdAt does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
255
256
        return $this;
257
    }
258
259
    /**
260
     * @return \DateTime
261
     */
262
    public function getUpdatedAt()
263
    {
264
        return $this->updatedAt;
265
    }
266
267
    /**
268
     * @param \DateTime $updatedAt
269
     *
270
     * @return SkillRelItem
271
     */
272
    public function setUpdatedAt($updatedAt)
273
    {
274
        $this->updatedAt = $updatedAt;
0 ignored issues
show
Bug Best Practice introduced by
The property updatedAt does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
275
276
        return $this;
277
    }
278
279
    /**
280
     * @return int
281
     */
282
    public function getCreatedBy()
283
    {
284
        return $this->createdBy;
285
    }
286
287
    /**
288
     * @param int $createdBy
289
     *
290
     * @return SkillRelItem
291
     */
292
    public function setCreatedBy($createdBy)
293
    {
294
        $this->createdBy = $createdBy;
295
296
        return $this;
297
    }
298
299
    /**
300
     * @return int
301
     */
302
    public function getUpdatedBy()
303
    {
304
        return $this->updatedBy;
305
    }
306
307
    /**
308
     * @param int $updatedBy
309
     *
310
     * @return SkillRelItem
311
     */
312
    public function setUpdatedBy($updatedBy)
313
    {
314
        $this->updatedBy = $updatedBy;
315
316
        return $this;
317
    }
318
319
    /**
320
     * @return int
321
     */
322
    public function getItemType()
323
    {
324
        return $this->itemType;
325
    }
326
327
    /**
328
     * @param int $itemType
329
     *
330
     * @return SkillRelItem
331
     */
332
    public function setItemType($itemType)
333
    {
334
        $this->itemType = $itemType;
335
336
        return $this;
337
    }
338
339
    /**
340
     * @return int
341
     */
342
    public function getCourseId()
343
    {
344
        return $this->courseId;
345
    }
346
347
    /**
348
     * @param int $courseId
349
     *
350
     * @return SkillRelItem
351
     */
352
    public function setCourseId($courseId)
353
    {
354
        $this->courseId = $courseId;
355
356
        return $this;
357
    }
358
359
    /**
360
     * @return int
361
     */
362
    public function getSessionId()
363
    {
364
        return $this->sessionId;
365
    }
366
367
    /**
368
     * @param int $sessionId
369
     *
370
     * @return SkillRelItem
371
     */
372
    public function setSessionId($sessionId)
373
    {
374
        $this->sessionId = $sessionId;
375
376
        return $this;
377
    }
378
379
    /**
380
     * @param string $cidReq
381
     *
382
     * @return string
383
     */
384
    public function getItemResultUrl($cidReq)
385
    {
386
        $url = '';
387
        switch ($this->getItemType()) {
388
            case ITEM_TYPE_EXERCISE:
389
                $url = 'exercise/exercise_show.php?action=qualify&'.$cidReq;
390
391
                break;
392
            case ITEM_TYPE_STUDENT_PUBLICATION:
393
                $url = 'work/view.php?'.$cidReq;
394
395
                break;
396
        }
397
398
        return $url;
399
    }
400
401
    /**
402
     * @param string $cidReq
403
     *
404
     * @return string
405
     */
406
    public function getItemResultList($cidReq)
407
    {
408
        $url = '';
409
        switch ($this->getItemType()) {
410
            case ITEM_TYPE_EXERCISE:
411
                $url = 'exercise/exercise_report.php?'.$cidReq.'&id='.$this->getItemId();
412
413
                break;
414
            case ITEM_TYPE_STUDENT_PUBLICATION:
415
                $url = 'work/work_list_all.php?'.$cidReq.'&id='.$this->getItemId();
416
417
                break;
418
        }
419
420
        return $url;
421
    }
422
}
423