@@ -1,10 +1,10 @@ |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * Created by PhpStorm. |
|
4 | - * User: device |
|
5 | - * Date: 18.03.16 |
|
6 | - * Time: 17:58 |
|
7 | - */ |
|
3 | + * Created by PhpStorm. |
|
4 | + * User: device |
|
5 | + * Date: 18.03.16 |
|
6 | + * Time: 17:58 |
|
7 | + */ |
|
8 | 8 | |
9 | 9 | namespace AppBundle\Tests\Controller; |
10 | 10 |
@@ -23,25 +23,25 @@ discard block |
||
23 | 23 | 'placeholder' => 'enter title' |
24 | 24 | ] |
25 | 25 | ]) |
26 | - ->add('rating', TextType::class,[ |
|
26 | + ->add('rating', TextType::class, [ |
|
27 | 27 | 'attr' => [ |
28 | 28 | 'class' => 'form-control', |
29 | 29 | 'placeholder' => 'enter rating' |
30 | 30 | ] |
31 | 31 | ]) |
32 | - ->add('persentSuccess', TextType::class,[ |
|
32 | + ->add('persentSuccess', TextType::class, [ |
|
33 | 33 | 'attr' => [ |
34 | 34 | 'class' => 'form-control', |
35 | 35 | 'placeholder' => 'enter persent' |
36 | 36 | ] |
37 | 37 | ]) |
38 | - ->add('time', TextType::class,[ |
|
38 | + ->add('time', TextType::class, [ |
|
39 | 39 | 'attr' => [ |
40 | 40 | 'class' => 'form-control', |
41 | 41 | 'placeholder' => 'enter time' |
42 | 42 | ] |
43 | 43 | ]) |
44 | - ->add('attempts', TextType::class,[ |
|
44 | + ->add('attempts', TextType::class, [ |
|
45 | 45 | 'attr' => [ |
46 | 46 | 'class' => 'form-control', |
47 | 47 | 'placeholder' => 'enter attempts' |
@@ -49,19 +49,19 @@ discard block |
||
49 | 49 | ]) |
50 | 50 | ->add('category', EntityType::class, [ |
51 | 51 | 'class' => 'AppBundle\Entity\Category', |
52 | - 'query_builder' => function (EntityRepository $er) { |
|
52 | + 'query_builder' => function(EntityRepository $er) { |
|
53 | 53 | return $er->createQueryBuilder('c') |
54 | 54 | ->orderBy('c.title', 'ASC'); |
55 | 55 | }, |
56 | 56 | 'label' => 'Category', |
57 | 57 | 'property' => 'title', |
58 | - 'attr' => ['class' => 'chosen-select'], |
|
58 | + 'attr' => [ 'class' => 'chosen-select' ], |
|
59 | 59 | 'required' => true |
60 | 60 | ]) |
61 | 61 | ->add('module_image', FileType::class, [ |
62 | 62 | 'required' => false |
63 | 63 | ]) |
64 | - ->addEventListener(FormEvents::POST_SUBMIT, function(FormEvent $event) { |
|
64 | + ->addEventListener(FormEvents::POST_SUBMIT, function(FormEvent $event) { |
|
65 | 65 | $data = $event->getData(); |
66 | 66 | |
67 | 67 |
@@ -12,17 +12,17 @@ |
||
12 | 12 | { |
13 | 13 | public function buildForm(FormBuilderInterface $builder, array $options) |
14 | 14 | { |
15 | - $user = $options['user']; |
|
15 | + $user = $options[ 'user' ]; |
|
16 | 16 | |
17 | 17 | $builder |
18 | 18 | ->add('module', EntityType::class, [ |
19 | 19 | 'class' => 'AppBundle\Entity\Module', |
20 | - 'query_builder' => function (EntityRepository $er) use ($user) { |
|
20 | + 'query_builder' => function(EntityRepository $er) use ($user) { |
|
21 | 21 | return $er->getFreeModulesForUserQuery($user); |
22 | 22 | }, |
23 | 23 | 'label' => 'Choose module', |
24 | 24 | 'property' => 'title', |
25 | - 'attr' => ['class' => 'chosen-select'], |
|
25 | + 'attr' => [ 'class' => 'chosen-select' ], |
|
26 | 26 | 'required' => true |
27 | 27 | ]); |
28 | 28 | } |
@@ -14,9 +14,9 @@ discard block |
||
14 | 14 | { |
15 | 15 | public function buildForm(FormBuilderInterface $builder, array $options) |
16 | 16 | { |
17 | - $answers = $options['answers']; |
|
18 | - $idQuestion = $options['idQuestion']; |
|
19 | - $idPassModule = $options['idPassModule']; |
|
17 | + $answers = $options[ 'answers' ]; |
|
18 | + $idQuestion = $options[ 'idQuestion' ]; |
|
19 | + $idPassModule = $options[ 'idPassModule' ]; |
|
20 | 20 | |
21 | 21 | $builder |
22 | 22 | ->add('idQuestion', HiddenType::class, [ |
@@ -26,14 +26,14 @@ discard block |
||
26 | 26 | 'data' => $idPassModule, |
27 | 27 | ]); |
28 | 28 | |
29 | - foreach($answers as $answer){ |
|
30 | - $builder->add('answer_' . $answer->getId(), CheckboxType::class,[ |
|
29 | + foreach ($answers as $answer) { |
|
30 | + $builder->add('answer_' . $answer->getId(), CheckboxType::class, [ |
|
31 | 31 | 'label' => $answer->getTextAnswer(), |
32 | 32 | 'required' => false |
33 | 33 | ]); |
34 | 34 | } |
35 | 35 | |
36 | - $builder->add('answer_all_incorrect', CheckboxType::class,[ |
|
36 | + $builder->add('answer_all_incorrect', CheckboxType::class, [ |
|
37 | 37 | 'label'=>'Question has no correct answers', |
38 | 38 | 'required' => false |
39 | 39 | ]); |
@@ -13,14 +13,14 @@ |
||
13 | 13 | public function buildForm(FormBuilderInterface $builder, array $options) |
14 | 14 | { |
15 | 15 | $builder |
16 | - ->add('textAnswer', TextType::class,[ |
|
16 | + ->add('textAnswer', TextType::class, [ |
|
17 | 17 | 'attr' => [ |
18 | 18 | 'class' => 'form-control', |
19 | 19 | 'placeholder' => 'enter answer', |
20 | 20 | 'style' => 'width:400px;' |
21 | 21 | ] |
22 | 22 | ]) |
23 | - ->add('correctly', CheckboxType::class,[ |
|
23 | + ->add('correctly', CheckboxType::class, [ |
|
24 | 24 | 'required' => false |
25 | 25 | ]); |
26 | 26 | // ->add('question', HiddenType::class); |
@@ -47,7 +47,7 @@ |
||
47 | 47 | ], |
48 | 48 | |
49 | 49 | ]) |
50 | - ->addEventListener(FormEvents::POST_SUBMIT, function(FormEvent $event) { |
|
50 | + ->addEventListener(FormEvents::POST_SUBMIT, function(FormEvent $event) { |
|
51 | 51 | $data = $event->getData(); |
52 | 52 | |
53 | 53 | foreach ($data->getAnswers() as $item) { |
@@ -89,7 +89,7 @@ discard block |
||
89 | 89 | { |
90 | 90 | $this->isActive = true; |
91 | 91 | $this->rating = 0; |
92 | - $this->answeredQuestionIds = []; |
|
92 | + $this->answeredQuestionIds = [ ]; |
|
93 | 93 | } |
94 | 94 | |
95 | 95 | |
@@ -236,7 +236,7 @@ discard block |
||
236 | 236 | */ |
237 | 237 | public function addAnsweredQuestionId($questionId) |
238 | 238 | { |
239 | - $this->answeredQuestionIds[] = $questionId; |
|
239 | + $this->answeredQuestionIds[ ] = $questionId; |
|
240 | 240 | |
241 | 241 | return $this; |
242 | 242 | } |
@@ -250,18 +250,18 @@ discard block |
||
250 | 250 | { |
251 | 251 | $countQuestions = $this->getModuleUser()->getModule()->getCountQuestions(); |
252 | 252 | $maxResult = $this->getModuleUser()->getModule()->getRating(); |
253 | - return $this->rating * $maxResult / $countQuestions ; |
|
253 | + return $this->rating * $maxResult / $countQuestions; |
|
254 | 254 | } |
255 | 255 | |
256 | 256 | public function getPercentResult() |
257 | 257 | { |
258 | 258 | $countQuestions = $this->getModuleUser()->getModule()->getCountQuestions(); |
259 | - return $this->rating * 100 / $countQuestions ; |
|
259 | + return $this->rating * 100 / $countQuestions; |
|
260 | 260 | } |
261 | 261 | |
262 | 262 | public function getStateResult() |
263 | 263 | { |
264 | - if($this->timeFinish === null) |
|
264 | + if ($this->timeFinish === null) |
|
265 | 265 | return self::STATE_EXPIRED; |
266 | 266 | |
267 | 267 | return $this->getPercentResult() >= $this->getModuleUser()->getModule()->getPersentSuccess() ? |
@@ -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; |
@@ -34,7 +34,7 @@ discard block |
||
34 | 34 | |
35 | 35 | } |
36 | 36 | |
37 | - return ['form' => $form->createView()]; |
|
37 | + return [ 'form' => $form->createView() ]; |
|
38 | 38 | } |
39 | 39 | |
40 | 40 | /** |
@@ -57,8 +57,8 @@ discard block |
||
57 | 57 | return $this->redirectToRoute('show_module'); |
58 | 58 | } |
59 | 59 | |
60 | - return ['module' => $module, |
|
61 | - 'form' => $form->createView()]; |
|
60 | + return [ 'module' => $module, |
|
61 | + 'form' => $form->createView() ]; |
|
62 | 62 | } |
63 | 63 | |
64 | 64 | /** |
@@ -88,12 +88,12 @@ discard block |
||
88 | 88 | $em = $this->getDoctrine()->getManager(); |
89 | 89 | |
90 | 90 | $module = $em->getRepository('AppBundle:Module') |
91 | - ->findBy([],['createdAt' => 'DESC']); |
|
91 | + ->findBy([ ], [ 'createdAt' => 'DESC' ]); |
|
92 | 92 | |
93 | - $form_delete = []; |
|
93 | + $form_delete = [ ]; |
|
94 | 94 | |
95 | 95 | foreach ($module as $item) { |
96 | - $form_delete[$item->getId()] = $this->createFormDelete($item->getId())->createView(); |
|
96 | + $form_delete[ $item->getId() ] = $this->createFormDelete($item->getId())->createView(); |
|
97 | 97 | } |
98 | 98 | |
99 | 99 | return [ |
@@ -109,7 +109,7 @@ discard block |
||
109 | 109 | private function createFormDelete($id) |
110 | 110 | { |
111 | 111 | return $this->createFormBuilder() |
112 | - ->setAction($this->generateUrl('remove_module', ['id' => $id])) |
|
112 | + ->setAction($this->generateUrl('remove_module', [ 'id' => $id ])) |
|
113 | 113 | ->setMethod('DELETE') |
114 | 114 | ->add('submit', SubmitType::class, [ |
115 | 115 | 'label' => ' ', |
@@ -26,10 +26,10 @@ |
||
26 | 26 | $modulesUser = $em->getRepository('AppBundle:ModuleUser') |
27 | 27 | ->findInfoPassModules($module); |
28 | 28 | |
29 | - return new Response(json_encode(['modulesUser' => $modulesUser])); |
|
29 | + return new Response(json_encode([ 'modulesUser' => $modulesUser ])); |
|
30 | 30 | } |
31 | 31 | |
32 | 32 | |
33 | - return ['modules' => $allmodules]; |
|
33 | + return [ 'modules' => $allmodules ]; |
|
34 | 34 | } |
35 | 35 | } |