blob: 2f86aa8cdbbdf5aa91bf8bd700aacb24c397fba8 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
|
<?php
/**
* main-class for connection to LonCapa
*
* This class contains the main methods of the elearning-interface to connect to
* LonCapa. Extends ConnectedCMS.
*
* @access public
* @modulegroup elearning_interface_modules
* @module LonCapaConnectedCMS
* @package ELearning-Interface
*/
class LonCapaConnectedCMS extends ConnectedCMS
{
public $user;
protected $seminarId;
protected $lcRequest;
protected $cmsUrl;
public function __construct($cms = '')
{
parent::__construct($cms);
$this->seminarId = Context::getId();
$this->user = User::findCurrent();
$this->lcRequest = new LonCapaRequest();
$this->cmsUrl = $this->ABSOLUTE_PATH_ELEARNINGMODULES;
}
/**
* search for content modules
*
* returns found content modules
* @throws AccessDeniedException
* @param string $key keyword
* @return array list of content modules
*/
public function searchContentModules($key)
{
if (!$GLOBALS['perm']->have_studip_perm('tutor', $this->seminarId)) {
throw new AccessDeniedException();
}
$url = $this->cmsUrl . '/courses?search=' . urlencode($key) . '&owner=' . urlencode($this->user->username);
$response = $this->lcRequest->request($url);
if ($response) {
$courses = new SimpleXMLElement($response);
$result = [];
foreach ($courses->course as $course) {
$temp = explode(':', (string)$course->owner);
$result[] = [
'ref_id' => (string)$course->id,
'title' => (string)$course->description,
'authors' => $temp[0],
'type' => $this->cms_type
];
}
}
return $result;
}
}
|