@@ -42,9 +42,11 @@ |
||
| 42 | 42 | |
| 43 | 43 | $em = $this->doctrine->getManager(); |
| 44 | 44 | $user = $em->getRepository('AppBundle:User')->findBy(['email' => $email]); |
| 45 | - if (!$user) |
|
| 46 | - $user = new User(); |
|
| 47 | - else $user = $user[0]; |
|
| 45 | + if (!$user) { |
|
| 46 | + $user = new User(); |
|
| 47 | + } else { |
|
| 48 | + $user = $user[0]; |
|
| 49 | + } |
|
| 48 | 50 | |
| 49 | 51 | $pass = $this->userPasswordEncoder->encodePassword($user, $password); |
| 50 | 52 | $user->setEmail($email); |
@@ -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; |
@@ -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 | |
@@ -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 |
@@ -56,8 +56,9 @@ discard block |
||
| 56 | 56 | return $this->generateOutput('error', 403, 'You do not have access to this module'); |
| 57 | 57 | } |
| 58 | 58 | |
| 59 | - if ($moduleUser->getAttempts() == $moduleUser->getModule()->getAttempts()) |
|
| 60 | - return $this->generateOutput('error', 403, 'Your attempts are exhausted'); |
|
| 59 | + if ($moduleUser->getAttempts() == $moduleUser->getModule()->getAttempts()) { |
|
| 60 | + return $this->generateOutput('error', 403, 'Your attempts are exhausted'); |
|
| 61 | + } |
|
| 61 | 62 | |
| 62 | 63 | $lastPass = $moduleUser->getPassModules()->last(); |
| 63 | 64 | |
@@ -68,8 +69,9 @@ discard block |
||
| 68 | 69 | |
| 69 | 70 | $time_residue = $this->checkDatePass($lastPass); |
| 70 | 71 | |
| 71 | - if (!$time_residue) |
|
| 72 | - $this->identPass($idModule); |
|
| 72 | + if (!$time_residue) { |
|
| 73 | + $this->identPass($idModule); |
|
| 74 | + } |
|
| 73 | 75 | |
| 74 | 76 | return $this->generateOutput('redirect_to_pass', 301, $lastPass->getId()); |
| 75 | 77 | } |
@@ -137,8 +139,9 @@ discard block |
||
| 137 | 139 | $firstQuestionForPass = $this->doctrine->getRepository('AppBundle:Question') |
| 138 | 140 | ->getFirstQuestionForPass($passModule->getId()); |
| 139 | 141 | |
| 140 | - if(null === $firstQuestionForPass) |
|
| 141 | - return $this->generateOutput('error', 500, 'This module does not have any questions ;('); |
|
| 142 | + if(null === $firstQuestionForPass) { |
|
| 143 | + return $this->generateOutput('error', 500, 'This module does not have any questions ;('); |
|
| 144 | + } |
|
| 142 | 145 | |
| 143 | 146 | $passModule->setCurrentQuestion($firstQuestionForPass); |
| 144 | 147 | $this->doctrine->getEntityManager()->flush(); |
@@ -150,8 +153,9 @@ discard block |
||
| 150 | 153 | |
| 151 | 154 | $time_residue = $this->checkDatePass($passModule); |
| 152 | 155 | |
| 153 | - if (!$time_residue) |
|
| 154 | - return $this->generateOutput('error', 403, 'This pass is overdue ;('); |
|
| 156 | + if (!$time_residue) { |
|
| 157 | + return $this->generateOutput('error', 403, 'This pass is overdue ;('); |
|
| 158 | + } |
|
| 155 | 159 | |
| 156 | 160 | |
| 157 | 161 | $currentQuestion = $passModule->getCurrentQuestion(); |
@@ -64,8 +64,7 @@ |
||
| 64 | 64 | $result = $sumTrueCorrect != 0 ? 1 / $sumTrueCorrect / 2 : 0; |
| 65 | 65 | } elseif ($countFalseAnswers > 1) { |
| 66 | 66 | $result = 0; |
| 67 | - } |
|
| 68 | - else { |
|
| 67 | + } else { |
|
| 69 | 68 | $result = $sumTrueCorrect != 0 ? 1 / $sumTrueCorrect : 0; |
| 70 | 69 | } |
| 71 | 70 | //third type question |
@@ -261,8 +261,9 @@ |
||
| 261 | 261 | |
| 262 | 262 | public function getStateResult() |
| 263 | 263 | { |
| 264 | - if($this->timeFinish === null) |
|
| 265 | - return self::STATE_EXPIRED; |
|
| 264 | + if($this->timeFinish === null) { |
|
| 265 | + return self::STATE_EXPIRED; |
|
| 266 | + } |
|
| 266 | 267 | |
| 267 | 268 | return $this->getPercentResult() >= $this->getModuleUser()->getModule()->getPersentSuccess() ? |
| 268 | 269 | self::STATE_PASSED : self::STATE_FAILED; |
@@ -40,8 +40,9 @@ discard block |
||
| 40 | 40 | $data["answer_{$item->getId()}"] ? $countAllChecks++ : null; |
| 41 | 41 | if ($item->getCorrectly() === $data["answer_{$item->getId()}"]) { |
| 42 | 42 | $sumAllCorrect++; |
| 43 | - if ($item->getCorrectly()) |
|
| 44 | - $sumCorrectChecks++; |
|
| 43 | + if ($item->getCorrectly()) { |
|
| 44 | + $sumCorrectChecks++; |
|
| 45 | + } |
|
| 45 | 46 | } else { |
| 46 | 47 | if ($item->getCorrectly() === false) { |
| 47 | 48 | $sumFalseAnswers++; |
@@ -58,8 +59,9 @@ discard block |
||
| 58 | 59 | if ($question->getAllIncorrect() || $data['answer_all_incorrect']) { |
| 59 | 60 | if ($question->getAllIncorrect() === $data['answer_all_incorrect'] && $question->getAllIncorrect() === true && |
| 60 | 61 | $sumAllCorrect == $countOriginalAnswers |
| 61 | - ) |
|
| 62 | - return 1; |
|
| 62 | + ) { |
|
| 63 | + return 1; |
|
| 64 | + } |
|
| 63 | 65 | |
| 64 | 66 | return 0; |
| 65 | 67 | } |
@@ -7,7 +7,6 @@ |
||
| 7 | 7 | use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route; |
| 8 | 8 | use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template; |
| 9 | 9 | use Symfony\Component\HttpFoundation\Request; |
| 10 | -use Symfony\Component\HttpFoundation\Response; |
|
| 11 | 10 | |
| 12 | 11 | class AccountController extends Controller |
| 13 | 12 | { |
@@ -57,11 +57,13 @@ |
||
| 57 | 57 | ->getDonePassModuleByIdAndUser($idPass,$this->getUser()->getId()) |
| 58 | 58 | ; |
| 59 | 59 | |
| 60 | - if($passModule === null) |
|
| 61 | - throw new HttpException(403, 'You don\'t have permission for look this data'); |
|
| 60 | + if($passModule === null) { |
|
| 61 | + throw new HttpException(403, 'You don\'t have permission for look this data'); |
|
| 62 | + } |
|
| 62 | 63 | |
| 63 | - if($passModule->getStateResult() === PassModule::STATE_EXPIRED) |
|
| 64 | - throw new HttpException(403, 'This pass expired.'); |
|
| 64 | + if($passModule->getStateResult() === PassModule::STATE_EXPIRED) { |
|
| 65 | + throw new HttpException(403, 'This pass expired.'); |
|
| 66 | + } |
|
| 65 | 67 | |
| 66 | 68 | return ['passModule' => $passModule]; |
| 67 | 69 | } |