Skip to content

Commit b02ea27

Browse files
committed
Use Opencast PHP Library for api call
Change error message
1 parent 58c4e74 commit b02ea27

File tree

2 files changed

+12
-11
lines changed

2 files changed

+12
-11
lines changed

classes/local/lti_helper.php

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424

2525
namespace filter_opencast\local;
2626

27-
use core\check\performance\debugging;
2827
use oauth_helper;
2928
use tool_opencast\local\settings_api;
3029
use tool_opencast\local\api;
@@ -199,20 +198,22 @@ public static function get_filter_lti_launch_url(int $ocinstanceid, int $coursei
199198
* This function calls an api endpoint because the url of the engage.ui is different depending on
200199
* the installation (All-In-One or Multiple Servers).
201200
*
202-
* @param int $ocinstancid
201+
* @param int $ocinstanceid
203202
* @return string $url the url of the engage.ui of the opencast installation
204203
* @throws \moodle_exception
205204
*/
206-
public static function get_engage_url(int $ocinstancid) {
207-
$api = api::get_instance($ocinstancid);
205+
public static function get_engage_url(int $ocinstanceid) {
206+
$api = api::get_instance($ocinstanceid);
208207
// Endpoint to call the engage.ui url of presentation node.
209208
// Make sure the api user has the rights to call that api endpoint.
210-
$engageurlendpoint = '/api/info/organization/properties/engageuiurl';
211-
$result = json_decode($api->oc_get($engageurlendpoint), true);
212-
$url = $result['org.opencastproject.engage.ui.url'];
213-
if (!$url) {
214-
throw new \moodle_exception('no_engageurl_error', 'filter_opencast');
209+
$response = $api->opencastapi->baseApi->getOrgEngageUIUrl();
210+
if ($response['code'] != 200) {
211+
global $CFG;
212+
$supportemail = $CFG->supportemail;
213+
throw new \moodle_exception('no_engageurl_error', 'filter_opencast', '', $supportemail);
214+
} else {
215+
$engageui = $response['body'];
216+
return $engageui->{'org.opencastproject.engage.ui.url'};
215217
}
216-
return $url;
217218
}
218219
}

lang/en/filter_opencast.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,4 +35,4 @@
3535
$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.';
3636
$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}';
3737
$string['setting_uselti_ocinstance_name'] = 'Opencast API {$a} Instance';
38-
$string['no_engageurl_error'] = 'No URL available. Please check if the api endpoint is available and if the api user has the proper rights.';
38+
$string['no_engageurl_error'] = 'Opencast API call for Engage URL not successful. Please contact your support {$a}.';

0 commit comments

Comments
 (0)