@@ -233,7 +233,7 @@ |
||
| 233 | 233 | */ |
| 234 | 234 | public function getRoles() |
| 235 | 235 | { |
| 236 | - return [$this->role]; |
|
| 236 | + return [ $this->role ]; |
|
| 237 | 237 | |
| 238 | 238 | } |
| 239 | 239 | |
@@ -41,10 +41,10 @@ |
||
| 41 | 41 | $role = User::ROLE_ADMIN; |
| 42 | 42 | |
| 43 | 43 | $em = $this->doctrine->getManager(); |
| 44 | - $user = $em->getRepository('AppBundle:User')->findBy(['email' => $email]); |
|
| 44 | + $user = $em->getRepository('AppBundle:User')->findBy([ 'email' => $email ]); |
|
| 45 | 45 | if (!$user) |
| 46 | 46 | $user = new User(); |
| 47 | - else $user = $user[0]; |
|
| 47 | + else $user = $user[ 0 ]; |
|
| 48 | 48 | |
| 49 | 49 | $pass = $this->userPasswordEncoder->encodePassword($user, $password); |
| 50 | 50 | $user->setEmail($email); |
@@ -43,6 +43,6 @@ |
||
| 43 | 43 | $this->getContainer()->get('app.admin.creator') |
| 44 | 44 | ->create($email, $password, $firstName, $lastName); |
| 45 | 45 | |
| 46 | - $output->writeln(sprintf('User <comment>%s</comment> was created/updated', $firstName.' '.$lastName)); |
|
| 46 | + $output->writeln(sprintf('User <comment>%s</comment> was created/updated', $firstName . ' ' . $lastName)); |
|
| 47 | 47 | } |
| 48 | 48 | } |
@@ -18,6 +18,6 @@ |
||
| 18 | 18 | */ |
| 19 | 19 | public function indexAction() |
| 20 | 20 | { |
| 21 | - return []; |
|
| 21 | + return [ ]; |
|
| 22 | 22 | } |
| 23 | 23 | } |
@@ -2,7 +2,6 @@ |
||
| 2 | 2 | |
| 3 | 3 | namespace AppBundle\Controller\Admin; |
| 4 | 4 | |
| 5 | -use AppBundle\Entity\Answer; |
|
| 6 | 5 | use AppBundle\Entity\Module; |
| 7 | 6 | use AppBundle\Entity\Question; |
| 8 | 7 | use AppBundle\Form\QuestionType; |
@@ -40,7 +40,7 @@ discard block |
||
| 40 | 40 | } |
| 41 | 41 | } |
| 42 | 42 | |
| 43 | - return ['form' => $form->createView(), |
|
| 43 | + return [ 'form' => $form->createView(), |
|
| 44 | 44 | 'idModule' => $idModule |
| 45 | 45 | ]; |
| 46 | 46 | } |
@@ -80,7 +80,7 @@ discard block |
||
| 80 | 80 | return $this->redirectToRoute('edit_question', array('id' => $id, 'idModule' => $idModule)); |
| 81 | 81 | } |
| 82 | 82 | |
| 83 | - return ['form' => $form->createView(), |
|
| 83 | + return [ 'form' => $form->createView(), |
|
| 84 | 84 | 'idModule' => $idModule |
| 85 | 85 | ]; |
| 86 | 86 | } |
@@ -116,10 +116,10 @@ discard block |
||
| 116 | 116 | $question = $em->getRepository('AppBundle:Question') |
| 117 | 117 | ->findByModuleWithSorting($idModule); |
| 118 | 118 | |
| 119 | - $form_delete = []; |
|
| 119 | + $form_delete = [ ]; |
|
| 120 | 120 | |
| 121 | 121 | foreach ($question as $item) { |
| 122 | - $form_delete[$item->getId()] = $this->createFormDelete($item->getId(), $idModule)->createView(); |
|
| 122 | + $form_delete[ $item->getId() ] = $this->createFormDelete($item->getId(), $idModule)->createView(); |
|
| 123 | 123 | } |
| 124 | 124 | |
| 125 | 125 | return [ |
@@ -136,7 +136,7 @@ discard block |
||
| 136 | 136 | private function createFormDelete($id, $idModule) |
| 137 | 137 | { |
| 138 | 138 | return $this->createFormBuilder() |
| 139 | - ->setAction($this->generateUrl('remove_question', ['id' => $id, 'idModule' => $idModule])) |
|
| 139 | + ->setAction($this->generateUrl('remove_question', [ 'id' => $id, 'idModule' => $idModule ])) |
|
| 140 | 140 | ->setMethod('DELETE') |
| 141 | 141 | ->add('submit', SubmitType::class, [ |
| 142 | 142 | 'label' => ' ', |
@@ -7,7 +7,6 @@ |
||
| 7 | 7 | use Sensio\Bundle\FrameworkExtraBundle\Configuration\Method; |
| 8 | 8 | use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route; |
| 9 | 9 | use AppBundle\Entity\User; |
| 10 | -use AppBundle\Form\UserType; |
|
| 11 | 10 | use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template; |
| 12 | 11 | use Symfony\Component\Form\Extension\Core\Type\SubmitType; |
| 13 | 12 | |
@@ -30,10 +30,10 @@ discard block |
||
| 30 | 30 | $em = $this->getDoctrine()->getManager(); |
| 31 | 31 | $users = $em->getRepository('AppBundle:User')->findUsersWithoutRole(User::ROLE_ADMIN); |
| 32 | 32 | |
| 33 | - $form_delete = []; |
|
| 33 | + $form_delete = [ ]; |
|
| 34 | 34 | |
| 35 | 35 | foreach ($users as $item) { |
| 36 | - $form_delete[$item->getId()] = $this->createFormDelete($item->getId())->createView(); |
|
| 36 | + $form_delete[ $item->getId() ] = $this->createFormDelete($item->getId())->createView(); |
|
| 37 | 37 | } |
| 38 | 38 | |
| 39 | 39 | return [ |
@@ -97,13 +97,13 @@ discard block |
||
| 97 | 97 | private function createFormDelete($id) |
| 98 | 98 | { |
| 99 | 99 | return $this->createFormBuilder() |
| 100 | - ->setAction($this->generateUrl('user_delete', ['id' => $id])) |
|
| 100 | + ->setAction($this->generateUrl('user_delete', [ 'id' => $id ])) |
|
| 101 | 101 | ->setMethod('DELETE') |
| 102 | - ->add('submit', SubmitType::class, ['label' => ' ', |
|
| 102 | + ->add('submit', SubmitType::class, [ 'label' => ' ', |
|
| 103 | 103 | 'attr' => [ |
| 104 | 104 | 'class' => 'glyphicon glyphicon-remove btn-link', |
| 105 | 105 | 'onclick' => 'return confirm("Are you sure?")' |
| 106 | - ]]) |
|
| 106 | + ] ]) |
|
| 107 | 107 | ->getForm(); |
| 108 | 108 | } |
| 109 | 109 | } |
| 110 | 110 | \ No newline at end of file |
@@ -1,23 +1,15 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | namespace AppBundle\Services; |
| 3 | 3 | |
| 4 | -use AppBundle\Entity\Comment; |
|
| 5 | 4 | use AppBundle\Entity\ModuleUser; |
| 6 | 5 | use AppBundle\Entity\PassModule; |
| 7 | 6 | use AppBundle\Form\AnswerForPassType; |
| 8 | -use AppBundle\Form\CommentType; |
|
| 9 | 7 | use AppBundle\Traits\GenerateOutput; |
| 10 | 8 | use Faker\Provider\cs_CZ\DateTime; |
| 11 | -use Knp\Component\Pager\PaginatorInterface; |
|
| 12 | -use Proxies\__CG__\AppBundle\Entity\Module; |
|
| 13 | 9 | use Symfony\Bridge\Doctrine\RegistryInterface; |
| 14 | 10 | use Symfony\Component\Form\Extension\Core\Type\SubmitType; |
| 15 | 11 | use Symfony\Component\Form\FormFactoryInterface; |
| 16 | -use Symfony\Component\HttpFoundation\RedirectResponse; |
|
| 17 | 12 | use Symfony\Component\HttpFoundation\Request; |
| 18 | -use Symfony\Component\HttpKernel\CacheWarmer\WarmableInterface; |
|
| 19 | -use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; |
|
| 20 | -use Symfony\Component\Routing\RouterInterface; |
|
| 21 | 13 | use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface; |
| 22 | 14 | |
| 23 | 15 | class PassManager |
@@ -81,7 +81,7 @@ discard block |
||
| 81 | 81 | $dateEstimate = $pass->getTimeStart() |
| 82 | 82 | ->modify("+{$pass->getTimePeriod()} minutes"); |
| 83 | 83 | |
| 84 | - if($nowDate > $dateEstimate){ |
|
| 84 | + if ($nowDate > $dateEstimate) { |
|
| 85 | 85 | // $pass->setIsActive(false); |
| 86 | 86 | // $this->doctrine->getEntityManager()->flush(); |
| 87 | 87 | $this->deactivation->deactivation($pass); |
@@ -137,14 +137,14 @@ discard block |
||
| 137 | 137 | $firstQuestionForPass = $this->doctrine->getRepository('AppBundle:Question') |
| 138 | 138 | ->getFirstQuestionForPass($passModule->getId()); |
| 139 | 139 | |
| 140 | - if(null === $firstQuestionForPass) |
|
| 140 | + if (null === $firstQuestionForPass) |
|
| 141 | 141 | return $this->generateOutput('error', 500, 'This module does not have any questions ;('); |
| 142 | 142 | |
| 143 | 143 | $passModule->setCurrentQuestion($firstQuestionForPass); |
| 144 | 144 | $this->doctrine->getEntityManager()->flush(); |
| 145 | 145 | } |
| 146 | 146 | |
| 147 | - if(!($passModule->getIsActive())){ |
|
| 147 | + if (!($passModule->getIsActive())) { |
|
| 148 | 148 | return $this->generateOutput('error', 403, 'This pass is not active ;('); |
| 149 | 149 | } |
| 150 | 150 | |
@@ -161,9 +161,9 @@ discard block |
||
| 161 | 161 | 'idPassModule' => $idPassModule, |
| 162 | 162 | 'answers' => $currentQuestion->getAnswers()->toArray() |
| 163 | 163 | ]); |
| 164 | - $form->add('submit', SubmitType::class, ['label' => 'Save', 'attr' => [ 'class' => 'btn btn-primary' ]]); |
|
| 164 | + $form->add('submit', SubmitType::class, [ 'label' => 'Save', 'attr' => [ 'class' => 'btn btn-primary' ] ]); |
|
| 165 | 165 | |
| 166 | - $currentNumberQuestion = $passModule->getCountPassedQuestions()+1; |
|
| 166 | + $currentNumberQuestion = $passModule->getCountPassedQuestions() + 1; |
|
| 167 | 167 | |
| 168 | 168 | return $this->generateOutput('ok', 200, [ |
| 169 | 169 | $form, |
@@ -41,7 +41,7 @@ discard block |
||
| 41 | 41 | { |
| 42 | 42 | $em = $this->em; |
| 43 | 43 | $type = $response->getResourceOwner()->getName(); |
| 44 | - $user = $em->getRepository('AppBundle:User')->findOneBy(['email' => $response->getEmail()]); |
|
| 44 | + $user = $em->getRepository('AppBundle:User')->findOneBy([ 'email' => $response->getEmail() ]); |
|
| 45 | 45 | if ($user === null) { |
| 46 | 46 | $user = new User(); |
| 47 | 47 | $user->setEmail($response->getEmail()) |
@@ -89,7 +89,7 @@ discard block |
||
| 89 | 89 | */ |
| 90 | 90 | public function loadUserByUsername($username) |
| 91 | 91 | { |
| 92 | - $user = $this->em->getRepository('AppBundle:User')->findOneBy(['email' => $username]); |
|
| 92 | + $user = $this->em->getRepository('AppBundle:User')->findOneBy([ 'email' => $username ]); |
|
| 93 | 93 | if (!$user) { |
| 94 | 94 | throw new UsernameNotFoundException(sprintf("User '%s' not found.", $username)); |
| 95 | 95 | } |
@@ -24,7 +24,7 @@ discard block |
||
| 24 | 24 | { |
| 25 | 25 | $em = $this->doctrine->getManager(); |
| 26 | 26 | $question = $em->getRepository('AppBundle:Question') |
| 27 | - ->find($data['idQuestion']); |
|
| 27 | + ->find($data[ 'idQuestion' ]); |
|
| 28 | 28 | |
| 29 | 29 | $originalAnswers = $question->getAnswers(); |
| 30 | 30 | $countOriginalAnswers = $question->getCountAnswers(); |
@@ -37,8 +37,8 @@ discard block |
||
| 37 | 37 | |
| 38 | 38 | foreach ($originalAnswers as $item) { |
| 39 | 39 | $item->getCorrectly() ? $countAllTrueAnswers++ : null; |
| 40 | - $data["answer_{$item->getId()}"] ? $countAllChecks++ : null; |
|
| 41 | - if ($item->getCorrectly() === $data["answer_{$item->getId()}"]) { |
|
| 40 | + $data[ "answer_{$item->getId()}" ] ? $countAllChecks++ : null; |
|
| 41 | + if ($item->getCorrectly() === $data[ "answer_{$item->getId()}" ]) { |
|
| 42 | 42 | $sumAllCorrect++; |
| 43 | 43 | if ($item->getCorrectly()) |
| 44 | 44 | $sumCorrectChecks++; |
@@ -55,8 +55,8 @@ discard block |
||
| 55 | 55 | $maxCountAnswers = $countAllTrueAnswers; |
| 56 | 56 | } |
| 57 | 57 | |
| 58 | - if ($question->getAllIncorrect() || $data['answer_all_incorrect']) { |
|
| 59 | - if ($question->getAllIncorrect() === $data['answer_all_incorrect'] && $question->getAllIncorrect() === true && |
|
| 58 | + if ($question->getAllIncorrect() || $data[ 'answer_all_incorrect' ]) { |
|
| 59 | + if ($question->getAllIncorrect() === $data[ 'answer_all_incorrect' ] && $question->getAllIncorrect() === true && |
|
| 60 | 60 | $sumAllCorrect == $countOriginalAnswers |
| 61 | 61 | ) |
| 62 | 62 | return $result = 1; |
@@ -68,7 +68,7 @@ discard block |
||
| 68 | 68 | if ($sumAllCorrect && $sumCorrectChecks && $countAllChecks <= $maxCountAnswers) { |
| 69 | 69 | // second type question |
| 70 | 70 | if ($countAllTrueAnswers == 1) { |
| 71 | - $result = (1 / $maxCountAnswers) * ($sumCorrectChecks + ($sumFalseAnswers > 0 ? 0: 1)); |
|
| 71 | + $result = (1 / $maxCountAnswers) * ($sumCorrectChecks + ($sumFalseAnswers > 0 ? 0 : 1)); |
|
| 72 | 72 | } |
| 73 | 73 | // third type question |
| 74 | 74 | elseif ($countAllTrueAnswers > 1) { |