Exercise - Improve icon to get exercise url to include it in a iframe - refs BT#19381

pull/4150/head
Christian 4 years ago
parent 3eef3e9f17
commit c772d01564
  1. 4
      main/exercise/exercise.class.php
  2. 2
      main/exercise/exercise_question_reminder.php
  3. 2
      main/exercise/exercise_reminder.php
  4. 12
      main/exercise/exercise_result.php
  5. 32
      main/exercise/exercise_submit.php
  6. 2
      main/exercise/overview.php
  7. 2
      main/exercise/result.php

@ -9597,7 +9597,7 @@ class Exercise
); );
// Link to embed the quiz // Link to embed the quiz
$urlEmbed = api_get_path(WEB_CODE_PATH).'exercise/overview.php?'.api_get_cidreq().'&origin=embeddable&exerciseId='.$row['iid']; $urlEmbed = api_get_path(WEB_CODE_PATH).'exercise/overview.php?'.api_get_cidreq().'&origin=iframe&exerciseId='.$row['iid'];
$actions .= Display::url( $actions .= Display::url(
Display::return_icon('new_link.png', get_lang('Embed')), Display::return_icon('new_link.png', get_lang('Embed')),
'', '',
@ -11824,7 +11824,7 @@ class Exercise
$msg = str_replace("#mail#", $user_info['email'], $msg1); $msg = str_replace("#mail#", $user_info['email'], $msg1);
$msg = str_replace("#course#", $courseInfo['name'], $msg1); $msg = str_replace("#course#", $courseInfo['name'], $msg1);
if (!in_array($origin, ['learnpath', 'embeddable'])) { if (!in_array($origin, ['learnpath', 'embeddable', 'iframe'])) {
$msg .= '<br /><a href="#url#">'.get_lang('ClickToCommentAndGiveFeedback').'</a>'; $msg .= '<br /><a href="#url#">'.get_lang('ClickToCommentAndGiveFeedback').'</a>';
} }
$msg1 = str_replace("#url#", $url_email, $msg); $msg1 = str_replace("#url#", $url_email, $msg);

@ -93,7 +93,7 @@ if ($validateCategory) {
$nameTools = get_lang('Exercises'); $nameTools = get_lang('Exercises');
$interbreadcrumb[] = ['url' => 'exercise.php?'.api_get_cidreq(), 'name' => get_lang('Exercises')]; $interbreadcrumb[] = ['url' => 'exercise.php?'.api_get_cidreq(), 'name' => get_lang('Exercises')];
$hideHeaderAndFooter = in_array($origin, ['learnpath', 'embeddable']); $hideHeaderAndFooter = in_array($origin, ['learnpath', 'embeddable', 'iframe']);
if (!$hideHeaderAndFooter) { if (!$hideHeaderAndFooter) {
Display::display_header($nameTools, get_lang('Exercise')); Display::display_header($nameTools, get_lang('Exercise'));

@ -79,7 +79,7 @@ if (empty($exercise_stat_info) || empty($question_list)) {
$nameTools = get_lang('Exercises'); $nameTools = get_lang('Exercises');
$interbreadcrumb[] = ['url' => 'exercise.php?'.api_get_cidreq(), 'name' => get_lang('Exercises')]; $interbreadcrumb[] = ['url' => 'exercise.php?'.api_get_cidreq(), 'name' => get_lang('Exercises')];
$hideHeaderAndFooter = in_array($origin, ['learnpath', 'embeddable']); $hideHeaderAndFooter = in_array($origin, ['learnpath', 'embeddable', 'iframe']);
if (!$hideHeaderAndFooter) { if (!$hideHeaderAndFooter) {
Display::display_header($nameTools, get_lang('Exercise')); Display::display_header($nameTools, get_lang('Exercise'));

@ -88,14 +88,14 @@ $pageTop = '';
$pageBottom = ''; $pageBottom = '';
$pageContent = ''; $pageContent = '';
$courseInfo = api_get_course_info(); $courseInfo = api_get_course_info();
if (!in_array($origin, ['learnpath', 'embeddable', 'mobileapp'])) { if (!in_array($origin, ['learnpath', 'embeddable', 'mobileapp', 'iframe'])) {
// So we are not in learnpath tool // So we are not in learnpath tool
$showHeader = true; $showHeader = true;
$showLearnPath = false; $showLearnPath = false;
} }
// I'm in a preview mode as course admin. Display the action menu. // I'm in a preview mode as course admin. Display the action menu.
if (api_is_course_admin() && !in_array($origin, ['learnpath', 'embeddable'])) { if (api_is_course_admin() && !in_array($origin, ['learnpath', 'embeddable', 'iframe'])) {
$pageActions = Display::toolbarAction( $pageActions = Display::toolbarAction(
'exercise_result_actions', 'exercise_result_actions',
[ [
@ -143,7 +143,7 @@ if ($origin === 'learnpath') {
$i = $total_score = $max_score = 0; $i = $total_score = $max_score = 0;
$remainingMessage = ''; $remainingMessage = '';
$attemptButton = ''; $attemptButton = '';
if ($origin !== 'embeddable') { if (!in_array($origin, ['iframe', 'embeddable'])) {
$attemptButton = Display::toolbarButton( $attemptButton = Display::toolbarButton(
get_lang('AnotherAttempt'), get_lang('AnotherAttempt'),
api_get_path(WEB_CODE_PATH).'exercise/overview.php?'.api_get_cidreq().'&'.http_build_query( api_get_path(WEB_CODE_PATH).'exercise/overview.php?'.api_get_cidreq().'&'.http_build_query(
@ -178,7 +178,7 @@ if ($objExercise->selectAttempts() > 0) {
) )
); );
if (!in_array($origin, ['learnpath', 'embeddable'])) { if (!in_array($origin, ['learnpath', 'embeddable', 'iframe'])) {
$showFooter = true; $showFooter = true;
} }
@ -307,7 +307,7 @@ ExerciseLib::exercise_time_control_delete(
ExerciseLib::delete_chat_exercise_session($exeId); ExerciseLib::delete_chat_exercise_session($exeId);
if (!in_array($origin, ['learnpath', 'embeddable', 'mobileapp'])) { if (!in_array($origin, ['learnpath', 'embeddable', 'mobileapp', 'iframe'])) {
$pageBottom .= '<div class="question-return">'; $pageBottom .= '<div class="question-return">';
$pageBottom .= Display::url( $pageBottom .= Display::url(
get_lang('ReturnToCourseHomepage'), get_lang('ReturnToCourseHomepage'),
@ -321,7 +321,7 @@ if (!in_array($origin, ['learnpath', 'embeddable', 'mobileapp'])) {
} }
$showFooter = true; $showFooter = true;
} elseif (in_array($origin, ['embeddable', 'mobileapp'])) { } elseif (in_array($origin, ['embeddable', 'mobileapp', 'iframe'])) {
if (api_is_allowed_to_session_edit()) { if (api_is_allowed_to_session_edit()) {
Exercise::cleanSessionVariables(); Exercise::cleanSessionVariables();
} }

@ -84,7 +84,7 @@ if ('true' === api_get_setting('enable_record_audio')) {
} }
$zoomOptions = api_get_configuration_value('quiz_image_zoom'); $zoomOptions = api_get_configuration_value('quiz_image_zoom');
if (isset($zoomOptions['options']) && !in_array($origin, ['embeddable', 'mobileapp'])) { if (isset($zoomOptions['options']) && !in_array($origin, ['embeddable', 'iframe', 'mobileapp'])) {
$options = $zoomOptions['options']; $options = $zoomOptions['options'];
$htmlHeadXtra[] = '<script src="'.api_get_path(WEB_LIBRARY_JS_PATH).'jquery.elevatezoom.js"></script>'; $htmlHeadXtra[] = '<script src="'.api_get_path(WEB_LIBRARY_JS_PATH).'jquery.elevatezoom.js"></script>';
$htmlHeadXtra[] = '<script> $htmlHeadXtra[] = '<script>
@ -165,7 +165,7 @@ if (empty($exerciseInSession) || (!empty($exerciseInSession) && $exerciseInSessi
// if the specified exercise doesn't exist or is disabled // if the specified exercise doesn't exist or is disabled
if (!$objExercise->read($exerciseId) || if (!$objExercise->read($exerciseId) ||
(!$objExercise->selectStatus() && !$is_allowedToEdit && !in_array($origin, ['learnpath', 'embeddable'])) (!$objExercise->selectStatus() && !$is_allowedToEdit && !in_array($origin, ['learnpath', 'embeddable', 'iframe']))
) { ) {
unset($objExercise); unset($objExercise);
$error = get_lang('ExerciseNotFound'); $error = get_lang('ExerciseNotFound');
@ -268,7 +268,7 @@ if ($objExercise->selectAttempts() > 0) {
if ($attempt_count >= $objExercise->selectAttempts()) { if ($attempt_count >= $objExercise->selectAttempts()) {
$show_clock = false; $show_clock = false;
if (!api_is_allowed_to_edit(null, true)) { if (!api_is_allowed_to_edit(null, true)) {
if ($objExercise->results_disabled == 0 && !in_array($origin, ['learnpath', 'embeddable'])) { if ($objExercise->results_disabled == 0 && !in_array($origin, ['learnpath', 'embeddable', 'iframe'])) {
// Showing latest attempt according with task BT#1628 // Showing latest attempt according with task BT#1628
$exercise_stat_info = Event::getExerciseResultsByUser( $exercise_stat_info = Event::getExerciseResultsByUser(
$user_id, $user_id,
@ -295,7 +295,7 @@ if ($objExercise->selectAttempts() > 0) {
) )
); );
if (in_array($origin, ['learnpath', 'embeddable'])) { if (in_array($origin, ['learnpath', 'embeddable', 'iframe'])) {
Display::display_reduced_header(); Display::display_reduced_header();
Display::display_reduced_footer(); Display::display_reduced_footer();
} else { } else {
@ -348,14 +348,14 @@ if ($objExercise->selectAttempts() > 0) {
$attempt_html .= $messageReachedMax; $attempt_html .= $messageReachedMax;
} }
if (in_array($origin, ['learnpath', 'embeddable'])) { if (in_array($origin, ['learnpath', 'embeddable', 'iframe'])) {
Display::display_reduced_header(); Display::display_reduced_header();
} else { } else {
Display::display_header(get_lang('Exercises')); Display::display_header(get_lang('Exercises'));
} }
echo $attempt_html; echo $attempt_html;
if (!in_array($origin, ['learnpath', 'embeddable'])) { if (!in_array($origin, ['learnpath', 'embeddable', 'iframe'])) {
Display::display_footer(); Display::display_footer();
} }
exit; exit;
@ -837,7 +837,7 @@ if ($formSent && isset($_POST)) {
'warning', 'warning',
false false
); );
if (!in_array($origin, ['learnpath', 'embeddable'])) { if (!in_array($origin, ['learnpath', 'embeddable', 'iframe'])) {
//so we are not in learnpath tool //so we are not in learnpath tool
echo '</div>'; //End glossary div echo '</div>'; //End glossary div
Display::display_footer(); Display::display_footer();
@ -904,7 +904,7 @@ if ($question_count != 0) {
'warning', 'warning',
false false
); );
if (!in_array($origin, ['learnpath', 'embeddable'])) { if (!in_array($origin, ['learnpath', 'embeddable', 'iframe'])) {
//so we are not in learnpath tool //so we are not in learnpath tool
echo '</div>'; //End glossary div echo '</div>'; //End glossary div
Display::display_footer(); Display::display_footer();
@ -1023,7 +1023,7 @@ if (false !== $quizKeepAlivePingInterval) {
})</script>"; })</script>";
} }
if (!in_array($origin, ['learnpath', 'embeddable', 'mobileapp'])) { if (!in_array($origin, ['learnpath', 'embeddable', 'mobileapp', 'iframe'])) {
//so we are not in learnpath tool //so we are not in learnpath tool
SessionManager::addFlashSessionReadOnly(); SessionManager::addFlashSessionReadOnly();
Display::display_header(null, 'Exercises'); Display::display_header(null, 'Exercises');
@ -1041,7 +1041,7 @@ if ($origin === 'mobileapp') {
$show_quiz_edition = $objExercise->added_in_lp(); $show_quiz_edition = $objExercise->added_in_lp();
// I'm in a preview mode // I'm in a preview mode
if (api_is_course_admin() && !in_array($origin, ['learnpath', 'embeddable'])) { if (api_is_course_admin() && !in_array($origin, ['learnpath', 'embeddable', 'iframe'])) {
echo '<div class="actions">'; echo '<div class="actions">';
if ($show_quiz_edition == false) { if ($show_quiz_edition == false) {
echo '<a href="exercise_admin.php?'.api_get_cidreq().'&modifyExercise=yes&exerciseId='.$objExercise->iid.'">'. echo '<a href="exercise_admin.php?'.api_get_cidreq().'&modifyExercise=yes&exerciseId='.$objExercise->iid.'">'.
@ -1063,14 +1063,14 @@ $is_visible_return = $objExercise->is_visible(
if ($is_visible_return['value'] == false) { if ($is_visible_return['value'] == false) {
echo $is_visible_return['message']; echo $is_visible_return['message'];
if (!in_array($origin, ['learnpath', 'embeddable'])) { if (!in_array($origin, ['learnpath', 'embeddable', 'iframe'])) {
Display::display_footer(); Display::display_footer();
} }
exit; exit;
} }
if (!api_is_allowed_to_session_edit()) { if (!api_is_allowed_to_session_edit()) {
if (!in_array($origin, ['learnpath', 'embeddable'])) { if (!in_array($origin, ['learnpath', 'embeddable', 'iframe'])) {
Display::display_footer(); Display::display_footer();
} }
exit; exit;
@ -1103,7 +1103,7 @@ if ($limit_time_exists) {
), ),
'warning' 'warning'
); );
if (!in_array($origin, ['learnpath', 'embeddable'])) { if (!in_array($origin, ['learnpath', 'embeddable', 'iframe'])) {
Display::display_footer(); Display::display_footer();
} }
exit; exit;
@ -1135,7 +1135,7 @@ if (isset($_custom['exercises_hidden_when_no_start_date']) &&
), ),
'warning' 'warning'
); );
if (!in_array($origin, ['learnpath', 'embeddable'])) { if (!in_array($origin, ['learnpath', 'embeddable', 'iframe'])) {
Display::display_footer(); Display::display_footer();
exit; exit;
} }
@ -1156,7 +1156,7 @@ if ($showQuestionClock) {
</div>'; </div>';
} }
if (!in_array($origin, ['learnpath', 'embeddable'])) { if (!in_array($origin, ['learnpath', 'embeddable', 'iframe'])) {
echo '<div id="highlight-plugin" class="glossary-content">'; echo '<div id="highlight-plugin" class="glossary-content">';
} }
if (2 === $reminder) { if (2 === $reminder) {
@ -1844,7 +1844,7 @@ if ($objExercise->type == ALL_ON_ONE_PAGE) {
} }
echo '</form>'; echo '</form>';
if (!in_array($origin, ['learnpath', 'embeddable'])) { if (!in_array($origin, ['learnpath', 'embeddable', 'iframe'])) {
// So we are not in learnpath tool // So we are not in learnpath tool
echo '</div>'; //End glossary div echo '</div>'; //End glossary div
} }

@ -83,7 +83,7 @@ if ($time_control) {
$htmlHeadXtra[] = $objExercise->showTimeControlJS($time_left, $exercise_url); $htmlHeadXtra[] = $objExercise->showTimeControlJS($time_left, $exercise_url);
} }
if (!in_array($origin, ['learnpath', 'embeddable', 'mobileapp'])) { if (!in_array($origin, ['learnpath', 'embeddable', 'mobileapp', 'iframe'])) {
SessionManager::addFlashSessionReadOnly(); SessionManager::addFlashSessionReadOnly();
Display::display_header(); Display::display_header();
} else { } else {

@ -17,7 +17,7 @@ $show_headers = isset($_REQUEST['show_headers']) ? (int) $_REQUEST['show_headers
$action = isset($_REQUEST['action']) ? $_REQUEST['action'] : ''; $action = isset($_REQUEST['action']) ? $_REQUEST['action'] : '';
$origin = api_get_origin(); $origin = api_get_origin();
if (in_array($origin, ['learnpath', 'embeddable', 'mobileapp'])) { if (in_array($origin, ['learnpath', 'embeddable', 'mobileapp', 'iframe'])) {
$show_headers = false; $show_headers = false;
} }

Loading…
Cancel
Save