diff --git a/main/install/configuration.dist.php b/main/install/configuration.dist.php index ecba29f127..7b98d8c290 100755 --- a/main/install/configuration.dist.php +++ b/main/install/configuration.dist.php @@ -263,6 +263,8 @@ $_configuration['system_stable'] = NEW_VERSION_STABLE; //$_configuration['lp_replace_http_to_https'] = false; // Fix embedded videos inside lps, adding an optional popup //$_configuration['lp_fix_embed_content'] = false; +// Check the prerequisite in lp of a quiz to use only the last score in the attempts +// $_configuration['lp_prerequisite_use_last_attempt_only'] = false; // Manage deleted files marked with "DELETED" (by course and only by allowed by admin) //$_configuration['document_manage_deleted_files'] = false; // Hide tabs in the main/session/index.php page diff --git a/main/lp/learnpathItem.class.php b/main/lp/learnpathItem.class.php index 4905247fe1..4c688657dc 100755 --- a/main/lp/learnpathItem.class.php +++ b/main/lp/learnpathItem.class.php @@ -2354,6 +2354,8 @@ class learnpathItem if ($this->prevent_reinit == 1) { // 2. If is completed we check the results in the DB of the quiz. if ($returnstatus) { + $checkLastScoreAttempt = api_get_configuration_value('lp_prerequisite_use_last_attempt_only'); + $orderBy = ($checkLastScoreAttempt?'ORDER BY exe_date DESC':'ORDER BY (exe_result/exe_weighting) DESC'); $sql = 'SELECT exe_result, exe_weighting FROM '.Database::get_main_table(TABLE_STATISTIC_TRACK_E_EXERCISES).' WHERE @@ -2363,7 +2365,7 @@ class learnpathItem orig_lp_item_id = '.$prereqs_string.' AND status <> "incomplete" AND c_id = '.$courseId.' - ORDER BY exe_date DESC + '.$orderBy.' LIMIT 0, 1'; $rs_quiz = Database::query($sql); if ($quiz = Database::fetch_array($rs_quiz)) {