File tree 2 files changed +36
-0
lines changed
src/CoreBundle/Repository
2 files changed +36
-0
lines changed Original file line number Diff line number Diff line change @@ -8792,6 +8792,13 @@ public static function exerciseGridResource(
8792
8792
8793
8793
$ repo = Container::getQuizRepository ();
8794
8794
8795
+ $ trackEExerciseRepo = Container::getTrackEExerciseRepository ();
8796
+ $ pendingCorrections = $ trackEExerciseRepo ->getPendingCorrectionsByExercise ($ courseId );
8797
+ $ pendingAttempts = [];
8798
+ foreach ($ pendingCorrections as $ correction ) {
8799
+ $ pendingAttempts [$ correction ['exerciseId ' ]] = $ correction ['pendingCount ' ];
8800
+ }
8801
+
8795
8802
// 2. Get query builder from repo.
8796
8803
$ qb = $ repo ->getResourcesByCourse ($ course , $ session );
8797
8804
@@ -9027,6 +9034,18 @@ public static function exerciseGridResource(
9027
9034
$ url .= Display::div ($ embeddableIcon , ['class ' => 'pull-right ' ]);
9028
9035
}
9029
9036
9037
+ $ pendingCount = $ pendingAttempts [$ exerciseId ] ?? 0 ;
9038
+ if ($ pendingCount > 0 ) {
9039
+ $ pendingIcon = Display::getMdiIcon (
9040
+ ActionIcon::ALERT ->value ,
9041
+ 'ch-tool-icon ' ,
9042
+ null ,
9043
+ ICON_SIZE_SMALL ,
9044
+ get_lang ('Pending attempts ' ) . ": $ pendingCount "
9045
+ );
9046
+ $ url .= " $ pendingIcon " ;
9047
+ }
9048
+
9030
9049
$ currentRow ['title ' ] = $ url .$ lp_blocked ;
9031
9050
$ rowi = $ exerciseEntity ->getQuestions ()->count ();
9032
9051
if ($ allowToEditBaseCourse || $ allowToEditSession ) {
Original file line number Diff line number Diff line change @@ -22,4 +22,21 @@ public function delete(TrackEExercise $track): void
22
22
$ this ->getEntityManager ()->remove ($ track );
23
23
$ this ->getEntityManager ()->flush ();
24
24
}
25
+
26
+ /**
27
+ * Get exercises with pending corrections grouped by exercise ID.
28
+ */
29
+ public function getPendingCorrectionsByExercise (int $ courseId ): array
30
+ {
31
+ $ qb = $ this ->createQueryBuilder ('te ' );
32
+
33
+ $ qb ->select ('IDENTITY(te.quiz) AS exerciseId, COUNT(te.exeId) AS pendingCount ' )
34
+ ->where ('te.status = :status ' )
35
+ ->andWhere ('te.course = :courseId ' )
36
+ ->setParameter ('status ' , 'incomplete ' )
37
+ ->setParameter ('courseId ' , $ courseId )
38
+ ->groupBy ('te.quiz ' );
39
+
40
+ return $ qb ->getQuery ()->getResult ();
41
+ }
25
42
}
You can’t perform that action at this time.
0 commit comments