<commit_before><?php

namespace Acatism\MainBundle\Controller;

use Acatism\MainBundle\Document\SocialMedia;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\Security\Core\SecurityContext;
use Symfony\Component\Security;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Acatism\MainBundle\Document\Student;
use Acatism\MainBundle\Document\Professor;
use Acatism\MainBundle\Form\Type\PersonUploadType;
use Acatism\MainBundle\Document\Task;
use Acatism\MainBundle\Form\Type\TaskType;
use Acatism\MainBundle\Document\Project;
use Acatism\MainBundle\Document\Post;
use Acatism\MainBundle\Document\GithubAccount;
use Acatism\MainBundle\Document\TaskProgress;


class DefaultController extends Controller
{
   public function indexAction()
    {
        //
        if($this->get('security.context')->isGranted('ROLE_STUDENT') === true)
        {
            
            $student = $this->getStudentInformation();

            if(is_null($student))
            {
                $this->get('session')->set('person', new Student());
                return $this->redirect($this->generateUrl('wizard_first'));
            }
            else
            {
                $user = $this->getUser();

                $dm = $this->get('doctrine_mongodb')->getManager();

                // getting student social links
                $qb = $dm->createQueryBuilder('AcatismMainBundle:SocialMedia')
                         ->field('user')->references($user);
                $social = $qb->getQuery()->getSingleResult();

                // getting student applications
                $qb = $dm->createQueryBuilder('AcatismMainBundle:Application')
                         ->field('student')->references($user);
                $applications = $qb->getQuery()->execute();


                // if studdent has a collaboration, get his tasks
                $githubAccount = $dm->createQueryBuilder('AcatismMainBundle:GithubAccount')
                                    ->field('user')->references($user)
                                    ->getQuery()->getSingleResult();

                if($student->getIsAccepted() === true && !is_null($githubAccount))
                {
                    $qb = $dm->createQueryBuilder('AcatismMainBundle:Collaboration')
                             ->field('student')
                             ->references($user);
                    $collaboration = $qb->getQuery()->getSingleResult();

                    $supervisor = $collaboration->getProfessor();

                    $qb = $dm->createQueryBuilder('AcatismMainBundle:Task')
                             ->field('professor')->references($supervisor)
                             ->sort('dueDate', 'ASC');

                    $tasklist = $qb->getQuery()->execute();

                    foreach($tasklist as $task) {
                        $taskProgress = $dm->createQueryBuilder('AcatismMainBundle:TaskProgress')
                                           ->field('student')->references($user)
                                           ->field('task')->references($task)
                                           ->getQuery()
                                           ->getSingleResult();
                        if(is_null($taskProgress)) {
                            $taskProgress = new TaskProgress();
                            $taskProgress->setStudent($user);
                            $taskProgress->setTask($task);
                            $taskProgress->setDueDate($task->getDueDate());
                            if($task->getRequireSourceCode() === true) {
                                $taskProgress->setRepository($githubAccount->createRepository($task->getTitle()));
                            }
                            $dm->persist($taskProgress);
                        }
                    }
                    $dm->flush();

                    $taskProgressList = $dm->createQueryBuilder('AcatismMainBundle:TaskProgress')
                                           ->field('student')->references($user)
                                           ->getQuery()
                                           ->execute();

                    return $this->render('AcatismMainBundle:Show:StudView.html.twig',
                           array('student' => $student,
                                 'applicationlist' => $applications,
                                 'taskProgressList' => $taskProgressList,
                                 'sociallinks' => $social
                            ));
                }
                else
                {
                    return $this->render('AcatismMainBundle:Show:StudView.html.twig',
                           array('student' => $student,
                                 'applicationlist' => $applications,
                                 'sociallinks' => $social
                            ));
                } 
            }
        }
        elseif ($this->get('security.context')->isGranted('ROLE_PROFESSOR') === true)
        {
            $professor = $this->getProfessorInformation();

            if(is_null($professor))
            {
                $this->get('session')->set('person', new Professor());
                return $this->redirect($this->generateUrl('wizard_first'));
            }
            else
            {

                $user = $this->getUser();

                $dm = $this->get('doctrine_mongodb')->getManager();

                // getting prof social links
                $qb = $dm->createQueryBuilder('AcatismMainBundle:SocialMedia')
                    ->field('user')->references($user);<commit_msg>Github flag variable<commit_after><?php

namespace Acatism\MainBundle\Controller;

use Acatism\MainBundle\Document\SocialMedia;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\Security\Core\SecurityContext;
use Symfony\Component\Security;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Acatism\MainBundle\Document\Student;
use Acatism\MainBundle\Document\Professor;
use Acatism\MainBundle\Form\Type\PersonUploadType;
use Acatism\MainBundle\Document\Task;
use Acatism\MainBundle\Form\Type\TaskType;
use Acatism\MainBundle\Document\Project;
use Acatism\MainBundle\Document\Post;
use Acatism\MainBundle\Document\GithubAccount;
use Acatism\MainBundle\Document\TaskProgress;


class DefaultController extends Controller
{
   public function indexAction()
    {
        //
        if($this->get('security.context')->isGranted('ROLE_STUDENT') === true)
        {
            
            $student = $this->getStudentInformation();

            if(is_null($student))
            {
                $this->get('session')->set('person', new Student());
                return $this->redirect($this->generateUrl('wizard_first'));
            }
            else
            {
                $user = $this->getUser();

                $dm = $this->get('doctrine_mongodb')->getManager();

                // getting student social links
                $qb = $dm->createQueryBuilder('AcatismMainBundle:SocialMedia')
                         ->field('user')->references($user);
                $social = $qb->getQuery()->getSingleResult();

                // getting student applications
                $qb = $dm->createQueryBuilder('AcatismMainBundle:Application')
                         ->field('student')->references($user);
                $applications = $qb->getQuery()->execute();


                // if studdent has a collaboration, get his tasks
                $githubAccount = $dm->createQueryBuilder('AcatismMainBundle:GithubAccount')
                                    ->field('user')->references($user)
                                    ->getQuery()->getSingleResult();

                $hasGithubAccount = false;

                if(!is_null($githubAccount)) {
                  $hasGithubAccount = true;
                }

                if($student->getIsAccepted() === true && !is_null($githubAccount))
                {
                    $qb = $dm->createQueryBuilder('AcatismMainBundle:Collaboration')
                             ->field('student')
                             ->references($user);
                    $collaboration = $qb->getQuery()->getSingleResult();

                    $supervisor = $collaboration->getProfessor();

                    $qb = $dm->createQueryBuilder('AcatismMainBundle:Task')
                             ->field('professor')->references($supervisor)
                             ->sort('dueDate', 'ASC');

                    $tasklist = $qb->getQuery()->execute();

                    foreach($tasklist as $task) {
                        $taskProgress = $dm->createQueryBuilder('AcatismMainBundle:TaskProgress')
                                           ->field('student')->references($user)
                                           ->field('task')->references($task)
                                           ->getQuery()
                                           ->getSingleResult();
                        if(is_null($taskProgress)) {
                            $taskProgress = new TaskProgress();
                            $taskProgress->setStudent($user);
                            $taskProgress->setTask($task);
                            $taskProgress->setDueDate($task->getDueDate());
                            if($task->getRequireSourceCode() === true) {
                                $taskProgress->setRepository($githubAccount->createRepository($task->getTitle()));
                            }
                            $dm->persist($taskProgress);
                        }
                    }
                    $dm->flush();

                    $taskProgressList = $dm->createQueryBuilder('AcatismMainBundle:TaskProgress')
                                           ->field('student')->references($user)
                                           ->getQuery()
                                           ->execute();

                    return $this->render('AcatismMainBundle:Show:StudView.html.twig',
                           array('student' => $student,
                                 'applicationlist' => $applications,
                                 'taskProgressList' => $taskProgressList,
                                 'sociallinks' => $social,
                                 'hasGithubAccount' => $hasGithubAccount
                            ));
                }
                else
                {
                    return $this->render('AcatismMainBundle:Show:StudView.html.twig',
                           array('student' => $student,
                                 'applicationlist' => $applications,
                                 'sociallinks' => $social,
                                 'hasGithubAccount' => $hasGithubAccount
                            ));
                } 
            }
        }
        elseif ($this->get('security.context')->isGranted('ROLE_PROFESSOR') === true)
        {
            $professor = $this->getProfessorInformation();

            if(is_null($professor))
            {
                $this->get('session')->set('person', new Professor());
                return $this->redirect($this->generateUrl('wizard_first'));
            }
            else
            {

                $user = $this->getUser();

                $dm = $this->get('doctrine_mongodb')->getManager();

                // getting prof social links
                $qb = $dm->createQueryBuilder('AcatismMainBundle:SocialMedia')
                    ->field('user')->references($user);
{'fraction_non_alphanumeric': 0.12411438326931284, 'fraction_numerical': 0.0, 'mean_word_length': 1.4097079391197038, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 169, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 44, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3518309', 'n_tokens_mistral': 2795, 'n_tokens_neox': 2592, 'n_words': 350}