Skip to content

Commit

Permalink
Learnpath: Fix final item access and LP progress to accept failed ite…
Browse files Browse the repository at this point in the history
…ms when lp_prerequisit_on_quiz_unblock_if_max_attempt_reached is true - refs BT#21735
  • Loading branch information
NicoDucou committed Oct 11, 2024
1 parent 0ee56d4 commit 54d4774
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
3 changes: 2 additions & 1 deletion main/lp/learnpathItem.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -3631,7 +3631,8 @@ public function isLpItemsCompleted()
{
$lp = new Learnpath(api_get_course_id(), $this->lp_id, api_get_user_id());
$count = $lp->getTotalItemsCountWithoutDirs([TOOL_LP_FINAL_ITEM]);
$completed = $lp->get_complete_items_count(true, [TOOL_LP_FINAL_ITEM]);
$excludeFailedStatus = !(true === api_get_configuration_value('lp_prerequisit_on_quiz_unblock_if_max_attempt_reached'));
$completed = $lp->get_complete_items_count($excludeFailedStatus, [TOOL_LP_FINAL_ITEM]);
$isCompleted = ($count - $completed == 0);

return $isCompleted;
Expand Down
3 changes: 2 additions & 1 deletion main/lp/lp_final_item.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,8 @@
// Check prerequisites and total completion of the learning path
$lp = new Learnpath($courseCode, $lpId, $userId);
$count = $lp->getTotalItemsCountWithoutDirs();
$completed = $lp->get_complete_items_count(true);
$excludeFailedStatus = !(true === api_get_configuration_value('lp_prerequisit_on_quiz_unblock_if_max_attempt_reached'));
$completed = $lp->get_complete_items_count($excludeFailedStatus);
$currentItemId = $lp->get_current_item_id();
$currentItem = $lp->items[$currentItemId];
$currentItemStatus = $currentItem->get_status();
Expand Down

0 comments on commit 54d4774

Please sign in to comment.