|
27 | 27 | $em = Database::getManager();
|
28 | 28 | $focusedLogRepository = $em->getRepository(FocusedLog::class);
|
29 | 29 | $attempsRepository = $em->getRepository(TrackEAttempt::class);
|
30 |
| -$monitoringLogRepository = $em->getRepository(MonitoringLog::class); |
31 | 30 |
|
32 | 31 | if (!$plugin->isEnabled(true)) {
|
33 | 32 | api_not_allowed(true);
|
|
85 | 84 | ];
|
86 | 85 | $data[] = [];
|
87 | 86 |
|
| 87 | + $data[] = [ |
| 88 | + $plugin->get_lang('LevelReached'), |
| 89 | + get_lang('DateExo'), |
| 90 | + get_lang('Score'), |
| 91 | + $plugin->get_lang('Outfocused'), |
| 92 | + $plugin->get_lang('Returns'), |
| 93 | + $monitoringPluginIsEnabled ? $monitoringPlugin->get_lang('Snapshots') : '', |
| 94 | + ]; |
| 95 | + |
88 | 96 | if (ONE_PER_PAGE === $quizType) {
|
89 | 97 | $questionList = explode(',', $trackExe->getDataTracking());
|
90 | 98 |
|
91 |
| - $row = [ |
92 |
| - $plugin->get_lang('LevelReached'), |
93 |
| - get_lang('DateExo'), |
94 |
| - get_lang('Score'), |
95 |
| - $plugin->get_lang('Outfocused'), |
96 |
| - $plugin->get_lang('Returns'), |
97 |
| - ]; |
98 |
| - |
99 |
| - if ($monitoringPluginIsEnabled) { |
100 |
| - $row[] = $monitoringPlugin->get_lang('Snapshots'); |
101 |
| - } |
102 |
| - |
103 |
| - $data[] = $row; |
104 |
| - |
105 | 99 | foreach ($questionList as $idx => $questionId) {
|
106 | 100 | $attempt = $attempsRepository->findOneBy(
|
107 | 101 | ['exeId' => $trackExe->getExeId(), 'questionId' => $questionId],
|
|
130 | 124 | $result['score'].' / '.$result['weight'],
|
131 | 125 | $focusedLogRepository->countByActionAndLevel($trackExe, FocusedLog::TYPE_OUTFOCUSED, $questionId),
|
132 | 126 | $focusedLogRepository->countByActionAndLevel($trackExe, FocusedLog::TYPE_RETURN, $questionId),
|
| 127 | + getSnapshotListForLevel($questionId, $trackExe), |
133 | 128 | ];
|
134 | 129 |
|
135 |
| - if ($monitoringPluginIsEnabled) { |
136 |
| - $monitoringLogsByQuestion = $monitoringLogRepository->findByLevelAndExe($questionId, $trackExe); |
137 |
| - $snapshotList = []; |
138 |
| - |
139 |
| - /** @var MonitoringLog $logByQuestion */ |
140 |
| - foreach ($monitoringLogsByQuestion as $logByQuestion) { |
141 |
| - $snapshotUrl = ExerciseMonitoringPlugin::generateSnapshotUrl( |
142 |
| - $user->getId(), |
143 |
| - $logByQuestion->getImageFilename() |
144 |
| - ); |
145 |
| - $snapshotList[] = api_get_local_time($logByQuestion->getCreatedAt()).' '.$snapshotUrl; |
146 |
| - } |
147 |
| - |
148 |
| - $row[] = implode(PHP_EOL, $snapshotList); |
149 |
| - } |
150 |
| - |
151 | 130 | $data[] = $row;
|
152 | 131 | }
|
153 | 132 | } elseif (ALL_ON_ONE_PAGE === $quizType) {
|
@@ -261,3 +240,29 @@ function findResults(array $formValues, EntityManagerInterface $em, ExerciseFocu
|
261 | 240 |
|
262 | 241 | return $query->getResult();
|
263 | 242 | }
|
| 243 | + |
| 244 | +function getSnapshotListForLevel(int $level, TrackEExercises $trackExe): string |
| 245 | +{ |
| 246 | + $monitoringPluginIsEnabled = ExerciseMonitoringPlugin::create()->isEnabled(true); |
| 247 | + |
| 248 | + if (!$monitoringPluginIsEnabled) { |
| 249 | + return ''; |
| 250 | + } |
| 251 | + |
| 252 | + $user = api_get_user_entity($trackExe->getExeUserId()); |
| 253 | + $monitoringLogRepository = Database::getManager()->getRepository(MonitoringLog::class); |
| 254 | + |
| 255 | + $monitoringLogsByQuestion = $monitoringLogRepository->findByLevelAndExe($level, $trackExe); |
| 256 | + $snapshotList = []; |
| 257 | + |
| 258 | + /** @var MonitoringLog $logByQuestion */ |
| 259 | + foreach ($monitoringLogsByQuestion as $logByQuestion) { |
| 260 | + $snapshotUrl = ExerciseMonitoringPlugin::generateSnapshotUrl( |
| 261 | + $user->getId(), |
| 262 | + $logByQuestion->getImageFilename() |
| 263 | + ); |
| 264 | + $snapshotList[] = api_get_local_time($logByQuestion->getCreatedAt()).' '.$snapshotUrl; |
| 265 | + } |
| 266 | + |
| 267 | + return implode(PHP_EOL, $snapshotList); |
| 268 | +} |
0 commit comments