<?php

namespace Modules\Evaluation\Controller;

use Entity\Model\BibGrpNot;
use Entity\Model\BibQstQ;
use Entity\Model\BibQstTh;
use Entity\Model\CampGrpNot;
use Entity\Model\CampLstNotGrp;
use Entity\Model\CampQstQ;
use Entity\Model\CampQstTh;
use Entity\Model\GrilGrpNot;
use Entity\Model\GrilQstQ;
use Entity\Model\GrilTheme;
use GuzzleHttp\Psr7\Response;
use Helpers\Ariane\Ariane;
use Helpers\Ariane\ArianeSub;
use Helpers\Filter\FiltreAvance\Generator;
use Helpers\Outil\Roles;
use Helpers\Pagination\Paginator;
use Helpers\Pagination\PaginatorGestion;
use Helpers\Trad\Trad;
use Modules\Evaluation\MenuContextuel\GroupOfRatersMenuContextuel;
use Modules\Evaluation\Repository\Model;
use Modules\Evaluation\Repository\Rater;
use Modules\Evaluation\Service\CampaignService;
use PDO;
use Skeleton\Controller\Controller;
use Helpers\Session\Enums\MenuTopEnum;
use Helpers\Session\Session;

class GroupOfRatersController extends Controller
{
    /**
     * @var array<mixed>
     */
    protected array $droits = [];

    /**
     * init
     * gestion des droits
     *
     * @return void
     */
    public function init()
    {
        $droits = [
            'HA_MQUESCM' => Roles::droitsUtilisateur($this->pdo, 'HA_MQUESCM', $_SESSION["Session_Login"]), // Droit de création et modification des modèles et les catégories de modèles
            'HA_CEVAVIS' => Roles::droitsUtilisateur($this->pdo, 'HA_CEVAVIS', $_SESSION["Session_Login"]), // Droit de visu des campagnes
            'HA_CEVALCM' => Roles::droitsUtilisateur($this->pdo, 'HA_CEVALCM', $_SESSION["Session_Login"]), // Droit de création et modification des campagnes
            'HA_CEVASUP' => Roles::droitsUtilisateur($this->pdo, 'HA_CEVASUP', $_SESSION["Session_Login"]), // Droit de suppression des campagnes d'évaluation
            'HA_BIBQTCM' => Roles::droitsUtilisateur($this->pdo, 'HA_BIBQTCM', $_SESSION["Session_Login"]), // Droit de création et modification de questionnaire
        ];

        $this->droits = $droits;
    }
    /**
     * indexAction
     *
     * @return string|Response
     */
    public function indexAction()
    {
        $id = $this->request->getAttribute('id');
        $mode = $this->request->getAttribute('mode');
        $post = $this->request->getParsedBody();

        $trad = $this->getTranslationService();

        $menuContextuel   = new GroupOfRatersMenuContextuel($this->pdo, $this->router, $this->getTranslationService(), $this->droits);

        if ($mode == 'campaign') {
            $campGrpNot = new CampGrpNot($this->pdo);
            $groupsOfRaters = $campGrpNot->findAll(
                ['ID_CAMP' => $id],
                ['GROUPE'],
                $post
            );

            $raters = (new Rater($this->pdo, $this->pdoStorage))->getRatersByGroupByCampaign($id, '');

            foreach ($raters as &$rater) {
                $rater['deleteMessage'] = Trad::strBuild($trad->t('Voulez-vous retirer l\'évaluateur @1@ du groupe ?'), $rater['NOM']);
            }

            $ratersByGroup = [];
            foreach ($raters as $raterByGroup) {
                $ratersByGroup[$raterByGroup['GROUPE']][] = $raterByGroup;
            }

            foreach ($groupsOfRaters as &$group) {
                $group['menuContextuel'] = $menuContextuel->generate($id, $mode, $group['GROUPE']);
                $group['raters'] = $ratersByGroup[$group['GROUPE']];
            }

            $campaign = (new CampaignService($this->pdo, $this->getTranslationService()))
                ->campaignDetail(
                    $id,
                    $this->router,
                    $this->droits
                );

            ArianeSub::generate(
                0,
                2,
                $trad->t('Évaluateurs'),
                $this->router->generateUri(
                    'Evaluation.GroupOfRaters.index',
                    ['id' => $id, 'mode' => 'campaign']
                ),
                1
            );

            $tableTitle = $trad->t('Gérez vos groupes d\'évaluateurs');
            $tableSubTitle = $trad->t('Utilisez les boutons "+" pour ajouter un groupe ou ajouter des évaluateurs aux groupes existants');
            $deleteMessage = $trad->t('Voulez-vous supprimer la campagne @1@ ?');

            return $this->renderer->render(
                '@Evaluation/Campaign/detail',
                [
                    'id'                => $id,
                    'title'             => $trad->t('Campagnes d\'évaluation'),
                    'menuActive'        => Session::verifySessionTypeMenuTop(MenuTopEnum::S2C) ? 'Consultations' : 'Evaluations',
                    'tab'               => 'GroupOfRaters/index',
                    'mode'              => $mode,
                    'groupsOfRaters'    => $groupsOfRaters,
                    'campaign'          => $campaign,
                    'tableTitle'        => $post['group'] ?? $tableTitle,
                    'tableSubTitle'     => $tableSubTitle,
                    'droits'            => $this->droits,
                    'deleteMessage'     => $deleteMessage,
                    'chosenGroup'       => $post['group'] ?? false,
                ]
            );
        } elseif ($mode == 'question') {
            Ariane::generate(0, $trad->t('Gestion'));

            $bibGrpNot = new BibGrpNot($this->pdo);
            $groupsOfRaters = $bibGrpNot->fetchAll(
                ['GROUPE'],
                $post,
                PDO::FETCH_ASSOC
            );

            foreach ($groupsOfRaters as &$group) {
                $group['menuContextuel'] = $menuContextuel->generate($id, $mode, $group['GROUPE']);
            }

            $paginator = new Paginator();
            $pagingInfo = $paginator->generate($groupsOfRaters, 15, $post);

            $advancedFilter = new Generator($post);
            $advancedFilter->setFiltre('GROUPE', 'text', $trad->t('Libellé'));

            return $this->renderer->render(
                '@Evaluation/BilbliothequeDeQuestions/Raters/raters',
                [
                    'title'             => $trad->t('Groupes d\'évaluateurs pour la bibliothèque'),
                    'id'                => 'library',
                    'pagingInfo'        => $pagingInfo,
                    'menuActive'        => Session::verifySessionTypeMenuTop(MenuTopEnum::S2C) ? 'Consultations' : 'Evaluations',
                    'tab'               => 'Raters/index',
                    'mode'              => $mode,
                    'filtreAvance'      => $advancedFilter->getFiltres(),
                    'initFiltreAvance'  => $advancedFilter->getInit(),
                    'groupsOfRaters'    => $groupsOfRaters,
                    'droits'            => $this->droits,
                    'post'              => $post,
                ]
            );
        } elseif ($mode == 'modele') {
            $modelRepo = new Model($this->pdo);
            $groupsOfRaters = $modelRepo->findModelsGroupsOfRaters($id, $post);

            $infoPagination = PaginatorGestion::getInfoPagination();

            foreach ($groupsOfRaters as &$group) {
                $group['deleteMessage'] = Trad::strBuild($trad->t('Voulez-vous supprimer le groupe @1@ ?'), $group['GROUPE']);
            }

            $modelRepo = new Model($this->pdo);
            $model = $modelRepo->modelDetail($id);
            ArianeSub::generate(
                0,
                1,
                $trad->t('Groupes d\'évaluateurs'),
                $this->router->generateUri(
                    'Evaluation.GroupOfRaters.index',
                    ['id' => $id, 'mode' => 'modele']
                ),
                1
            );

            $tableTitle = 'Gérez vos groupes d\'évaluateurs';
            $tableSubTitle = 'Utilisez les boutons "+" pour ajouter un groupe';

            return $this->renderer->render(
                '@Evaluation/Modele/detail',
                [
                    'id'                => $id,
                    'title'             => $trad->t('Campagnes d\'évaluation'),
                    'menuActive'        => Session::verifySessionTypeMenuTop(MenuTopEnum::S2C) ? 'Consultations' : 'Evaluations',
                    'tab'               => 'GroupOfRaters/index',
                    'mode'              => $mode,
                    'groupsOfRaters'    => $groupsOfRaters,
                    'post'              => $post,
                    'modele'            => $model,
                    'infoPagination'    => $infoPagination,
                    'tableTitle'        => $tableTitle,
                    'tableSubTitle'     => $tableSubTitle,
                    'droits'            => $this->droits,
                ]
            );
        } else {
            return new Response();
        }
    }

    /**
     * createditAction
     *
     * @return string|Response
     */
    public function creatEditAction()
    {
        $id = $this->request->getAttribute('id');
        $mode = $this->request->getAttribute('mode');
        $group = $this->request->getAttribute('group');
        $post = $this->request->getParsedBody();

        $trad = $this->getTranslationService();

        switch ($mode) {
            case 'campaign':
                $deleteMessage = $trad->t('Voulez-vous supprimer la campagne @1@ ?');
                $campaign = (new CampaignService($this->pdo, $this->getTranslationService()))
                    ->campaignDetail(
                        $id,
                        $this->router,
                        $this->droits
                    );

                if ($group) {
                    ArianeSub::generate(
                        1,
                        0,
                        $trad->t('Modifier le groupe d\'évaluateurs'),
                        $this->router->generateUri(
                            'Evaluation.GroupOfRaters.creatEdit',
                            ['mode' => $mode, 'id' => $id, 'group' => $group]
                        ),
                        1
                    );

                    return $this->renderer->render(
                        '@Evaluation/Campaign/detail',
                        [
                            'menuActive'    => Session::verifySessionTypeMenuTop(MenuTopEnum::S2C) ? 'Consultations' : 'Evaluations',
                            'menuLeft'      => 'ratings',
                            'title'         => $trad->t('Campagnes d\'évaluation'),
                            'campaign'      => $campaign,
                            'tab'           => 'Raters/new',
                            'mode'          => $mode,
                            'id'            => $id,
                            'droits'        => $this->droits,
                            'group'         => $group,
                            'deleteMessage' => $deleteMessage,
                        ]
                    );
                } else {
                    ArianeSub::generate(
                        1,
                        0,
                        $trad->t('Nouveau groupe d\'évaluateurs'),
                        $this->router->generateUri(
                            'Evaluation.GroupOfRaters.creatEdit',
                            ['mode' => $mode, 'id' => $id]
                        ),
                        1
                    );

                    return $this->renderer->render(
                        '@Evaluation/Campaign/detail',
                        [
                            'menuActive'    => Session::verifySessionTypeMenuTop(MenuTopEnum::S2C) ? 'Consultations' : 'Evaluations',
                            'menuLeft'      => 'ratings',
                            'title'         => $trad->t('Campagnes d\'évaluation'),
                            'campaign'      => $campaign,
                            'tab'           => 'Raters/new',
                            'mode'          => $mode,
                            'id'            => $id,
                            'droits'        => $this->droits,
                            'deleteMessage'     => $deleteMessage,
                        ]
                    );
                }

            case 'question':
                if ($group) {
                    Ariane::generate(2, $trad->t('Modifier le groupe d\'évaluateurs'));
                    return $this->renderer->render(
                        '@Evaluation/BilbliothequeDeQuestions/Raters/new',
                        [
                            'menuActive'    => Session::verifySessionTypeMenuTop(MenuTopEnum::S2C) ? 'Consultations' : 'Evaluations',
                            'menuLeft'      => 'library',
                            'title'         => $trad->t('Bibliothèque de données'),
                            'mode'          => $mode,
                            'id'            => $id,
                            'droits'        => $this->droits,
                            'group'         => $group,
                        ]
                    );
                } else {
                    Ariane::generate(2, $trad->t('Nouveau groupe d\'évaluateurs'));
                    return $this->renderer->render(
                        '@Evaluation/BilbliothequeDeQuestions/Raters/new',
                        [
                            'menuActive'    => Session::verifySessionTypeMenuTop(MenuTopEnum::S2C) ? 'Consultations' : 'Evaluations',
                            'menuLeft'      => 'library',
                            'title'         => $trad->t('Bibliothèque de données'),
                            'mode'          => $mode,
                            'id'            => $id,
                            'droits'        => $this->droits,
                        ]
                    );
                }

            case 'modele':
                if ($group) {
                    ArianeSub::generate(
                        1,
                        0,
                        $trad->t('Modifier le groupe d\'évaluateurs'),
                        $this->router->generateUri(
                            'Evaluation.GroupOfRaters.creatEdit',
                            ['mode' => $mode, 'id' => $id, 'group' => $group]
                        ),
                        1
                    );
                    return $this->renderer->render(
                        '@Evaluation/Modele/detail',
                        [
                            'menuActive'    => Session::verifySessionTypeMenuTop(MenuTopEnum::S2C) ? 'Consultations' : 'Evaluations',
                            'menuLeft'      => 'library',
                            'tab'           => 'GroupOfRaters/new',
                            'title'         => $trad->t('Modèles de questionnaire'),
                            'mode'          => $mode,
                            'id'            => $id,
                            'droits'        => $this->droits,
                            'group'         => $group,
                        ]
                    );
                } else {
                    ArianeSub::generate(
                        1,
                        0,
                        $trad->t('Nouveau groupe d\'évaluateurs'),
                        $this->router->generateUri(
                            'Evaluation.GroupOfRaters.creatEdit',
                            ['mode' => $mode, 'id' => $id, 'group' => $group]
                        ),
                        1
                    );
                    return $this->renderer->render(
                        '@Evaluation/Modele/detail',
                        [
                            'menuActive'    => Session::verifySessionTypeMenuTop(MenuTopEnum::S2C) ? 'Consultations' : 'Evaluations',
                            'menuLeft'      => 'library',
                            'tab'           => 'GroupOfRaters/new',
                            'title'         => $trad->t('Modèles de questionnaire'),
                            'mode'          => $mode,
                            'id'            => $id,
                            'droits'        => $this->droits,
                            'group'         => $group,
                        ]
                    );
                }

            default:
                return new Response();
        }
    }

    /**
     * validateAction
     *
     * @return Response
     */
    public function validateAction()
    {
        $id = $this->request->getAttribute('id');
        $mode = $this->request->getAttribute('mode');
        $group = $this->request->getAttribute('group');
        $post = $this->request->getParsedBody();

        $validator = $this->createValidator();

        $trad = $this->getTranslationService();

        switch ($mode) {
            case 'campaign':
                $post['numerique_ID_CAMP'] = $id;
                $validator->isCode(
                    $trad->t('Libellé'),
                    $post['GROUPE'],
                    1,
                    30
                );
                $campGrpNot = new CampGrpNot($this->pdo);
                if ($group) {
                    $campGrpNot->delete([
                        'ID_CAMP'   => $id,
                        'GROUPE'    => $group,
                    ]);
                }
                $groupAlreadyExists = $campGrpNot->find(
                    ['ID_CAMP' => $id, 'GROUPE' => $post['GROUPE']],
                    ['GROUPE'],
                );
                if (!$groupAlreadyExists && $validator->isValid()) {
                    $campGrpNot->insert($post);
                    return new Response(
                        200,
                        [],
                        (string) \json_encode([
                            'statut' => 'O',
                            'path' => $this->router->generateUri(
                                'Evaluation.GroupOfRaters.index',
                                ['id' => $id, 'mode' => 'campaign']
                            ),
                        ])
                    );
                } else {
                    if ($group) {
                        $post['GROUPE'] = $group;
                        $campGrpNot->insert($post);
                    }
                    return new Response(
                        200,
                        [],
                        (string) \json_encode([
                            'statut' => 'E',
                            'erreur' => $validator->getError()
                                ? $validator->getError()
                                : $trad->t('Le groupe existe déjà.'),
                        ])
                    );
                }

            case 'modele':
                $grilGrpNot = new GrilGrpNot($this->pdo);
                $post['ID_MODEL'] = $id;
                if ($group) {
                    $grilGrpNot->delete([
                        'ID_CAMP'   => $id,
                        'GROUPE'    => $group,
                    ]);
                }
                $validator->isCode(
                    $trad->t('Libellé'),
                    $post['GROUPE'],
                    1,
                    30
                );
                $groupAlreadyExists = $grilGrpNot->find(
                    [
                        'GROUPE'    => $post['GROUPE'],
                        'ID_MODEL'  => $id
                    ],
                    ['GROUPE'],
                );
                if (!$groupAlreadyExists && $validator->isValid()) {
                    $grilGrpNot->insert($post);
                    return new Response(
                        200,
                        [],
                        (string) \json_encode([
                            'statut' => 'O',
                            'path' => $this->router->generateUri(
                                'Evaluation.GroupOfRaters.index',
                                ['id' => $id, 'mode' => $mode]
                            ),
                        ])
                    );
                } else {
                    if ($group) {
                        $post['GROUPE'] = $group;
                        $grilGrpNot->insert($post);
                    }
                    return new Response(
                        200,
                        [],
                        (string) \json_encode([
                            'statut' => 'E',
                            'erreur' => $validator->getError()
                                ? $validator->getError()
                                : $trad->t('Le groupe existe déjà.'),
                        ])
                    );
                }

            case 'question':
                $bibGrpNot = new BibGrpNot($this->pdo);
                if ($group) {
                    $bibGrpNot->delete([
                        'GROUPE'    => $group,
                    ]);
                }
                $validator->isCode(
                    $trad->t('Libellé'),
                    $post['GROUPE'],
                    1,
                    30
                );
                $groupAlreadyExists = $bibGrpNot->find(
                    ['GROUPE' => $post['GROUPE']],
                    ['GROUPE'],
                );
                if (!$groupAlreadyExists && $validator->isValid()) {
                    $bibGrpNot->insert($post);
                    return new Response(
                        200,
                        [],
                        (string) \json_encode([
                            'statut' => 'O',
                            'path' => $this->router->generateUri(
                                'Evaluation.GroupOfRaters.index',
                                ['id' => $id, 'mode' => $mode]
                            ),
                        ])
                    );
                } else {
                    if ($group) {
                        $post['GROUPE'] = $group;
                        $bibGrpNot->insert($post);
                    }
                    return new Response(
                        200,
                        [],
                        (string) \json_encode([
                            'statut' => 'E',
                            'erreur' => $validator->getError()
                                ? $validator->getError()
                                : $trad->t('Le groupe existe déjà.'),
                        ])
                    );
                }

            default:
                return new Response();
        }
    }

    /**
     * deleteAction
     *
     * @return Response
     */
    public function deleteAction()
    {
        $id = $this->request->getAttribute('id');
        $mode = $this->request->getAttribute('mode');
        $group = $this->request->getAttribute('group');

        $trad = $this->getTranslationService();
        $campGrpNot = new CampGrpNot($this->pdo);
        $campQstQ = new CampQstQ($this->pdo);
        $campQstTh = new CampQstTh($this->pdo);
        $grilGrpNot = new GrilGrpNot($this->pdo);
        $grilQstQ = new GrilQstQ($this->pdo);
        $grilTheme = new GrilTheme($this->pdo);
        $bibGrpNot = new BibGrpNot($this->pdo);
        $bibQstQ = new BibQstQ($this->pdo);
        $bibQstTh = new BibQstTh($this->pdo);
        $campLstotGrp = new CampLstNotGrp($this->pdo);

        switch ($mode) {
            case 'campaign':
                $groupIsUsedInCampaign = $campQstQ->find([
                    'PROFNOTEUR1'   => 'G',
                    'PROFNOTEUR2'   => $group,
                    'ID_CAMP'       => $id
                ]);
                if (!$groupIsUsedInCampaign) {
                    $campGrpNot->delete([
                        'GROUPE' => $group,
                    ]);
                    $campLstotGrp->delete([
                        'GROUPE' => $group,
                        'ID_CAMP' => $id
                    ]);

                    return new Response(200, [], (string) \json_encode([
                        'path' => $this->router->generateUri('Evaluation.GroupOfRaters.index', ['mode' => $mode, 'id' => $id])
                    ]));
                } else {
                    $theme = $campQstTh->find([
                        'ID_CAMP'   => $id,
                        'ID_THEME'  => $groupIsUsedInCampaign['ID_THEME']
                    ], [
                        'LIB_THEME'
                    ], [], PDO::FETCH_ASSOC);
                    return new Response(
                        443,
                        [],
                        $this->renderer->render('@popup-erreur/confirmationSuppresion', [
                            'message'   => '<b>' .
                                $trad->t('Ce groupe est lié à une question de votre campagne') .
                                ' :</b></br></br>"' .
                                $groupIsUsedInCampaign['LIB_QUEST'] .
                                '" (' .
                                $theme['LIB_THEME'] .
                                ')</br></br>' .
                                'Voulez-vous supprimer le groupe malgré tout ?',
                            'div'       => 'redirect',
                            'pathURL'   => $this->router->generateUri(
                                'Evaluation.GroupOfRaters.confirmedDelete',
                                [
                                    'mode' => $mode,
                                    'id' => $id,
                                    'group' => $group
                                ]
                            ),
                        ])
                    );
                }

            case 'question':
                $groupIsUsedInLibrary = $bibQstQ->find([
                    'PROFNOTEUR1' => 'G',
                    'PROFNOTEUR2' => $group,
                ]);
                if (!$groupIsUsedInLibrary) {
                    $bibGrpNot->delete([
                        'GROUPE' => $group,
                    ]);
                    return new Response(200, [], (string) \json_encode([
                        'path' => $this->router->generateUri('Evaluation.GroupOfRaters.index', ['mode' => $mode, 'id' => $id])
                    ]));
                } else {
                    $theme = $bibQstTh->find([
                        'ID_THEME'  => $groupIsUsedInLibrary['ID_THEME']
                    ], [
                        'LIB_THEME'
                    ], [], PDO::FETCH_ASSOC);
                    return new Response(
                        443,
                        [],
                        $this->renderer->render('@popup-erreur/confirmationSuppresion', [
                            'message'   => '<b>' .
                                $trad->t('Ce groupe est lié à une question de votre bibliothèque') .
                                ' :</b></br></br>"' .
                                $groupIsUsedInLibrary['LIB_QUEST'] .
                                '" (' .
                                $theme['LIB_THEME'] .
                                ')</br></br>' .
                                'Voulez-vous supprimer le groupe malgré tout ?',
                            'div'       => 'redirect',
                            'pathURL'   => $this->router->generateUri(
                                'Evaluation.GroupOfRaters.confirmedDelete',
                                [
                                    'mode' => $mode,
                                    'id' => $id,
                                    'group' => $group
                                ]
                            ),
                        ])
                    );
                }

            case 'modele':
                $groupIsUsedInModel = $grilQstQ->find([
                    'PROFNOTEUR1'   => 'G',
                    'PROFNOTEUR2'   => $group,
                    'ID_MODEL'      => $id,
                ]);

                if (!$groupIsUsedInModel) {
                    $grilGrpNot->delete([
                        'GROUPE'    => $group,
                        'ID_MODEL'  => $id
                    ]);
                    return new Response(200, [], (string) \json_encode([
                        'path' => $this->router->generateUri('Evaluation.GroupOfRaters.index', ['mode' => $mode, 'id' => $id])
                    ]));
                } else {
                    $theme = $grilTheme->find([
                        'ID_THEME'  => $groupIsUsedInModel['ID_THEME']
                    ], [
                        'LIB_THEME'
                    ], [], PDO::FETCH_ASSOC);
                    return new Response(
                        443,
                        [],
                        $this->renderer->render('@popup-erreur/confirmationSuppresion', [
                            'message'   => '<b>' .
                                $trad->t('Ce groupe est lié à une question de votre modèle') .
                                ' :</b></br></br>"' .
                                $groupIsUsedInModel['LIB_QUEST'] .
                                '" (' .
                                $theme['LIB_THEME'] .
                                ')</br></br>' .
                                'Voulez-vous supprimer le groupe malgré tout ?',
                            'div'       => 'redirect',
                            'pathURL'   => $this->router->generateUri(
                                'Evaluation.GroupOfRaters.confirmedDelete',
                                [
                                    'mode' => $mode,
                                    'id' => $id,
                                    'group' => $group
                                ]
                            ),
                        ])
                    );
                }

            default:
                return new Response();
        }
    }

    /**
     * confirmedDeleteAction
     *
     * @return Response
     */
    public function confirmedDeleteAction()
    {
        $id = $this->request->getAttribute('id');
        $mode = $this->request->getAttribute('mode');
        $group = $this->request->getAttribute('group');

        $campGrpNot = new CampGrpNot($this->pdo);
        $campQstQ = new CampQstQ($this->pdo);
        $bibGrpNot = new BibGrpNot($this->pdo);
        $bibQstQ = new BibQstQ($this->pdo);
        $grilGrpNot = new GrilGrpNot($this->pdo);
        $grilQstQ = new GrilQstQ($this->pdo);

        switch ($mode) {
            case 'campaign':
                $campGrpNot->delete([
                    'GROUPE' => $group,
                    'ID_CAMP' => $id
                ]);
                $campQstQ->update([
                    'PROFNOTEUR1'   => '',
                    'PROFNOTEUR2'   => '',
                ], [
                    'ID_CAMP'       => $id,
                    'PROFNOTEUR1'   => 'G',
                    'PROFNOTEUR2'   => $group,
                ]);
                return new Response(200, [], (string) \json_encode([
                    'path' => $this->router->generateUri('Evaluation.GroupOfRaters.index', ['mode' => $mode, 'id' => $id])
                ]));

            case 'modele':
                $grilGrpNot->delete([
                    'GROUPE' => $group,
                    'ID_MODEL' => $id
                ]);
                $grilQstQ->update([
                    'PROFNOTEUR1'   => '',
                    'PROFNOTEUR2'   => '',
                ], [
                    'ID_MODEL'    => $id,
                    'PROFNOTEUR1' => 'G',
                    'PROFNOTEUR2' => $group,
                ]);
                return new Response(200, [], (string) \json_encode([
                    'path' => $this->router->generateUri('Evaluation.GroupOfRaters.index', ['mode' => $mode, 'id' => $id])
                ]));

            case 'question':
                $bibGrpNot->delete([
                    'GROUPE' => $group,
                ]);
                $bibQstQ->update([
                    'PROFNOTEUR1'   => '',
                    'PROFNOTEUR2'   => '',
                ], [
                    'PROFNOTEUR1'   => 'G',
                    'PROFNOTEUR2'   => $group,
                ]);
                return new Response(200, [], (string) \json_encode([
                    'path' => $this->router->generateUri('Evaluation.GroupOfRaters.index', ['mode' => $mode, 'id' => $id])
                ]));

            default:
                return new Response();
        }
    }

    /**
     * exportAction
     *
     * @return void
     */
    public function exportAction()
    {
    }

    /**
     * importIndexAction
     *
     * @return void
     */
    public function importIndexAction()
    {
    }

    /**
     * importAction
     *
     * @return void
     */
    public function importAction()
    {
    }

    /**
     * importSummaryAction
     *
     * @return void
     */
    public function importSummaryAction()
    {
    }
}
