diff --git a/filter.php b/filter.php index fda0c3a53664aed07c5fd791c58a620a5d5f5e17..754791f2126e5dedb847e5fcc7ba5d81d6367f49 100644 --- a/filter.php +++ b/filter.php @@ -69,24 +69,28 @@ class filter_opencast extends moodle_text_filter { } else if ($video) { $video = false; if (substr($match, 0, 7) === "<source") { - // Get apiurl from opencast tool. - $apiurl = get_config('tool_opencast', 'apiurl'); + // 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. - if (strpos($match, $apiurl) === false) { + if (strpos($match, $baseurl) === false) { continue; } - if (strpos($apiurl, 'http') !== 0) { - $apiurl = 'http://' . $apiurl; + if (strpos($baseurl, 'http') !== 0) { + $baseurl = 'http://' . $baseurl; } // Extract id. $id = substr($match, strpos($match, 'api/') + 4, 36); - $src = $CFG->wwwroot . '/filter/opencast/player/core.html?id=' . $id . '&ocurl=' . urlencode($apiurl); + $src = $CFG->wwwroot . '/filter/opencast/player/core.html?id=' . $id . '&ocurl=' . urlencode($baseurl); // Create link to video. - $link = $apiurl . '/engage/theodul/ui/core.html?id=' . $id; + $link = $baseurl . '/engage/theodul/ui/core.html?id=' . $id; // Collect the needed data being submitted to the template. $mustachedata = new stdClass(); diff --git a/lang/en/filter_opencast.php b/lang/en/filter_opencast.php index cd97c6d351baa651c1cbc7ad4d76403fdb34bd17..7a97e5d56b44fe010bb9cb17b7be21e6eeb3176c 100644 --- a/lang/en/filter_opencast.php +++ b/lang/en/filter_opencast.php @@ -28,4 +28,6 @@ $string['pluginname'] = 'Opencast Filter'; $string['setting_consumerkey'] = 'Consumer key'; $string['setting_consumerkey_desc'] = 'LTI Consumer key'; $string['setting_consumersecret'] = 'Consumer secret'; -$string['setting_consumersecret_desc'] = 'LTI Consumer secret'; \ No newline at end of file +$string['setting_consumersecret_desc'] = 'LTI Consumer secret'; +$string['setting_engageurl'] = 'URL of the Opencast Engage server'; +$string['setting_engageurl_desc'] = 'If empty, the base URL of the admin tool is used.'; \ No newline at end of file diff --git a/lib.php b/lib.php index a9b3856a3baa8b5c7ba01f2802f5af3711daa0a5..1347972a93fa5b5a9ab36064d781fea38a993d6c 100644 --- a/lib.php +++ b/lib.php @@ -32,8 +32,8 @@ require_once($CFG->dirroot . '/lib/oauthlib.php'); function filter_opencast_login() { global $PAGE; - // Get api url of opencast. - $endpoint = get_config('tool_opencast', 'apiurl'); + // Get url of opencast engage server + $endpoint = get_config('filter_opencast', 'engageurl'); if (strpos($endpoint, 'http') !== 0) { $endpoint = 'http://' . $endpoint; } @@ -44,13 +44,13 @@ function filter_opencast_login() { // Render form. $renderer = $PAGE->get_renderer('filter_opencast'); - echo $renderer->render_player($endpoint, $params); + echo $renderer->render_lti_form($endpoint, $params); // Submit form. $PAGE->requires->js_call_amd('filter_opencast/form', 'init'); } -function filter_opencast_create_parameters() { +function filter_opencast_create_parameters($endpoint) { global $CFG, $COURSE, $USER; // Get consumerkey and consumersecret. diff --git a/settings.php b/settings.php index cd977f93eb94af47607c0b78e11dd5f50338c6fd..9851cb9dd45405c1adbcb1c6aedd0b6d841b778e 100644 --- a/settings.php +++ b/settings.php @@ -27,7 +27,11 @@ if ($ADMIN->fulltree) { $settings->add(new admin_setting_configtext('filter_opencast/consumerkey', get_string('setting_consumerkey', 'filter_opencast'), get_string('setting_consumerkey_desc', 'filter_opencast'), '')); - $settings->add(new admin_setting_configtext('filter_opencast/consumersecret', + $settings->add(new admin_setting_configpasswordunmask('filter_opencast/consumersecret', get_string('setting_consumersecret', 'filter_opencast'), get_string('setting_consumersecret_desc', 'filter_opencast'), '')); + $settings->add(new admin_setting_configtext('filter_opencast/engageurl', + get_string('setting_engageurl', 'filter_opencast'), + get_string('setting_engageurl_desc', 'filter_opencast'), '')); + } diff --git a/version.php b/version.php index 3d007ef7531e0a0bcb3c6920d20ae0ec34583e3c..649b8239ab69da89f231f40d5d407afdb6493012 100644 --- a/version.php +++ b/version.php @@ -25,7 +25,7 @@ defined('MOODLE_INTERNAL') || die(); -$plugin->version = 2018021501; // The current plugin version (Date: YYYYMMDDXX). +$plugin->version = 2018031900; // The current plugin version (Date: YYYYMMDDXX). $plugin->requires = 2017050500; // Requires this Moodle version. $plugin->component = 'filter_opencast'; // Full name of the plugin. $plugin->dependencies = array('tool_opencast' => ANY_VERSION);