Skip to content
Snippets Groups Projects
Commit 29ed1551 authored by Tobias Reischmann's avatar Tobias Reischmann
Browse files

Merge branch 'develop'

parents 2b15e3c0 5764cef8
Branches
Tags
No related merge requests found
...@@ -43,7 +43,13 @@ class filter_opencast extends moodle_text_filter { ...@@ -43,7 +43,13 @@ class filter_opencast extends moodle_text_filter {
public function filter($text, array $options = array()) { public function filter($text, array $options = array()) {
global $PAGE; global $PAGE;
if (stripos($text, '</video>') === false) { // Get baseurl either from engageurl setting or from opencast tool.
$baseurl = get_config('filter_opencast', 'engageurl');
if (empty($baseurl)) {
$baseurl = get_config('tool_opencast', 'apiurl');
}
if (stripos($text, $baseurl) === false) {
// Performance shortcut - if there are no </video> tags, nothing can match. // Performance shortcut - if there are no </video> tags, nothing can match.
return $text; return $text;
} }
...@@ -56,7 +62,7 @@ class filter_opencast extends moodle_text_filter { ...@@ -56,7 +62,7 @@ class filter_opencast extends moodle_text_filter {
// Login if user is not logged in yet. // Login if user is not logged in yet.
$loggedin = true; $loggedin = true;
if (!isset($_COOKIE['JSESSIONID']) && !self::$loginrendered) { if (!self::$loginrendered) {
// Login and set cookie. // Login and set cookie.
filter_opencast_login(); filter_opencast_login();
$loggedin = false; $loggedin = false;
...@@ -73,29 +79,20 @@ class filter_opencast extends moodle_text_filter { ...@@ -73,29 +79,20 @@ class filter_opencast extends moodle_text_filter {
$video = false; $video = false;
if (substr($match, 0, 7) === "<source") { if (substr($match, 0, 7) === "<source") {
// Get baseurl either from engageurl setting or from opencast tool.
$baseurl = get_config('filter_opencast', 'engageurl');
if (empty($baseurl)) {
$baseurl = get_config('tool_opencast', 'apiurl');
}
// Check if video is from opencast. // Check if video is from opencast.
if (strpos($match, $baseurl) === false) { if (strpos($match, $baseurl) === false) {
continue; continue;
} }
if (strpos($baseurl, 'http') !== 0) { // Extract url.
$baseurl = 'http://' . $baseurl; preg_match_all('/<source[^>]+src=([\'"])(?<src>.+?)\1[^>]*>/i', $match, $result);
}
// Extract id.
$id = substr($match, strpos($match, 'api/') + 4, 36);
// Create link to video.
$playerurl = get_config('filter_opencast', 'playerurl');
// Change url for loading the (Paella) Player. // Change url for loading the (Paella) Player.
$link = $baseurl . $playerurl .'?id=' . $id; $link = $result['src'][0];
if (strpos($link, 'http') !== 0) {
$link = 'http://' . $link;
}
// Create source with embedded mode. // Create source with embedded mode.
$src = $link; $src = $link;
...@@ -109,7 +106,7 @@ class filter_opencast extends moodle_text_filter { ...@@ -109,7 +106,7 @@ class filter_opencast extends moodle_text_filter {
$newtext = $renderer->render_player($mustachedata); $newtext = $renderer->render_player($mustachedata);
// Replace video tag. // Replace video tag.
$text = preg_replace('/<video.*<\/video>/', $newtext, $text, 1); $text = preg_replace('/<video(?:(?!<\/video>).)*?' . preg_quote($match, '/') . '.*?<\/video>/', $newtext, $text, 1);
} }
} }
} }
......
...@@ -92,6 +92,7 @@ function filter_opencast_create_parameters($endpoint) { ...@@ -92,6 +92,7 @@ function filter_opencast_create_parameters($endpoint) {
$params['lti_message_type'] = 'basic-lti-launch-request'; $params['lti_message_type'] = 'basic-lti-launch-request';
$urlparts = parse_url($CFG->wwwroot); $urlparts = parse_url($CFG->wwwroot);
$params['tool_consumer_instance_guid'] = $urlparts['host']; $params['tool_consumer_instance_guid'] = $urlparts['host'];
$params['custom_tool'] = '/ltitools';
// User data. // User data.
$params['user_id'] = $USER->id; $params['user_id'] = $USER->id;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment