Skip to content

Commit

Permalink
Use Opencast PHP Library for api call
Browse files Browse the repository at this point in the history
Change error message
  • Loading branch information
elke-hsh committed Jan 15, 2025
1 parent 58c4e74 commit b02ea27
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 11 deletions.
21 changes: 11 additions & 10 deletions classes/local/lti_helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@

namespace filter_opencast\local;

use core\check\performance\debugging;
use oauth_helper;
use tool_opencast\local\settings_api;
use tool_opencast\local\api;
Expand Down Expand Up @@ -199,20 +198,22 @@ public static function get_filter_lti_launch_url(int $ocinstanceid, int $coursei
* This function calls an api endpoint because the url of the engage.ui is different depending on
* the installation (All-In-One or Multiple Servers).
*
* @param int $ocinstancid
* @param int $ocinstanceid
* @return string $url the url of the engage.ui of the opencast installation
* @throws \moodle_exception
*/
public static function get_engage_url(int $ocinstancid) {
$api = api::get_instance($ocinstancid);
public static function get_engage_url(int $ocinstanceid) {
$api = api::get_instance($ocinstanceid);
// Endpoint to call the engage.ui url of presentation node.
// Make sure the api user has the rights to call that api endpoint.
$engageurlendpoint = '/api/info/organization/properties/engageuiurl';
$result = json_decode($api->oc_get($engageurlendpoint), true);
$url = $result['org.opencastproject.engage.ui.url'];
if (!$url) {
throw new \moodle_exception('no_engageurl_error', 'filter_opencast');
$response = $api->opencastapi->baseApi->getOrgEngageUIUrl();
if ($response['code'] != 200) {
global $CFG;
$supportemail = $CFG->supportemail;
throw new \moodle_exception('no_engageurl_error', 'filter_opencast', '', $supportemail);
} else {
$engageui = $response['body'];
return $engageui->{'org.opencastproject.engage.ui.url'};
}
return $url;
}
}
2 changes: 1 addition & 1 deletion lang/en/filter_opencast.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,4 @@
$string['setting_uselti_desc'] = 'When enabled, Opencast videos are delivered through LTI authentication using the <strong>default Opencast video player</strong>. This is typically used alongside Secure Static Files in Opencast for enhanced security.';
$string['setting_uselti_nolti_desc'] = 'To enable LTI Authentication for Opencast, you must configure the required credentials (Consumer Key and Consumer Secret) for this instance. Please do so via this link: {$a}';
$string['setting_uselti_ocinstance_name'] = 'Opencast API {$a} Instance';
$string['no_engageurl_error'] = 'No URL available. Please check if the api endpoint is available and if the api user has the proper rights.';
$string['no_engageurl_error'] = 'Opencast API call for Engage URL not successful. Please contact your support {$a}.';

0 comments on commit b02ea27

Please sign in to comment.