From ed38dc279e11ee4b030fee241d49e60226dc2bc5 Mon Sep 17 00:00:00 2001 From: Julio Montoya Date: Thu, 29 Nov 2018 09:40:27 +0100 Subject: [PATCH] New setting added "exercises_disable_new_attempts" see BT#15091 Disable all new exercise attempts in all the platform --- main/exercise/exercise_submit.php | 5 +++++ main/exercise/overview.php | 8 +++++++- main/install/configuration.dist.php | 3 +++ 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/main/exercise/exercise_submit.php b/main/exercise/exercise_submit.php index 551c1b5872..95ffe6c785 100755 --- a/main/exercise/exercise_submit.php +++ b/main/exercise/exercise_submit.php @@ -331,6 +331,11 @@ $questionListUncompressed = $objExercise->getQuestionListWithMediasUncompressed( Session::write('question_list_uncompressed', $questionListUncompressed); $clock_expired_time = null; if (empty($exercise_stat_info)) { + $disable = api_get_configuration_value('exercises_disable_new_attempts'); + if ($disable) { + api_not_allowed(true); + } + if ($debug) { error_log('5 $exercise_stat_info is empty '); } diff --git a/main/exercise/overview.php b/main/exercise/overview.php index d7aea93332..b995ca4bce 100755 --- a/main/exercise/overview.php +++ b/main/exercise/overview.php @@ -106,7 +106,7 @@ if (api_get_configuration_value('save_titles_as_html')) { ); } -//Exercise description +// Exercise description if (!empty($objExercise->description)) { $html .= Display::div($objExercise->description, ['class' => 'exercise_description']); } @@ -345,6 +345,12 @@ if ($time_control) { $html .= $message; +$disable = api_get_configuration_value('exercises_disable_new_attempts'); + +if ($disable && empty($exercise_stat_info)) { + $exercise_url_button = Display::return_message(get_lang('NewExerciseAttemptDisabled')); +} + if (!empty($exercise_url_button)) { $html .= Display::div( Display::div( diff --git a/main/install/configuration.dist.php b/main/install/configuration.dist.php index 004afc05d8..7e6882f2b8 100755 --- a/main/install/configuration.dist.php +++ b/main/install/configuration.dist.php @@ -1032,6 +1032,9 @@ VALUES (2, 13, 'session_courses_read_only_mode', 'Lock Course In Session', 1, 1, ] ];*/ +// Disable all new exercise attempts in all the platform +// $_configuration['exercises_disable_new_attempts'] = false; + // ------ Custom DB changes (keep this at the end) // Add user activation by confirmation email // This option prevents the new user to login in the platform if your account is not confirmed via email