Commit ea412a31 authored by Patrick Etcheverry's avatar Patrick Etcheverry

- Gérer les scénarios pédagogiques à partir de PROJET

parent 6a3d770e
......@@ -9,6 +9,8 @@ use Symfony\Component\HttpFoundation\Request;
// To use Security annotations on the top of fuctions
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Security;
use ScenarioBundle\Entity\Project;
/**
* Pedagogical Scenario controller.
*
......@@ -211,4 +213,24 @@ class PedagogicalScenarioController extends Controller
'pedagogicalScenario' => $pedagogicalScenario
));
}
// On change le projet. Appelé depuis le menu des projets, lors du changement de projet d'un scénar
public function changeProjectAction(PedagogicalScenario $pedagogicalScenario, Project $project)
{
$em = $this->getDoctrine()->getManager();
// On défait l'ancien lien entre le projet et le scénario
if ($pedagogicalScenario->getProject() != null)
$pedagogicalScenario->getProject()->removePedagogicalScenario($pedagogicalScenario);
$pedagogicalScenario->setProject($project);
$em->persist($pedagogicalScenario);
$em->flush();
return $this->redirectToRoute('project_pedagogical_scenario_management', array('id' => $project->getId(), 'userRole' => "pedagogical-engineer"));
}
}
......@@ -144,4 +144,43 @@ class ProjectController extends Controller
->getForm()
;
}
public function pedagogicalScenarioManagementAction(Project $project)
{
$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 scénarios pédagogiques qui n'ont pas pour projet le projet courant
$dql_pedagogicalScenariosAvailable = $em->createQuery ('
select ps
FROM ScenarioBundle:PedagogicalScenario ps
WHERE ps.project != :currentProject');
$dql_pedagogicalScenariosAvailable->setParameter('currentProject', $project);
// On récupère la liste des scénarios pédagogiques qui ont pour projet le projet courant
$dql_pedagogicalScenariosAlreadyLinked = $em->createQuery ('
select ps
FROM ScenarioBundle:PedagogicalScenario ps
WHERE ps.project = :currentProject');
$dql_pedagogicalScenariosAlreadyLinked->setParameter('currentProject', $project);
$pedagogicalScenariosAvailable = $dql_pedagogicalScenariosAvailable->getResult();
$pedagogicalScenariosAlreadyLinked = $dql_pedagogicalScenariosAlreadyLinked->getResult();
return $this->render('ScenarioBundle:project:pedagogicalscenariomanagement.html.twig', array(
'pedagogicalScenariosAvailable' => $pedagogicalScenariosAvailable,
'pedagogicalScenariosAlreadyLinked' => $pedagogicalScenariosAlreadyLinked,
'project' => $project
));
}
}
......@@ -27,7 +27,7 @@ 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
......@@ -38,3 +38,8 @@ pedagogicalscenario_formation_add:
path: /{id}/pedagogical-scenario/{formation}/add
defaults: { _controller: "ScenarioBundle:Formation:addPedagogicalScenario" }
methods: GET
pedagogicalscenario_project_change:
path: /{id}/pedagogical-scenario/{project}/project-change
defaults: { _controller: "ScenarioBundle:PedagogicalScenario:changeProject" }
methods: GET
......@@ -22,3 +22,8 @@ project_delete:
path: /{id}/delete
defaults: { _controller: "ScenarioBundle:Project:delete" }
methods: DELETE
project_pedagogical_scenario_management:
path: /{id}/pedagogical-scenario/
defaults: { _controller: "ScenarioBundle:Project:pedagogicalScenarioManagement" }
methods: GET
......@@ -26,6 +26,9 @@
<li>
<a href="{{ path('project_edit', { 'id': project.id, 'userRole': currentRole }) }}">{{ 'edit'|trans }}</a>
</li>
<li>
<a href="{{ path('project_pedagogical_scenario_management', { 'id': project.id, 'userRole': currentRole } ) }}">Associer les scénarios pédagogiques</a>
</li>
{% endif %}
</ul>
</td>
......
{% extends 'base.html.twig' %}
{% block body %}
<h1>Gestion des scénarios pédagoiques d'un projet</h1>
Projet courant : {{ project.shortname }}
<hr/>
<p> Liste des scénarios pédagogiques disponibles </p>
{% if pedagogicalScenariosAvailable is not empty %}
<table class="table">
<thead>
<tr>
<th>{{ 'shortname'|trans }}</th>
<th>{{ 'fullname'|trans }}</th>
<th>{{ 'Current Project'|trans }}</th>
<th>{{ 'actions'|trans }}</th>
</tr>
</thead>
<tbody>
{% for pedagogicalScenario in pedagogicalScenariosAvailable %}
<tr>
<td>{{ pedagogicalScenario.shortname }}</td>
<td>{{ pedagogicalScenario.fullname }}</td>
<td>{{ pedagogicalScenario.project.shortname }}</td>
<td><a href="{{ path('pedagogicalscenario_project_change', {'userRole': currentRole, 'id' : pedagogicalScenario.id, 'project' : project.id}) }} ">Change the project</a></td>
<td></td>
</tr>
{% endfor %}
</tbody>
</table>
{% else %}
<p><i>&nbsp;&nbsp;&nbsp;&nbsp;Aucun scénario pédagogique à lier avec {{project.shortname}} </i></p>
{% endif %}
<br/>
<p> Liste des scénarios pédagogiques déjà liés à {{project.shortname}} : </p>
{% if pedagogicalScenariosAlreadyLinked is not empty %}
<table class="table">
<thead>
<tr>
<th>{{ 'shortname'|trans }}</th>
<th>{{ 'fullname'|trans }}</th>
<th>{{ 'Current Project'|trans }}</th>
</tr>
</thead>
<tbody>
{% for pedagogicalScenario in pedagogicalScenariosAlreadyLinked %}
<tr>
<td>{{ pedagogicalScenario.shortname }}</td>
<td>{{ pedagogicalScenario.fullname }}</td>
<td>{{ pedagogicalScenario.project.shortname }}</td>
</tr>
{% endfor %}
</tbody>
</table>
{% else %}
<p><i>&nbsp;&nbsp;&nbsp;&nbsp;Aucun scénario pédagogique. </i></p>
{% endif %}
{% endblock %}
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