Passed
Pull Request — 1.11.x (#4900)
by Angel Fernando Quiroz
11:42
created

AdminController::__invoke()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 25
Code Lines 14

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 14
c 1
b 0
f 0
dl 0
loc 25
rs 9.7998
cc 2
nc 2
nop 0
1
<?php
2
3
/* For licensing terms, see /license.txt */
4
5
namespace Chamilo\PluginBundle\ExerciseFocused\Controller;
6
7
use Chamilo\PluginBundle\ExerciseFocused\Traits\ReportingFilterTrait;
8
use Display;
9
use Symfony\Component\HttpFoundation\Response as HttpResponse;
10
11
class AdminController extends BaseController
12
{
13
    use ReportingFilterTrait;
14
15
    public function __invoke(): HttpResponse
16
    {
17
        parent::__invoke();
18
19
        $form = $this->createForm();
20
21
        $results = [];
22
23
        if ($form->validate()) {
24
            $results = $this->findResults(
25
                $form->exportValues()
26
            );
27
        }
28
29
        $table = $this->createTable($results);
30
31
        $content = $form->returnForm()
32
            .Display::page_subheader2($this->plugin->get_lang('ReportByAttempts'))
33
            .$table->toHtml();
34
35
        $this->setBreadcrumb();
36
37
        return $this->renderView(
38
            $this->plugin->get_title(),
39
            $content
40
        );
41
    }
42
43
    private function setBreadcrumb()
44
    {
45
        $codePath = api_get_path(WEB_CODE_PATH);
46
47
        $GLOBALS['interbreadcrumb'][] = [
48
            'url' => $codePath.'admin/index.php',
49
            'name' => get_lang('Administration'),
50
        ];
51
    }
52
}
53