From 8e506f0deea0b96fa846a3e69bac764770aaec61 Mon Sep 17 00:00:00 2001 From: Nosolored Date: Fri, 31 Jul 2020 08:33:38 +0200 Subject: [PATCH 1/3] noheader value in origin variable to hide headers --- main/exercise/exercise.php | 2 +- main/exercise/exercise_result.php | 6 +++--- main/exercise/exercise_submit.php | 9 ++++++++- main/exercise/overview.php | 9 ++++++++- main/exercise/result.php | 9 ++++++++- main/inc/lib/display.lib.php | 6 +++++- 6 files changed, 33 insertions(+), 8 deletions(-) diff --git a/main/exercise/exercise.php b/main/exercise/exercise.php index 8b21b3837e..04654a0889 100644 --- a/main/exercise/exercise.php +++ b/main/exercise/exercise.php @@ -506,7 +506,7 @@ if ($is_allowedToEdit) { } } -if ($origin !== 'learnpath') { +if (!in_array($origin, ['learnpath', 'noheader'])) { //so we are not in learnpath tool Display::display_header($nameTools, get_lang('Exercise')); if (isset($_GET['message']) && in_array($_GET['message'], ['ExerciseEdited'])) { diff --git a/main/exercise/exercise_result.php b/main/exercise/exercise_result.php index 3759781d48..e9bdec0d9f 100755 --- a/main/exercise/exercise_result.php +++ b/main/exercise/exercise_result.php @@ -89,7 +89,7 @@ $pageTop = ''; $pageBottom = ''; $pageContent = ''; -if (!in_array($origin, ['learnpath', 'embeddable'])) { +if (!in_array($origin, ['learnpath', 'embeddable', 'noheader'])) { // So we are not in learnpath tool $showHeader = true; } @@ -240,7 +240,7 @@ ExerciseLib::exercise_time_control_delete( ExerciseLib::delete_chat_exercise_session($exe_id); -if (!in_array($origin, ['learnpath', 'embeddable'])) { +if (!in_array($origin, ['learnpath', 'embeddable', 'noheader'])) { $pageBottom .= '
'; $pageBottom .= Display::url( get_lang('ReturnToCourseHomepage'), @@ -254,7 +254,7 @@ if (!in_array($origin, ['learnpath', 'embeddable'])) { } $showFooter = true; -} elseif ($origin === 'embeddable') { +} elseif (in_array($origin, ['embeddable', 'noheader'])) { if (api_is_allowed_to_session_edit()) { Exercise::cleanSessionVariables(); } diff --git a/main/exercise/exercise_submit.php b/main/exercise/exercise_submit.php index 382d442532..ec788ae5b0 100755 --- a/main/exercise/exercise_submit.php +++ b/main/exercise/exercise_submit.php @@ -879,7 +879,7 @@ $interbreadcrumb[] = [ ]; $interbreadcrumb[] = ['url' => '#', 'name' => $objExercise->selectTitle(true)]; -if (!in_array($origin, ['learnpath', 'embeddable'])) { //so we are not in learnpath tool +if (!in_array($origin, ['learnpath', 'embeddable', 'noheader'])) { //so we are not in learnpath tool if (!api_is_allowed_to_session_edit()) { Display::addFlash( Display::return_message(get_lang('SessionIsReadOnly'), 'warning') @@ -892,6 +892,13 @@ if (!in_array($origin, ['learnpath', 'embeddable'])) { //so we are not in learnp echo '
 
'; } +if ($origin == 'noheader') { + echo ''; +} + $show_quiz_edition = $objExercise->added_in_lp(); // I'm in a preview mode diff --git a/main/exercise/overview.php b/main/exercise/overview.php index bfd0b4cd0f..4a7696075d 100755 --- a/main/exercise/overview.php +++ b/main/exercise/overview.php @@ -71,7 +71,7 @@ if ($time_control) { $htmlHeadXtra[] = $objExercise->showTimeControlJS($time_left); } -if (!in_array($origin, ['learnpath', 'embeddable'])) { +if (!in_array($origin, ['learnpath', 'embeddable', 'noheader'])) { Display::display_header(); } else { $htmlHeadXtra[] = " @@ -82,6 +82,13 @@ if (!in_array($origin, ['learnpath', 'embeddable'])) { Display::display_reduced_header(); } +if ($origin == 'noheader') { + echo ''; +} + $html = ''; $message = ''; $html .= '
'; diff --git a/main/exercise/result.php b/main/exercise/result.php index 02045c503c..dbab16829b 100755 --- a/main/exercise/result.php +++ b/main/exercise/result.php @@ -15,7 +15,7 @@ $id = isset($_REQUEST['id']) ? (int) $_GET['id'] : 0; // exe id $show_headers = isset($_REQUEST['show_headers']) ? (int) $_REQUEST['show_headers'] : null; $origin = api_get_origin(); -if (in_array($origin, ['learnpath', 'embeddable'])) { +if (in_array($origin, ['learnpath', 'embeddable', 'noheader'])) { $show_headers = false; } @@ -77,6 +77,13 @@ if ($show_headers) { $htmlHeadXtra[] = ''; + + if ($origin == 'noheader') { + echo ''; + } } $message = Session::read('attempt_remaining'); diff --git a/main/inc/lib/display.lib.php b/main/inc/lib/display.lib.php index c2297d359d..1f41f01f6f 100755 --- a/main/inc/lib/display.lib.php +++ b/main/inc/lib/display.lib.php @@ -64,7 +64,11 @@ class Display ) { $origin = api_get_origin(); $showHeader = true; - if (isset($origin) && $origin == 'learnpath') { + if (isset($origin) && ($origin == 'learnpath' || $origin == 'noheader')) { + $showHeader = false; + } + + if (Session::read('origin') == 'noheader') { $showHeader = false; } From 75da2b784515fa486937f0b7dbb40068ef429cf6 Mon Sep 17 00:00:00 2001 From: Nosolored Date: Fri, 31 Jul 2020 08:55:15 +0200 Subject: [PATCH 2/3] Minor - flint fixes --- main/course_home/last_course.php | 2 +- main/exercise/result.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/main/course_home/last_course.php b/main/course_home/last_course.php index 6c64d52991..988da08ae4 100644 --- a/main/course_home/last_course.php +++ b/main/course_home/last_course.php @@ -20,7 +20,7 @@ $sql = "SELECT c_id, session_id $result = Database::query($sql); -if (Database::num_rows($result )) { +if (Database::num_rows($result)) { $result = Database::fetch_array($result, 'ASSOC'); $courseId = (int) $result['c_id']; $sessionId = (int) $result['session_id']; diff --git a/main/exercise/result.php b/main/exercise/result.php index dbab16829b..d4b13fd7cb 100755 --- a/main/exercise/result.php +++ b/main/exercise/result.php @@ -77,7 +77,7 @@ if ($show_headers) { $htmlHeadXtra[] = ''; - + if ($origin == 'noheader') { echo '
'; echo ''. From 48c60d97690d78056f6eb1b47bcd3d5531ea39c7 Mon Sep 17 00:00:00 2001 From: Nosolored Date: Fri, 31 Jul 2020 14:17:09 +0200 Subject: [PATCH 3/3] mobileapp value in origin variable to hide headers --- main/exercise/exercise.php | 2 +- main/exercise/exercise_result.php | 6 +++--- main/exercise/exercise_submit.php | 6 +++--- main/exercise/overview.php | 4 ++-- main/exercise/result.php | 4 ++-- main/inc/lib/display.lib.php | 4 ++-- 6 files changed, 13 insertions(+), 13 deletions(-) diff --git a/main/exercise/exercise.php b/main/exercise/exercise.php index 04654a0889..a67c71b3fe 100644 --- a/main/exercise/exercise.php +++ b/main/exercise/exercise.php @@ -506,7 +506,7 @@ if ($is_allowedToEdit) { } } -if (!in_array($origin, ['learnpath', 'noheader'])) { +if (!in_array($origin, ['learnpath', 'mobileapp'])) { //so we are not in learnpath tool Display::display_header($nameTools, get_lang('Exercise')); if (isset($_GET['message']) && in_array($_GET['message'], ['ExerciseEdited'])) { diff --git a/main/exercise/exercise_result.php b/main/exercise/exercise_result.php index e9bdec0d9f..4235ed9291 100755 --- a/main/exercise/exercise_result.php +++ b/main/exercise/exercise_result.php @@ -89,7 +89,7 @@ $pageTop = ''; $pageBottom = ''; $pageContent = ''; -if (!in_array($origin, ['learnpath', 'embeddable', 'noheader'])) { +if (!in_array($origin, ['learnpath', 'embeddable', 'mobileapp'])) { // So we are not in learnpath tool $showHeader = true; } @@ -240,7 +240,7 @@ ExerciseLib::exercise_time_control_delete( ExerciseLib::delete_chat_exercise_session($exe_id); -if (!in_array($origin, ['learnpath', 'embeddable', 'noheader'])) { +if (!in_array($origin, ['learnpath', 'embeddable', 'mobileapp'])) { $pageBottom .= '
'; $pageBottom .= Display::url( get_lang('ReturnToCourseHomepage'), @@ -254,7 +254,7 @@ if (!in_array($origin, ['learnpath', 'embeddable', 'noheader'])) { } $showFooter = true; -} elseif (in_array($origin, ['embeddable', 'noheader'])) { +} elseif (in_array($origin, ['embeddable', 'mobileapp'])) { if (api_is_allowed_to_session_edit()) { Exercise::cleanSessionVariables(); } diff --git a/main/exercise/exercise_submit.php b/main/exercise/exercise_submit.php index ec788ae5b0..b544735b91 100755 --- a/main/exercise/exercise_submit.php +++ b/main/exercise/exercise_submit.php @@ -79,7 +79,7 @@ if ('true' === api_get_setting('enable_record_audio')) { } $zoomOptions = api_get_configuration_value('quiz_image_zoom'); -if (isset($zoomOptions['options']) && !in_array($origin, ['embeddable', 'noheader'])) { +if (isset($zoomOptions['options']) && !in_array($origin, ['embeddable', 'mobileapp'])) { $options = $zoomOptions['options']; $htmlHeadXtra[] = ''; $htmlHeadXtra[] = '