Upgrade 1-11.38

This commit is contained in:
xesmyd
2026-03-30 14:10:30 +02:00
parent f2a7e6d1fc
commit ac648ef29d
24665 changed files with 69682 additions and 2205004 deletions
+58 -57
View File
@@ -2366,61 +2366,65 @@ class learnpathItem
// For one and first attempt.
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
exe_exo_id = '.$items[$refs_list[$prereqs_string]]->path.' AND
exe_user_id = '.$user_id.' AND
orig_lp_id = '.$this->lp_id.' AND
orig_lp_item_id = '.$prereqs_string.' AND
status <> "incomplete" AND
c_id = '.$courseId.'
'.$orderBy.'
LIMIT 0, 1';
$rs_quiz = Database::query($sql);
if ($quiz = Database::fetch_array($rs_quiz)) {
/** @var learnpathItem $myItemToCheck */
$myItemToCheck = $items[$refs_list[$this->get_id()]];
$minScore = $myItemToCheck->getPrerequisiteMinScore();
$maxScore = $myItemToCheck->getPrerequisiteMaxScore();
// 2. Always check the results in the DB of the quiz (previously checked only if status was completed)
$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
exe_exo_id = '.$items[$refs_list[$prereqs_string]]->path.' AND
exe_user_id = '.$user_id.' AND
orig_lp_id = '.$this->lp_id.' AND
orig_lp_item_id = '.$prereqs_string.' AND
status <> "incomplete" AND
c_id = '.$courseId.'
'.$orderBy.'
LIMIT 0, 1';
$rs_quiz = Database::query($sql);
if ($quiz = Database::fetch_array($rs_quiz)) {
/** @var learnpathItem $myItemToCheck */
$myItemToCheck = $items[$refs_list[$this->get_id()]];
$minScore = $myItemToCheck->getPrerequisiteMinScore();
if (empty($minScore)) {
// Try with mastery_score
$masteryScoreAsMin = $myItemToCheck->get_mastery_score();
if (!empty($masteryScoreAsMin)) {
$minScore = $masteryScoreAsMin;
}
}
if (isset($minScore) && isset($minScore)) {
// Taking min/max prerequisites values see BT#5776
if ($quiz['exe_result'] >= $minScore &&
$quiz['exe_result'] <= $maxScore
) {
$returnstatus = true;
} else {
$explanation = sprintf(
get_lang('YourResultAtXBlocksThisElement'),
$itemToCheck->get_title()
);
$this->prereq_alert = $explanation;
$returnstatus = false;
}
if (!empty($minScore)) {
// Taking min/max prerequisites values see BT#5776
if ($quiz['exe_result'] >= $minScore) {
$this->prereq_alert = '';
$returnstatus = true;
} else {
// Classic way
if ($quiz['exe_result'] >=
$items[$refs_list[$prereqs_string]]->get_mastery_score()
) {
$returnstatus = true;
} else {
$explanation = sprintf(
get_lang('YourResultAtXBlocksThisElement'),
$itemToCheck->get_title()
);
$this->prereq_alert = $explanation;
$returnstatus = false;
}
$explanation = sprintf(
get_lang('YourResultAtXBlocksThisElement'),
$itemToCheck->get_title()
);
$this->prereq_alert = $explanation;
$returnstatus = false;
}
} else {
$this->prereq_alert = get_lang('LearnpathPrereqNotCompleted');
$returnstatus = false;
// Classic way
if ($quiz['exe_result'] >=
$items[$refs_list[$prereqs_string]]->get_mastery_score()
) {
$this->prereq_alert = '';
$returnstatus = true;
} else {
$explanation = sprintf(
get_lang('YourResultAtXBlocksThisElement'),
$itemToCheck->get_title()
);
$this->prereq_alert = $explanation;
$returnstatus = false;
}
}
} else {
$this->prereq_alert = get_lang('LearnpathPrereqNotCompleted');
$returnstatus = false;
}
} else {
// 3. For multiple attempts we check that there are minimum 1 item completed
@@ -2440,7 +2444,6 @@ class learnpathItem
/** @var learnpathItem $myItemToCheck */
$myItemToCheck = $items[$refs_list[$this->get_id()]];
$minScore = $myItemToCheck->getPrerequisiteMinScore();
$maxScore = $myItemToCheck->getPrerequisiteMaxScore();
if (empty($minScore)) {
// Try with mastery_score
@@ -2449,11 +2452,9 @@ class learnpathItem
$minScore = $masteryScoreAsMin;
}
}
if (isset($minScore) && isset($minScore)) {
if (!empty($minScore)) {
// Taking min/max prerequisites values see BT#5776
if ($quiz['exe_result'] >= $minScore &&
$quiz['exe_result'] <= $maxScore
) {
if ($quiz['exe_result'] >= $minScore) {
$returnstatus = true;
break;
} else {
@@ -3629,7 +3630,7 @@ class learnpathItem
public function isLpItemsCompleted()
{
$lp = new Learnpath(api_get_course_id(), $this->lp_id, api_get_user_id());
$lp = new learnpath(api_get_course_id(), $this->lp_id, api_get_user_id());
$count = $lp->getTotalItemsCountWithoutDirs([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]);
@@ -3640,7 +3641,7 @@ class learnpathItem
public function getLpFinalItem()
{
$lp = new Learnpath(api_get_course_id(), $this->lp_id, api_get_user_id());
$lp = new learnpath(api_get_course_id(), $this->lp_id, api_get_user_id());
return $lp->getFinalItem();
}