{"action":"created","comment":{"url":"https://api.github.com/repos/framgia/fels_75/pulls/comments/38616068","id":38616068,"diff_hunk":"@@ -2,54 +2,92 @@\n \n namespace ElearningBundle\\Controller;\n \n+use ElearningBundle\\Entity\\Answer;\n+use ElearningBundle\\Form\\DoLessonType;\n use Symfony\\Bundle\\FrameworkBundle\\Controller\\Controller;\n use Sensio\\Bundle\\FrameworkExtraBundle\\Configuration\\Route;\n use Sensio\\Bundle\\FrameworkExtraBundle\\Configuration\\Template;\n+use Sensio\\Bundle\\FrameworkExtraBundle\\Configuration\\Method;\n use ElearningBundle\\Entity\\Category;\n use ElearningBundle\\Entity\\Result;\n use ElearningBundle\\Entity\\Lesson;\n use ElearningBundle\\Entity\\Word;\n+use Symfony\\Component\\HttpFoundation\\Request;\n \n class LessonController extends Controller\n {\n     /**\n      * @Route(\"/categories/{categoryId}/lesson/new\", name=\"create_lesson\")\n+     * @Method(\"POST\")\n      * @Template()\n      */\n-    public function createAction($categoryId)\n+    public function createAction(Request $request, $categoryId)\n     {\n         $user = $this->getUser();\n         $em = $this->getDoctrine()->getManager();\n         $category = $em->getRepository('ElearningBundle:Category')->find($categoryId);\n-        if ($category->isEnoughWords()) {\n+        $lesson_learned = $em->getRepository('ElearningBundle:Lesson')->getLessonLearned($this->getUser());\n+        $result_learned = $em->getRepository('ElearningBundle:Result')->getResultFromLesson($lesson_learned);\n+        $words = $em->getRepository('ElearningBundle:Word')->getWordsForLesson($category, $result_learned);\n+\n+        if (count($words) >= $this->container->getParameter('word_per_lesson')) {\n             $lesson = new Lesson();\n             $lesson->setCategory($category);\n             $lesson->setUser($user);\n-            $words = $em->getRepository('ElearningBundle:Word')->getWordsForLesson($category, count($category->getWords()));\n+            shuffle($words);\n+            $words = array_slice($words, 0, $this->container->getParameter('word_per_lesson'));\n             foreach ($words as $word) {\n                 $result = new Result();\n                 $result->setLesson($lesson);\n                 $result->setWord($word);\n                 $em->persist($result);\n+                $lesson->addResult($result);\n             }\n             $em->persist($lesson);\n             $em->flush();\n+            $this->addFlash('success', 'Yay do lesson now !!!');\n \n-            return $this->redirectToRoute('do_lesson');\n+            return $this->redirectToRoute('do_lesson', ['lesson' => $lesson->getId()]);\n         } else {\n-            $this->addFlash('danger', 'Not enough word to create lesson !!!');\n+            $this->addFlash('danger', 'Sorry ! Not enough word to create lesson !!!');\n \n             return $this->redirectToRoute('elearning_homepage');\n         }\n     }\n \n     /**\n-     * @Route(\"/lesson/{id}/do\", name=\"do_lesson\")\n+     * @Route(\"/lesson/{lesson}/start\", name=\"do_lesson\")\n+     * @Method({\"GET\",\"POST\"})\n      * @Template()\n      */\n-    public function doAction($id)\n-    {\n+    public function doAction(Request $request,Lesson $lesson) {\n+        $form = $this->createForm(new DoLessonType(), $lesson);\n+        $form->handleRequest($request);\n+        if ($form->isValid() && $form->isSubmitted()) {\n+            foreach($_POST as $key => $value) {","path":"src/ElearningBundle/Controller/LessonController.php","position":74,"original_position":74,"commit_id":"c7676eec48ebf93d8abcd28018b86b2ae39d82fd","original_commit_id":"c7676eec48ebf93d8abcd28018b86b2ae39d82fd","user":{"login":"dinhhoanglong91","id":1893820,"avatar_url":"https://avatars.githubusercontent.com/u/1893820?v=3","gravatar_id":"","url":"https://api.github.com/users/dinhhoanglong91","html_url":"https://github.com/dinhhoanglong91","followers_url":"https://api.github.com/users/dinhhoanglong91/followers","following_url":"https://api.github.com/users/dinhhoanglong91/following{/other_user}","gists_url":"https://api.github.com/users/dinhhoanglong91/gists{/gist_id}","starred_url":"https://api.github.com/users/dinhhoanglong91/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dinhhoanglong91/subscriptions","organizations_url":"https://api.github.com/users/dinhhoanglong91/orgs","repos_url":"https://api.github.com/users/dinhhoanglong91/repos","events_url":"https://api.github.com/users/dinhhoanglong91/events{/privacy}","received_events_url":"https://api.github.com/users/dinhhoanglong91/received_events","type":"User","site_admin":false},"body":"Convention","created_at":"2015-09-03T06:20:38Z","updated_at":"2015-09-03T06:20:38Z","html_url":"https://github.com/framgia/fels_75/pull/12#discussion_r38616068","pull_request_url":"https://api.github.com/repos/framgia/fels_75/pulls/12","_links":{"self":{"href":"https://api.github.com/repos/framgia/fels_75/pulls/comments/38616068"},"html":{"href":"https://github.com/framgia/fels_75/pull/12#discussion_r38616068"},"pull_request":{"href":"https://api.github.com/repos/framgia/fels_75/pulls/12"}}},"pull_request":{"url":"https://api.github.com/repos/framgia/fels_75/pulls/12","id":44068092,"html_url":"https://github.com/framgia/fels_75/pull/12","diff_url":"https://github.com/framgia/fels_75/pull/12.diff","patch_url":"https://github.com/framgia/fels_75/pull/12.patch","issue_url":"https://api.github.com/repos/framgia/fels_75/issues/12","number":12,"state":"open","locked":false,"title":"Do lesson","user":{"login":"MichalPlachyFramgia","id":12692498,"avatar_url":"https://avatars.githubusercontent.com/u/12692498?v=3","gravatar_id":"","url":"https://api.github.com/users/MichalPlachyFramgia","html_url":"https://github.com/MichalPlachyFramgia","followers_url":"https://api.github.com/users/MichalPlachyFramgia/followers","following_url":"https://api.github.com/users/MichalPlachyFramgia/following{/other_user}","gists_url":"https://api.github.com/users/MichalPlachyFramgia/gists{/gist_id}","starred_url":"https://api.github.com/users/MichalPlachyFramgia/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/MichalPlachyFramgia/subscriptions","organizations_url":"https://api.github.com/users/MichalPlachyFramgia/orgs","repos_url":"https://api.github.com/users/MichalPlachyFramgia/repos","events_url":"https://api.github.com/users/MichalPlachyFramgia/events{/privacy}","received_events_url":"https://api.github.com/users/MichalPlachyFramgia/received_events","type":"User","site_admin":false},"body":"","created_at":"2015-09-03T04:16:51Z","updated_at":"2015-09-03T06:20:38Z","closed_at":null,"merged_at":null,"merge_commit_sha":"6a3cde6c960b237f726bfb45bad24487866df3bc","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/framgia/fels_75/pulls/12/commits","review_comments_url":"https://api.github.com/repos/framgia/fels_75/pulls/12/comments","review_comment_url":"https://api.github.com/repos/framgia/fels_75/pulls/comments{/number}","comments_url":"https://api.github.com/repos/framgia/fels_75/issues/12/comments","statuses_url":"https://api.github.com/repos/framgia/fels_75/statuses/c7676eec48ebf93d8abcd28018b86b2ae39d82fd","head":{"label":"MichalPlachyFramgia:word_filter","ref":"word_filter","sha":"c7676eec48ebf93d8abcd28018b86b2ae39d82fd","user":{"login":"MichalPlachyFramgia","id":12692498,"avatar_url":"https://avatars.githubusercontent.com/u/12692498?v=3","gravatar_id":"","url":"https://api.github.com/users/MichalPlachyFramgia","html_url":"https://github.com/MichalPlachyFramgia","followers_url":"https://api.github.com/users/MichalPlachyFramgia/followers","following_url":"https://api.github.com/users/MichalPlachyFramgia/following{/other_user}","gists_url":"https://api.github.com/users/MichalPlachyFramgia/gists{/gist_id}","starred_url":"https://api.github.com/users/MichalPlachyFramgia/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/MichalPlachyFramgia/subscriptions","organizations_url":"https://api.github.com/users/MichalPlachyFramgia/orgs","repos_url":"https://api.github.com/users/MichalPlachyFramgia/repos","events_url":"https://api.github.com/users/MichalPlachyFramgia/events{/privacy}","received_events_url":"https://api.github.com/users/MichalPlachyFramgia/received_events","type":"User","site_admin":false},"repo":{"id":40957574,"name":"fels_75","full_name":"MichalPlachyFramgia/fels_75","owner":{"login":"MichalPlachyFramgia","id":12692498,"avatar_url":"https://avatars.githubusercontent.com/u/12692498?v=3","gravatar_id":"","url":"https://api.github.com/users/MichalPlachyFramgia","html_url":"https://github.com/MichalPlachyFramgia","followers_url":"https://api.github.com/users/MichalPlachyFramgia/followers","following_url":"https://api.github.com/users/MichalPlachyFramgia/following{/other_user}","gists_url":"https://api.github.com/users/MichalPlachyFramgia/gists{/gist_id}","starred_url":"https://api.github.com/users/MichalPlachyFramgia/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/MichalPlachyFramgia/subscriptions","organizations_url":"https://api.github.com/users/MichalPlachyFramgia/orgs","repos_url":"https://api.github.com/users/MichalPlachyFramgia/repos","events_url":"https://api.github.com/users/MichalPlachyFramgia/events{/privacy}","received_events_url":"https://api.github.com/users/MichalPlachyFramgia/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/MichalPlachyFramgia/fels_75","description":"Framgia E-Learning System (training)","fork":true,"url":"https://api.github.com/repos/MichalPlachyFramgia/fels_75","forks_url":"https://api.github.com/repos/MichalPlachyFramgia/fels_75/forks","keys_url":"https://api.github.com/repos/MichalPlachyFramgia/fels_75/keys{/key_id}","collaborators_url":"https://api.github.com/repos/MichalPlachyFramgia/fels_75/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/MichalPlachyFramgia/fels_75/teams","hooks_url":"https://api.github.com/repos/MichalPlachyFramgia/fels_75/hooks","issue_events_url":"https://api.github.com/repos/MichalPlachyFramgia/fels_75/issues/events{/number}","events_url":"https://api.github.com/repos/MichalPlachyFramgia/fels_75/events","assignees_url":"https://api.github.com/repos/MichalPlachyFramgia/fels_75/assignees{/user}","branches_url":"https://api.github.com/repos/MichalPlachyFramgia/fels_75/branches{/branch}","tags_url":"https://api.github.com/repos/MichalPlachyFramgia/fels_75/tags","blobs_url":"https://api.github.com/repos/MichalPlachyFramgia/fels_75/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/MichalPlachyFramgia/fels_75/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/MichalPlachyFramgia/fels_75/git/refs{/sha}","trees_url":"https://api.github.com/repos/MichalPlachyFramgia/fels_75/git/trees{/sha}","statuses_url":"https://api.github.com/repos/MichalPlachyFramgia/fels_75/statuses/{sha}","languages_url":"https://api.github.com/repos/MichalPlachyFramgia/fels_75/languages","stargazers_url":"https://api.github.com/repos/MichalPlachyFramgia/fels_75/stargazers","contributors_url":"https://api.github.com/repos/MichalPlachyFramgia/fels_75/contributors","subscribers_url":"https://api.github.com/repos/MichalPlachyFramgia/fels_75/subscribers","subscription_url":"https://api.github.com/repos/MichalPlachyFramgia/fels_75/subscription","commits_url":"https://api.github.com/repos/MichalPlachyFramgia/fels_75/commits{/sha}","git_commits_url":"https://api.github.com/repos/MichalPlachyFramgia/fels_75/git/commits{/sha}","comments_url":"https://api.github.com/repos/MichalPlachyFramgia/fels_75/comments{/number}","issue_comment_url":"https://api.github.com/repos/MichalPlachyFramgia/fels_75/issues/comments{/number}","contents_url":"https://api.github.com/repos/MichalPlachyFramgia/fels_75/contents/{+path}","compare_url":"https://api.github.com/repos/MichalPlachyFramgia/fels_75/compare/{base}...{head}","merges_url":"https://api.github.com/repos/MichalPlachyFramgia/fels_75/merges","archive_url":"https://api.github.com/repos/MichalPlachyFramgia/fels_75/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/MichalPlachyFramgia/fels_75/downloads","issues_url":"https://api.github.com/repos/MichalPlachyFramgia/fels_75/issues{/number}","pulls_url":"https://api.github.com/repos/MichalPlachyFramgia/fels_75/pulls{/number}","milestones_url":"https://api.github.com/repos/MichalPlachyFramgia/fels_75/milestones{/number}","notifications_url":"https://api.github.com/repos/MichalPlachyFramgia/fels_75/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/MichalPlachyFramgia/fels_75/labels{/name}","releases_url":"https://api.github.com/repos/MichalPlachyFramgia/fels_75/releases{/id}","created_at":"2015-08-18T07:33:01Z","updated_at":"2015-08-18T07:30:40Z","pushed_at":"2015-09-03T06:08:15Z","git_url":"git://github.com/MichalPlachyFramgia/fels_75.git","ssh_url":"git@github.com:MichalPlachyFramgia/fels_75.git","clone_url":"https://github.com/MichalPlachyFramgia/fels_75.git","svn_url":"https://github.com/MichalPlachyFramgia/fels_75","homepage":null,"size":215,"stargazers_count":0,"watchers_count":0,"language":null,"has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"framgia:develop","ref":"develop","sha":"4e95a544fbe7804ba79144156163e82989b2a200","user":{"login":"framgia","id":2322183,"avatar_url":"https://avatars.githubusercontent.com/u/2322183?v=3","gravatar_id":"","url":"https://api.github.com/users/framgia","html_url":"https://github.com/framgia","followers_url":"https://api.github.com/users/framgia/followers","following_url":"https://api.github.com/users/framgia/following{/other_user}","gists_url":"https://api.github.com/users/framgia/gists{/gist_id}","starred_url":"https://api.github.com/users/framgia/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/framgia/subscriptions","organizations_url":"https://api.github.com/users/framgia/orgs","repos_url":"https://api.github.com/users/framgia/repos","events_url":"https://api.github.com/users/framgia/events{/privacy}","received_events_url":"https://api.github.com/users/framgia/received_events","type":"Organization","site_admin":false},"repo":{"id":40957476,"name":"fels_75","full_name":"framgia/fels_75","owner":{"login":"framgia","id":2322183,"avatar_url":"https://avatars.githubusercontent.com/u/2322183?v=3","gravatar_id":"","url":"https://api.github.com/users/framgia","html_url":"https://github.com/framgia","followers_url":"https://api.github.com/users/framgia/followers","following_url":"https://api.github.com/users/framgia/following{/other_user}","gists_url":"https://api.github.com/users/framgia/gists{/gist_id}","starred_url":"https://api.github.com/users/framgia/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/framgia/subscriptions","organizations_url":"https://api.github.com/users/framgia/orgs","repos_url":"https://api.github.com/users/framgia/repos","events_url":"https://api.github.com/users/framgia/events{/privacy}","received_events_url":"https://api.github.com/users/framgia/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/framgia/fels_75","description":"Framgia E-Learning System (training)","fork":false,"url":"https://api.github.com/repos/framgia/fels_75","forks_url":"https://api.github.com/repos/framgia/fels_75/forks","keys_url":"https://api.github.com/repos/framgia/fels_75/keys{/key_id}","collaborators_url":"https://api.github.com/repos/framgia/fels_75/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/framgia/fels_75/teams","hooks_url":"https://api.github.com/repos/framgia/fels_75/hooks","issue_events_url":"https://api.github.com/repos/framgia/fels_75/issues/events{/number}","events_url":"https://api.github.com/repos/framgia/fels_75/events","assignees_url":"https://api.github.com/repos/framgia/fels_75/assignees{/user}","branches_url":"https://api.github.com/repos/framgia/fels_75/branches{/branch}","tags_url":"https://api.github.com/repos/framgia/fels_75/tags","blobs_url":"https://api.github.com/repos/framgia/fels_75/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/framgia/fels_75/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/framgia/fels_75/git/refs{/sha}","trees_url":"https://api.github.com/repos/framgia/fels_75/git/trees{/sha}","statuses_url":"https://api.github.com/repos/framgia/fels_75/statuses/{sha}","languages_url":"https://api.github.com/repos/framgia/fels_75/languages","stargazers_url":"https://api.github.com/repos/framgia/fels_75/stargazers","contributors_url":"https://api.github.com/repos/framgia/fels_75/contributors","subscribers_url":"https://api.github.com/repos/framgia/fels_75/subscribers","subscription_url":"https://api.github.com/repos/framgia/fels_75/subscription","commits_url":"https://api.github.com/repos/framgia/fels_75/commits{/sha}","git_commits_url":"https://api.github.com/repos/framgia/fels_75/git/commits{/sha}","comments_url":"https://api.github.com/repos/framgia/fels_75/comments{/number}","issue_comment_url":"https://api.github.com/repos/framgia/fels_75/issues/comments{/number}","contents_url":"https://api.github.com/repos/framgia/fels_75/contents/{+path}","compare_url":"https://api.github.com/repos/framgia/fels_75/compare/{base}...{head}","merges_url":"https://api.github.com/repos/framgia/fels_75/merges","archive_url":"https://api.github.com/repos/framgia/fels_75/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/framgia/fels_75/downloads","issues_url":"https://api.github.com/repos/framgia/fels_75/issues{/number}","pulls_url":"https://api.github.com/repos/framgia/fels_75/pulls{/number}","milestones_url":"https://api.github.com/repos/framgia/fels_75/milestones{/number}","notifications_url":"https://api.github.com/repos/framgia/fels_75/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/framgia/fels_75/labels{/name}","releases_url":"https://api.github.com/repos/framgia/fels_75/releases{/id}","created_at":"2015-08-18T07:30:40Z","updated_at":"2015-08-18T07:30:40Z","pushed_at":"2015-09-03T06:08:16Z","git_url":"git://github.com/framgia/fels_75.git","ssh_url":"git@github.com:framgia/fels_75.git","clone_url":"https://github.com/framgia/fels_75.git","svn_url":"https://github.com/framgia/fels_75","homepage":null,"size":675,"stargazers_count":0,"watchers_count":0,"language":null,"has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":2,"mirror_url":null,"open_issues_count":1,"forks":2,"open_issues":1,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/framgia/fels_75/pulls/12"},"html":{"href":"https://github.com/framgia/fels_75/pull/12"},"issue":{"href":"https://api.github.com/repos/framgia/fels_75/issues/12"},"comments":{"href":"https://api.github.com/repos/framgia/fels_75/issues/12/comments"},"review_comments":{"href":"https://api.github.com/repos/framgia/fels_75/pulls/12/comments"},"review_comment":{"href":"https://api.github.com/repos/framgia/fels_75/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/framgia/fels_75/pulls/12/commits"},"statuses":{"href":"https://api.github.com/repos/framgia/fels_75/statuses/c7676eec48ebf93d8abcd28018b86b2ae39d82fd"}}}}