diff --git a/public/main/exercise/exercise.class.php b/public/main/exercise/exercise.class.php index 12f745501c2..6ef9a7244bc 100644 --- a/public/main/exercise/exercise.class.php +++ b/public/main/exercise/exercise.class.php @@ -8792,6 +8792,13 @@ public static function exerciseGridResource( $repo = Container::getQuizRepository(); + $trackEExerciseRepo = Container::getTrackEExerciseRepository(); + $pendingCorrections = $trackEExerciseRepo->getPendingCorrectionsByExercise($courseId); + $pendingAttempts = []; + foreach ($pendingCorrections as $correction) { + $pendingAttempts[$correction['exerciseId']] = $correction['pendingCount']; + } + // 2. Get query builder from repo. $qb = $repo->getResourcesByCourse($course, $session); @@ -9027,6 +9034,18 @@ public static function exerciseGridResource( $url .= Display::div($embeddableIcon, ['class' => 'pull-right']); } + $pendingCount = $pendingAttempts[$exerciseId] ?? 0; + if ($pendingCount > 0) { + $pendingIcon = Display::getMdiIcon( + ActionIcon::ALERT->value, + 'ch-tool-icon', + null, + ICON_SIZE_SMALL, + get_lang('Pending Attempts') . ": $pendingCount" + ); + $url .= " $pendingIcon"; + } + $currentRow['title'] = $url.$lp_blocked; $rowi = $exerciseEntity->getQuestions()->count(); if ($allowToEditBaseCourse || $allowToEditSession) { diff --git a/src/CoreBundle/Repository/TrackEExerciseRepository.php b/src/CoreBundle/Repository/TrackEExerciseRepository.php index ab35eff5a68..a1a445abc00 100644 --- a/src/CoreBundle/Repository/TrackEExerciseRepository.php +++ b/src/CoreBundle/Repository/TrackEExerciseRepository.php @@ -22,4 +22,21 @@ public function delete(TrackEExercise $track): void $this->getEntityManager()->remove($track); $this->getEntityManager()->flush(); } + + /** + * Get exercises with pending corrections grouped by exercise ID. + */ + public function getPendingCorrectionsByExercise(int $courseId): array + { + $qb = $this->createQueryBuilder('te'); + + $qb->select('IDENTITY(te.quiz) AS exerciseId, COUNT(te.exeId) AS pendingCount') + ->where('te.status = :status') + ->andWhere('te.course = :courseId') + ->setParameter('status', 'incomplete') + ->setParameter('courseId', $courseId) + ->groupBy('te.quiz'); + + return $qb->getQuery()->getResult(); + } }