Test Failed
Push — master ( 482637...7bef58 )
by Julito
33:32
created

SkillRelItem::getItemResultList()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 13
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

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