Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes Opencast-Moodle/moodle-filter_opencast#54 #55

Open
wants to merge 1 commit into
base: MOODLE_405_STABLE
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 28 additions & 1 deletion classes/local/lti_helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,11 @@

namespace filter_opencast\local;

use core\check\performance\debugging;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove this if it is not in use!

use oauth_helper;
use tool_opencast\local\settings_api;
use tool_opencast\local\api;
use moodle_exception;

/**
* LTI helper class for filter opencast.
Expand Down Expand Up @@ -151,7 +154,8 @@ public static function is_lti_credentials_configured(int $ocinstanceid) {
*/
public static function get_lti_set_object(int $ocinstanceid) {
$lticredentials = self::get_lti_credentials($ocinstanceid);
$baseurl = settings_api::get_apiurl($ocinstanceid);
// get url of the engage.ui
$baseurl = self::get_engage_url($ocinstanceid);

return (object) [
'ocinstanceid' => $ocinstanceid,
Expand Down Expand Up @@ -188,4 +192,27 @@ public static function get_filter_lti_launch_url(int $ocinstanceid, int $coursei
}
return $ltilaunchurl;
}

/**
* Calls the URL of the presention node of opencast.
*
* 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
* @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);
// 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);
Copy link
Contributor

@ferishili ferishili Jan 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use opencastapi (Opencast PHP Library) property: getOrgEngageUIUrl
So that would be something like this:
$api->opencastapi->baseApi->getOrgEngageUIUrl();

api->oc_get is no more recommened and it will be removed in near future!

$url = $result['org.opencastproject.engage.ui.url'];
if (!$url) {
throw new \moodle_exception('no_engageurl_error', 'filter_opencast');
}
return $url;
}
}
1 change: 1 addition & 0 deletions lang/en/filter_opencast.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +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.';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to use a more comprehensive (not-technical) info here, as it might be displayed to the end-users and they for example cannot check the api or the user rights!
What do you think?