Skip to content

Commit

Permalink
Merge pull request #5656 from christianbeeznest/ofaj-21855
Browse files Browse the repository at this point in the history
Internal: Fix DQL query in exerciseResultsInRanking function - refs BT#21855
  • Loading branch information
christianbeeznest authored Jul 11, 2024
2 parents 2395d82 + 6d4d34b commit 1ee4da7
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions public/main/inc/lib/exercise.lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -4842,8 +4842,8 @@ public static function exerciseResultsInRanking($exerciseId, $courseId, $session
{
$em = Database::getManager();

$dql = 'SELECT DISTINCT te.exeUserId FROM ChamiloCoreBundle:TrackEExercise te WHERE te.exeExoId = :id AND te.course = :cId';
$dql .= api_get_session_condition($sessionId, true, false, 'te.sessionId');
$dql = 'SELECT DISTINCT u.id FROM ChamiloCoreBundle:TrackEExercise te JOIN te.user u WHERE te.quiz = :id AND te.course = :cId';
$dql .= api_get_session_condition($sessionId, true, false, 'te.session');

$result = $em
->createQuery($dql)
Expand All @@ -4853,7 +4853,14 @@ public static function exerciseResultsInRanking($exerciseId, $courseId, $session
$data = [];

foreach ($result as $item) {
$data[] = self::get_best_attempt_by_user($item['exeUserId'], $exerciseId, $courseId, $sessionId);
$attempt = self::get_best_attempt_by_user($item['id'], $exerciseId, $courseId, $sessionId);
if (!empty($attempt) && isset($attempt['score']) && isset($attempt['exe_date'])) {
$data[] = $attempt;
}
}

if (empty($data)) {
return [];
}

usort(
Expand Down

0 comments on commit 1ee4da7

Please sign in to comment.