{"action":"created","comment":{"url":"https://api.github.com/repos/incuna/incuna-surveys/pulls/comments/78013315","id":78013315,"diff_hunk":"@@ -39,11 +50,49 @@ module.directive('surveysForm', [\n                             // been set.\n                             if (Object.keys(scope.model).length === 0) {\n                                 scope.model = FieldsetParser.parseFormToModel(structure);\n+                                countQuestionsTotal();\n                             }\n                         });\n                     }\n                 });\n \n+                // answers is an object containing objects\n+                // object {\n+                //     1 : {\n+                //         2 : 0\n+                //         3 : 0\n+                //     }\n+                // }\n+                // answered is a number of type number\n+                const countNumberOfAnsweredQuestions = function (answers) {\n+                    let answered = 0;\n+\n+                    for (let groupKey in answers) {\n+                        let answerGroup = answers[groupKey]\n+                        for (let answerKey in answerGroup) {\n+                            let answer = answerGroup[answerKey]\n+                            if (answer > 0 || answer.length > 0) {\n+                                answered++;\n+                            }\n+                        }\n+                    }\n+\n+                    return answered;\n+                };\n+\n+                const calculatePercentageComplete = function (completedQuestions) {\n+                    const result = ((completedQuestions / totalQuestionCount) * 100)\n+                    if (!isNaN(result)) {\n+                        scope.percentageComplete = Math.round(result) + '%';\n+                    }","path":"web/app/scripts/src/directives/form.es.js","position":56,"original_position":56,"commit_id":"42d65663ac7260dd24ae5b26930daad5cb8b0f56","original_commit_id":"42d65663ac7260dd24ae5b26930daad5cb8b0f56","user":{"login":"wytrych","id":10600101,"avatar_url":"https://avatars.githubusercontent.com/u/10600101?v=3","gravatar_id":"","url":"https://api.github.com/users/wytrych","html_url":"https://github.com/wytrych","followers_url":"https://api.github.com/users/wytrych/followers","following_url":"https://api.github.com/users/wytrych/following{/other_user}","gists_url":"https://api.github.com/users/wytrych/gists{/gist_id}","starred_url":"https://api.github.com/users/wytrych/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wytrych/subscriptions","organizations_url":"https://api.github.com/users/wytrych/orgs","repos_url":"https://api.github.com/users/wytrych/repos","events_url":"https://api.github.com/users/wytrych/events{/privacy}","received_events_url":"https://api.github.com/users/wytrych/received_events","type":"User","site_admin":false},"body":"the only case where `result` would be `NaN` is whern `totalQuestionsCount` is `0`. So what I think is the better solution is to make `scope.percentageComplete = '100%`;` in that case:\r\n```\r\nif (totalQuestoinsCount === 0) {\r\n    scope.percentageComplete = '100%';\r\n} else {\r\n const result = ....;\r\n...\r\n}\r\n```\r\n```","created_at":"2016-09-08T14:11:12Z","updated_at":"2016-09-08T14:11:12Z","html_url":"https://github.com/incuna/incuna-surveys/pull/47#discussion_r78013315","pull_request_url":"https://api.github.com/repos/incuna/incuna-surveys/pulls/47","_links":{"self":{"href":"https://api.github.com/repos/incuna/incuna-surveys/pulls/comments/78013315"},"html":{"href":"https://github.com/incuna/incuna-surveys/pull/47#discussion_r78013315"},"pull_request":{"href":"https://api.github.com/repos/incuna/incuna-surveys/pulls/47"}}},"pull_request":{"url":"https://api.github.com/repos/incuna/incuna-surveys/pulls/47","id":84455789,"html_url":"https://github.com/incuna/incuna-surveys/pull/47","diff_url":"https://github.com/incuna/incuna-surveys/pull/47.diff","patch_url":"https://github.com/incuna/incuna-surveys/pull/47.patch","issue_url":"https://api.github.com/repos/incuna/incuna-surveys/issues/47","number":47,"state":"open","locked":false,"title":"Percentage done add","user":{"login":"Minglee01","id":10808373,"avatar_url":"https://avatars.githubusercontent.com/u/10808373?v=3","gravatar_id":"","url":"https://api.github.com/users/Minglee01","html_url":"https://github.com/Minglee01","followers_url":"https://api.github.com/users/Minglee01/followers","following_url":"https://api.github.com/users/Minglee01/following{/other_user}","gists_url":"https://api.github.com/users/Minglee01/gists{/gist_id}","starred_url":"https://api.github.com/users/Minglee01/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Minglee01/subscriptions","organizations_url":"https://api.github.com/users/Minglee01/orgs","repos_url":"https://api.github.com/users/Minglee01/repos","events_url":"https://api.github.com/users/Minglee01/events{/privacy}","received_events_url":"https://api.github.com/users/Minglee01/received_events","type":"User","site_admin":false},"body":"@incuna/js \r\n\r\nplease review\r\nfor https://incuna-pm.atlassian.net/browse/OP-160\r\n\r\nbut dont merge ill add the tests after the code is ok","created_at":"2016-09-08T10:55:19Z","updated_at":"2016-09-08T14:11:12Z","closed_at":null,"merged_at":null,"merge_commit_sha":"d90b6732b1679f16da4fd626a83048052e4cdf76","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/incuna/incuna-surveys/pulls/47/commits","review_comments_url":"https://api.github.com/repos/incuna/incuna-surveys/pulls/47/comments","review_comment_url":"https://api.github.com/repos/incuna/incuna-surveys/pulls/comments{/number}","comments_url":"https://api.github.com/repos/incuna/incuna-surveys/issues/47/comments","statuses_url":"https://api.github.com/repos/incuna/incuna-surveys/statuses/42d65663ac7260dd24ae5b26930daad5cb8b0f56","head":{"label":"incuna:percentage-done-add","ref":"percentage-done-add","sha":"42d65663ac7260dd24ae5b26930daad5cb8b0f56","user":{"login":"incuna","id":55510,"avatar_url":"https://avatars.githubusercontent.com/u/55510?v=3","gravatar_id":"","url":"https://api.github.com/users/incuna","html_url":"https://github.com/incuna","followers_url":"https://api.github.com/users/incuna/followers","following_url":"https://api.github.com/users/incuna/following{/other_user}","gists_url":"https://api.github.com/users/incuna/gists{/gist_id}","starred_url":"https://api.github.com/users/incuna/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/incuna/subscriptions","organizations_url":"https://api.github.com/users/incuna/orgs","repos_url":"https://api.github.com/users/incuna/repos","events_url":"https://api.github.com/users/incuna/events{/privacy}","received_events_url":"https://api.github.com/users/incuna/received_events","type":"Organization","site_admin":false},"repo":{"id":64744169,"name":"incuna-surveys","full_name":"incuna/incuna-surveys","owner":{"login":"incuna","id":55510,"avatar_url":"https://avatars.githubusercontent.com/u/55510?v=3","gravatar_id":"","url":"https://api.github.com/users/incuna","html_url":"https://github.com/incuna","followers_url":"https://api.github.com/users/incuna/followers","following_url":"https://api.github.com/users/incuna/following{/other_user}","gists_url":"https://api.github.com/users/incuna/gists{/gist_id}","starred_url":"https://api.github.com/users/incuna/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/incuna/subscriptions","organizations_url":"https://api.github.com/users/incuna/orgs","repos_url":"https://api.github.com/users/incuna/repos","events_url":"https://api.github.com/users/incuna/events{/privacy}","received_events_url":"https://api.github.com/users/incuna/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/incuna/incuna-surveys","description":"Allows the creation of custom questionnaires and surveys via the Django admin.","fork":false,"url":"https://api.github.com/repos/incuna/incuna-surveys","forks_url":"https://api.github.com/repos/incuna/incuna-surveys/forks","keys_url":"https://api.github.com/repos/incuna/incuna-surveys/keys{/key_id}","collaborators_url":"https://api.github.com/repos/incuna/incuna-surveys/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/incuna/incuna-surveys/teams","hooks_url":"https://api.github.com/repos/incuna/incuna-surveys/hooks","issue_events_url":"https://api.github.com/repos/incuna/incuna-surveys/issues/events{/number}","events_url":"https://api.github.com/repos/incuna/incuna-surveys/events","assignees_url":"https://api.github.com/repos/incuna/incuna-surveys/assignees{/user}","branches_url":"https://api.github.com/repos/incuna/incuna-surveys/branches{/branch}","tags_url":"https://api.github.com/repos/incuna/incuna-surveys/tags","blobs_url":"https://api.github.com/repos/incuna/incuna-surveys/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/incuna/incuna-surveys/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/incuna/incuna-surveys/git/refs{/sha}","trees_url":"https://api.github.com/repos/incuna/incuna-surveys/git/trees{/sha}","statuses_url":"https://api.github.com/repos/incuna/incuna-surveys/statuses/{sha}","languages_url":"https://api.github.com/repos/incuna/incuna-surveys/languages","stargazers_url":"https://api.github.com/repos/incuna/incuna-surveys/stargazers","contributors_url":"https://api.github.com/repos/incuna/incuna-surveys/contributors","subscribers_url":"https://api.github.com/repos/incuna/incuna-surveys/subscribers","subscription_url":"https://api.github.com/repos/incuna/incuna-surveys/subscription","commits_url":"https://api.github.com/repos/incuna/incuna-surveys/commits{/sha}","git_commits_url":"https://api.github.com/repos/incuna/incuna-surveys/git/commits{/sha}","comments_url":"https://api.github.com/repos/incuna/incuna-surveys/comments{/number}","issue_comment_url":"https://api.github.com/repos/incuna/incuna-surveys/issues/comments{/number}","contents_url":"https://api.github.com/repos/incuna/incuna-surveys/contents/{+path}","compare_url":"https://api.github.com/repos/incuna/incuna-surveys/compare/{base}...{head}","merges_url":"https://api.github.com/repos/incuna/incuna-surveys/merges","archive_url":"https://api.github.com/repos/incuna/incuna-surveys/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/incuna/incuna-surveys/downloads","issues_url":"https://api.github.com/repos/incuna/incuna-surveys/issues{/number}","pulls_url":"https://api.github.com/repos/incuna/incuna-surveys/pulls{/number}","milestones_url":"https://api.github.com/repos/incuna/incuna-surveys/milestones{/number}","notifications_url":"https://api.github.com/repos/incuna/incuna-surveys/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/incuna/incuna-surveys/labels{/name}","releases_url":"https://api.github.com/repos/incuna/incuna-surveys/releases{/id}","deployments_url":"https://api.github.com/repos/incuna/incuna-surveys/deployments","created_at":"2016-08-02T09:38:09Z","updated_at":"2016-09-02T16:32:36Z","pushed_at":"2016-09-08T14:02:18Z","git_url":"git://github.com/incuna/incuna-surveys.git","ssh_url":"git@github.com:incuna/incuna-surveys.git","clone_url":"https://github.com/incuna/incuna-surveys.git","svn_url":"https://github.com/incuna/incuna-surveys","homepage":"","size":536,"stargazers_count":2,"watchers_count":2,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":4,"forks":1,"open_issues":4,"watchers":2,"default_branch":"master"}},"base":{"label":"incuna:master","ref":"master","sha":"88a9998ba7a52ecb0061c5298344433e625ae8aa","user":{"login":"incuna","id":55510,"avatar_url":"https://avatars.githubusercontent.com/u/55510?v=3","gravatar_id":"","url":"https://api.github.com/users/incuna","html_url":"https://github.com/incuna","followers_url":"https://api.github.com/users/incuna/followers","following_url":"https://api.github.com/users/incuna/following{/other_user}","gists_url":"https://api.github.com/users/incuna/gists{/gist_id}","starred_url":"https://api.github.com/users/incuna/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/incuna/subscriptions","organizations_url":"https://api.github.com/users/incuna/orgs","repos_url":"https://api.github.com/users/incuna/repos","events_url":"https://api.github.com/users/incuna/events{/privacy}","received_events_url":"https://api.github.com/users/incuna/received_events","type":"Organization","site_admin":false},"repo":{"id":64744169,"name":"incuna-surveys","full_name":"incuna/incuna-surveys","owner":{"login":"incuna","id":55510,"avatar_url":"https://avatars.githubusercontent.com/u/55510?v=3","gravatar_id":"","url":"https://api.github.com/users/incuna","html_url":"https://github.com/incuna","followers_url":"https://api.github.com/users/incuna/followers","following_url":"https://api.github.com/users/incuna/following{/other_user}","gists_url":"https://api.github.com/users/incuna/gists{/gist_id}","starred_url":"https://api.github.com/users/incuna/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/incuna/subscriptions","organizations_url":"https://api.github.com/users/incuna/orgs","repos_url":"https://api.github.com/users/incuna/repos","events_url":"https://api.github.com/users/incuna/events{/privacy}","received_events_url":"https://api.github.com/users/incuna/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/incuna/incuna-surveys","description":"Allows the creation of custom questionnaires and surveys via the Django admin.","fork":false,"url":"https://api.github.com/repos/incuna/incuna-surveys","forks_url":"https://api.github.com/repos/incuna/incuna-surveys/forks","keys_url":"https://api.github.com/repos/incuna/incuna-surveys/keys{/key_id}","collaborators_url":"https://api.github.com/repos/incuna/incuna-surveys/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/incuna/incuna-surveys/teams","hooks_url":"https://api.github.com/repos/incuna/incuna-surveys/hooks","issue_events_url":"https://api.github.com/repos/incuna/incuna-surveys/issues/events{/number}","events_url":"https://api.github.com/repos/incuna/incuna-surveys/events","assignees_url":"https://api.github.com/repos/incuna/incuna-surveys/assignees{/user}","branches_url":"https://api.github.com/repos/incuna/incuna-surveys/branches{/branch}","tags_url":"https://api.github.com/repos/incuna/incuna-surveys/tags","blobs_url":"https://api.github.com/repos/incuna/incuna-surveys/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/incuna/incuna-surveys/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/incuna/incuna-surveys/git/refs{/sha}","trees_url":"https://api.github.com/repos/incuna/incuna-surveys/git/trees{/sha}","statuses_url":"https://api.github.com/repos/incuna/incuna-surveys/statuses/{sha}","languages_url":"https://api.github.com/repos/incuna/incuna-surveys/languages","stargazers_url":"https://api.github.com/repos/incuna/incuna-surveys/stargazers","contributors_url":"https://api.github.com/repos/incuna/incuna-surveys/contributors","subscribers_url":"https://api.github.com/repos/incuna/incuna-surveys/subscribers","subscription_url":"https://api.github.com/repos/incuna/incuna-surveys/subscription","commits_url":"https://api.github.com/repos/incuna/incuna-surveys/commits{/sha}","git_commits_url":"https://api.github.com/repos/incuna/incuna-surveys/git/commits{/sha}","comments_url":"https://api.github.com/repos/incuna/incuna-surveys/comments{/number}","issue_comment_url":"https://api.github.com/repos/incuna/incuna-surveys/issues/comments{/number}","contents_url":"https://api.github.com/repos/incuna/incuna-surveys/contents/{+path}","compare_url":"https://api.github.com/repos/incuna/incuna-surveys/compare/{base}...{head}","merges_url":"https://api.github.com/repos/incuna/incuna-surveys/merges","archive_url":"https://api.github.com/repos/incuna/incuna-surveys/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/incuna/incuna-surveys/downloads","issues_url":"https://api.github.com/repos/incuna/incuna-surveys/issues{/number}","pulls_url":"https://api.github.com/repos/incuna/incuna-surveys/pulls{/number}","milestones_url":"https://api.github.com/repos/incuna/incuna-surveys/milestones{/number}","notifications_url":"https://api.github.com/repos/incuna/incuna-surveys/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/incuna/incuna-surveys/labels{/name}","releases_url":"https://api.github.com/repos/incuna/incuna-surveys/releases{/id}","deployments_url":"https://api.github.com/repos/incuna/incuna-surveys/deployments","created_at":"2016-08-02T09:38:09Z","updated_at":"2016-09-02T16:32:36Z","pushed_at":"2016-09-08T14:02:18Z","git_url":"git://github.com/incuna/incuna-surveys.git","ssh_url":"git@github.com:incuna/incuna-surveys.git","clone_url":"https://github.com/incuna/incuna-surveys.git","svn_url":"https://github.com/incuna/incuna-surveys","homepage":"","size":536,"stargazers_count":2,"watchers_count":2,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":4,"forks":1,"open_issues":4,"watchers":2,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/incuna/incuna-surveys/pulls/47"},"html":{"href":"https://github.com/incuna/incuna-surveys/pull/47"},"issue":{"href":"https://api.github.com/repos/incuna/incuna-surveys/issues/47"},"comments":{"href":"https://api.github.com/repos/incuna/incuna-surveys/issues/47/comments"},"review_comments":{"href":"https://api.github.com/repos/incuna/incuna-surveys/pulls/47/comments"},"review_comment":{"href":"https://api.github.com/repos/incuna/incuna-surveys/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/incuna/incuna-surveys/pulls/47/commits"},"statuses":{"href":"https://api.github.com/repos/incuna/incuna-surveys/statuses/42d65663ac7260dd24ae5b26930daad5cb8b0f56"}}}}
{"actor":{"display_login":"wytrych"}}