Skip to content

Commit

Permalink
Quiz: Dont allow start/continuesession is session read-only - refs BT…
Browse files Browse the repository at this point in the history
…#16791
  • Loading branch information
AngelFQC committed Aug 10, 2020
1 parent ade11fa commit 2900dfa
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 6 deletions.
15 changes: 9 additions & 6 deletions main/exercise/exercise_submit.php
Original file line number Diff line number Diff line change
Expand Up @@ -880,11 +880,7 @@
$interbreadcrumb[] = ['url' => '#', 'name' => $objExercise->selectTitle(true)];

if (!in_array($origin, ['learnpath', 'embeddable', 'mobileapp'])) { //so we are not in learnpath tool
if (!api_is_allowed_to_session_edit()) {
Display::addFlash(
Display::return_message(get_lang('SessionIsReadOnly'), 'warning')
);
}
SessionManager::addFlashSessionReadOnly();

Display::display_header(null, 'Exercises');
} else {
Expand Down Expand Up @@ -928,6 +924,13 @@
exit;
}

if (!api_is_allowed_to_session_edit()) {
if (!in_array($origin, ['learnpath', 'embeddable'])) {
Display::display_footer();
}
exit;
}

$exercise_timeover = false;
$limit_time_exists = (!empty($objExercise->start_time) || !empty($objExercise->end_time)) ? true : false;

Expand Down Expand Up @@ -1330,7 +1333,7 @@ function save_now(question_id, url_extra) {
$("#save_for_now_"+question_id).html(\''.
Display::return_icon('save.png', get_lang('Saved'), [], ICON_SIZE_SMALL).'\');
// window.quizTimeEnding will be reset in exercise.class.php
// window.quizTimeEnding will be reset in exercise.class.php
if (window.quizTimeEnding) {
redirectExerciseToResult();
} else {
Expand Down
6 changes: 6 additions & 0 deletions main/exercise/overview.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@
}

if (!in_array($origin, ['learnpath', 'embeddable', 'mobileapp'])) {
SessionManager::addFlashSessionReadOnly();

Display::display_header();
} else {
$htmlHeadXtra[] = "
Expand Down Expand Up @@ -192,6 +194,10 @@
}
}

if (!api_is_allowed_to_session_edit()) {
$exercise_url_button = null;
}

$attempts = Event::getExerciseResultsByUser(
api_get_user_id(),
$objExercise->id,
Expand Down
12 changes: 12 additions & 0 deletions main/inc/lib/sessionmanager.lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -9674,4 +9674,16 @@ private static function compareByCourse($listA, $listB)
return -1;
}
}

/**
* Add a warning message when session is read-only mode.
*/
public static function addFlashSessionReadOnly()
{
if (api_get_session_id() && !api_is_allowed_to_session_edit()) {
Display::addFlash(
Display::return_message(get_lang('SessionIsReadOnly'), 'warning')
);
}
}
}

0 comments on commit 2900dfa

Please sign in to comment.