1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/* For licensing terms, see /license.txt */ |
4
|
|
|
|
5
|
|
|
namespace Chamilo\PluginBundle\ExerciseFocused\Controller; |
6
|
|
|
|
7
|
|
|
use Chamilo\CoreBundle\Entity\TrackEExercises; |
8
|
|
|
use Chamilo\CourseBundle\Entity\CQuiz; |
9
|
|
|
use Chamilo\PluginBundle\ExerciseFocused\Traits\ReportingFilterTrait; |
10
|
|
|
use Display; |
11
|
|
|
use Exception; |
12
|
|
|
use Symfony\Component\HttpFoundation\Response as HttpResponse; |
13
|
|
|
|
14
|
|
|
class ReportingController extends BaseController |
15
|
|
|
{ |
16
|
|
|
use ReportingFilterTrait; |
17
|
|
|
|
18
|
|
|
public function __invoke(): HttpResponse |
19
|
|
|
{ |
20
|
|
|
parent::__invoke(); |
21
|
|
|
|
22
|
|
|
$exerciseId = $this->request->query->getInt('id'); |
23
|
|
|
$exercise = $this->em->find(CQuiz::class, $exerciseId); |
24
|
|
|
|
25
|
|
|
if (!$exercise) { |
26
|
|
|
throw new Exception(); |
27
|
|
|
} |
28
|
|
|
|
29
|
|
|
$courseCode = api_get_course_id(); |
30
|
|
|
$sessionId = api_get_session_id(); |
31
|
|
|
|
32
|
|
|
$form = $this->createForm(); |
33
|
|
|
$form->updateAttributes(['action' => api_get_self().'?'.api_get_cidreq().'&id='.$exercise->getId()]); |
34
|
|
|
$form->addHidden('cidReq', $courseCode); |
35
|
|
|
$form->addHidden('id_session', $sessionId); |
36
|
|
|
$form->addHidden('gidReq', 0); |
37
|
|
|
$form->addHidden('gradebook', 0); |
38
|
|
|
$form->addHidden('origin', api_get_origin()); |
39
|
|
|
$form->addHidden('id', $exercise->getId()); |
40
|
|
|
|
41
|
|
|
if ($form->validate()) { |
42
|
|
|
$formValues = $form->exportValues(); |
43
|
|
|
|
44
|
|
|
$results = $this->findResults($formValues); |
45
|
|
|
} else { |
46
|
|
|
$results = $this->findResults([ |
47
|
|
|
'extra_periodo' => '202309', |
48
|
|
|
]); |
49
|
|
|
} |
50
|
|
|
|
51
|
|
|
$table = $this->createTable($results); |
52
|
|
|
|
53
|
|
|
$this->setBreadcrumb($exercise->getId()); |
54
|
|
|
|
55
|
|
|
$content = $form->returnForm() |
56
|
|
|
.Display::page_subheader(get_lang('ReportByAttempts')) |
57
|
|
|
.$table->toHtml(); |
58
|
|
|
|
59
|
|
|
return $this->renderView( |
60
|
|
|
get_lang('ReportByAttempts'), |
61
|
|
|
$content, |
62
|
|
|
$exercise->getTitle() |
63
|
|
|
); |
64
|
|
|
} |
65
|
|
|
|
66
|
|
|
/** |
67
|
|
|
* @return array<int, TrackEExercises> |
68
|
|
|
*/ |
69
|
|
|
private function setBreadcrumb($exerciseId): void |
70
|
|
|
{ |
71
|
|
|
$codePath = api_get_path('WEB_CODE_PATH'); |
72
|
|
|
$cidReq = api_get_cidreq(); |
73
|
|
|
|
74
|
|
|
$GLOBALS['interbreadcrumb'][] = [ |
75
|
|
|
'url' => $codePath."exercise/exercise.php?$cidReq", |
76
|
|
|
'name' => get_lang('Exercises'), |
77
|
|
|
]; |
78
|
|
|
$GLOBALS['interbreadcrumb'][] = [ |
79
|
|
|
'url' => $codePath."exercise/exercise_report.php?$cidReq&".http_build_query(['exerciseId' => $exerciseId]), |
80
|
|
|
'name' => get_lang('StudentScore'), |
81
|
|
|
]; |
82
|
|
|
} |
83
|
|
|
} |
84
|
|
|
|