Commit 17462691 authored by Laurent Lécluse's avatar Laurent Lécluse
Browse files

Mise en place du système de tests pour la formule

parent b8ed96f1
......@@ -57,6 +57,11 @@ INSERT INTO CATEGORIE_PRIVILEGE (ID,CODE,LIBELLE) VALUES (
'structures',
'Structures'
);
INSERT INTO CATEGORIE_PRIVILEGE (ID,CODE,LIBELLE) VALUES (
CATEGORIE_PRIVILEGE_ID_SEQ.nextval,
'formule',
'Formule de calcul'
);
INSERT INTO PRIVILEGE (ID, CATEGORIE_ID, CODE, LIBELLE, ORDRE)
SELECT
......@@ -67,19 +72,21 @@ SELECT
(SELECT count(*) FROM PRIVILEGE WHERE categorie_id = (SELECT id FROM CATEGORIE_PRIVILEGE WHERE code = t1.c )) + rownum ORDRE
FROM (
SELECT 'odf' c, 'grands-types-diplome-visualisation' p, 'Grands types de diplômes (visualisation)' l FROM dual
UNION ALL SELECT 'odf' c, 'grands-types-diplome-edition' p, 'Grands types de diplômes (édition)' l FROM dual
SELECT 'odf' c, 'grands-types-diplome-visualisation' p, 'Grands types de diplômes (visualisation)' l FROM dual
UNION ALL SELECT 'odf' c, 'grands-types-diplome-edition' p, 'Grands types de diplômes (édition)' l FROM dual
UNION ALL SELECT 'odf' c, 'types-diplome-visualisation' p, 'Types de diplômes (visualisation)' l FROM dual
UNION ALL SELECT 'odf' c, 'types-diplome-edition' p, 'Types de diplômes (édition)' l FROM dual
UNION ALL SELECT 'odf' c, 'types-diplome-visualisation' p, 'Types de diplômes (visualisation)' l FROM dual
UNION ALL SELECT 'odf' c, 'types-diplome-edition' p, 'Types de diplômes (édition)' l FROM dual
UNION ALL SELECT 'motifs-modification-service-du' c, 'visualisation' p, 'Administration (visualisation)' l FROM dual
UNION ALL SELECT 'motifs-modification-service-du' c, 'edition' p, 'Administration (édition)' l FROM dual
UNION ALL SELECT 'motifs-modification-service-du' c, 'visualisation' p, 'Administration (visualisation)' l FROM dual
UNION ALL SELECT 'motifs-modification-service-du' c, 'edition' p, 'Administration (édition)' l FROM dual
UNION ALL SELECT 'structures' c, 'administration-visualisation' p, 'Administration (visualisation)' l FROM dual
UNION ALL SELECT 'structures' c, 'administration-edition' p, 'Administration (édition)' l FROM dual
UNION ALL SELECT 'structures' c, 'administration-visualisation' p, 'Administration (visualisation)' l FROM dual
UNION ALL SELECT 'structures' c, 'administration-edition' p, 'Administration (édition)' l FROM dual
UNION ALL SELECT 'budget' c, 'types-ressources-visualisation' p, 'Types de ressources - Visualisation' l FROM dual
UNION ALL SELECT 'budget' c, 'types-ressources-edition' p, 'Types de ressources - Édition' l FROM dual
UNION ALL SELECT 'budget' c, 'types-ressources-visualisation' p, 'Types de ressources - Visualisation' l FROM dual
UNION ALL SELECT 'budget' c, 'types-ressources-edition' p, 'Types de ressources - Édition' l FROM dual
UNION ALL SELECT 'formule' c, 'tests' p, 'Tests' l FROM dual
) t1;
\ No newline at end of file
) t1;
\ No newline at end of file
......@@ -2,15 +2,73 @@
namespace Application;
use Application\Provider\Privilege\Privileges;
use UnicaenAuth\Guard\PrivilegeController;
return [
/* Déclaration du contrôleur */
'controllers' => [
'controllers' => [
'factories' => [
'Application\Controller\Formule' => Controller\Factory\FormuleControllerFactory::class,
],
],
'router' => [
'routes' => [
'formule-calcul' => [
'type' => 'Literal',
'options' => [
'route' => '/formule-calcul',
'defaults' => [
'controller' => 'Application\Controller\Formule',
//'action' => 'index',
],
],
'child_routes' => [
'test' => [
'type' => 'Literal',
'options' => [
'route' => '/test',
'defaults' => [
'action' => 'test',
],
],
'may_terminate' => true,
'child_routes' => [
'saisir' => [
'type' => 'Segment',
'options' => [
'route' => '/saisir[/:formuleTestIntervenant]',
'constraints' => [
'formuleTestIntervenant' => '[0-9]*',
],
'defaults' => [
'action' => 'test-saisir',
],
],
'may_terminate' => true,
],
'supprimer' => [
'type' => 'Segment',
'options' => [
'route' => '/supprimer/:formuleTestIntervenant',
'constraints' => [
'formuleTestIntervenant' => '[0-9]*',
],
'defaults' => [
'action' => 'test-supprimer',
],
],
'may_terminate' => true,
],
],
],
],
],
],
],
'console' => [
'router' => [
'routes' => [
......@@ -27,9 +85,43 @@ return [
],
],
'navigation' => [
'default' => [
'home' => [
'pages' => [
'administration' => [
'pages' => [
'formule-calcul' => [
'label' => 'Test de formule de calcul',
'icon' => 'glyphicon glyphicon-briefcase',
'route' => 'formule-calcul/test',
'resource' => PrivilegeController::getResourceId('Application\Controller\Formule', 'test'),
'order' => 80,
'border-color' => '#0C8758',
],
],
],
],
],
],
],
'bjyauthorize' => [
'guards' => [
PrivilegeController::class => [
[
'controller' => 'Application\Controller\Formule',
'action' => ['test', 'test-saisir', 'test-supprimer'],
'privileges' => [Privileges::FORMULE_TESTS],
],
],
],
],
'service_manager' => [
'factories' => [
Service\FormuleService::class => Service\Factory\FormuleServiceFactory::class,
'factories' => [
Service\FormuleService::class => Service\Factory\FormuleServiceFactory::class,
Service\FormuleTestIntervenantService::class => Service\Factory\FormuleTestIntervenantServiceFactory::class,
],
'invokables' => [
Service\FormuleResultatService::class => Service\FormuleResultatService::class,
......@@ -39,4 +131,10 @@ return [
Service\FormuleResultatVolumeHoraireReferentielService::class => Service\FormuleResultatVolumeHoraireReferentielService::class,
],
],
'form_elements' => [
'factories' => [
Form\FormuleTest\IntervenantForm::class => Form\FormuleTest\Factory\IntervenantFormFactory::class,
],
],
];
\ No newline at end of file
......@@ -3,6 +3,10 @@
namespace Application\Controller;
use Application\Entity\Db\FormuleTestIntervenant;
use Application\Form\FormuleTest\Traits\IntervenantFormAwareTrait;
use Application\Service\Traits\FormuleTestIntervenantServiceAwareTrait;
/**
* Description of FormuleController
*
......@@ -10,6 +14,63 @@ namespace Application\Controller;
*/
class FormuleController extends AbstractController
{
use FormuleTestIntervenantServiceAwareTrait;
use IntervenantFormAwareTrait;
public function testAction()
{
$fti = $this->getServiceFormuleTestIntervenant()->getList();
return compact('fti', 'title');
}
public function testSaisirAction()
{
/* @var $formuleTestIntervenant FormuleTestIntervenant */
$formuleTestIntervenant = $this->getEvent()->getParam('formuleTestIntervenant');
$form = $this->getFormFormuleTestIntervenant();
if (!$formuleTestIntervenant) {
$title = 'Ajout d\'un test de formule';
$formuleTestIntervenant = new FormuleTestIntervenant();
} else {
$title = 'Modification d\'un test de formule';
}
$form->bindRequestSave($formuleTestIntervenant, $this->getRequest(), function (FormuleTestIntervenant $fti) {
try {
$this->getServiceFormuleTestIntervenant()->save($fti);
$this->flashMessenger()->addSuccessMessage('Test de formule bien enregistré');
return $this->redirect()->toRoute('formule-calcul/test');
} catch (\Exception $e) {
$this->flashMessenger()->addErrorMessage($this->translate($e));
}
});
return compact('form', 'formuleTestIntervenant', 'title');
}
public function testSupprimerAction()
{
/* @var $formuleTestIntervenant FormuleTestIntervenant */
$formuleTestIntervenant = $this->getEvent()->getParam('FormuleTestIntervenant');
try {
$this->getServiceFormuleTestIntervenant()->delete($formuleTestIntervenant);
$this->flashMessenger()->addSuccessMessage("Test de formule supprimé avec succès.");
} catch (\Exception $e) {
$this->flashMessenger()->addErrorMessage(DbException::translate($e)->getMessage());
}
return new MessengerViewModel();
}
public function calculerToutAction()
{
......
......@@ -13,7 +13,6 @@ use Application\Service\Traits\ContextServiceAwareTrait;
use Application\Service\Traits\ElementPedagogiqueServiceAwareTrait;
use Application\Service\Traits\EtapeServiceAwareTrait;
use Application\Service\Traits\NiveauEtapeServiceAwareTrait;
use Application\Exception\DbException;
/**
* Description of EtapeController
......@@ -60,8 +59,7 @@ class EtapeController extends AbstractController
$this->getServiceEtape()->save($etape);
$form->get('id')->setValue($etape->getId()); // transmet le nouvel ID
} catch (\Exception $e) {
$e = DbException::translate($e);
$errors[] = $e->getMessage();
$errors[] = $this->translate($e);
}
}
}
......
<?php
namespace Application\Entity\Db;
use Application\Entity\Db\Traits\AnneeAwareTrait;
use Application\Entity\Db\Traits\EtatVolumeHoraireAwareTrait;
use Application\Entity\Db\Traits\FormuleAwareTrait;
use Application\Entity\Db\Traits\FormuleTestStructureAwareTrait;
use Application\Entity\Db\Traits\TypeIntervenantAwareTrait;
use Application\Entity\Db\Traits\TypeVolumeHoraireAwareTrait;
class FormuleTestIntervenant
{
use FormuleAwareTrait;
use AnneeAwareTrait;
use TypeIntervenantAwareTrait;
use FormuleTestStructureAwareTrait;
use TypeVolumeHoraireAwareTrait;
use EtatVolumeHoraireAwareTrait;
/**
* @var integer
*/
private $id;
/**
* @var string
*/
private $libelle;
/**
* @var float
*/
private $heuresDecharge = 0;
/**
* @var float
*/
private $heuresServiceStatutaire = 0;
/**
* @var float
*/
private $heuresServiceModifie = 0;
/**
* @var bool
*/
private $depassementServiceDuSansHC = false;
/**
* @var string
*/
private $param1;
/**
* @var string
*/
private $param2;
/**
* @var string
*/
private $param3;
/**
* @var string
*/
private $param4;
/**
* @var string
*/
private $param5;
/**
* @var float
*/
private $aServiceDu = 0;
/**
* @var float
*/
private $cServiceDu;
/**
* @var \Doctrine\Common\Collections\Collection
*/
protected $volumeHoraireTest;
/**
* @return int
*/
public function getId()
{
return $this->id;
}
/**
* @return string
*/
public function getLibelle()
{
return $this->libelle;
}
/**
* @param string $libelle
*/
public function setLibelle(string $libelle)
{
$this->libelle = $libelle;
}
/**
* @return float
*/
public function getHeuresDecharge()
{
return $this->heuresDecharge;
}
/**
* @param float $heuresDecharge
*/
public function setHeuresDecharge(float $heuresDecharge)
{
$this->heuresDecharge = $heuresDecharge;
}
/**
* @return float
*/
public function getHeuresServiceStatutaire()
{
return $this->heuresServiceStatutaire;
}
/**
* @param float $heuresServiceStatutaire
*/
public function setHeuresServiceStatutaire(float $heuresServiceStatutaire)
{
$this->heuresServiceStatutaire = $heuresServiceStatutaire;
}
/**
* @return float
*/
public function getHeuresServiceModifie()
{
return $this->heuresServiceModifie;
}
/**
* @param float $heuresServiceModifie
*/
public function setHeuresServiceModifie(float $heuresServiceModifie)
{
$this->heuresServiceModifie = $heuresServiceModifie;
}
/**
* @return bool
*/
public function isDepassementServiceDuSansHC(): bool
{
return $this->depassementServiceDuSansHC;
}
/**
* @param bool $depassementServiceDuSansHC
*/
public function setDepassementServiceDuSansHC(bool $depassementServiceDuSansHC)
{
$this->depassementServiceDuSansHC = $depassementServiceDuSansHC;
}
/**
* @return string
*/
public function getParam1()
{
return $this->param1;
}
/**
* @param string $param1
*/
public function setParam1(string $param1)
{
$this->param1 = $param1;
}
/**
* @return string
*/
public function getParam2()
{
return $this->param2;
}
/**
* @param string $param2
*/
public function setParam2(string $param2)
{
$this->param2 = $param2;
}
/**
* @return string
*/
public function getParam3()
{
return $this->param3;
}
/**
* @param string $param3
*/
public function setParam3(string $param3)
{
$this->param3 = $param3;
}
/**
* @return string
*/
public function getParam4()
{
return $this->param4;
}
/**
* @param string $param4
*/
public function setParam4(string $param4)
{
$this->param4 = $param4;
}
/**
* @return string
*/
public function getParam5()
{
return $this->param5;
}
/**
* @param string $param5
*/
public function setParam5(string $param5)
{
$this->param5 = $param5;
}
/**
* @return float
*/
public function getAServiceDu()
{
return $this->aServiceDu;
}
/**
* @param float $aServiceDu
*/
public function setAServiceDu(float $aServiceDu)
{
$this->aServiceDu = $aServiceDu;
}
/**
* @return float
*/
public function getCServiceDu()
{