Lti provider - Fix redirection inside lti provider iframe - refs BT#20093

pull/4369/head
Christian 3 years ago
parent 65c9b20623
commit b60c618cad
  1. 2
      main/exercise/exercise_result.php
  2. 6
      main/inc/lib/formvalidator/FormValidator.class.php
  3. 6
      main/inc/lib/javascript/bigupload/inc/bigUpload.php
  4. 10
      main/lp/lp_controller.php

@ -341,7 +341,9 @@ if (!in_array($origin, ['learnpath', 'embeddable', 'mobileapp', 'iframe'])) {
// Record the results in the learning path, using the SCORM interface (API) // Record the results in the learning path, using the SCORM interface (API)
$pageBottom .= "<script>window.parent.API.void_save_asset('$total_score', '$max_score', 0, 'completed');</script>"; $pageBottom .= "<script>window.parent.API.void_save_asset('$total_score', '$max_score', 0, 'completed');</script>";
if (empty($_SESSION['oLP']->lti_launch_id)) {
$pageBottom .= '<script type="text/javascript">'.$href.'</script>'; $pageBottom .= '<script type="text/javascript">'.$href.'</script>';
}
$showFooter = false; $showFooter = false;
} }

@ -1798,6 +1798,10 @@ EOT;
*/ */
private function addMultipleUploadJavascript($url, $inputName, $urlToRedirect = '') private function addMultipleUploadJavascript($url, $inputName, $urlToRedirect = '')
{ {
$target = '_blank';
if (!empty($_SESSION['oLP']->lti_launch_id)) {
$target = '_self';
}
$redirectCondition = ''; $redirectCondition = '';
if (!empty($urlToRedirect)) { if (!empty($urlToRedirect)) {
$redirectCondition = "window.location.replace('$urlToRedirect'); "; $redirectCondition = "window.location.replace('$urlToRedirect'); ";
@ -1914,7 +1918,7 @@ EOT;
} }
if (file.url) { if (file.url) {
var link = $('<a>') var link = $('<a>')
.attr({target: '_blank', class : 'panel-image'}) .attr({target: '".$target."', class : 'panel-image'})
.prop('href', file.url); .prop('href', file.url);
$(data.context.children()[index]).parent().wrap(link); $(data.context.children()[index]).parent().wrap(link);
} }

@ -250,7 +250,11 @@ class BigUploadResponse
$file, $file,
api_get_configuration_value('assignment_prevent_duplicate_upload') api_get_configuration_value('assignment_prevent_duplicate_upload')
); );
$redirectUrl = api_get_path(WEB_CODE_PATH).'work/work.php?'.api_get_cidreq(); $extraParams = '';
if (!empty($_SESSION['oLP'])) {
$extraParams .= '&origin=learnpath';
}
$redirectUrl = api_get_path(WEB_CODE_PATH).'work/work.php?'.api_get_cidreq().$extraParams;
return json_encode(['errorStatus' => 0, 'redirect' => $redirectUrl]); return json_encode(['errorStatus' => 0, 'redirect' => $redirectUrl]);
} }

@ -428,6 +428,11 @@ $is_allowed_to_edit = api_is_allowed_to_edit(false, true, false, false);
if (isset($_SESSION['oLP'])) { if (isset($_SESSION['oLP'])) {
// Reinitialises array used by javascript to update items in the TOC. // Reinitialises array used by javascript to update items in the TOC.
$_SESSION['oLP']->update_queue = []; $_SESSION['oLP']->update_queue = [];
// We check if a tool provider
if (isset($_REQUEST['lti_launch_id'])) {
$ltiLaunchId = Security::remove_XSS($_REQUEST['lti_launch_id']);
$_SESSION['oLP']->lti_launch_id = $ltiLaunchId;
}
} }
$action = !empty($_REQUEST['action']) ? $_REQUEST['action'] : ''; $action = !empty($_REQUEST['action']) ? $_REQUEST['action'] : '';
@ -1657,11 +1662,6 @@ switch ($action) {
} }
if (!empty($_SESSION['oLP'])) { if (!empty($_SESSION['oLP'])) {
// We check if a tool provider
if (isset($_REQUEST['lti_launch_id'])) {
$ltiLaunchId = Security::remove_XSS($_REQUEST['lti_launch_id']);
$_SESSION['oLP']->lti_launch_id = $ltiLaunchId;
}
$_SESSION['lpobject'] = serialize($_SESSION['oLP']); $_SESSION['lpobject'] = serialize($_SESSION['oLP']);
if ($debug > 0) { if ($debug > 0) {
error_log('lpobject is serialized in session', 0); error_log('lpobject is serialized in session', 0);

Loading…
Cancel
Save