From 8c44368bcd296113ba68807d543bb3beef6585ba Mon Sep 17 00:00:00 2001 From: Christian Date: Tue, 31 Aug 2021 23:40:10 -0500 Subject: [PATCH 1/3] Lp: Implement to use the best result of a quiz in lp - refs BT19079 --- main/install/configuration.dist.php | 2 ++ main/lp/learnpathItem.class.php | 4 +++- 2 files changed, 5 insertions(+), 1 deletion(-) 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)) { From 988ecd1e2e408d20a23d7a658ebd5712bb89cbce Mon Sep 17 00:00:00 2001 From: Christian Date: Wed, 1 Sep 2021 09:58:25 -0500 Subject: [PATCH 2/3] Exercise: Fix spaces between ? and : - refs BT19079 --- main/lp/learnpathItem.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main/lp/learnpathItem.class.php b/main/lp/learnpathItem.class.php index 4c688657dc..a1997c97a7 100755 --- a/main/lp/learnpathItem.class.php +++ b/main/lp/learnpathItem.class.php @@ -2355,7 +2355,7 @@ class learnpathItem // 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'); + $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 From 0bc5e78b1418dd59bb6c0c891c61ba2434b322f4 Mon Sep 17 00:00:00 2001 From: Christian Date: Wed, 1 Sep 2021 10:21:26 -0500 Subject: [PATCH 3/3] Exercise: Fix space in foreach verified by flintci in this PR - refs BT19079 --- main/inc/ajax/exercise.ajax.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main/inc/ajax/exercise.ajax.php b/main/inc/ajax/exercise.ajax.php index a2ed5834f0..9ef58bbeaf 100755 --- a/main/inc/ajax/exercise.ajax.php +++ b/main/inc/ajax/exercise.ajax.php @@ -672,7 +672,7 @@ switch ($action) { if (!empty($uploadAnswerFileNames)) { // Clean user upload_answer folder $userUploadAnswerSyspath = UserManager::getUserPathById(api_get_user_id(), 'system').'my_files'.'/upload_answer/'.$exeId.'/'.$my_question_id.'/*'; - foreach(glob($userUploadAnswerSyspath) as $file) { + foreach (glob($userUploadAnswerSyspath) as $file) { $filename = basename($file); if (!in_array($filename, $uploadAnswerFileNames[$my_question_id])) { unlink($file);