Commit af293bd9 authored by Jean-Baptiste Oellers's avatar Jean-Baptiste Oellers
Browse files

Ajout des réponses aux questionsé

parent 9e3b452d
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -20,6 +20,10 @@ class ConventionModeleInstanceController extends AbstractOscarController
            return ['conventionModeleInstance' => $conventionModeleInstance];
        }

        if ($this->params()->fromPost('action') == "enregistrer_reponse") {
            $this->conventionModeleInstanceService->enregitrerRéponse($conventionModeleInstance, $this->params()->fromQuery('question', ''), $this->params()->fromQuery('reponse', ''), $this->getCurrentPerson());
        }

        return $this->redirect()->toRoute('conventionModeleInstances/afficher', ['id' => $conventionModeleInstance->id]);
    }

+8 −0
Original line number Diff line number Diff line
@@ -54,9 +54,17 @@ class ConventionModeleInstance
     */
    public $conventionModeleEtapeEnCours;

    /**
     * Liste des réponses.
     *
     * @ORM\Column(type="json", nullable=false)
     */
    public $reponses;

    public function __construct()
    {
        $this->dateCreated = new \DateTime();
        $this->reponses = [];
    }

    public function getResourceId()
+12 −0
Original line number Diff line number Diff line
@@ -31,4 +31,16 @@ class ConventionModeleInstanceService implements UseEntityManager, UseLoggerServ
    return $conventionModeleInstance;
  }

  public function enregitrerRéponse(\Oscar\Entity\ConventionModeleInstance $conventionModeleInstance, string $question, string $reponse, \Oscar\Entity\Person $person): \Oscar\Entity\ConventionModeleInstance
  {
    $this->getLoggerService()->info("ConventionModeleInstanceService enregitrerRéponse");
    $this->getLoggerService()->info("by: " . $person);
    $conventionModeleInstance->updatedBy = $person;
    $conventionModeleInstance->dateUpdated = new \DateTime();
    $conventionModeleInstance->reponses[$question] = $reponse;
    $this->getEntityManager()->persist($conventionModeleInstance);
    $this->getEntityManager()->flush();
    return $conventionModeleInstance;
  }

}
+7 −6
Original line number Diff line number Diff line
@@ -44,10 +44,11 @@
      <h1 style="padding-bottom: 3rem;"><?= $conventionModeleInstance->conventionModeleEtapeEnCours->titre ?></h1>

      <form method="post">
        <input type="hidden" name="action" value="enregistrer_reponse">
        <?php foreach( $conventionModeleInstance->conventionModeleEtapeEnCours->informations as $information ): ?>
        <!-- <?= $information->nom ?> -->
        <?php foreach( $information->reponses as $reponse ): ?>
      <input type="submit" value="<?= $reponse ?>">
        <input type="submit" formaction="?<?= http_build_query(array('question' => $information->nom, 'reponse' => $reponse)); ?>" value="<?= $reponse ?>">
        <?php endforeach; ?>
        <?php endforeach; ?>
      </form>