{"action":"created","comment":{"url":"https://api.github.com/repos/framgia/fels_124/pulls/comments/59157376","id":59157376,"diff_hunk":"@@ -0,0 +1,144 @@\n+$(document).ready(function() {\n+    $.ajaxSetup({\n+       headers: { 'X-CSRF-Token' : $('meta[name=_token]').attr('content') }\n+    });\n+\n+    jQuery('.reponse-ajax').hide();\n+\n+    // Handle add and remove dynamic answer - admin/word_answer\n+    var wrapper_add_answer = $(\".input_fields_wrap\");\n+    var add_button_answer = $(\".add_field_button\");\n+    var x = 1; //initlal text box count\n+\n+    $(add_button_answer).click(function(e){ //on add input button click\n+        e.preventDefault();\n+        var addAnswer = '<div class=\"row\"><input class=\"best_answer\" name=\"correct\" type=\"radio\" value=\"' + x + '\">';\n+        addAnswer += '<input type=\"text\" name=\"word_answer[' + x + ']\" class=\"word_answer app-admin-margin form-control\" id=\"answer-' + x + '\">';\n+        addAnswer += '<a href=\"#\" class=\"remove_field btn btn-danger\">Remove</a></div>';\n+\n+        $(wrapper_add_answer).append(addAnswer); //add input box\n+        x++; //text box increment\n+    });\n+\n+    $(wrapper_add_answer).on(\"click\",\".remove_field\", function(e){ //user click on remove text\n+        e.preventDefault(); $(this).parent('div').remove();\n+    });\n+\n+    function validateWordAnswer(correct, answers) {\n+        var valid = true;\n+\n+        // Not choosen answer\n+        if (jQuery.type(correct) === \"undefined\") {\n+            return false;\n+        }\n+\n+        //choosen answer but not content\n+        $.each(answers, function( index, value ) {\n+            if (index == correct) {\n+                if (jQuery.isEmptyObject(value)) {\n+                    valid = false;\n+                    return false;\n+                }\n+            }\n+        });\n+\n+        return valid;\n+    }\n+\n+    // Handle form create word answer\n+    $('#create-word-answer').submit(function(e){\n+        e.preventDefault();\n+        var $form = $(this);\n+\n+        //get data\n+        var url = $form.attr('action');\n+        var _token = $('input[name=_token]').val();\n+        var correct = $form.find('input[name=correct]:checked').val();\n+        var word_id = $form.find('select').val();\n+\n+        var answer = {};\n+\n+        $('input.word_answer').each(function(value, index) {\n+            var index = $(this).attr(\"id\").split('-');\n+            if (index[1] == correct) {\n+                correct = value;\n+            }\n+            answer[value] = $(this).val();\n+        });\n+\n+        var validate = validateWordAnswer(correct, answer);\n+\n+        if (validate) {\n+            ajaxWordAnswer(url, 'POST', _token, correct, answer, word_id);\n+        } else {\n+            jQuery('.reponse-ajax').empty().html('Content of correctly answer blank or not choosen correct answer').show();\n+        }\n+\n+    });\n+\n+    // Handle form update word answer\n+    $('#update-word-answer').submit(function(e){\n+        e.preventDefault();\n+        var $form = $(this);\n+\n+        //get data\n+        var url = $form.attr('action');\n+        var _token = $form.find('input[name=\"_token\"]').val();\n+        var correct = $form.find('input[name=correct]:checked').val();\n+\n+        var answer = {};\n+\n+        $('input.word_answer').each(function(value, index) {\n+            var index = $(this).attr(\"id\").split('-');\n+            if (index[1] == correct) {\n+                correct = value;\n+            }\n+            answer[value] = $(this).val();\n+        });\n+\n+        var validate = validateWordAnswer(correct, answer);\n+\n+        if (validate) {\n+            ajaxWordAnswer(url, 'PUT', _token, correct, answer);\n+        } else {\n+            jQuery('.reponse-ajax').empty().html('Content of correctly answer blank or not choosen correct answer').show();\n+        }\n+\n+    });\n+\n+    // handle ajax request for Word Answer\n+    function ajaxWordAnswer(url, type, _token, correct, answer, word_id = null) {\n+        $.ajax({\n+            url : url,\n+            type : type,\n+            dateType:\"text\",\n+            data : {\n+                _token: _token,\n+                word_id: word_id,","path":"public/js/jquery-admin.js","position":117,"original_position":117,"commit_id":"5026623cde865e58411892aa78017519e65fa8e4","original_commit_id":"5026623cde865e58411892aa78017519e65fa8e4","user":{"login":"namnv609","id":8691772,"avatar_url":"https://avatars.githubusercontent.com/u/8691772?v=3","gravatar_id":"","url":"https://api.github.com/users/namnv609","html_url":"https://github.com/namnv609","followers_url":"https://api.github.com/users/namnv609/followers","following_url":"https://api.github.com/users/namnv609/following{/other_user}","gists_url":"https://api.github.com/users/namnv609/gists{/gist_id}","starred_url":"https://api.github.com/users/namnv609/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/namnv609/subscriptions","organizations_url":"https://api.github.com/users/namnv609/orgs","repos_url":"https://api.github.com/users/namnv609/repos","events_url":"https://api.github.com/users/namnv609/events{/privacy}","received_events_url":"https://api.github.com/users/namnv609/received_events","type":"User","site_admin":false},"body":"Thống nhất 1 cách dùng ``key: value`` hoặc ``key : value`` nhé. Tìm và sửa lại hết cho tớ!","created_at":"2016-04-11T06:08:26Z","updated_at":"2016-04-11T06:08:26Z","html_url":"https://github.com/framgia/fels_124/pull/17#discussion_r59157376","pull_request_url":"https://api.github.com/repos/framgia/fels_124/pulls/17","_links":{"self":{"href":"https://api.github.com/repos/framgia/fels_124/pulls/comments/59157376"},"html":{"href":"https://github.com/framgia/fels_124/pull/17#discussion_r59157376"},"pull_request":{"href":"https://api.github.com/repos/framgia/fels_124/pulls/17"}}},"pull_request":{"url":"https://api.github.com/repos/framgia/fels_124/pulls/17","id":65562412,"html_url":"https://github.com/framgia/fels_124/pull/17","diff_url":"https://github.com/framgia/fels_124/pull/17.diff","patch_url":"https://github.com/framgia/fels_124/pull/17.patch","issue_url":"https://api.github.com/repos/framgia/fels_124/issues/17","number":17,"state":"open","locked":false,"title":"Word Answer Admin Manager","user":{"login":"nguyenvanthucframgia2016","id":17847399,"avatar_url":"https://avatars.githubusercontent.com/u/17847399?v=3","gravatar_id":"","url":"https://api.github.com/users/nguyenvanthucframgia2016","html_url":"https://github.com/nguyenvanthucframgia2016","followers_url":"https://api.github.com/users/nguyenvanthucframgia2016/followers","following_url":"https://api.github.com/users/nguyenvanthucframgia2016/following{/other_user}","gists_url":"https://api.github.com/users/nguyenvanthucframgia2016/gists{/gist_id}","starred_url":"https://api.github.com/users/nguyenvanthucframgia2016/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nguyenvanthucframgia2016/subscriptions","organizations_url":"https://api.github.com/users/nguyenvanthucframgia2016/orgs","repos_url":"https://api.github.com/users/nguyenvanthucframgia2016/repos","events_url":"https://api.github.com/users/nguyenvanthucframgia2016/events{/privacy}","received_events_url":"https://api.github.com/users/nguyenvanthucframgia2016/received_events","type":"User","site_admin":false},"body":"","created_at":"2016-04-07T01:44:23Z","updated_at":"2016-04-11T06:08:26Z","closed_at":null,"merged_at":null,"merge_commit_sha":"119b519556faa5cb07558ae32afd85d1b0eecf39","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/framgia/fels_124/pulls/17/commits","review_comments_url":"https://api.github.com/repos/framgia/fels_124/pulls/17/comments","review_comment_url":"https://api.github.com/repos/framgia/fels_124/pulls/comments{/number}","comments_url":"https://api.github.com/repos/framgia/fels_124/issues/17/comments","statuses_url":"https://api.github.com/repos/framgia/fels_124/statuses/5026623cde865e58411892aa78017519e65fa8e4","head":{"label":"nguyenvanthucframgia2016:wordAnswerAdminManager","ref":"wordAnswerAdminManager","sha":"5026623cde865e58411892aa78017519e65fa8e4","user":{"login":"nguyenvanthucframgia2016","id":17847399,"avatar_url":"https://avatars.githubusercontent.com/u/17847399?v=3","gravatar_id":"","url":"https://api.github.com/users/nguyenvanthucframgia2016","html_url":"https://github.com/nguyenvanthucframgia2016","followers_url":"https://api.github.com/users/nguyenvanthucframgia2016/followers","following_url":"https://api.github.com/users/nguyenvanthucframgia2016/following{/other_user}","gists_url":"https://api.github.com/users/nguyenvanthucframgia2016/gists{/gist_id}","starred_url":"https://api.github.com/users/nguyenvanthucframgia2016/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nguyenvanthucframgia2016/subscriptions","organizations_url":"https://api.github.com/users/nguyenvanthucframgia2016/orgs","repos_url":"https://api.github.com/users/nguyenvanthucframgia2016/repos","events_url":"https://api.github.com/users/nguyenvanthucframgia2016/events{/privacy}","received_events_url":"https://api.github.com/users/nguyenvanthucframgia2016/received_events","type":"User","site_admin":false},"repo":{"id":54865479,"name":"fels_124","full_name":"nguyenvanthucframgia2016/fels_124","owner":{"login":"nguyenvanthucframgia2016","id":17847399,"avatar_url":"https://avatars.githubusercontent.com/u/17847399?v=3","gravatar_id":"","url":"https://api.github.com/users/nguyenvanthucframgia2016","html_url":"https://github.com/nguyenvanthucframgia2016","followers_url":"https://api.github.com/users/nguyenvanthucframgia2016/followers","following_url":"https://api.github.com/users/nguyenvanthucframgia2016/following{/other_user}","gists_url":"https://api.github.com/users/nguyenvanthucframgia2016/gists{/gist_id}","starred_url":"https://api.github.com/users/nguyenvanthucframgia2016/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nguyenvanthucframgia2016/subscriptions","organizations_url":"https://api.github.com/users/nguyenvanthucframgia2016/orgs","repos_url":"https://api.github.com/users/nguyenvanthucframgia2016/repos","events_url":"https://api.github.com/users/nguyenvanthucframgia2016/events{/privacy}","received_events_url":"https://api.github.com/users/nguyenvanthucframgia2016/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/nguyenvanthucframgia2016/fels_124","description":"Framgia E-Learning System (training)","fork":true,"url":"https://api.github.com/repos/nguyenvanthucframgia2016/fels_124","forks_url":"https://api.github.com/repos/nguyenvanthucframgia2016/fels_124/forks","keys_url":"https://api.github.com/repos/nguyenvanthucframgia2016/fels_124/keys{/key_id}","collaborators_url":"https://api.github.com/repos/nguyenvanthucframgia2016/fels_124/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/nguyenvanthucframgia2016/fels_124/teams","hooks_url":"https://api.github.com/repos/nguyenvanthucframgia2016/fels_124/hooks","issue_events_url":"https://api.github.com/repos/nguyenvanthucframgia2016/fels_124/issues/events{/number}","events_url":"https://api.github.com/repos/nguyenvanthucframgia2016/fels_124/events","assignees_url":"https://api.github.com/repos/nguyenvanthucframgia2016/fels_124/assignees{/user}","branches_url":"https://api.github.com/repos/nguyenvanthucframgia2016/fels_124/branches{/branch}","tags_url":"https://api.github.com/repos/nguyenvanthucframgia2016/fels_124/tags","blobs_url":"https://api.github.com/repos/nguyenvanthucframgia2016/fels_124/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/nguyenvanthucframgia2016/fels_124/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/nguyenvanthucframgia2016/fels_124/git/refs{/sha}","trees_url":"https://api.github.com/repos/nguyenvanthucframgia2016/fels_124/git/trees{/sha}","statuses_url":"https://api.github.com/repos/nguyenvanthucframgia2016/fels_124/statuses/{sha}","languages_url":"https://api.github.com/repos/nguyenvanthucframgia2016/fels_124/languages","stargazers_url":"https://api.github.com/repos/nguyenvanthucframgia2016/fels_124/stargazers","contributors_url":"https://api.github.com/repos/nguyenvanthucframgia2016/fels_124/contributors","subscribers_url":"https://api.github.com/repos/nguyenvanthucframgia2016/fels_124/subscribers","subscription_url":"https://api.github.com/repos/nguyenvanthucframgia2016/fels_124/subscription","commits_url":"https://api.github.com/repos/nguyenvanthucframgia2016/fels_124/commits{/sha}","git_commits_url":"https://api.github.com/repos/nguyenvanthucframgia2016/fels_124/git/commits{/sha}","comments_url":"https://api.github.com/repos/nguyenvanthucframgia2016/fels_124/comments{/number}","issue_comment_url":"https://api.github.com/repos/nguyenvanthucframgia2016/fels_124/issues/comments{/number}","contents_url":"https://api.github.com/repos/nguyenvanthucframgia2016/fels_124/contents/{+path}","compare_url":"https://api.github.com/repos/nguyenvanthucframgia2016/fels_124/compare/{base}...{head}","merges_url":"https://api.github.com/repos/nguyenvanthucframgia2016/fels_124/merges","archive_url":"https://api.github.com/repos/nguyenvanthucframgia2016/fels_124/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/nguyenvanthucframgia2016/fels_124/downloads","issues_url":"https://api.github.com/repos/nguyenvanthucframgia2016/fels_124/issues{/number}","pulls_url":"https://api.github.com/repos/nguyenvanthucframgia2016/fels_124/pulls{/number}","milestones_url":"https://api.github.com/repos/nguyenvanthucframgia2016/fels_124/milestones{/number}","notifications_url":"https://api.github.com/repos/nguyenvanthucframgia2016/fels_124/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/nguyenvanthucframgia2016/fels_124/labels{/name}","releases_url":"https://api.github.com/repos/nguyenvanthucframgia2016/fels_124/releases{/id}","deployments_url":"https://api.github.com/repos/nguyenvanthucframgia2016/fels_124/deployments","created_at":"2016-03-28T04:31:12Z","updated_at":"2016-03-25T08:21:54Z","pushed_at":"2016-04-11T03:39:53Z","git_url":"git://github.com/nguyenvanthucframgia2016/fels_124.git","ssh_url":"git@github.com:nguyenvanthucframgia2016/fels_124.git","clone_url":"https://github.com/nguyenvanthucframgia2016/fels_124.git","svn_url":"https://github.com/nguyenvanthucframgia2016/fels_124","homepage":null,"size":177,"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":"9d8a5d61351748a01675e316d7dbe9b423bed2a4","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":54705289,"name":"fels_124","full_name":"framgia/fels_124","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_124","description":"Framgia E-Learning System (training)","fork":false,"url":"https://api.github.com/repos/framgia/fels_124","forks_url":"https://api.github.com/repos/framgia/fels_124/forks","keys_url":"https://api.github.com/repos/framgia/fels_124/keys{/key_id}","collaborators_url":"https://api.github.com/repos/framgia/fels_124/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/framgia/fels_124/teams","hooks_url":"https://api.github.com/repos/framgia/fels_124/hooks","issue_events_url":"https://api.github.com/repos/framgia/fels_124/issues/events{/number}","events_url":"https://api.github.com/repos/framgia/fels_124/events","assignees_url":"https://api.github.com/repos/framgia/fels_124/assignees{/user}","branches_url":"https://api.github.com/repos/framgia/fels_124/branches{/branch}","tags_url":"https://api.github.com/repos/framgia/fels_124/tags","blobs_url":"https://api.github.com/repos/framgia/fels_124/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/framgia/fels_124/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/framgia/fels_124/git/refs{/sha}","trees_url":"https://api.github.com/repos/framgia/fels_124/git/trees{/sha}","statuses_url":"https://api.github.com/repos/framgia/fels_124/statuses/{sha}","languages_url":"https://api.github.com/repos/framgia/fels_124/languages","stargazers_url":"https://api.github.com/repos/framgia/fels_124/stargazers","contributors_url":"https://api.github.com/repos/framgia/fels_124/contributors","subscribers_url":"https://api.github.com/repos/framgia/fels_124/subscribers","subscription_url":"https://api.github.com/repos/framgia/fels_124/subscription","commits_url":"https://api.github.com/repos/framgia/fels_124/commits{/sha}","git_commits_url":"https://api.github.com/repos/framgia/fels_124/git/commits{/sha}","comments_url":"https://api.github.com/repos/framgia/fels_124/comments{/number}","issue_comment_url":"https://api.github.com/repos/framgia/fels_124/issues/comments{/number}","contents_url":"https://api.github.com/repos/framgia/fels_124/contents/{+path}","compare_url":"https://api.github.com/repos/framgia/fels_124/compare/{base}...{head}","merges_url":"https://api.github.com/repos/framgia/fels_124/merges","archive_url":"https://api.github.com/repos/framgia/fels_124/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/framgia/fels_124/downloads","issues_url":"https://api.github.com/repos/framgia/fels_124/issues{/number}","pulls_url":"https://api.github.com/repos/framgia/fels_124/pulls{/number}","milestones_url":"https://api.github.com/repos/framgia/fels_124/milestones{/number}","notifications_url":"https://api.github.com/repos/framgia/fels_124/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/framgia/fels_124/labels{/name}","releases_url":"https://api.github.com/repos/framgia/fels_124/releases{/id}","deployments_url":"https://api.github.com/repos/framgia/fels_124/deployments","created_at":"2016-03-25T08:21:54Z","updated_at":"2016-03-25T08:21:54Z","pushed_at":"2016-04-11T03:28:34Z","git_url":"git://github.com/framgia/fels_124.git","ssh_url":"git@github.com:framgia/fels_124.git","clone_url":"https://github.com/framgia/fels_124.git","svn_url":"https://github.com/framgia/fels_124","homepage":null,"size":167,"stargazers_count":0,"watchers_count":0,"language":null,"has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":3,"mirror_url":null,"open_issues_count":4,"forks":3,"open_issues":4,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/framgia/fels_124/pulls/17"},"html":{"href":"https://github.com/framgia/fels_124/pull/17"},"issue":{"href":"https://api.github.com/repos/framgia/fels_124/issues/17"},"comments":{"href":"https://api.github.com/repos/framgia/fels_124/issues/17/comments"},"review_comments":{"href":"https://api.github.com/repos/framgia/fels_124/pulls/17/comments"},"review_comment":{"href":"https://api.github.com/repos/framgia/fels_124/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/framgia/fels_124/pulls/17/commits"},"statuses":{"href":"https://api.github.com/repos/framgia/fels_124/statuses/5026623cde865e58411892aa78017519e65fa8e4"}}}}