| Conditions | 4 |
| Paths | 6 |
| Total Lines | 43 |
| Code Lines | 25 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 11 | public function hookCreated(HookLearningPathCreatedEventInterface $hookEvent) |
||
| 12 | { |
||
| 13 | /** @var learnpath $lp */ |
||
| 14 | $lp = $hookEvent->getEventData()['lp']; |
||
| 15 | $userId = api_get_user_id(); |
||
| 16 | $courseCode = api_get_course_id(); |
||
| 17 | |||
| 18 | $cidreq = api_get_cidreq(); |
||
| 19 | |||
| 20 | $url = api_get_path(WEB_CODE_PATH).'lp/lp_controller.php?'; |
||
| 21 | $url .= ($cidreq ? $cidreq.'&' : ''); |
||
| 22 | $url .= http_build_query( |
||
| 23 | [ |
||
| 24 | 'action' => 'view', |
||
| 25 | 'lp_id' => $lp->lp_id, |
||
| 26 | 'isStudentView' => 'true', |
||
| 27 | ] |
||
| 28 | ); |
||
| 29 | |||
| 30 | try { |
||
| 31 | $json = $this->doCreateRequest( |
||
| 32 | [ |
||
| 33 | 'user_id' => $userId, |
||
| 34 | 'course_code' => $courseCode, |
||
| 35 | 'content_id' => $lp->get_id(), |
||
| 36 | 'content_type' => 'lp', |
||
| 37 | 'content_url' => $url, |
||
| 38 | 'post_title' => $lp->get_name(), |
||
| 39 | ] |
||
| 40 | ); |
||
| 41 | } catch (Exception $e) { |
||
| 42 | Display::addFlash( |
||
| 43 | Display::return_message($e->getMessage(), 'error') |
||
| 44 | ); |
||
| 45 | |||
| 46 | return; |
||
| 47 | } |
||
| 48 | |||
| 49 | if (empty($json)) { |
||
| 50 | return; |
||
| 51 | } |
||
| 52 | |||
| 53 | error_log('ExtNotifConn: Learning path created: ID '.$json['data']['notification_id']); |
||
| 54 | } |
||
| 56 |