Skip to content

Commit

Permalink
Lp: Implement to use the best result of a quiz in lp - refs BT19079
Browse files Browse the repository at this point in the history
  • Loading branch information
cfasanando committed Sep 1, 2021
1 parent 88b3cce commit 8c44368
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 2 additions & 0 deletions main/install/configuration.dist.php
Expand Up @@ -263,6 +263,8 @@
//$_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
Expand Down
4 changes: 3 additions & 1 deletion main/lp/learnpathItem.class.php
Expand Up @@ -2354,6 +2354,8 @@ public function parse_prereq($prereqs_string, $items, $refs_list, $user_id)
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
Expand All @@ -2363,7 +2365,7 @@ public function parse_prereq($prereqs_string, $items, $refs_list, $user_id)
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)) {
Expand Down

0 comments on commit 8c44368

Please sign in to comment.