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

notifyLearningPathEnd()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 13
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 7
nc 1
nop 1
dl 0
loc 13
c 1
b 0
f 0
cc 1
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
/* For licensing terms, see /license.txt */
6
7
use Chamilo\PluginBundle\XApi\ToolExperience\Statement\LearningPathCompleted;
8
9
class XApiLearningPathEndHookObserver extends XApiActivityHookObserver implements HookLearningPathEndObserverInterface
10
{
11
    public function notifyLearningPathEnd(HookLearningPathEndEventInterface $event): void
12
    {
13
        $data = $event->getEventData();
14
        $em = Database::getManager();
15
16
        $lpView = $em->find('ChamiloCourseBundle:CLpView', $data['lp_view_id']);
17
        $lp = $em->find('ChamiloCourseBundle:CLp', $lpView->getLpId());
18
19
        $learningPathEnded = new LearningPathCompleted($lpView, $lp);
20
21
        $statement = $learningPathEnded->generate();
22
23
        $this->saveSharedStatement($statement);
24
    }
25
}
26