Commit 66741e99 authored by Patrick Etcheverry's avatar Patrick Etcheverry

- Suppression de l'héritage ;

- Changement du nom 'Lecturer' et 'Engineer' ;
- Crudage et adaptation de Projet.
parent 591c8e7f
......@@ -11,7 +11,7 @@ title: "Title"
description: "Description"
position: "Position"
referentLecturer: "Referent Lecturer"
referentLecturer: "Referent Teacher"
project: "Project"
user: "User"
......@@ -26,8 +26,8 @@ deconnexion: "Log out"
shortname: "Shortname"
fullname: "Fullname"
ROLE_ENGINEER: "Engineer"
ROLE_LECTURER: "Lecturer"
ROLE_PEDAGOGICAL_ENGINEER: "Pedagogical Engineer"
ROLE_TEACHER: "Teacher"
fr: "French"
en: "English"
......
......@@ -11,7 +11,7 @@ title: ""
description: ""
position: "Position"
referentLecturer: ""
referentTeacher: ""
project: ""
user: ""
......@@ -26,12 +26,12 @@ deconnexion: "Cerrar sesión"
shortname: "Shortname"
fullname: "Fullname"
ROLE_ENGINEER: "Engineer"
ROLE_LECTURER: "Lecturer"
ROLE_PEDAGOGICAL_ENGINEER: "Ingenior pedagogico"
ROLE_TEACHER: "Profesor"
fr: "French"
en: "English"
es: "Spanish"
fr: "Frances"
en: "Ingles"
es: "Español"
lastname: "Lastname"
firstname: "Firstname"
......
......@@ -11,7 +11,7 @@ title: "Intitulé"
description: "Description"
position: "Position"
referentLecturer: "Enseignant Référent"
referentTeacher: "Enseignant Référent"
project: "Projet"
user: "Utilisateur"
......@@ -26,8 +26,8 @@ deconnexion: "Se déconnecter"
shortname: "Nom court"
fullname: "Nom complet"
ROLE_ENGINEER: "Ingénieur"
ROLE_LECTURER: "Enseignant"
ROLE_PEDAGOGICAL_ENGINEER: "Ingénieur Pédagogique"
ROLE_TEACHER: "Enseignant"
fr: "Français"
en: "Anglais"
......
......@@ -2,10 +2,10 @@
{% set appName = "Txuleton" %}
{# On regarde le rôle de l'utilisateur courant et on l'enregistre dans une variable qui sera globale aux autres vues #}
{% if is_granted('ROLE_ENGINEER') %}
{% set currentRole = "engineer" %}
{% elseif is_granted('ROLE_LECTURER') %}
{% set currentRole = "lecturer" %}
{% if is_granted('ROLE_PEDAGOGICAL_ENGINEER') %}
{% set currentRole = "pedagogical-engineer" %}
{% elseif is_granted('ROLE_TEACHER') %}
{% set currentRole = "teacher" %}
{% else %}
{% set currentRole = null %}
{% endif %}
......
......@@ -12,9 +12,9 @@
<span class="couleurBleuLien">{{'menu.scenariopedagogique'|trans}} </span>
</a>
</li>
{% if is_granted('ROLE_ENGINEER') %}
{% if currentRole == "pedagogical-engineer" %}
<li>
<a class="lienNonBleu" href="#">
<a class="lienNonBleu" href="{{ path('project_index', { 'userRole': currentRole })}}">
<img src="https://maxcdn.icons8.com/windows8/PNG/26/Business/graduation_cap-26.png" title="Chapeau de diplôme" width="16" height="16">
<span class="couleurBleuLien">{{'menu.projets'|trans}} </span>
</a>
......
......@@ -3,7 +3,7 @@
# USER BUNDLE
user_bundle:
resource: "@UserBundle/Resources/config/routing/user.yml"
prefix: /{_locale}/engineer/user
prefix: /{_locale}/pedagogical-engineer/user
# SCENARIO BUNDLE
scenario_bundle:
......@@ -11,12 +11,12 @@ scenario_bundle:
prefix: /{_locale}/{userRole}/
requirements:
_locale: fr|es|en
userRole: engineer|lecturer
userRole: pedagogical-engineer|teacher
# SCENARISATION PROCESS BUNDLE
demarche_scenarisation:
resource: "@ScenarisationProcessBundle/Resources/config/routing.yml"
prefix: /{_locale}/engineer/scenarisation
prefix: /{_locale}/pedagogical-engineer/scenarisation
redirect_to_login:
pattern: /
......
......@@ -4,7 +4,7 @@ security:
UserBundle\Entity\User: sha512
role_hierarchy:
ROLE_SUPER_ADMIN: [ROLE_ENGINEER, ROLE_LECTURER, ROLE_ALLOWED_TO_SWITCH]
ROLE_SUPER_ADMIN: [ROLE_PEDAGOGICAL_ENGINEER, ROLE_TEACHER, ROLE_ALLOWED_TO_SWITCH]
providers:
main:
......@@ -13,8 +13,8 @@ security:
property: email
access_control:
- { path: ^/%languages%/engineer/, roles: ROLE_ENGINEER }
- { path: ^/%languages%/lecturer/, roles: ROLE_LECTURER }
- { path: ^/%languages%/engineer/, roles: ROLE_PEDAGOGICAL_ENGINEER }
- { path: ^/%languages%/lecturer/, roles: ROLE_TEACHER }
firewalls:
# disables authentication for assets and the profiler
......
......@@ -41,7 +41,7 @@ class PedagogicalScenarioController extends Controller
/**
* Creates a new pedagogicalScenario entity.
* @Security("has_role('ROLE_ENGINEER')")
* @Security("has_role('ROLE_PEDAGOGICAL_ENGINEER')")
*/
public function newAction(Request $request)
{
......@@ -54,7 +54,7 @@ class PedagogicalScenarioController extends Controller
$em->persist($pedagogicalScenario);
$em->flush();
return $this->redirectToRoute('pedagogicalscenario_show', array('id' => $pedagogicalScenario->getId(), 'userRole' => "engineer"));
return $this->redirectToRoute('pedagogicalscenario_show', array('id' => $pedagogicalScenario->getId(), 'userRole' => "pedagogical-engineer"));
}
return $this->render('ScenarioBundle:pedagogicalscenario:new.html.twig', array(
......@@ -77,7 +77,7 @@ class PedagogicalScenarioController extends Controller
$toutesInfos = $entityManager->createQuery ('
select scenarioPedagogique, projet, referent, process
FROM ScenarioBundle:PedagogicalScenario scenarioPedagogique
JOIN scenarioPedagogique.referentLecturer referent
JOIN scenarioPedagogique.referentTeacher referent
JOIN scenarioPedagogique.project projet
JOIN scenarioPedagogique.scenarisationProcess process
WHERE scenarioPedagogique = :scenarioPedagogique');
......@@ -94,19 +94,23 @@ class PedagogicalScenarioController extends Controller
/**
* Displays a form to edit an existing pedagogicalScenario entity.
* @Security("has_role('ROLE_ENGINEER')")
* @Security("has_role('ROLE_PEDAGOGICAL_ENGINEER')")
*/
public function editAction(Request $request, PedagogicalScenario $pedagogicalScenario)
{
$deleteForm = $this->createDeleteForm($pedagogicalScenario);
$editForm = $this->createForm('ScenarioBundle\Form\PedagogicalScenarioType', $pedagogicalScenario);
// Une fois que la démarche de scénarisation d'un scénario pédagogique a été défini, on ne peut plus la modifier.
$editForm->remove('scenarisationProcess');
$editForm->handleRequest($request);
if ($editForm->isSubmitted() && $editForm->isValid())
{
$this->getDoctrine()->getManager()->flush();
return $this->redirectToRoute('pedagogicalscenario_edit', array('id' => $pedagogicalScenario->getId(), 'userRole' => 'engineer'));
return $this->redirectToRoute('pedagogicalscenario_edit', array('id' => $pedagogicalScenario->getId(), 'userRole' => 'pedagogical-engineer'));
}
return $this->render('ScenarioBundle:pedagogicalscenario:edit.html.twig', array(
......@@ -118,7 +122,7 @@ class PedagogicalScenarioController extends Controller
/**
* Deletes a pedagogicalScenario entity.
* @Security("has_role('ROLE_ENGINEER')")
* @Security("has_role('ROLE_PEDAGOGICAL_ENGINEER')")
*/
public function deleteAction(Request $request, PedagogicalScenario $pedagogicalScenario)
{
......@@ -131,7 +135,7 @@ class PedagogicalScenarioController extends Controller
$em->flush();
}
return $this->redirectToRoute('pedagogicalscenario_index', array('userRole' => "engineer"));
return $this->redirectToRoute('pedagogicalscenario_index', array('userRole' => "pedagogical-engineer"));
}
/**
......@@ -143,13 +147,13 @@ class PedagogicalScenarioController extends Controller
*/
private function createDeleteForm(PedagogicalScenario $pedagogicalScenario)
{
if ($this->get('security.context')->isGranted('ROLE_ENGINEER'))
if ($this->get('security.context')->isGranted('ROLE_PEDAGOGICAL_ENGINEER'))
{
$currentRole = 'engineer';
$currentRole = 'pedagogical-engineer';
}
else if ($this->get('security.context')->isGranted('ROLE_LECTURER'))
else if ($this->get('security.context')->isGranted('ROLE_TEACHER'))
{
$currentRole = 'lecturer';
$currentRole = 'teacher';
}
return $this->createFormBuilder()
->setAction($this->generateUrl('pedagogicalscenario_delete', array('id' => $pedagogicalScenario->getId(), 'userRole' => $currentRole)))
......
<?php
namespace ScenarioBundle\Controller;
use ScenarioBundle\Entity\Project;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\Request;
// To use Security annotations on the top of fuctions
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Security;
/**
* Project controller.
*
*/
class ProjectController extends Controller
{
/**
* Lists all project entities.
*
*/
public function indexAction(Request $request)
{
$em = $this->getDoctrine()->getManager();
//$projects = $em->getRepository('ScenarioBundle:Project')->findAll();
$queryBuilder = $em->getRepository('ScenarioBundle:Project')->createQueryBuilder('projects');
$query = $queryBuilder->getQuery();
$paginator = $this->get('knp_paginator');
$projects = $paginator->paginate(
$query,
$request->query->getInt('page', 1)/*page number*/,
5/*limit per page*/
);
return $this->render('ScenarioBundle:project:index.html.twig', array(
'projects' => $projects,
));
}
/**
* Creates a new project entity.
* @Security("has_role('ROLE_PEDAGOGICAL_ENGINEER')")
*/
public function newAction(Request $request)
{
$project = new Project();
$form = $this->createForm('ScenarioBundle\Form\ProjectType', $project);
$form->handleRequest($request);
if ($form->isSubmitted() && $form->isValid()) {
$em = $this->getDoctrine()->getManager();
$em->persist($project);
$em->flush();
return $this->redirectToRoute('project_show', array('id' => $project->getId(), 'userRole' => "pedagogical-engineer"));
}
return $this->render('ScenarioBundle:project:new.html.twig', array(
'project' => $project,
'form' => $form->createView(),
));
}
/**
* Finds and displays a project entity.
*
*/
public function showAction(Project $project)
{
$deleteForm = $this->createDeleteForm($project);
return $this->render('ScenarioBundle:project:show.html.twig', array(
'project' => $project,
'delete_form' => $deleteForm->createView(),
));
}
/**
* Displays a form to edit an existing project entity.
* @Security("has_role('ROLE_PEDAGOGICAL_ENGINEER')")
*/
public function editAction(Request $request, Project $project)
{
$deleteForm = $this->createDeleteForm($project);
$editForm = $this->createForm('ScenarioBundle\Form\ProjectType', $project);
$editForm->handleRequest($request);
if ($editForm->isSubmitted() && $editForm->isValid()) {
$this->getDoctrine()->getManager()->flush();
return $this->redirectToRoute('project_edit', array('id' => $project->getId()));
}
return $this->render('ScenarioBundle:project:edit.html.twig', array(
'project' => $project,
'edit_form' => $editForm->createView(),
'delete_form' => $deleteForm->createView(),
));
}
/**
* Deletes a project entity.
* @Security("has_role('ROLE_PEDAGOGICAL_ENGINEER')")
*/
public function deleteAction(Request $request, Project $project)
{
$form = $this->createDeleteForm($project);
$form->handleRequest($request);
if ($form->isSubmitted() && $form->isValid()) {
$em = $this->getDoctrine()->getManager();
$em->remove($project);
$em->flush();
}
return $this->redirectToRoute('project_index', array('userRole' => 'pedagogical-engineer'));
}
/**
* Creates a form to delete a project entity.
*
* @param Project $project The project entity
*
* @return \Symfony\Component\Form\Form The form
*/
private function createDeleteForm(Project $project)
{
if ($this->get('security.context')->isGranted('ROLE_PEDAGOGICAL_ENGINEER'))
{
$currentRole = 'pedagogical-engineer';
}
else if ($this->get('security.context')->isGranted('ROLE_TEACHER'))
{
$currentRole = 'teacher';
}
return $this->createFormBuilder()
->setAction($this->generateUrl('project_delete', array('id' => $project->getId(), 'userRole'=> $currentRole )))
->setMethod('DELETE')
->getForm()
;
}
}
......@@ -39,7 +39,7 @@ class PedagogicalScenario
* @ORM\ManyToOne(targetEntity="UserBundle\Entity\User", inversedBy="pedagogicalScenarioPiloted")
* @ORM\JoinColumn(nullable=true, onDelete="SET NULL")
*/
private $referentLecturer;
private $referentTeacher;
/**
* @ORM\ManyToOne(targetEntity="ScenarioBundle\Entity\Project", inversedBy="pedagogicalScenarios")
......@@ -124,26 +124,26 @@ class PedagogicalScenario
}
/**
* Set referentLecturer
* Set referentTeacher
*
* @param \UserBundle\Entity\User $referentLecturer
* @param \UserBundle\Entity\User $referentTeacher
*
* @return PedagogicalScenario
*/
public function setReferentLecturer(\UserBundle\Entity\User $referentLecturer = null)
public function setReferentTeacher(\UserBundle\Entity\User $referentTeacher = null)
{
$this->referentLecturer = $referentLecturer;
$this->referentTeacher = $referentTeacher;
if ($referentLecturer != null)
$referentLecturer->addPedagogicalScenarioPiloted($this);
if ($referentTeacher != null)
$referentTeacher->addPedagogicalScenarioPiloted($this);
return $this;
}
/**
* Update referentLecturer
* Update referentTeacher
*
* @param \UserBundle\Entity\User $referentLecturer
* @param \UserBundle\Entity\User $referentTeacher
*
* @return PedagogicalScenario
*
......@@ -151,25 +151,25 @@ class PedagogicalScenario
* Si le nouvel enseignant référent ne 'concoit' pas déjà le pédagogique,
* la fonction l'ajoute.
*/
public function updateReferentLecturer(\UserBundle\Entity\User $newReferentLecturer)
public function updateReferentTeacher(\UserBundle\Entity\User $newReferentTeacher)
{
/* Si l'utilisateur que l'on veut nommer comme référent n'est pas null ou ne l'est pas déjà */
if ($newReferentLecturer != null && $this->getReferentLecturer() != $newReferentLecturer)
if ($newReferentTeacher != null && $this->getReferentTeacher() != $newReferentTeacher)
{
/* Déjà, on récupère la liste des PedagogicalScenario Concus par le nouvel utilisateur */
$tab_pedagogicalScenarioDesigned = $newReferentLecturer->getPedagogicalScenarioDesigned()->toArray();
$tab_pedagogicalScenarioDesigned = $newReferentTeacher->getPedagogicalScenarioDesigned()->toArray();
/* Si le PedagogicalScenario courant n'est pas dans cette liste, on l'ajoute */
if (!in_array($this, $tab_pedagogicalScenarioDesigned))
$newReferentLecturer->addPedagogicalScenarioDesigned($this);
$newReferentTeacher->addPedagogicalScenarioDesigned($this);
/* On spécifie chez l'ancien utilisateur qu'il n'est plus référent du scénario pédagogique courant */
if ($this->getReferentLecturer() != null)
$this->getReferentLecturer()->removePedagogicalScenarioPiloted($this);
if ($this->getReferentTeacher() != null)
$this->getReferentTeacher()->removePedagogicalScenarioPiloted($this);
/* Ce setter fait automatiquement utilisateur->addPedagogicalScenarioDesigned*/
$this->setReferentLecturer($newReferentLecturer);
$this->setReferentTeacher($newReferentTeacher);
}
......@@ -177,13 +177,13 @@ class PedagogicalScenario
}
/**
* Get referentLecturer
* Get referentTeacher
*
* @return \UserBundle\Entity\User
*/
public function getReferentLecturer()
public function getReferentTeacher()
{
return $this->referentLecturer;
return $this->referentTeacher;
}
/**
......
......@@ -25,19 +25,19 @@ class PedagogicalScenarioType extends AbstractType
$builder->add('shortname','text', array( 'label' => 'shortname'));
$builder->add('fullname','text', array( 'label' => 'fullname'));
$builder->add('referentLecturer', EntityType::class, array(
'label' => 'referentLecturer',
'class' => 'UserBundle:Lecturer',
$builder->add('referentTeacher', EntityType::class, array(
'label' => 'referentTeacher',
'class' => 'UserBundle:User',
'choice_label' => 'lastnameFirstname',
'query_builder' => function (EntityRepository $er) {
return $er->createQueryBuilder('l')
->orderBy('l.lastname', 'ASC');
return $er->createQueryBuilder('u')
->where('u.roles LIKE :role')
->orderBy('u.lastname', 'ASC')
->setParameter('role','%ROLE_TEACHER%');
}
//'multiple' => true
));
$builder->add('scenarisationProcess', EntityType::class, array(
'label' => 'scenarisationProcess',
'class' => 'ScenarisationProcessBundle:ScenarisationProcess',
......
<?php
namespace ScenarioBundle\Form;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
class ProjectType extends AbstractType
{
/**
* {@inheritdoc}
*/
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder->add('shortname','text', array( 'label' => 'shortname'));
$builder->add('fullname','text', array( 'label' => 'fullname'));
}
/**
* {@inheritdoc}
*/
public function configureOptions(OptionsResolver $resolver)
{
$resolver->setDefaults(array(
'data_class' => 'ScenarioBundle\Entity\Project'
));
}
/**
* {@inheritdoc}
*/
public function getBlockPrefix()
{
return 'scenariobundle_project';
}
}
scenario_pedagogicalscenario:
resource: "@ScenarioBundle/Resources/config/routing/pedagogicalscenario.yml"
prefix: /pedagogical-scenario
scenario_project:
resource: "@ScenarioBundle/Resources/config/routing/project.yml"
prefix: /project
project_index:
path: /
defaults: { _controller: "ScenarioBundle:Project:index" }
methods: GET
project_show:
path: /{id}/show
defaults: { _controller: "ScenarioBundle:Project:show" }
methods: GET
project_new:
path: /new
defaults: { _controller: "ScenarioBundle:Project:new" }
methods: [GET, POST]
project_edit:
path: /{id}/edit
defaults: { _controller: "ScenarioBundle:Project:edit" }
methods: [GET, POST]
project_delete:
path: /{id}/delete
defaults: { _controller: "ScenarioBundle:Project:delete" }
methods: DELETE
......@@ -3,3 +3,9 @@ pedagogicalScenario:
list: "Liste des Scénarios pédagogiques"
edit: "Modifier un Scénario pédagogique"
add: "Ajout d'un Scénario pédagogique"
project:
new: "Ajouter un nouveau Projet"
list: "Liste des Projets"
edit: "Modifier un Projet"
add: "Ajout d'un Projet"
......@@ -21,9 +21,9 @@
<li>
<a href="{{ path('pedagogicalscenario_show', { 'userRole': currentRole, 'id': pedagogicalScenario.id }) }}">{{ 'show'|trans }}</a>
</li>
{% if currentRole == "engineer" %}
{% if currentRole == "pedagogical-engineer" %}
<li>
<a href="{{ path('pedagogicalscenario_edit', { 'userRole': "engineer", 'id': pedagogicalScenario.id }) }}">{{ 'edit'|trans }}</a>
<a href="{{ path('pedagogicalscenario_edit', { 'userRole': "pedagogical-engineer", 'id': pedagogicalScenario.id }) }}">{{ 'edit'|trans }}</a>
</li>
{% endif %}
</ul>
......@@ -33,10 +33,10 @@
</tbody>
</table>
{% if currentRole == "engineer" %}
{% if currentRole == "pedagogical-engineer" %}
<ul>
<li>
<a href="{{ path('pedagogicalscenario_new', { 'userRole': "engineer" }) }}">{{ 'pedagogicalScenario.new'|trans }}</a>
<a href="{{ path('pedagogicalscenario_new', { 'userRole': "pedagogical-engineer" }) }}">{{ 'pedagogicalScenario.new'|trans }}</a>
</li>
</ul>
{% endif %}
......
{% extends 'base.html.twig' %}
{% block body %}
<h1>{{'project.edit'|trans}}</h1>