ILIAS  trunk Revision v11.0_alpha-1769-g99a433fe2dc
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
class.ilECSCourseMemberConnector.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
27 {
32  public function getCourseMember($course_member_id, bool $a_details = false)
33  {
34  $this->path_postfix = '/campusconnect/course_members/' . (int) $course_member_id;
35 
36  if ($a_details && $course_member_id) {
37  $this->path_postfix .= '/details';
38  }
39 
40  try {
41  $this->prepareConnection();
42  $this->setHeader(array());
43  if ($a_details) {
44  $this->addHeader('Accept', 'application/json');
45  }
46  $this->curl->setOpt(CURLOPT_HTTPHEADER, $this->getHeader());
47  $res = $this->call();
48 
49  if (strpos($res, 'http') === 0) {
50  $json = file_get_contents($res);
51  $ecs_result = new ilECSResult($json);
52  } else {
53  $ecs_result = new ilECSResult($res);
54  }
55 
56  // Return ECSEContentDetails for details switch
57  if ($a_details) {
58  $details = new ilECSEContentDetails();
59  $this->logger->debug(print_r($res, true));
60  $details->loadFromJson($ecs_result->getResult());
61  return $details;
62  }
63 
64  return $ecs_result->getResult();
65  } catch (ilCurlConnectionException $e) {
66  throw new ilECSConnectorException('Error calling ECS service: ' . $e->getMessage());
67  }
68  }
69 }
$res
Definition: ltiservices.php:66
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
getCourseMember($course_member_id, bool $a_details=false)
Get single directory tree.
addHeader(string $a_name, string $a_value)
Add Header.
Presentation of ecs content details (http://...campusconnect/courselinks/id/details) ...
Connector for course member ressource.
setHeader(array $a_header_strings)
prepareConnection()
prepare connection