| Code Coverage
| Lines | Functions and Methods | Classes and Traits
Total | 35.48% covered (danger) | 35.48% | 11 / 31 | 0.00% covered (danger) | 0.00% | 0 / 5 | CRAP | 0.00% covered (danger) | 0.00% | 0 / 1
EvaluationsController | 35.48% covered (danger) | 35.48% | 11 / 31 | 0.00% covered (danger) | 0.00% | 0 / 5 | 50.67 | 0.00% covered (danger) | 0.00% | 0 / 1
index | 0.00% covered (danger) | 0.00% | 0 / 4 | 0.00% covered (danger) | 0.00% | 0 / 1 | 6 |
quickChecks | 0.00% covered (danger) | 0.00% | 0 / 4 | 0.00% covered (danger) | 0.00% | 0 / 1 | 6 |
new | 75.00% covered (warning) | 75.00% | 3 / 4 | 0.00% covered (danger) | 0.00% | 0 / 1 | 2.06 |
create | 33.33% covered (danger) | 33.33% | 5 / 15 | 0.00% covered (danger) | 0.00% | 0 / 1 | 8.74 |
show | 75.00% covered (warning) | 75.00% | 3 / 4 | 0.00% covered (danger) | 0.00% | 0 / 1 | 2.06 |

1 | <?php
2 |
3 | namespace App\Controllers;
4 |
5 | class EvaluationsController extends BaseController
6 | {
7 | public function index()
8 | {
9 | $data = service('evaluations')->getIndexData($this->request->getGet(), auth()->user(), 'full-evaluation');
10 |
11 | if ($data === null) {
12 | return $this->forbidden('Tipul de evaluare solicitat nu este disponibil.');
13 | }
14 |
15 | return view('evaluations/index', $data);
16 | }
17 |
18 | public function quickChecks()
19 | {
20 | $data = service('evaluations')->getIndexData($this->request->getGet(), auth()->user(), 'quick-check');
21 |
22 | if ($data === null) {
23 | return $this->forbidden('Tipul de evaluare solicitat nu este disponibil.');
24 | }
25 |
26 | return view('evaluations/index', $data);
27 | }
28 |
29 | public function new(int $childId, string $typeSlug)
30 | {
31 | $data = service('evaluations')->getFormData($childId, $typeSlug, auth()->user());
32 |
33 | if ($data === null) {
34 | return $this->forbidden('Nu ai acces la aceasta evaluare sau copilul nu exista.');
35 | }
36 |
37 | return view('evaluations/form', $data);
38 | }
39 |
40 | public function create(int $childId, string $typeSlug)
41 | {
42 | $result = service('evaluations')->save($childId, $typeSlug, $this->request->getPost(), auth()->user());
43 |
44 | if (! $result['success']) {
45 | if (! empty($result['forbidden'])) {
46 | return $this->forbidden('Nu ai acces sa adaugi o evaluare pentru acest copil.');
47 | }
48 |
49 | $data = service('evaluations')->getFormData(
50 | $childId,
51 | $typeSlug,
52 | auth()->user(),
53 | $this->request->getPost(),
54 | $result['errors'] ?? [],
55 | );
56 |
57 | if ($data === null) {
58 | return $this->forbidden('Nu ai acces la aceasta evaluare sau copilul nu exista.');
59 | }
60 |
61 | return view('evaluations/form', $data);
62 | }
63 |
64 | return redirect()->to(url_to('evaluations.show', $result['evaluation_id']))->with('message', 'Evaluarea a fost salvata cu succes.');
65 | }
66 |
67 | public function show(int $evaluationId)
68 | {
69 | $data = service('evaluations')->getDetailData($evaluationId, auth()->user());
70 |
71 | if ($data === null) {
72 | return $this->forbidden('Nu ai acces la aceasta evaluare.');
73 | }
74 |
75 | return view('evaluations/show', $data);
76 | }
77 | }