Commit 2f96641c authored by Patrick Etcheverry's avatar Patrick Etcheverry

- Vues pour pouvoir associer des formations à partir d'un scénario pédagogique

parent 6e345ef0
......@@ -206,7 +206,15 @@ class FormationController extends Controller
$em->persist($pedagogicalScenarioFormation);
$em->flush();
return $this->redirectToRoute('formation_pedagogical_scenario_management', array('userRole' => 'pedagogical-engineer', 'id' => $formation->getId()));
// Cette méthode est également utilisée par le Scénario Pédagogique
// Il faut dont renvoyer vers la bonne vue
$request = $this->container->get('request');
$routeName = $request->get('_route');
if ($routeName == 'pedagogicalscenario_formation_add')
return $this->redirectToRoute('pedagogicalscenario_formation_management', array('userRole' => 'pedagogical-engineer', 'id' => $pedagogicalScenario->getId()));
else
return $this->redirectToRoute('formation_pedagogical_scenario_management', array('userRole' => 'pedagogical-engineer', 'id' => $formation->getId()));
}
/**
......@@ -234,6 +242,14 @@ class FormationController extends Controller
$em->remove($pedagogicalScenarioFormation);
$em->flush();
return $this->redirectToRoute('formation_pedagogical_scenario_management', array('userRole' => 'pedagogical-engineer', 'id' => $formation->getId()));
// Cette méthode est également utilisée par le Scénario Pédagogique
// Il faut dont renvoyer vers la bonne vue
$request = $this->container->get('request');
$routeName = $request->get('_route');
if ($routeName == 'pedagogicalscenario_formation_delete')
return $this->redirectToRoute('pedagogicalscenario_formation_management', array('userRole' => 'pedagogical-engineer', 'id' => $pedagogicalScenario->getId()));
else
return $this->redirectToRoute('formation_pedagogical_scenario_management', array('userRole' => 'pedagogical-engineer', 'id' => $formation->getId()));
}
}
......@@ -161,4 +161,55 @@ class PedagogicalScenarioController extends Controller
->getForm()
;
}
/**
* Permit to manage the Formations of a Pedagogical Scenario
*
* @param PedagogicalScenario $pedagogicalScenario The pedagogicalScenarioEntity entity
*
*/
public function formationManagementAction(PedagogicalScenario $pedagogicalScenario)
{
$em = $this->getDoctrine()->getManager();
/*$queryBuilder = $em->getRepository('ScenarioBundle:PedagogicalScenario')->createQueryBuilder('pedagogicalScenarios');
$query = $queryBuilder->getQuery();
$paginator = $this->get('knp_paginator');
$pedagogicalScenarios = $paginator->paginate(
$query,
$request->query->getInt('page', 1), // page number
5 // limit per page
);*/
// On récupère la liste des formations dans lesquelles le scenarioPedagogique est déjà associé
$formationsAlreadyLinked = $em->createQuery ('
select f, psf, ps
FROM ScenarioBundle:Formation f
JOIN f.pedagogicalScenarioFormation psf
JOIN psf.pedagogicalScenario ps
WHERE psf.pedagogicalScenario = :pedagogicalScenario');
$formationsAlreadyLinked->setParameter('pedagogicalScenario', $pedagogicalScenario);
// On récupère la liste formations dans laquelle le scénario pédagogique n'est pas lié
$formationsAvailable = $em->createQuery ('
select ff
FROM ScenarioBundle:Formation ff
WHERE ff NOT IN (select f
FROM ScenarioBundle:Formation f
JOIN f.pedagogicalScenarioFormation psf
JOIN psf.pedagogicalScenario ps
WHERE psf.pedagogicalScenario = :pedagogicalScenario)');
$formationsAvailable->setParameter('pedagogicalScenario', $pedagogicalScenario);
$formationsAlreadyLinked = $formationsAlreadyLinked->getResult();
$formationsAvailable = $formationsAvailable->getResult();
return $this->render('ScenarioBundle:pedagogicalscenario:formationmanagement.html.twig', array(
'formationsAlreadyLinked' => $formationsAlreadyLinked,
'formationsAvailable' => $formationsAvailable,
'pedagogicalScenario' => $pedagogicalScenario
));
}
}
......@@ -22,3 +22,19 @@ pedagogicalscenario_delete:
path: /{id}/delete
defaults: { _controller: "ScenarioBundle:PedagogicalScenario:delete" }
methods: DELETE
pedagogicalscenario_formation_management:
path: /{id}/formation/
defaults: { _controller: "ScenarioBundle:PedagogicalScenario:formationManagement" }
methods: GET
# On renvoie vers le controller de Formation pour économiser deux méthodes
pedagogicalscenario_formation_delete:
path: /{id}/pedagogical-scenario/{formation}/delete
defaults: { _controller: "ScenarioBundle:Formation:deletePedagogicalScenario" }
methods: GET
pedagogicalscenario_formation_add:
path: /{id}/pedagogical-scenario/{formation}/add
defaults: { _controller: "ScenarioBundle:Formation:addPedagogicalScenario" }
methods: GET
......@@ -26,7 +26,7 @@
<a href="{{ path('formation_edit', { 'id': formation.id, 'userRole': currentRole }) }}">{{ 'edit'|trans }}</a>
</li>
<li>
<a href="{{ path('formation_pedagogical_scenario_management', { 'id': formation.id, 'userRole': currentRole } ) }}">AJOUTER UN SCENARIO PEDAGOGIQUE</a>
<a href="{{ path('formation_pedagogical_scenario_management', { 'id': formation.id, 'userRole': currentRole } ) }}">GERER LES SCENARIO PEDAGOGIQUE</a>
</li>
{% endif %}
</ul>
......
{% extends 'base.html.twig' %}
{% block body %}
<h1>Gestion des formations d'un scénario pédagogique</h1>
Scénario Pédagogique courant : {{ pedagogicalScenario.shortname }}
<hr/>
{% if formationsAlreadyLinked is not empty %}
<p> Liste des formations déjà liés </p>
<table class="table">
<thead>
<tr>
<th>{{ 'shortname'|trans }}</th>
<th>{{ 'fullname'|trans }}</th>
<th>{{ 'actions'|trans }}</th>
</tr>
</thead>
<tbody>
{% for formation in formationsAlreadyLinked %}
<tr>
<td>{{ formation.shortname }}</td>
<td>{{ formation.fullname }}</td>
<td><a href="{{ path('pedagogicalscenario_formation_delete', {'userRole': currentRole, 'id' : pedagogicalScenario.id, 'formation' : formation.id}) }}">{{ 'Delete'|trans}}</a></td>
<td></td>
</tr>
{% endfor %}
</tbody>
</table>
{% else %}
<p> Le scénario pédagogique courant ne possède aucun formation </p>
{% endif %}
{% if formationsAvailable is not empty %}
<p> Liste des formations disponibles </p>
<table class="table">
<thead>
<tr>
<th>{{ 'shortname'|trans }}</th>
<th>{{ 'fullname'|trans }}</th>
<th>{{ 'actions'|trans }}</th>
</tr>
</thead>
<tbody>
{% for formation in formationsAvailable %}
<tr>
<td>{{ formation.shortname }}</td>
<td>{{ formation.fullname }}</td>
<td><a href="{{ path('pedagogicalscenario_formation_add', {'userRole': currentRole, 'id' : pedagogicalScenario.id, 'formation' : formation.id}) }}">{{ 'Add'|trans}}</a></td>
</tr>
{% endfor %}
</tbody>
</table>
{% else %}
<p> Aucune formation de disponible </p>
{% endif %}
{% endblock %}
......@@ -25,6 +25,9 @@
<li>
<a href="{{ path('pedagogicalscenario_edit', { 'userRole': "pedagogical-engineer", 'id': pedagogicalScenario.id }) }}">{{ 'edit'|trans }}</a>
</li>
<li>
<a href="{{ path('pedagogicalscenario_formation_management', { 'id': pedagogicalScenario.id, 'userRole': currentRole } ) }}">LIER A DES FORMATIONS</a>
</li>
{% endif %}
</ul>
</td>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment