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

XApiLearningPathEndHookObserver   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 15
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 8
dl 0
loc 15
c 1
b 0
f 0
rs 10
wmc 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A notifyLearningPathEnd() 0 13 1
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