<commit_before><?php

namespace Cleverweb\CommonBundle\Controller;

use Cleverweb\CommonBundle\Entity\Quiz;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;

class QuizController extends Controller
{
    /**
     * @Route("/quizzes/new", name="cleverweb_common_quiz_create")
     * @Template()
     */
    public function createQuizAction()
    {
        $quiz = new Quiz();

        $form = $this->createFormBuilder($quiz)
            ->add('name', 'text')
            ->add('category')
            ->getForm();


        return array(
            'form' => $form->createView()
        );
    }
}<commit_msg>Created button "add quiz" and code for creating quiz.<commit_after><?php

namespace Cleverweb\CommonBundle\Controller;

use Cleverweb\CommonBundle\Entity\Quiz;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;
use Symfony\Component\HttpFoundation\Request;

class QuizController extends Controller
{
    /**
     * @Route("/quizzes/new", name="cleverweb_common_quiz_create")
     * @Template()
     */
    public function createQuizAction(Request $request)
    {
        $quiz = new Quiz();
        $em = $this->getDoctrine()->getManager();

        $form = $this->createFormBuilder($quiz)
            ->add('name', 'text')
            ->add('category')
            ->add('add quiz', 'submit')
            ->getForm();

        $form->handleRequest($request);
        if ($form->isValid()) {

            $em->persist($quiz);
            $em->flush();

            return $this->redirect($this->generateUrl('cleverweb_common_quiz_create'));
        }

        return array(
            'form' => $form->createView()
        );
    }
}
{'fraction_non_alphanumeric': 0.14120734908136484, 'fraction_numerical': 0.0, 'mean_word_length': 2.8273092369477912, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 24, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3432191', 'n_tokens_mistral': 556, 'n_tokens_neox': 546, 'n_words': 91}