Commit fb347011 authored by Patrick Etcheverry's avatar Patrick Etcheverry

Lier des enseignants à un scénario pédagogique

parent c49da081
......@@ -10,6 +10,7 @@ enWording: "English wording"
esWording: "Spanish wording"
frWording: "French wording"
(none): "(None)"
goals: "Goals"
title: "Title"
description: "Description"
......
......@@ -10,6 +10,7 @@ enWording: ""
esWording: ""
frWording: ""
(none): ""
goals: ""
title: ""
description: ""
......
......@@ -10,6 +10,7 @@ enWording: "Libellé anglais"
esWording: "Libellé espagnol"
frWording: "Libellé français"
(none): "(Aucun)"
goals: "Objectifs"
title: "Intitulé"
description: "Description"
......
......@@ -13,7 +13,7 @@ use Sensio\Bundle\FrameworkExtraBundle\Configuration\Security;
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
use ScenarioBundle\Entity\Project;
use UserBundle\Entity\User;
/**
* Pedagogical Scenario controller.
......@@ -29,9 +29,18 @@ class PedagogicalScenarioController extends Controller
{
$em = $this->getDoctrine()->getManager();
//$pedagogicalScenarios = $em->getRepository('ScenarioBundle:PedagogicalScenario')->findAll();
$queryBuilder = $em->getRepository('ScenarioBundle:PedagogicalScenario')->createQueryBuilder('pedagogicalScenarios');
$query = $queryBuilder->getQuery();
// Si l'utilisateur est un ingénieur pédagogique, on affiche tous les scénarios pédagogiques
if ($this->get('security.authorization_checker')->isGranted('ROLE_PEDAGOGICAL_ENGINEER'))
{
$queryBuilder = $em->getRepository('ScenarioBundle:PedagogicalScenario')->createQueryBuilder('pedagogicalScenarios');
$query = $queryBuilder->getQuery();
}
//Sinon, on affiche seulement ceux dans lesquels l'enseignant intervient
else
{
// On veut récupérer les scénarios pédagogiques de l'utilisateur courant
$query = $this->get('security.context')->getToken()->getUser()->getPedagogicalScenarioDesigned();
}
$paginator = $this->get('knp_paginator');
......@@ -109,6 +118,7 @@ class PedagogicalScenarioController extends Controller
if ($editForm->isSubmitted() && $editForm->isValid())
{
$this->getDoctrine()->getManager()->flush();
return $this->redirectToRoute('pedagogicalscenario_edit', array('id' => $pedagogicalScenario->getId(), 'userRole' => 'pedagogical-engineer'));
......@@ -233,4 +243,39 @@ class PedagogicalScenarioController extends Controller
}
public function defineTeachersAction(PedagogicalScenario $pedagogicalScenario)
{
$em = $this->getDoctrine()->getManager();
$repo = $em->getRepository('UserBundle:User');
$teachersDesigning = $repo->getTeachersDesigningPedagogicalScenario($pedagogicalScenario);
$teachersNotDesigning = $repo->getTeachersNotDesigningPedagogicalScenario($pedagogicalScenario);
return $this->render('ScenarioBundle:pedagogicalscenario:defineteachers.html.twig', array(
'teachersDesigning' => $teachersDesigning,
'teachersNotDesigning' => $teachersNotDesigning,
'pedagogicalScenario' => $pedagogicalScenario
) );
}
public function addTeacherAction(PedagogicalScenario $pedagogicalScenario,User $teacher)
{
$em = $this->getDoctrine()->getManager();
$teacher->addPedagogicalScenarioDesigned($pedagogicalScenario);
$em->persist($teacher);
$em->flush();
return $this->redirectToRoute('pedagogicalscenario_define_teachers', array('id' => $pedagogicalScenario->getId(), 'userRole' => "pedagogical-engineer"));
}
public function removeTeacherAction(PedagogicalScenario $pedagogicalScenario,User $teacher)
{
$em = $this->getDoctrine()->getManager();
$teacher->removePedagogicalScenarioDesigned($pedagogicalScenario);
$em->persist($teacher);
$em->flush();
return $this->redirectToRoute('pedagogicalscenario_define_teachers', array('id' => $pedagogicalScenario->getId(), 'userRole' => "pedagogical-engineer"));
}
}
......@@ -37,11 +37,23 @@ class LoadPedagogicalScenarioData implements FixtureInterface, ContainerAwareInt
$repoUtilisateur = $em->getRepository('UserBundle:User');
$gaizka = $repoUtilisateur->findOneBy(array('firstname'=>'Gaizka'));
$patrick = $repoUtilisateur->findOneBy(array('firstname'=>'Patrick'));
$claire = $repoUtilisateur->findOneBy(array('firstname'=>'Claire'));
$pantxika = $repoUtilisateur->findOneBy(array('firstname'=>'Pantxika'));
$demarche = "Démarche de Marta";
/* On ajoute deux scenario pedagogique*/
$this->ajouterM1102($manager,$em,$patrick,$dutInfo,$demarche);
$this->ajouterM1103($manager,$em,$patrick,$dutInfo,$demarche);
$m1102 = $this->ajouterM1102($manager,$em,$patrick,$dutInfo,$demarche);
$m1103 = $this->ajouterM1103($manager,$em,$patrick,$dutInfo,$demarche);
$gaizka->addPedagogicalScenarioDesigned($m1102);
$pantxika->addPedagogicalScenarioDesigned($m1102);
$claire->addPedagogicalScenarioDesigned($m1102);
$claire->addPedagogicalScenarioDesigned($m1103);
$manager->flush();
}
public function ajouterM1102(ObjectManager $manager,$em,$enseignantReferent,$projet,$demarche)
......@@ -60,6 +72,8 @@ class LoadPedagogicalScenarioData implements FixtureInterface, ContainerAwareInt
$manager->persist($m1102);
$manager->flush();
return $m1102;
}
public function ajouterM1103(ObjectManager $manager,$em,$enseignantReferent,$projet,$demarche)
......@@ -78,6 +92,8 @@ class LoadPedagogicalScenarioData implements FixtureInterface, ContainerAwareInt
$manager->persist($m1103);
$manager->flush();
return $m1103;
}
public function getOrder()
......
......@@ -23,7 +23,8 @@ class PedagogicalScenarioTypeEdit extends AbstractType
'multiple' => false,
'expanded' => false,
'required' => false,
'empty_data' => null
'placeholder' => '(none)',
'empty_value' => null
));
$builder->add('shortname','text', array( 'label' => 'shortname'));
......@@ -41,11 +42,18 @@ class PedagogicalScenarioTypeEdit extends AbstractType
}
//'multiple' => true
));
// 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.
// Une fois que la démarche de scénarisation d'un scénario pédagogique a été définie, on ne peut plus la modifier.
$builder->add('scenarisationProcess', 'text', array(
/* On veut simplement afficher le nom de la démarche sous forme textuelle non pas
ss forme d'entité modifiable. L'option 'mapped' signale à Doctrine de ne pas
enregistrer ce champ qui est ici un texte et non pas une entité démarche enregistrable */
'mapped' => false,
'label' => 'scenarisationProcess',
'read_only' => 'true',
//'multiple' => true
'read_only' => true,
/* $option['data'] contient le scénario pédagogique courant sous forme object
il est envoyé par le controller par la méthode "createForm" */
'data' => $options['data']->getScenarisationProcess()->__toString()
));
......
......@@ -10,4 +10,5 @@ namespace ScenarioBundle\Repository;
*/
class PedagogicalScenarioRepository extends \Doctrine\ORM\EntityRepository
{
}
......@@ -43,3 +43,20 @@ pedagogicalscenario_project_change:
path: /{id}/pedagogical-scenario/{project}/project-change
defaults: { _controller: "ScenarioBundle:PedagogicalScenario:changeProject" }
methods: GET
pedagogicalscenario_define_teachers:
path: /{id}/define-teachers
defaults: { _controller: "ScenarioBundle:PedagogicalScenario:defineTeachers" }
methods: GET
# Ajoute un enseignant à la conception d'un cours
pedagogicalscenario_add_teacher:
path: /{id}/add-teacher/{teacher}
defaults: { _controller: "ScenarioBundle:PedagogicalScenario:addTeacher" }
methods: GET
# Retire un enseignant à la conception d'un cours
pedagogicalscenario_remove_teacher:
path: /{id}/remove-teacher/{teacher}
defaults: { _controller: "ScenarioBundle:PedagogicalScenario:removeTeacher" }
methods: GET
{% extends 'base.html.twig' %}
{# On a besoin de stocker le numéro de la page courante pour pouvoir revenir dessus après ajout dans une démarche #}
{% set currentPage = app.request.query.get('page') %}
{% block body %}
<h1>{{'pedagogicalScenario.teachersManagement'|trans}}</h1>
<h2>{{ pedagogicalScenario.shortname }} - Enseignant référent : {{ pedagogicalScenario.referentTeacher.firstname }} {{ pedagogicalScenario.referentTeacher.lastname }} </h2>
<hr/>
{# Si le cours est designé par des enseignants #}
{% if teachersDesigning is not empty %}
{# On parcourt la liste des utilisateurs #}
<table class="table table-striped">
<thead>
<tr>
<th>{{'user'|trans}}</th>
<th>{{'action'|trans}}</th>
</tr>
</thead>
<tbody>
{# On affiche chacune des utilisateurs #}
{% for teacher in teachersDesigning %}
<tr>
<td>{{ teacher.lastname }} {{ teacher.firstname }}</td>
<td><a href="{{ path('pedagogicalscenario_remove_teacher', {'userRole': currentRole, 'id' : pedagogicalScenario.id, 'teacher' : teacher.id}) }}">RETIRER</a></td>
</tr>
{% endfor %}
</tbody>
</table>
{% else %}
<p> Aucun enseignant inscrit dans la conception de ce scénario pédagogique</p>
{% endif %}
{% if teachersNotDesigning is not empty %}
<table class="table table-striped">
<thead>
<tr>
<th>{{'user'|trans}}</th>
<th>{{'action'|trans}}</th>
</tr>
</thead>
<tbody>
{# On affiche chacune des utilisateurs #}
{% for teacher in teachersNotDesigning %}
<tr>
<td>{{ teacher.lastname }} {{ teacher.firstname }}</td>
<td><a href="{{ path('pedagogicalscenario_add_teacher', {'userRole': currentRole, 'id' : pedagogicalScenario.id, 'teacher' : teacher.id}) }}">AJOUTER</a></td>
</tr>
{% endfor %}
</tbody>
</table>
{% else %}
<p> Aucun enseignant disponible </p>
{% endif %}
<ul>
<li>
<a href="">{{'backToList'|trans}}</a>
</li>
</ul>
{% endblock %}
......@@ -28,6 +28,9 @@
<li>
<a href="{{ path('pedagogicalscenario_formation_management', { 'id': pedagogicalScenario.id, 'userRole': currentRole } ) }}">LIER A DES FORMATIONS</a>
</li>
<li>
<a href="{{ path('pedagogicalscenario_define_teachers', { 'id': pedagogicalScenario.id, 'userRole': currentRole } ) }}">DEFINIR LES ENSEIGNANTS</a>
</li>
{% endif %}
</ul>
</td>
......
......@@ -33,6 +33,7 @@ class LoadUserData implements FixtureInterface, ContainerAwareInterface, Ordered
$this->creerUtilisateur("Etcheverry","Patrick","es","azerty","patrick.Etcheverry@iutbayonne.univ-pau.fr","ROLE_TEACHER",$manager);
$this->creerUtilisateur("Dagorret","Pantxika","en","azerty","pantxika.dagorret@iutbayonne.univ-pau.fr","ROLE_PEDAGOGICAL_ENGINEER",$manager);
$this->creerUtilisateur("Toribio","Marta","es","azerty","marta@yahoo.fr","ROLE_PEDAGOGICAL_ENGINEER",$manager);
$this->creerUtilisateur("Teacher","Teacher","fr","teacher","teacher@yahoo.fr","ROLE_TEACHER",$manager);
$this->creerUtilisateurFictif("Charier","Claire",$manager);
$this->creerUtilisateurFictif("Etchemaite","Mailys",$manager);
......@@ -45,7 +46,6 @@ class LoadUserData implements FixtureInterface, ContainerAwareInterface, Ordered
public function creerUtilisateur($lastname, $firstname, $platformLanguage, $plainPassword, $email, $role, ObjectManager $manager)
{
$user = new User();
$user->setLastname($lastname);
......
......@@ -76,6 +76,7 @@ class User implements UserInterface
/**
* @ORM\ManyToMany(targetEntity="ScenarioBundle\Entity\PedagogicalScenario", cascade={"persist"})
* @ORM\JoinColumn(nullable=true)
*/
private $pedagogicalScenarioDesigned;
......@@ -324,7 +325,7 @@ class User implements UserInterface
*/
public function removePedagogicalScenarioDesigned(\ScenarioBundle\Entity\PedagogicalScenario $pedagogicalScenarioDedigned)
{
$this->$pedagogicalScenarioDesigned->removeElement($pedagogicalScenarioDedigned);
$this->pedagogicalScenarioDesigned->removeElement($pedagogicalScenarioDedigned);
}
/**
......@@ -365,7 +366,7 @@ class User implements UserInterface
*
* @return \Doctrine\Common\Collections\Collection
*/
public function getPedagogicalScenarioPiloteds()
public function getPedagogicalScenarioPiloted()
{
return $this->pedagogicalScenarioPiloted;
}
......
......@@ -10,4 +10,61 @@ namespace UserBundle\Repository;
*/
class UserRepository extends \Doctrine\ORM\EntityRepository
{
// Me retourne ce que je veux, c'est à dire pour un scénario pédagogique donné,
// Les utilisateurs qui design ce cours
public function getTeachersDesigningPedagogicalScenario(\ScenarioBundle\Entity\PedagogicalScenario $pedagogicalScenario)
{
$gestionnaireEntite = $this->_em;
$qb = $gestionnaireEntite->createQuery('
SELECT u
FROM UserBundle:User u
JOIN u.pedagogicalScenarioDesigned p
WHERE p = :peda AND u.roles LIKE :teacher AND u != :pilote');
/* ->join('document.users', 'u')
->where('u = :user') */
$qb->setParameter('peda',$pedagogicalScenario);
$qb->setParameter('teacher',"%ROLE_TEACHER%");
$qb->setParameter('pilote',$pedagogicalScenario->getReferentTeacher());
return $qb->getResult();
}
public function getTeachersNotDesigningPedagogicalScenario(\ScenarioBundle\Entity\PedagogicalScenario $pedagogicalScenario)
{
$gestionnaireEntite = $this->_em;
$qb = $gestionnaireEntite->createQuery('
SELECT uu
FROM UserBundle:User uu
WHERE uu NOT IN ( SELECT u
FROM UserBundle:User u
LEFT JOIN u.pedagogicalScenarioDesigned p
WHERE p = :peda AND u.roles LIKE :teacher) AND uu.roles LIKE :teacher AND uu != :pilote');
$qb->setParameter('peda',$pedagogicalScenario);
$qb->setParameter('teacher',"%ROLE_TEACHER%");
$qb->setParameter('pilote',$pedagogicalScenario->getReferentTeacher());
return $qb->getResult();
}
}
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