From 4f91917833b993f385076a8d5741f16aff64c988 Mon Sep 17 00:00:00 2001 From: Wilmer Ramones Date: Fri, 29 Jul 2016 15:23:49 -0400 Subject: [PATCH] lograda la inscripcion a groso modo... falta mejorarla, depurarla y validarla --- app/Resources/views/base_app.html.twig | 3 +- .../views/planificacioncalificacion/edit.html.twig | 21 +++ .../planificacioncalificacion/index.html.twig | 37 +++++ .../views/planificacioncalificacion/new.html.twig | 27 ++++ .../views/planificacioncalificacion/show.html.twig | 28 ++++ .../views/planificacionseccion/index.html.twig | 5 + .../views/planificacionseccion/show.html.twig | 28 ++-- src/AppBundle/Controller/InscripcionController.php | 7 +- .../PlanificacionCalificacionController.php | 166 +++++++++++++++++++++ .../Controller/PlanificacionSeccionController.php | 11 +- src/AppBundle/Entity/Calificacion.php | 7 + src/AppBundle/Entity/EstadoAcademico.php | 10 ++ src/AppBundle/Entity/EstatusNota.php | 7 + src/AppBundle/Entity/Inscripcion.php | 8 + src/AppBundle/Entity/PlanificacionSeccion.php | 4 + .../Form/PlanificacionCalificacionType.php | 34 +++++ .../PlanificacionCalificacionControllerTest.php | 55 +++++++ 17 files changed, 434 insertions(+), 24 deletions(-) create mode 100644 app/Resources/views/planificacioncalificacion/edit.html.twig create mode 100644 app/Resources/views/planificacioncalificacion/index.html.twig create mode 100644 app/Resources/views/planificacioncalificacion/new.html.twig create mode 100644 app/Resources/views/planificacioncalificacion/show.html.twig create mode 100644 src/AppBundle/Controller/PlanificacionCalificacionController.php create mode 100644 src/AppBundle/Form/PlanificacionCalificacionType.php create mode 100644 src/AppBundle/Tests/Controller/PlanificacionCalificacionControllerTest.php diff --git a/app/Resources/views/base_app.html.twig b/app/Resources/views/base_app.html.twig index d20410a..d559e42 100644 --- a/app/Resources/views/base_app.html.twig +++ b/app/Resources/views/base_app.html.twig @@ -74,8 +74,7 @@ Serv. docentes {% endif %} diff --git a/app/Resources/views/planificacioncalificacion/edit.html.twig b/app/Resources/views/planificacioncalificacion/edit.html.twig new file mode 100644 index 0000000..1d2d833 --- /dev/null +++ b/app/Resources/views/planificacioncalificacion/edit.html.twig @@ -0,0 +1,21 @@ +{% extends 'base.html.twig' %} + +{% block body %} +

PlanificacionCalificacion edit

+ + {{ form_start(edit_form) }} + {{ form_widget(edit_form) }} + + {{ form_end(edit_form) }} + + +{% endblock %} diff --git a/app/Resources/views/planificacioncalificacion/index.html.twig b/app/Resources/views/planificacioncalificacion/index.html.twig new file mode 100644 index 0000000..38d4775 --- /dev/null +++ b/app/Resources/views/planificacioncalificacion/index.html.twig @@ -0,0 +1,37 @@ +{% extends 'base.html.twig' %} + +{% block body %} +

PlanificacionCalificacion list

+ + + + + + + + + + {% for planificacionCalificacion in planificacionCalificacions %} + + + + + {% endfor %} + +
IdActions
{{ planificacionCalificacion.id }} + +
+ + +{% endblock %} diff --git a/app/Resources/views/planificacioncalificacion/new.html.twig b/app/Resources/views/planificacioncalificacion/new.html.twig new file mode 100644 index 0000000..b9d3c83 --- /dev/null +++ b/app/Resources/views/planificacioncalificacion/new.html.twig @@ -0,0 +1,27 @@ +{% extends 'base_app.html.twig' %} + +{% block body %} +

Registro Calificacion Planificacion

+

{{planificacion.idtemaUc}}

+ +
+
+
    + {% for o in planificacion.seccion.hasInscripcion %} + +
  • + {{o}} + + + +
  • + {% endfor %}
    +
+
+ + +
+ +{% endblock %} + + diff --git a/app/Resources/views/planificacioncalificacion/show.html.twig b/app/Resources/views/planificacioncalificacion/show.html.twig new file mode 100644 index 0000000..a442eb9 --- /dev/null +++ b/app/Resources/views/planificacioncalificacion/show.html.twig @@ -0,0 +1,28 @@ +{% extends 'base.html.twig' %} + +{% block body %} +

PlanificacionCalificacion

+ + + + + + + + +
Id{{ planificacionCalificacion.id }}
+ + +{% endblock %} diff --git a/app/Resources/views/planificacionseccion/index.html.twig b/app/Resources/views/planificacionseccion/index.html.twig index 6922323..05c7b18 100644 --- a/app/Resources/views/planificacionseccion/index.html.twig +++ b/app/Resources/views/planificacionseccion/index.html.twig @@ -35,6 +35,11 @@
  • edit
  • + {% if porcentaje == 100 %} +
  • + Calificar +
  • + {% endif %} diff --git a/app/Resources/views/planificacionseccion/show.html.twig b/app/Resources/views/planificacionseccion/show.html.twig index ab2f19b..35db98f 100644 --- a/app/Resources/views/planificacionseccion/show.html.twig +++ b/app/Resources/views/planificacionseccion/show.html.twig @@ -2,39 +2,43 @@ {% block body %}

    PlanificacionSeccion

    - + {% for planificacion in planificacionSeccion %} - + - + - + - +
    Fecha_creacion{% if planificacionSeccion.fechacreacion %}{{ planificacionSeccion.fechacreacion|date('Y-m-d H:i:s') }}{% endif %}{% if planificacion.fechacreacion %}{{ planificacion.fechacreacion|date('Y-m-d H:i:s') }}{% endif %}
    Fecha_ultima_actualizacion{% if planificacionSeccion.fechaultimaactualizacion %}{{ planificacionSeccion.fechaultimaactualizacion|date('Y-m-d H:i:s') }}{% endif %}{% if planificacion.fechaultimaactualizacion %}{{ planificacion.fechaultimaactualizacion|date('Y-m-d H:i:s') }}{% endif %}
    Observacion{{ planificacionSeccion.observacion }}{{ planificacion.observacion }}
    Id{{ planificacionSeccion.id }}{{ planificacion.id }}
    - + + + {% endfor %} + + {% endblock %} diff --git a/src/AppBundle/Controller/InscripcionController.php b/src/AppBundle/Controller/InscripcionController.php index 29d0ca0..5caa15d 100644 --- a/src/AppBundle/Controller/InscripcionController.php +++ b/src/AppBundle/Controller/InscripcionController.php @@ -50,9 +50,7 @@ class InscripcionController extends Controller $seccion = $this->getDoctrine()->getRepository('AppBundle:Seccion')->findAll(); - - $form = $this->createForm('AppBundle\Form\InscripcionType', $ea, array('inscripcion' => $ea,)); - $form->handleRequest($request); + if ($request->isMethod("POST")) { //var_dump($request->request->get('seccion')['idSeccion']); exit; @@ -73,8 +71,7 @@ class InscripcionController extends Controller return $this->render('inscripcion/new.html.twig', array( 'estado_academico' => $ea, 'oferta' => $oferta, - 'seccion' => $seccion, - 'form' => $form->createView() + 'seccion' => $seccion, )); } diff --git a/src/AppBundle/Controller/PlanificacionCalificacionController.php b/src/AppBundle/Controller/PlanificacionCalificacionController.php new file mode 100644 index 0000000..fd5fb1a --- /dev/null +++ b/src/AppBundle/Controller/PlanificacionCalificacionController.php @@ -0,0 +1,166 @@ +getDoctrine()->getManager(); + + $planificacionCalificacions = $em->getRepository('AppBundle:PlanificacionCalificacion')->findAll(); + + return $this->render('planificacioncalificacion/index.html.twig', array( + 'planificacionCalificacions' => $planificacionCalificacions, + )); + } + + /** + * Creates a new PlanificacionCalificacion entity. + * + * @Route("/new/{planificacion}", name="ceapp_docente_calificar_new") + * @Method({"GET", "POST"}) + */ + public function newAction(Request $request, PlanificacionSeccion $planificacion) + { + $planificacionCalificacion = new PlanificacionCalificacion(); + + if ($request->isMethod("POST")) { + $em = $this->getDoctrine()->getManager(); + //var_dump($request->request->get('planificacion_calificacion')); exit; + foreach ($request->request->get('planificacion_calificacion')['idInscripcion'] as $key => $value ){ + + + $insertar = explode("_", $key); + + if($insertar[0] == 'inscripcion'){ + $planificacionCalificacion = new PlanificacionCalificacion(); + $idInscripcion = $em->getRepository('AppBundle:Inscripcion')->findOneById($value); + $planificacionCalificacion->setIdInscripcion($idInscripcion); + }else if ($insertar[0] == 'calificacion'){ + $cal = $value; + }else if ($insertar[0] == 'porcentaje'){ + $idCalificacion = $em->getRepository('AppBundle:Calificacion')->findOneBy(array( + 'idNota' => $cal, + 'idPorcentaje' => $value + )); + $planificacionCalificacion->setIdCalificacion($idCalificacion); + $planificacionCalificacion->setIdEstatusNota($em->getRepository('AppBundle:EstatusNota')->findOneById(1)); + $planificacionCalificacion->setIdPlanificacionSeccion($planificacion); + $em->persist($planificacionCalificacion); + $em->flush(); + } + + + } + + + + + return $this->redirectToRoute('ceapp_docente_calificar_show', array('id' => $planificacionCalificacion->getId())); + } + + return $this->render('planificacioncalificacion/new.html.twig', array( + 'planificacion' => $planificacion, + )); + } + + /** + * Finds and displays a PlanificacionCalificacion entity. + * + * @Route("/{id}", name="ceapp_docente_calificar_show") + * @Method("GET") + */ + public function showAction(PlanificacionCalificacion $planificacionCalificacion) + { + $deleteForm = $this->createDeleteForm($planificacionCalificacion); + + return $this->render('planificacioncalificacion/show.html.twig', array( + 'planificacionCalificacion' => $planificacionCalificacion, + 'delete_form' => $deleteForm->createView(), + )); + } + + /** + * Displays a form to edit an existing PlanificacionCalificacion entity. + * + * @Route("/{id}/edit", name="ceapp_docente_calificar_edit") + * @Method({"GET", "POST"}) + */ + public function editAction(Request $request, PlanificacionCalificacion $planificacionCalificacion) + { + $deleteForm = $this->createDeleteForm($planificacionCalificacion); + $editForm = $this->createForm('AppBundle\Form\PlanificacionCalificacionType', $planificacionCalificacion); + $editForm->handleRequest($request); + + if ($editForm->isSubmitted() && $editForm->isValid()) { + $em = $this->getDoctrine()->getManager(); + $em->persist($planificacionCalificacion); + $em->flush(); + + return $this->redirectToRoute('ceapp_docente_calificar_edit', array('id' => $planificacionCalificacion->getId())); + } + + return $this->render('planificacioncalificacion/edit.html.twig', array( + 'planificacionCalificacion' => $planificacionCalificacion, + 'edit_form' => $editForm->createView(), + 'delete_form' => $deleteForm->createView(), + )); + } + + /** + * Deletes a PlanificacionCalificacion entity. + * + * @Route("/{id}", name="ceapp_docente_calificar_delete") + * @Method("DELETE") + */ + public function deleteAction(Request $request, PlanificacionCalificacion $planificacionCalificacion) + { + $form = $this->createDeleteForm($planificacionCalificacion); + $form->handleRequest($request); + + if ($form->isSubmitted() && $form->isValid()) { + $em = $this->getDoctrine()->getManager(); + $em->remove($planificacionCalificacion); + $em->flush(); + } + + return $this->redirectToRoute('ceapp_docente_calificar_index'); + } + + /** + * Creates a form to delete a PlanificacionCalificacion entity. + * + * @param PlanificacionCalificacion $planificacionCalificacion The PlanificacionCalificacion entity + * + * @return \Symfony\Component\Form\Form The form + */ + private function createDeleteForm(PlanificacionCalificacion $planificacionCalificacion) + { + return $this->createFormBuilder() + ->setAction($this->generateUrl('ceapp_docente_calificar_delete', array('id' => $planificacionCalificacion->getId()))) + ->setMethod('DELETE') + ->getForm() + ; + } +} diff --git a/src/AppBundle/Controller/PlanificacionSeccionController.php b/src/AppBundle/Controller/PlanificacionSeccionController.php index 2df0a1a..e1e10c4 100644 --- a/src/AppBundle/Controller/PlanificacionSeccionController.php +++ b/src/AppBundle/Controller/PlanificacionSeccionController.php @@ -94,16 +94,17 @@ class PlanificacionSeccionController extends Controller /** * Finds and displays a PlanificacionSeccion entity. * - * @Route("/{id}", name="ceapp_docente_planificacion_show") + * @Route("/{id}/{porcentaje}", name="ceapp_docente_planificacion_show") * @Method("GET") */ - public function showAction(PlanificacionSeccion $planificacionSeccion) + public function showAction(Seccion $seccion, $porcentaje = null) { - $deleteForm = $this->createDeleteForm($planificacionSeccion); - + $planificacionSeccion = $this->getDoctrine()->getRepository('AppBundle:PlanificacionSeccion')->findBySeccion($seccion); + //$deleteForm = $this->createDeleteForm($planificacionSeccion); + return $this->render('planificacionseccion/show.html.twig', array( 'planificacionSeccion' => $planificacionSeccion, - 'delete_form' => $deleteForm->createView(), + 'porcentaje' => $porcentaje )); } diff --git a/src/AppBundle/Entity/Calificacion.php b/src/AppBundle/Entity/Calificacion.php index 25a37ff..6fde9b2 100644 --- a/src/AppBundle/Entity/Calificacion.php +++ b/src/AppBundle/Entity/Calificacion.php @@ -135,4 +135,11 @@ class Calificacion { return $this->idCondicionCalificacion; } + + /** + * @return string + */ + public function __toString() { + return $this->getIdNota()->getIdNomenclaturaNota()->getNombre(); + } } \ No newline at end of file diff --git a/src/AppBundle/Entity/EstadoAcademico.php b/src/AppBundle/Entity/EstadoAcademico.php index ab35aab..659199b 100644 --- a/src/AppBundle/Entity/EstadoAcademico.php +++ b/src/AppBundle/Entity/EstadoAcademico.php @@ -313,4 +313,14 @@ class EstadoAcademico } + + /** + * @return string + * + */ + public function __toString() { + return $this->getIdRolInstitucion()->getIdRol()->getIdPersona()->getPrimerNombre(); + } + + } diff --git a/src/AppBundle/Entity/EstatusNota.php b/src/AppBundle/Entity/EstatusNota.php index 0fb7545..64d2248 100644 --- a/src/AppBundle/Entity/EstatusNota.php +++ b/src/AppBundle/Entity/EstatusNota.php @@ -63,4 +63,11 @@ class EstatusNota { return $this->id; } + + /** + * @return string + */ + public function __toString() { + return $this->getNombre(); + } } \ No newline at end of file diff --git a/src/AppBundle/Entity/Inscripcion.php b/src/AppBundle/Entity/Inscripcion.php index 5cee4d4..629bd1e 100644 --- a/src/AppBundle/Entity/Inscripcion.php +++ b/src/AppBundle/Entity/Inscripcion.php @@ -214,4 +214,12 @@ class Inscripcion { return $this->modified; } + + /** + * @return string + * + */ + public function __toString() { + return $this->getIdEstadoAcademico()->getIdRolInstitucion()->getIdRol()->getIdPersona()->getPrimerNombre(); + } } diff --git a/src/AppBundle/Entity/PlanificacionSeccion.php b/src/AppBundle/Entity/PlanificacionSeccion.php index ded7c7f..b6aca0e 100644 --- a/src/AppBundle/Entity/PlanificacionSeccion.php +++ b/src/AppBundle/Entity/PlanificacionSeccion.php @@ -393,4 +393,8 @@ class PlanificacionSeccion { return $this->objetivoEspecifico; } + + public function __toString() { + return $this->getSeccion()->getNombre(); + } } diff --git a/src/AppBundle/Form/PlanificacionCalificacionType.php b/src/AppBundle/Form/PlanificacionCalificacionType.php new file mode 100644 index 0000000..0e335cf --- /dev/null +++ b/src/AppBundle/Form/PlanificacionCalificacionType.php @@ -0,0 +1,34 @@ +add('idPlanificacionSeccion') + ->add('idInscripcion') + ->add('idCalificacion') + ->add('idEstatusNota') + ; + } + + /** + * @param OptionsResolver $resolver + */ + public function configureOptions(OptionsResolver $resolver) + { + $resolver->setDefaults(array( + 'data_class' => 'AppBundle\Entity\PlanificacionCalificacion' + )); + } +} diff --git a/src/AppBundle/Tests/Controller/PlanificacionCalificacionControllerTest.php b/src/AppBundle/Tests/Controller/PlanificacionCalificacionControllerTest.php new file mode 100644 index 0000000..422139b --- /dev/null +++ b/src/AppBundle/Tests/Controller/PlanificacionCalificacionControllerTest.php @@ -0,0 +1,55 @@ +request('GET', '/ceapp/docente/calificar/'); + $this->assertEquals(200, $client->getResponse()->getStatusCode(), "Unexpected HTTP status code for GET /ceapp/docente/calificar/"); + $crawler = $client->click($crawler->selectLink('Create a new entry')->link()); + + // Fill in the form and submit it + $form = $crawler->selectButton('Create')->form(array( + 'appbundle_planificacioncalificacion[field_name]' => 'Test', + // ... other fields to fill + )); + + $client->submit($form); + $crawler = $client->followRedirect(); + + // Check data in the show view + $this->assertGreaterThan(0, $crawler->filter('td:contains("Test")')->count(), 'Missing element td:contains("Test")'); + + // Edit the entity + $crawler = $client->click($crawler->selectLink('Edit')->link()); + + $form = $crawler->selectButton('Update')->form(array( + 'appbundle_planificacioncalificacion[field_name]' => 'Foo', + // ... other fields to fill + )); + + $client->submit($form); + $crawler = $client->followRedirect(); + + // Check the element contains an attribute with value equals "Foo" + $this->assertGreaterThan(0, $crawler->filter('[value="Foo"]')->count(), 'Missing element [value="Foo"]'); + + // Delete the entity + $client->submit($crawler->selectButton('Delete')->form()); + $crawler = $client->followRedirect(); + + // Check the entity has been delete on the list + $this->assertNotRegExp('/Foo/', $client->getResponse()->getContent()); + } + + */ +} -- 2.0.0