Exemplo n.º 1
0
 public function DisplayAction(Request $request)
 {
     // create a task and give it some dummy data for this example
     $questionnaire = new Questionnaire();
     $questionnaire->getCreatorId("This is a Test Question?");
     $questionnaire->getCreatedDate('1');
     $questionnaire->getHidden('1');
     $form = $this->createFormBuilder($questionnaire)->add('creatorId', 'text')->add('createdDate', 'text')->add('hidden', 'text')->add('save', 'submit', array('label' => 'Create Question'))->getForm();
     return $this->render('default/new.html.twig', array('form' => $form->createView()));
 }
Exemplo n.º 2
0
 /**
  * Set questionnaire
  *
  * @param \AppBundle\Entity\Questionnaire $questionnaire
  *
  * @return Reponses
  */
 public function setQuestionnaire(\AppBundle\Entity\Questionnaire $questionnaire = null)
 {
     $this->questionnaire = $questionnaire;
     $this->listreponses->clear();
     foreach ($questionnaire->getQuestions() as $key => $question) {
         $reponse = new Reponse();
         $reponse->setQuestion($question->getQuestion());
         $reponse->setReponses($this);
         $this->addListreponse($reponse);
     }
     return $this;
 }
Exemplo n.º 3
0
function displayQuestions(\AppBundle\Entity\Questionnaire $questionnaire)
{
    $str = "";
    foreach ($questionnaire->getQuestions() as $linkquestion) {
        $size = count($linkquestion->getQuestion()->getChoixs()) - 1;
        $str .= "<p class='choix__item'>";
        foreach ($linkquestion->getQuestion()->getChoixs() as $key => $choix) {
            $str .= $choix->getTitre();
            if ($key < $size) {
                $str .= " / ";
            }
        }
        $str .= "</p>";
    }
    return $str;
}
Exemplo n.º 4
0
 public function load(ObjectManager $manager)
 {
     //Contenu des mails
     $ContenuMails[] = "Cette année Koba et ses filiales souhaitent<br/> vous présenter des voeux personnalisés.<br/> <strong>Des voeux qui s’appuient<br/> sur ce que vous aimez.</strong>";
     $ContenuMails[] = "Nous vous préparons une surprise en ce début d’année.";
     foreach ($ContenuMails as $ContenuMail) {
         $ObjContenuMail = new ContenuMail();
         $ObjContenuMail->setContenuTxt($ContenuMail);
         $manager->persist($ObjContenuMail);
     }
     // Liste des choix
     $Questionnaires[] = array("Titre" => "Rubrique 1", "Questions" => array(array("Chocolat", "Barbe à papa"), array("Baignade", "Promenade"), array("Sauvignon", "Saint-emilion"), array("Metro", "Velo"), array("Chanter", "Danser")));
     $Questionnaires[] = array("Titre" => "Rubrique 2", "Questions" => array(array("Football", "Basketball"), array("Acras", "Foie gras"), array("Thé", "Café"), array("Poisson", "Filet mignon"), array("Panda", "Koala")));
     $Questionnaires[] = array("Titre" => "Rubrique 3", "Questions" => array(array("Pop", "Rock"), array("Fourchette", "Baguettes"), array("Bouquins", "Copains"), array("Camping", "Shopping"), array("Raclette", "Tartiflette")));
     $Questionnaires[] = array("Titre" => "Rubrique 4", "Questions" => array(array("Papeete", "Noirmoutier"), array("Prosceco", "Menthe à l’eau"), array("Rando", "Pédalo"), array("Zanzibar", "La Roche Bernard"), array("Musée", "Ciné")));
     $Questionnaires[] = array("Titre" => "Rubrique 5", "Questions" => array(array("Summer", "Winter"), array("Batman", "Superman"), array("Macarena", "Rihanna"), array("Sauvignon", "Saint-emilion"), array("La barbade", "Les Cyclades")));
     foreach ($Questionnaires as $Questionnaire) {
         $ObjQuestionnaire = new Questionnaire();
         $ObjQuestionnaire->setTitre($Questionnaire["Titre"]);
         foreach ($Questionnaire["Questions"] as $key => $Question) {
             $ObjQuestionnaireQuestion = new QuestionnaireQuestion();
             $ObjQuestionnaireQuestion->setOrdre($key);
             $ObjQuestion = new Question();
             $ObjQuestionnaireQuestion->setQuestionnaire($ObjQuestionnaire);
             $ObjQuestionnaireQuestion->setQuestion($ObjQuestion);
             foreach ($Question as $choix) {
                 $objChoix = new Choix();
                 $objChoix->setImagepath(slug_it($choix));
                 $objChoix->setTitre($choix);
                 $manager->persist($objChoix);
                 $ObjQuestion->addChoix($objChoix);
             }
             $manager->persist($ObjQuestionnaireQuestion);
             $manager->persist($ObjQuestion);
         }
         $manager->persist($ObjQuestionnaire);
     }
     $manager->flush();
 }
Exemplo n.º 5
0
 /**
  * @Route("/Questionnaire/create")
  */
 public function createActionQuestionnaire($array)
 {
     $questionnaire = new Questionnaire();
     $questionnaire->setCreatorId($array());
     $questionnaire->setCreatedDate('A Foo Bar');
     $questionnaire->setHidden('A Foo Bar');
     $em = $this->getDoctrine()->getManager();
     $em->persist($questionnaire);
     $em->flush();
     $questionnaireArray[] = $questionnaire->getId();
     $questionnaireArray[] = $questionnaire->getCreatorId();
     $questionnaireArray[] = $questionnaire->getCreatedDate();
     $questionnaireArray[] = $questionnaire->getHidden();
     return new Response(json_encode($questionnaireArray));
 }
 /**
  * Creates a form to delete a Questionnaire entity by id.
  *
  * This is necessary because browsers don't support HTTP methods different
  * from GET and POST. Since the controller that removes the blog posts expects
  * a DELETE method, the trick is to create a simple form that *fakes* the
  * HTTP DELETE method.
  * See http://symfony.com/doc/current/cookbook/routing/method_parameters.html.
  *
  * @param  Questionnaire $questionnaire The questionnaire object
  * @return \Symfony\Component\Form\Form The form
  */
 private function createDeleteForm(Questionnaire $questionnaire)
 {
     return $this->createFormBuilder()->setAction($this->generateUrl('questionnaire_post_delete', array('id' => $questionnaire->getId())))->setMethod('DELETE')->getForm();
 }
 private function createXML(Questionnaire $questionnaire, User $user)
 {
     $rootNode = new \SimpleXMLElement("<?xml version='1.0' encoding='UTF-8' standalone='yes'?><Antworten></Antworten>");
     $itemNode = $rootNode->addChild('item');
     $itemNode->addChild('itemCode', 'mk');
     // Let's load based on questionnaire:
     $repository = $this->getDoctrine()->getRepository('AppBundle:Question');
     $question = $repository->findOneBy(array('questionnaireId' => $questionnaire->getId()));
     /**
      * @var Question $question
      */
     while ($question != null) {
         $this->buildBlock($question, $user, $rootNode);
         $question = $this->getNextQuestion($question, $user);
     }
     echo $rootNode->asXML();
 }
Exemplo n.º 8
0
 /**
  * Gives new answers to existing Questionnaire Entity
  *
  * @Route("/new/{id}", requirements={"id" = "\d+"}, name="answer_post_new")
  * @Method({"GET", "POST", "DELETE"})
  *
  * NOTE: the Method annotation is optional, but it's a recommended practice
  * to constraint the HTTP methods each controller responds to (by default
  * it responds to all methods).
  */
 public function newAction(Questionnaire $questionnaire, Statement $statement, Request $request)
 {
     $em = $this->getDoctrine()->getManager();
     // $repository = $this->getDoctrine()->getRepository('AppBundle:Statement');
     // $statements = $repository->findAll();
     //
     // $statementCollection = new Answer;
     //
     // foreach ($statements as $statement) {
     //
     //   $statementCollection->getStatement()->add($statement);
     // }
     //
     // $collection = $this->createForm(new AnswerType, $statementCollection);
     //
     // return $this->render('Questionnaire/Answer/new.html.twig', array(
     //   'collection' => $collection->createView()
     // ));
     // $repo_statement = $this->getDoctrine()->getRepository('AppBundle:Statement');
     // $repo_questionnaire = $this->getDoctrine()->getRepository('AppBundle:Questionnaire');
     // $questionnaire = $repo_questionnaire->findOneById($id);
     //
     // if (is_null($questionnaire)) {
     //     throw new \Symfony\Component\HttpKernel\Exception\NotFoundHttpException();
     // }
     //
     // // $statement = $repo_statement->findOneBy(
     // //     array('questionnaire'=>$questionnaire,'statement'=>$this->getStatement())
     // // );
     foreach ($questionnaire->getstatements() as $key => $statement) {
         $repo_statement = $this->getDoctrine()->getRepository('AppBundle:Statement');
         $statement = $repo_statement->findOneBy(array('questionnaire' => $questionnaire, 'statement' => $this->getStatement()));
         $answer[$key] = new Answer($key);
         $form[$key] = $this->createForm(new AnswerType(), $answer[$key])->createView();
     }
     $request = $this->getRequest();
     if ($request->getMethod() == 'POST') {
         $form->bindRequest($request);
         // the isSubmitted() method is completely optional because the other
         // isValid() method already checks whether the form is submitted.
         // However, we explicitly add it to improve code readability.
         // See http://symfony.com/doc/current/best_practices/forms.html#handling-form-submits
         if ($form->isSubmitted() && $form->isValid()) {
             $questionnaireAns = $form["questionnaireAns"]->getData();
             foreach ($questionnaireAns as $questionnaire) {
                 $id = $questionnaire->getId();
                 $dbQuestionnaire = $em->getRepository('AppBundle:Questionnaire')->find($id);
                 if (!$dbQuestionnaire) {
                     throw $this - createNotFoundException('No $dbQuestionnaire found for id ' . $id);
                 }
                 $dbQuestionnaire->addAnswer($answer);
             }
             $statements = $form["statements"]->getData();
             foreach ($statements as $statement) {
                 $id = $statement->getId();
                 $dbStatement = $em->getRepository('AppBundle:Statement')->find($id);
                 if (!$dbStatement) {
                     throw $this - createNotFoundException('No dbStatement found for id ' . $id);
                 }
                 $dbStatement->addAnswer($answer);
             }
             $em->persist($answer);
             $em->flush();
             return $this->redirectToRoute('answer');
         }
     }
     return $this->render('Questionnaire/Answer/new.html.twig', array('questionnaire' => $questionnaire, 'statement' => $statement, 'answer' => $answer, 'form' => $form->createView()));
 }