<commit_before><?php

namespace IIT\AllSpeakBundle\Controller;

use IIT\AllSpeakBundle\Entity\SurveyAnswer;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\Form\Extension\Core\Type\NumberType;
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;

class DefaultController extends Controller
{
    public function indexAction()
    {
        return $this->render('IITAllSpeakBundle:Default:index.html.twig');
    }

    public function surveyAction(Request $request)
    {
        $surveyAnswer = new SurveyAnswer();

        $sentencesRepository = $this->getDoctrine()->getRepository('IITAllSpeakBundle:SurveySentence');

        $genderChoices = [
            'Maschio' => 'M',
            'Femmina' => 'F'
        ];
        $surveySentences = $sentencesRepository->findAll();
        $currentYear = date("Y");
        $minBirthYear = 1940;
        $minDiagnosisYear = 1980;
        $birthYearChoices = range($minBirthYear, $currentYear);
        $diagnosisYearChoices = range($minDiagnosisYear, $currentYear);
        $diagnosisChoices = [
            'Spinale' => 'S',
            'Bulbare' => 'B'
        ];
        $useValueAsLabel = function($value, $key, $index) {return $value;};
        $form = $this->createFormBuilder($surveyAnswer)
            ->add('gender', ChoiceType::class, [
                'label' => 'Genere',
                'choices' => $genderChoices
            ])
            ->add('birthYear', ChoiceType::class, [
                'label' => 'Anno di nascita',
                'choices' => $birthYearChoices,
                'choice_label' => $useValueAsLabel
            ])
            ->add('diagnosisYear', ChoiceType::class, [
                'label' => 'Anno di diagnosi',
                'choices' => $diagnosisYearChoices,
                'choice_label' => $useValueAsLabel
            ])
            ->add('alsfrsr', NumberType::class, [
                'label' => 'ALSFR-R'
            ])
            ->add('verbalScore', NumberType ::class, [
                'label' => 'Score verbale'
            ])
            ->add('diagnosis', ChoiceType::class, [
                'label' => 'Diagnosi',
                'choices' => $diagnosisChoices
            ])
            ->add('sentences', ChoiceType::class, [
                'label' => "Selezionare le frasi piu' importanti",
                'multiple' => true,
                'expanded' => true,
                'choices' => $surveySentences,
                'choice_label' => 'getText',
                'choice_value' => 'getId'
            ])
            ->add('submit', SubmitType::class, [
                'label' => 'Conferma'
            ])
            ->getForm();

        $form->handleRequest($request);

        if ($form->isSubmitted() && $form->isValid()) {

            $surveyAnswer = $form->getData();

            $em = $this->getDoctrine()->getManager();
            $em->persist($surveyAnswer);
            $em->flush();
<commit_msg>Survey fields 'alsfrsr' and 'verbalScore' are now integers.<commit_after><?php

namespace IIT\AllSpeakBundle\Controller;

use IIT\AllSpeakBundle\Entity\SurveyAnswer;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\Form\Extension\Core\Type\IntegerType;
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;

class DefaultController extends Controller
{
    public function indexAction()
    {
        return $this->render('IITAllSpeakBundle:Default:index.html.twig');
    }

    public function surveyAction(Request $request)
    {
        $surveyAnswer = new SurveyAnswer();

        $sentencesRepository = $this->getDoctrine()->getRepository('IITAllSpeakBundle:SurveySentence');

        $genderChoices = [
            'Maschio' => 'M',
            'Femmina' => 'F'
        ];
        $surveySentences = $sentencesRepository->findAll();
        $currentYear = date("Y");
        $minBirthYear = 1940;
        $minDiagnosisYear = 1980;
        $birthYearChoices = range($minBirthYear, $currentYear);
        $diagnosisYearChoices = range($minDiagnosisYear, $currentYear);
        $diagnosisChoices = [
            'Spinale' => 'S',
            'Bulbare' => 'B'
        ];
        $useValueAsLabel = function($value, $key, $index) {return $value;};
        $form = $this->createFormBuilder($surveyAnswer)
            ->add('gender', ChoiceType::class, [
                'label' => 'Genere',
                'choices' => $genderChoices
            ])
            ->add('birthYear', ChoiceType::class, [
                'label' => 'Anno di nascita',
                'choices' => $birthYearChoices,
                'choice_label' => $useValueAsLabel
            ])
            ->add('diagnosisYear', ChoiceType::class, [
                'label' => 'Anno di diagnosi',
                'choices' => $diagnosisYearChoices,
                'choice_label' => $useValueAsLabel
            ])
            ->add('alsfrsr', IntegerType::class, [
                'label' => 'ALSFR-R'
            ])
            ->add('verbalScore', IntegerType ::class, [
                'label' => 'Score verbale'
            ])
            ->add('diagnosis', ChoiceType::class, [
                'label' => 'Diagnosi',
                'choices' => $diagnosisChoices
            ])
            ->add('sentences', ChoiceType::class, [
                'label' => "Selezionare le frasi piu' importanti",
                'multiple' => true,
                'expanded' => true,
                'choices' => $surveySentences,
                'choice_label' => 'getText',
                'choice_value' => 'getId'
            ])
            ->add('submit', SubmitType::class, [
                'label' => 'Conferma'
            ])
            ->getForm();

        $form->handleRequest($request);

        if ($form->isSubmitted() && $form->isValid()) {

            $surveyAnswer = $form->getData();

            $em = $this->getDoctrine()->getManager();
            $em->persist($surveyAnswer);
            $em->flush();

{'fraction_non_alphanumeric': 0.14489763529598476, 'fraction_numerical': 0.0025392794794477066, 'mean_word_length': 2.03710843373494, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 93, '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': '4330964', 'n_tokens_mistral': 1880, 'n_tokens_neox': 1760, 'n_words': 291}