From 1f6a3ce07e171917dd8802ef092432a5c15247bf Mon Sep 17 00:00:00 2001 From: Wilmer Ramones Date: Thu, 28 Jul 2016 15:54:26 -0400 Subject: [PATCH] =?UTF-8?q?Excelente,=20es=20increible=20pero=20cierto....?= =?UTF-8?q?=20acabo=20de=20terminar=20de=20crear=20la=20planificaci=C3=B3n?= =?UTF-8?q?=20docente...=20si=20esto=20est=C3=A1=20listo...=20agarrate=20m?= =?UTF-8?q?undo...=20voy=20con=20todo.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../views/planificacionseccion/new.html.twig | 53 +++++ .../Controller/PlanificacionSeccionController.php | 34 ++-- src/AppBundle/Entity/PlanificacionSeccion.php | 2 +- .../Entity/PlanificacionSeccionEvaluacion.php | 132 ++++++++----- .../Entity/PlanificacionSeccionEvaluacion.php~ | 213 ++++++++++++++++++--- src/AppBundle/Entity/TipoInstrumentoEvaluacion.php | 49 +++++ .../Entity/TipoInstrumentoEvaluacion.php~ | 9 +- .../Form/PlanificacionSeccionEvaluacionType.php | 40 ++++ src/AppBundle/Form/PlanificacionSeccionType.php | 8 + 9 files changed, 436 insertions(+), 104 deletions(-) create mode 100644 src/AppBundle/Form/PlanificacionSeccionEvaluacionType.php diff --git a/app/Resources/views/planificacionseccion/new.html.twig b/app/Resources/views/planificacionseccion/new.html.twig index 971c424..8938716 100644 --- a/app/Resources/views/planificacionseccion/new.html.twig +++ b/app/Resources/views/planificacionseccion/new.html.twig @@ -20,6 +20,10 @@ + + {{ form_end(form) }} @@ -40,11 +44,13 @@ var $addEspecificoLink = $('Añadir Objetivos Especificos'); var $addContenidoLink = $('Añadir conceptos'); var $addEstrategiaLink = $('Añadir estrategias'); + var $addEvaluacionLink = $('Añadir Evaluaciones'); var $RemoveContenidoLink = $('Quitar Conceptos'); var $newLinkLiContenido = $('
  • ').append($addContenidoLink); var $newLinkLiEspecifico = $('
  • ').append($addEspecificoLink); var $newLinkLiEstrategia = $('
  • ').append($addEstrategiaLink); + var $newLinkLiEvaluacion = $('
  • ').append($addEvaluacionLink); jQuery(document).ready(function() { @@ -52,16 +58,19 @@ $contenidoHolder = $('ul.contenido'); $especificoHolder = $('ul.objetivoEspecifico'); $estrategiaHolder = $('ul.estrategia'); + $evaluacionHolder = $('ul.evaluacion'); // add the "add a tag" anchor and li to the tags ul $contenidoHolder.append($newLinkLiContenido); $especificoHolder.append($newLinkLiEspecifico); $estrategiaHolder.append($newLinkLiEstrategia); + $evaluacionHolder.append($newLinkLiEvaluacion); // count the current form inputs we have (e.g. 2), use that as the new // index when inserting a new item (e.g. 2) $contenidoHolder.data('index', $contenidoHolder.find(':input').length); $especificoHolder.data('index', $especificoHolder.find(':input').length); $estrategiaHolder.data('index', $estrategiaHolder.find(':input').length); + $evaluacionHolder.data('index', $evaluacionHolder.find(':input').length); $addContenidoLink.on('click', function(e) { // prevent the link from creating a "#" on the URL @@ -88,6 +97,14 @@ addEstrategiaForm($estrategiaHolder, $newLinkLiEstrategia); }); + $addEvaluacionLink.on('click', function(e) { + // prevent the link from creating a "#" on the URL + e.preventDefault(); + + // add a new tag form (see next code block) + addEvaluacionForm($evaluacionHolder, $newLinkLiEvaluacion); + }); + function addContenidoForm($contenidoHolder, $newLinkLiContenido) { @@ -196,6 +213,42 @@ + function addEvaluacionForm($evaluacionHolder, $newLinkLiEvaluacion) { + // Get the data-prototype explained earlier + var prototype = $evaluacionHolder.data('prototype'); + + // get the new index + var index = $evaluacionHolder.data('index'); + + // Replace '$$name$$' in the prototype's HTML to + // instead be a number based on how many items we have + var newFormEvaluacion = prototype.replace(/__name__/g, index); + + // increase the index with one for the next item + $evaluacionHolder.data('index', index + 1); + + // Display the form in the page in an li, before the "Add a tag" link li + var $newFormLiEvaluacion = $('
  • ').append(newFormEvaluacion); + + // also add a remove button, just for this example + $newFormLiEvaluacion.append('x'); + + $newLinkLiEvaluacion.before($newFormLiEvaluacion); + + // handle the removal, just for this example + $('.remove-tag').click(function(e) { + e.preventDefault(); + + $(this).parent().remove(); + + return false; + }); + + + } + + + }); diff --git a/src/AppBundle/Controller/PlanificacionSeccionController.php b/src/AppBundle/Controller/PlanificacionSeccionController.php index 7b0e277..2df0a1a 100644 --- a/src/AppBundle/Controller/PlanificacionSeccionController.php +++ b/src/AppBundle/Controller/PlanificacionSeccionController.php @@ -56,38 +56,26 @@ class PlanificacionSeccionController extends Controller if ($form->isSubmitted() && $form->isValid()) { - //var_dump($p->getId()); exit; - // ciclo a traves de las relaciones para cada contenido + $seccion->addPlanificacion($planificacionSeccion); + + // ciclo a traves de las relaciones para cada contenido añadirle la planificacion foreach($planificacionSeccion->getContenido() as $contenido){ - $contenido->setPlanificacionSeccionId($planificacionSeccion); - $seccion->addPlanificacion($planificacionSeccion); + $contenido->setPlanificacionSeccionId($planificacionSeccion); } foreach($planificacionSeccion->getObjetivoEspecifico() as $especifico){ - $especifico->setPlanificacionSeccionId($planificacionSeccion); - + $especifico->setPlanificacionSeccionId($planificacionSeccion); } - foreach ($planificacionSeccion->getEstrategia() as $estrategias){ - $estrategias->setPlanificacionSeccionId($planificacionSeccion); - - + foreach ($planificacionSeccion->getEstrategia() as $estrategias){ + $estrategias->setPlanificacionSeccionId($planificacionSeccion); } - /*foreach($planificacionSeccion->getEstrategia() as $estrategias){ - $estrategias->setPlanificacionSeccionId($planificacionSeccion); - foreach($estrategias->getTecnicasPlanificacion() as $t){ - $estrategias->addTecnicasPlanificacion($t); - } - foreach($estrategias->getRecursosPlanificacion() as $r){ - $estrategias->addRecursosPlanificacion($r); - } - - }*/ - - - + foreach ($planificacionSeccion->getEvaluacion() as $evaluaciones){ + $evaluaciones->setPlanificacionSeccionId($planificacionSeccion); + } + //var_dump($seccion->getPlanificacion()->count()); exit; $em = $this->getDoctrine()->getManager(); $em->persist($planificacionSeccion); diff --git a/src/AppBundle/Entity/PlanificacionSeccion.php b/src/AppBundle/Entity/PlanificacionSeccion.php index e33fce0..ded7c7f 100644 --- a/src/AppBundle/Entity/PlanificacionSeccion.php +++ b/src/AppBundle/Entity/PlanificacionSeccion.php @@ -55,7 +55,7 @@ class PlanificacionSeccion /** - * @ORM\OneToMany(targetEntity="PlanificacionSeccionEvaluacion", mappedBy="idPlanificacionEvaluacion") + * @ORM\OneToMany(targetEntity="PlanificacionSeccionEvaluacion", mappedBy="planificacionSeccionId", cascade={"all"}) */ private $evaluacion; diff --git a/src/AppBundle/Entity/PlanificacionSeccionEvaluacion.php b/src/AppBundle/Entity/PlanificacionSeccionEvaluacion.php index 1736d58..01246f5 100644 --- a/src/AppBundle/Entity/PlanificacionSeccionEvaluacion.php +++ b/src/AppBundle/Entity/PlanificacionSeccionEvaluacion.php @@ -8,31 +8,13 @@ use Symfony\Component\Validator\Constraints as Assert; /** * PlanificacionSeccionEvaluacion * - * @ORM\Table(name="planificacion_seccion_evaluacion", - * uniqueConstraints= - * {@ORM\UniqueConstraint(name="uq_planificacion_seccion", - * columns={"id_planificacion_seccion"}) - * }, - * indexes={ - * @ORM\Index(name="fki_id_planificacion_evaluacion", - * columns={"id_planificacion_seccion"}) - * } - * ) + * @ORM\Table(name="planificacion_seccion_evaluacion") * @ORM\Entity */ class PlanificacionSeccionEvaluacion { - /** - * @var \AppBundle\Entity\PlanificacionSeccion - * - * @ORM\ManyToOne(targetEntity="AppBundle\Entity\PlanificacionSeccion") - * @ORM\JoinColumns({ - * @ORM\JoinColumn(name="id_planificacion_seccion", referencedColumnName="id", nullable=false) - * }) - */ - private $idPlanificacionSeccion; - + /** * @var integer * @@ -54,12 +36,20 @@ class PlanificacionSeccionEvaluacion private $idTipoEvaluacion; - /** - * @var text + /** + * @var \Doctrine\Common\Collections\Collection * - * @ORM\Column(name="tipo_instrumento_evaluacion", type="text", nullable=false, options={"comment" = "Instrumentos para la evaluacion"}) + * @ORM\ManyToMany(targetEntity="AppBundle\Entity\TipoInstrumentoEvaluacion", inversedBy="evaluacion") + * @ORM\JoinTable(name="evaluacion_instrumento", + * joinColumns={ + * @ORM\JoinColumn(name="evaluacion_id", referencedColumnName="id", nullable=false) + * }, + * inverseJoinColumns={ + * @ORM\JoinColumn(name="instrumento_id", referencedColumnName="id", nullable=false) + * } + * ) */ - private $tipoInstrumentoEvaluacion; + protected $instrumentos; /** @@ -98,13 +88,9 @@ class PlanificacionSeccionEvaluacion /** * @ORM\ManyToOne(targetEntity="PlanificacionSeccion", inversedBy="evaluacion") - * @ORM\JoinColumn(name="id_planificacion_evaluacion", referencedColumnName="id") + * @ORM\JoinColumn(name="planificacion_seccion_id", referencedColumnName="id") */ - private $idPlanificacionEvaluacion; - - - - + private $planificacionSeccionId; @@ -187,28 +173,7 @@ class PlanificacionSeccionEvaluacion return $this->fechaEvaluacion; } - /** - * Set idPlanificacionSeccion - * - * @param \AppBundle\Entity\PlanificacionSeccion $idPlanificacionSeccion - * @return PlanificacionSeccionEvaluacion - */ - public function setIdPlanificacionSeccion(\AppBundle\Entity\PlanificacionSeccion $idPlanificacionSeccion) - { - $this->idPlanificacionSeccion = $idPlanificacionSeccion; - - return $this; - } - - /** - * Get idPlanificacionSeccion - * - * @return \AppBundle\Entity\PlanificacionSeccion - */ - public function getIdPlanificacionSeccion() - { - return $this->idPlanificacionSeccion; - } + /** * Set idTipoEvaluacion @@ -278,4 +243,67 @@ class PlanificacionSeccionEvaluacion { return $this->idPlanificacionEvaluacion; } + + /** + * Set planificacionSeccionId + * + * @param \AppBundle\Entity\PlanificacionSeccion $planificacionSeccionId + * @return PlanificacionSeccionEvaluacion + */ + public function setPlanificacionSeccionId(\AppBundle\Entity\PlanificacionSeccion $planificacionSeccionId = null) + { + $this->planificacionSeccionId = $planificacionSeccionId; + + return $this; + } + + /** + * Get planificacionSeccionId + * + * @return \AppBundle\Entity\PlanificacionSeccion + */ + public function getPlanificacionSeccionId() + { + return $this->planificacionSeccionId; + } + /** + * Constructor + */ + public function __construct() + { + $this->instrumentos = new \Doctrine\Common\Collections\ArrayCollection(); + } + + /** + * Add instrumentos + * + * @param \AppBundle\Entity\TipoInstrumentoEvaluacion $instrumentos + * @return PlanificacionSeccionEvaluacion + */ + public function addInstrumento(\AppBundle\Entity\TipoInstrumentoEvaluacion $instrumentos) + { + $this->instrumentos[] = $instrumentos; + + return $this; + } + + /** + * Remove instrumentos + * + * @param \AppBundle\Entity\TipoInstrumentoEvaluacion $instrumentos + */ + public function removeInstrumento(\AppBundle\Entity\TipoInstrumentoEvaluacion $instrumentos) + { + $this->instrumentos->removeElement($instrumentos); + } + + /** + * Get instrumentos + * + * @return \Doctrine\Common\Collections\Collection + */ + public function getInstrumentos() + { + return $this->instrumentos; + } } diff --git a/src/AppBundle/Entity/PlanificacionSeccionEvaluacion.php~ b/src/AppBundle/Entity/PlanificacionSeccionEvaluacion.php~ index 7c536fe..76ba943 100644 --- a/src/AppBundle/Entity/PlanificacionSeccionEvaluacion.php~ +++ b/src/AppBundle/Entity/PlanificacionSeccionEvaluacion.php~ @@ -8,31 +8,13 @@ use Symfony\Component\Validator\Constraints as Assert; /** * PlanificacionSeccionEvaluacion * - * @ORM\Table(name="planificacion_seccion_evaluacion", - * uniqueConstraints= - * {@ORM\UniqueConstraint(name="uq_planificacion_seccion", - * columns={"id_planificacion_seccion"}) - * }, - * indexes={ - * @ORM\Index(name="fki_id_planificacion_evaluacion", - * columns={"id_planificacion_seccion"}) - * } - * ) + * @ORM\Table(name="planificacion_seccion_evaluacion") * @ORM\Entity */ class PlanificacionSeccionEvaluacion { - /** - * @var \AppBundle\Entity\PlanificacionSeccion - * - * @ORM\ManyToOne(targetEntity="AppBundle\Entity\PlanificacionSeccion") - * @ORM\JoinColumns({ - * @ORM\JoinColumn(name="id_planificacion_seccion", referencedColumnName="id", nullable=false) - * }) - */ - private $idPlanificacionSeccion; - + /** * @var integer * @@ -54,12 +36,20 @@ class PlanificacionSeccionEvaluacion private $idTipoEvaluacion; - /** - * @var text + /** + * @var \Doctrine\Common\Collections\Collection * - * @ORM\Column(name="tipo_instrumento_evaluacion", type="text", nullable=false, options={"comment" = "Instrumentos para la evaluacion"}) + * @ORM\ManyToMany(targetEntity="AppBundle\Entity\TipoInstrumentoEvaluacion", inversedBy="evaluacion") + * @ORM\JoinTable(name="evaluacion_instrumento", + * joinColumns={ + * @ORM\JoinColumn(name="evaluacion_id", referencedColumnName="id", nullable=false) + * }, + * inverseJoinColumns={ + * @ORM\JoinColumn(name="instrumento_id", referencedColumnName="id", nullable=false) + * } + * ) */ - private $tipoInstrumentoEvaluacion; + protected $instrumentos; /** @@ -98,13 +88,182 @@ class PlanificacionSeccionEvaluacion /** * @ORM\ManyToOne(targetEntity="PlanificacionSeccion", inversedBy="evaluacion") - * @ORM\JoinColumn(name="id_planificacion_evaluacion", referencedColumnName="id") + * @ORM\JoinColumn(name="planificacion_seccion_id", referencedColumnName="id") */ - private $idPlanificacionEvaluacion; + private $planificacionSeccionId; - + /** + * Get id + * + * @return integer + */ + public function getId() + { + return $this->id; + } + + /** + * Set tipoInstrumentoEvaluacion + * + * @param string $tipoInstrumentoEvaluacion + * @return PlanificacionSeccionEvaluacion + */ + public function setTipoInstrumentoEvaluacion($tipoInstrumentoEvaluacion) + { + $this->tipoInstrumentoEvaluacion = $tipoInstrumentoEvaluacion; + + return $this; + } + + /** + * Get tipoInstrumentoEvaluacion + * + * @return string + */ + public function getTipoInstrumentoEvaluacion() + { + return $this->tipoInstrumentoEvaluacion; + } + + /** + * Set ponderacion + * + * @param integer $ponderacion + * @return PlanificacionSeccionEvaluacion + */ + public function setPonderacion($ponderacion) + { + $this->ponderacion = $ponderacion; + + return $this; + } + + /** + * Get ponderacion + * + * @return integer + */ + public function getPonderacion() + { + return $this->ponderacion; + } + + /** + * Set fechaEvaluacion + * + * @param \DateTime $fechaEvaluacion + * @return PlanificacionSeccionEvaluacion + */ + public function setFechaEvaluacion($fechaEvaluacion) + { + $this->fechaEvaluacion = $fechaEvaluacion; + + return $this; + } + + /** + * Get fechaEvaluacion + * + * @return \DateTime + */ + public function getFechaEvaluacion() + { + return $this->fechaEvaluacion; + } + + /** + * Set idTipoEvaluacion + * + * @param \AppBundle\Entity\TipoEvaluacion $idTipoEvaluacion + * @return PlanificacionSeccionEvaluacion + */ + public function setIdTipoEvaluacion(\AppBundle\Entity\TipoEvaluacion $idTipoEvaluacion) + { + $this->idTipoEvaluacion = $idTipoEvaluacion; + + return $this; + } + + /** + * Get idTipoEvaluacion + * + * @return \AppBundle\Entity\TipoEvaluacion + */ + public function getIdTipoEvaluacion() + { + return $this->idTipoEvaluacion; + } + + /** + * Set idEstatus + * + * @param \AppBundle\Entity\Estatus $idEstatus + * @return PlanificacionSeccionEvaluacion + */ + public function setIdEstatus(\AppBundle\Entity\Estatus $idEstatus) + { + $this->idEstatus = $idEstatus; + + return $this; + } + + /** + * Get idEstatus + * + * @return \AppBundle\Entity\Estatus + */ + public function getIdEstatus() + { + return $this->idEstatus; + } + + /** + * Set idPlanificacionEvaluacion + * + * @param \AppBundle\Entity\PlanificacionSeccion $idPlanificacionEvaluacion + * @return PlanificacionSeccionEvaluacion + */ + public function setIdPlanificacionEvaluacion(\AppBundle\Entity\PlanificacionSeccion $idPlanificacionEvaluacion = null) + { + $this->idPlanificacionEvaluacion = $idPlanificacionEvaluacion; + + return $this; + } + + /** + * Get idPlanificacionEvaluacion + * + * @return \AppBundle\Entity\PlanificacionSeccion + */ + public function getIdPlanificacionEvaluacion() + { + return $this->idPlanificacionEvaluacion; + } + + /** + * Set planificacionSeccionId + * + * @param \AppBundle\Entity\PlanificacionSeccion $planificacionSeccionId + * @return PlanificacionSeccionEvaluacion + */ + public function setPlanificacionSeccionId(\AppBundle\Entity\PlanificacionSeccion $planificacionSeccionId = null) + { + $this->planificacionSeccionId = $planificacionSeccionId; + + return $this; + } + + /** + * Get planificacionSeccionId + * + * @return \AppBundle\Entity\PlanificacionSeccion + */ + public function getPlanificacionSeccionId() + { + return $this->planificacionSeccionId; + } } diff --git a/src/AppBundle/Entity/TipoInstrumentoEvaluacion.php b/src/AppBundle/Entity/TipoInstrumentoEvaluacion.php index 5b24a60..ec5817c 100644 --- a/src/AppBundle/Entity/TipoInstrumentoEvaluacion.php +++ b/src/AppBundle/Entity/TipoInstrumentoEvaluacion.php @@ -29,6 +29,13 @@ class TipoInstrumentoEvaluacion * @ORM\SequenceGenerator(sequenceName="estado_id_seq", allocationSize=1, initialValue=1) */ private $id; + + /** + * @var \Doctrine\Common\Collections\Collection + * + * @ORM\ManyToMany(targetEntity="AppBundle\Entity\PlanificacionSeccionEvaluacion", mappedBy="instrumentos", cascade={"all"}) + */ + protected $evaluacion; @@ -46,6 +53,15 @@ class TipoInstrumentoEvaluacion + + /** + * Constructor + */ + public function __construct() + { + $this->evaluacion = new \Doctrine\Common\Collections\ArrayCollection(); + } + /** * Set nombre * @@ -78,4 +94,37 @@ class TipoInstrumentoEvaluacion { return $this->id; } + + /** + * Add evaluacion + * + * @param \AppBundle\Entity\PlanificacionSeccionEvaluacion $evaluacion + * @return TipoInstrumentoEvaluacion + */ + public function addEvaluacion(\AppBundle\Entity\PlanificacionSeccionEvaluacion $evaluacion) + { + $this->evaluacion[] = $evaluacion; + + return $this; + } + + /** + * Remove evaluacion + * + * @param \AppBundle\Entity\PlanificacionSeccionEvaluacion $evaluacion + */ + public function removeEvaluacion(\AppBundle\Entity\PlanificacionSeccionEvaluacion $evaluacion) + { + $this->evaluacion->removeElement($evaluacion); + } + + /** + * Get evaluacion + * + * @return \Doctrine\Common\Collections\Collection + */ + public function getEvaluacion() + { + return $this->evaluacion; + } } diff --git a/src/AppBundle/Entity/TipoInstrumentoEvaluacion.php~ b/src/AppBundle/Entity/TipoInstrumentoEvaluacion.php~ index f6e8537..5f6af00 100644 --- a/src/AppBundle/Entity/TipoInstrumentoEvaluacion.php~ +++ b/src/AppBundle/Entity/TipoInstrumentoEvaluacion.php~ @@ -29,6 +29,11 @@ class TipoInstrumentoEvaluacion * @ORM\SequenceGenerator(sequenceName="estado_id_seq", allocationSize=1, initialValue=1) */ private $id; + + /** + * @ORM\OneToMany(targetEntity="PlanificacionSeccionEvaluacion", mappedBy="instrumentos", cascade={"all"}) + */ + private $evaluacion; @@ -45,4 +50,6 @@ class TipoInstrumentoEvaluacion } -} \ No newline at end of file + + +} diff --git a/src/AppBundle/Form/PlanificacionSeccionEvaluacionType.php b/src/AppBundle/Form/PlanificacionSeccionEvaluacionType.php new file mode 100644 index 0000000..f6d25d0 --- /dev/null +++ b/src/AppBundle/Form/PlanificacionSeccionEvaluacionType.php @@ -0,0 +1,40 @@ +add('instrumentos', EntityType::class, array( + 'class' => 'AppBundle:TipoInstrumentoEvaluacion', + 'multiple' => TRUE, + 'expanded' => TRUE, + )) + ->add('ponderacion') + ->add('fechaEvaluacion') + ->add('idTipoEvaluacion') + ->add('idEstatus') + ; + } + + /** + * @param OptionsResolver $resolver + */ + public function configureOptions(OptionsResolver $resolver) + { + $resolver->setDefaults(array( + 'data_class' => 'AppBundle\Entity\PlanificacionSeccionEvaluacion' + )); + } +} diff --git a/src/AppBundle/Form/PlanificacionSeccionType.php b/src/AppBundle/Form/PlanificacionSeccionType.php index cbcc2aa..ddb4c87 100644 --- a/src/AppBundle/Form/PlanificacionSeccionType.php +++ b/src/AppBundle/Form/PlanificacionSeccionType.php @@ -73,6 +73,14 @@ class PlanificacionSeccionType extends AbstractType 'allow_add' => true, 'label' => false )) + + ->add('evaluacion', CollectionType::class, array( + 'entry_type' => PlanificacionSeccionEvaluacionType::class, + 'allow_add' => true, + 'label' => false + )) + + ; } -- 2.0.0