This commit is contained in:
Markos Gogoulos
2026-01-29 16:36:57 +02:00
parent c04380af47
commit 571bfcc4ce
2 changed files with 18 additions and 10 deletions

View File

@@ -239,7 +239,7 @@ CONCURRENT_UPLOADS = True
CHUNKS_DONE_PARAM_NAME = "done"
FILE_STORAGE = "django.core.files.storage.DefaultStorage"
X_FRAME_OPTIONS = "ALLOWALL"
X_FRAME_OPTIONS = "SAMEORIGIN"
EMAIL_BACKEND = "djcelery_email.backends.CeleryEmailBackend"
CELERY_EMAIL_TASK_CONFIG = {
"queue": "short_tasks",
@@ -416,8 +416,6 @@ CACHES = {
}
}
# Use cached_db for reliability - stores in both cache AND database
# This prevents session loss during multiple simultaneous LTI launches
SESSION_ENGINE = "django.contrib.sessions.backends.cache"
SESSION_CACHE_ALIAS = "default"
@@ -667,3 +665,6 @@ if USE_LTI:
SESSION_COOKIE_SECURE = True
CSRF_COOKIE_SAMESITE = 'None'
CSRF_COOKIE_SECURE = True
SESSION_ENGINE = "django.contrib.sessions.backends.cached_db"
# Use cached_db for reliability - stores in both cache AND database
# This prevents session loss during multiple simultaneous LTI launches

View File

@@ -29,7 +29,7 @@ defined('MOODLE_INTERNAL') || die();
/**
* Filter class for converting MediaCMS URLs to LTI iframes.
*/
class text_filter extends \core_filters\text_filter {
class text_filter extends \core_filters ext_filter {
/**
* Apply the filter to the given text.
@@ -70,7 +70,8 @@ class text_filter extends \core_filters\text_filter {
// - https://lti.mediacms.io/view?m=TOKEN
// - https://lti.mediacms.io/embed?m=TOKEN
// - http versions
$pattern = '/https?:\/\/' . $escapeddomain . '\/(view|embed)\?m=([a-zA-Z0-9_-]+)/i';
// Improved regex to handle parameters in any order
$pattern = '/https?:\/\/' . $escapeddomain . '\/(view|embed)\?(?:[^"\s]*&)?m=([a-zA-Z0-9_-]+)(?:&[^"\s]*)?/i';
// Find all matches.
if (!preg_match_all($pattern, $text, $matches, PREG_SET_ORDER)) {
@@ -106,19 +107,25 @@ class text_filter extends \core_filters\text_filter {
'height' => $iframeheight
]);
// Generate iframe (like Kaltura does)
// Calculate aspect ratio percentage for responsive container
$ratio = ($iframeheight / $iframewidth) * 100;
// Generate iframe (responsive)
$iframe = \html_writer::tag('iframe', '', array(
'width' => $iframewidth,
'height' => $iframeheight,
'width' => '100%',
'height' => '100%',
'class' => 'mediacms-player-iframe',
'allowfullscreen' => 'true',
'allow' => 'autoplay *; fullscreen *; encrypted-media *; camera *; microphone *; display-capture *;',
'src' => $launchurl->out(false),
'frameborder' => '0'
'frameborder' => '0',
'style' => 'position: absolute; top: 0; left: 0; width: 100%; height: 100%;',
'title' => 'MediaCMS Video'
));
$iframeContainer = \html_writer::tag('div', $iframe, array(
'class' => 'mediacms-player-container'
'class' => 'mediacms-player-container',
'style' => 'position: relative; padding-bottom: ' . $ratio . '%; height: 0; overflow: hidden; max-width: 100%; background: #000; border-radius: 4px;'
));
$text = str_replace($fullurl, $iframeContainer, $text);