Passed
Pull Request — master (#5629)
by Angel Fernando Quiroz
10:06 queued 01:32
created

Quiz::generate()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 24
Code Lines 15

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 15
c 1
b 0
f 0
nc 2
nop 0
dl 0
loc 24
rs 9.7666
1
<?php
2
3
declare(strict_types=1);
4
5
/* For licensing terms, see /license.txt */
6
7
namespace Chamilo\PluginBundle\XApi\ToolExperience\Activity;
8
9
use Chamilo\CourseBundle\Entity\CQuiz;
10
use Xabbuh\XApi\Model\Activity;
11
use Xabbuh\XApi\Model\Definition;
12
use Xabbuh\XApi\Model\IRI;
13
use Xabbuh\XApi\Model\LanguageMap;
14
15
/**
16
 * Class Quiz.
17
 */
18
class Quiz extends BaseActivity
19
{
20
    /**
21
     * @var CQuiz
22
     */
23
    private $quiz;
24
25
    public function __construct(CQuiz $quiz)
26
    {
27
        $this->quiz = $quiz;
28
    }
29
30
    public function generate(): Activity
31
    {
32
        $langIso = api_get_language_isocode();
33
34
        $iri = $this->generateIri(
35
            WEB_CODE_PATH,
36
            'exercise/overview.php',
37
            ['exerciseId' => $this->quiz->getId()]
0 ignored issues
show
Bug introduced by
The method getId() does not exist on Chamilo\CourseBundle\Entity\CQuiz. Did you maybe mean getIid()? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

37
            ['exerciseId' => $this->quiz->/** @scrutinizer ignore-call */ getId()]

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
38
        );
39
40
        $definitionDescription = null;
41
42
        if ($this->quiz->getDescription()) {
43
            $definitionDescription = LanguageMap::create(
44
                [$langIso => $this->quiz->getDescription()]
45
            );
46
        }
47
48
        return new Activity(
49
            IRI::fromString($iri),
50
            new Definition(
51
                LanguageMap::create([$langIso => $this->quiz->getTitle()]),
52
                $definitionDescription,
53
                IRI::fromString('http://adlnet.gov/expapi/activities/assessment')
54
            )
55
        );
56
    }
57
}
58