{"action":"created","comment":{"url":"https://api.github.com/repos/sgmap/pix/pulls/comments/154694301","pull_request_review_id":80895130,"id":154694301,"diff_hunk":"@@ -0,0 +1,66 @@\n+const minimumReproductibilityToBeCertified = 0.5;\n+const minimumReproductibilityToBeTrusted = 0.8;\n+const numberOfPixForOneLevel = 8;\n+const _ = require('lodash');\n+\n+function _getReproductibilityFromAnswers(listAnswers) {\n+  if(listAnswers.length < 1) {\n+    return 0;\n+  }\n+  const numberOfCorrectAnswers = _.filter(listAnswers, (answer) => (answer.get('result') === 'ok')).length;\n+  return numberOfCorrectAnswers/listAnswers.length;\n+}\n+\n+function _computeSumPixFromCompetences(listCompetences) {\n+  return _.reduce(listCompetences, (sum, competence) => sum + competence.pixScore, 0);\n+}\n+\n+function _enhanceAnswersWithCompetenceId(listAnswers, listChallenges) {\n+  return _.map(listAnswers, (answer) => {\n+    const competenceId = listChallenges\n+      .find((challenge) => challenge.get('challengeId') === answer.get('challengeId'))\n+      .get('competenceId');\n+    answer.set('competenceId', competenceId);\n+    return answer;\n+  });\n+}\n+\n+function _numberOfCorrectAnswersPerCompetence(answersWithCompetences, competence) {\n+  return _(answersWithCompetences)\n+    .filter(answer => answer.get('competenceId') === competence.id)\n+    .filter(answer => answer.get('result') === 'ok')\n+    .value()\n+    .length;\n+}\n+\n+function _computedMalusPerCompetence(numberOfCorrectAnswers, competence, reproductibility) {\n+  if (numberOfCorrectAnswers < 2) {\n+    return competence.pixScore;\n+  }\n+  if(reproductibility < minimumReproductibilityToBeTrusted && numberOfCorrectAnswers === 2) {\n+    return numberOfPixForOneLevel;\n+  }\n+  return 0;\n+}\n+\n+function _getMalusPix(answersWithCompetences, listCompetences, reproductibility) {\n+  return listCompetences.reduce((malus, competence) => {\n+    const numberOfCorrectAnswers = _numberOfCorrectAnswersPerCompetence(answersWithCompetences, competence);\n+    return malus + _computedMalusPerCompetence(numberOfCorrectAnswers, competence, reproductibility);\n+  }, 0);\n+}\n+\n+module.exports = {\n+  getScore(listAnswers, listChallenges, listCompetences) {\n+    const reproductibility = _getReproductibilityFromAnswers(listAnswers);","path":"api/lib/domain/services/certification-service.js","position":55,"original_position":55,"commit_id":"9e32dd6d0018c058cc26d78a96b0452d5a994961","original_commit_id":"7400afced2710ceca264e7156ba15a5b2fe6da51","user":{"login":"Akhilian","id":2499408,"avatar_url":"https://avatars2.githubusercontent.com/u/2499408?v=4","gravatar_id":"","url":"https://api.github.com/users/Akhilian","html_url":"https://github.com/Akhilian","followers_url":"https://api.github.com/users/Akhilian/followers","following_url":"https://api.github.com/users/Akhilian/following{/other_user}","gists_url":"https://api.github.com/users/Akhilian/gists{/gist_id}","starred_url":"https://api.github.com/users/Akhilian/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Akhilian/subscriptions","organizations_url":"https://api.github.com/users/Akhilian/orgs","repos_url":"https://api.github.com/users/Akhilian/repos","events_url":"https://api.github.com/users/Akhilian/events{/privacy}","received_events_url":"https://api.github.com/users/Akhilian/received_events","type":"User","site_admin":false},"body":"Ça ressemble à `certificationService.getAnswersSuccessRate`","created_at":"2017-12-04T16:12:43Z","updated_at":"2017-12-04T16:24:16Z","html_url":"https://github.com/sgmap/pix/pull/610#discussion_r154694301","pull_request_url":"https://api.github.com/repos/sgmap/pix/pulls/610","author_association":"COLLABORATOR","_links":{"self":{"href":"https://api.github.com/repos/sgmap/pix/pulls/comments/154694301"},"html":{"href":"https://github.com/sgmap/pix/pull/610#discussion_r154694301"},"pull_request":{"href":"https://api.github.com/repos/sgmap/pix/pulls/610"}}},"pull_request":{"url":"https://api.github.com/repos/sgmap/pix/pulls/610","id":155563119,"html_url":"https://github.com/sgmap/pix/pull/610","diff_url":"https://github.com/sgmap/pix/pull/610.diff","patch_url":"https://github.com/sgmap/pix/pull/610.patch","issue_url":"https://api.github.com/repos/sgmap/pix/issues/610","number":610,"state":"open","locked":false,"title":"[#610] [FEATURE] Calculer le score d'une certification (US-886).","user":{"login":"MelanieMEB","id":31532858,"avatar_url":"https://avatars1.githubusercontent.com/u/31532858?v=4","gravatar_id":"","url":"https://api.github.com/users/MelanieMEB","html_url":"https://github.com/MelanieMEB","followers_url":"https://api.github.com/users/MelanieMEB/followers","following_url":"https://api.github.com/users/MelanieMEB/following{/other_user}","gists_url":"https://api.github.com/users/MelanieMEB/gists{/gist_id}","starred_url":"https://api.github.com/users/MelanieMEB/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/MelanieMEB/subscriptions","organizations_url":"https://api.github.com/users/MelanieMEB/orgs","repos_url":"https://api.github.com/users/MelanieMEB/repos","events_url":"https://api.github.com/users/MelanieMEB/events{/privacy}","received_events_url":"https://api.github.com/users/MelanieMEB/received_events","type":"User","site_admin":false},"body":"**Ticket Trello :** https://trello.com/c/SouvNEnG/886-etq-candidat-jv-conna%C3%AEtre-mon-score-certifi%C3%A9\r\n**RA :** http://886-compute-score-for-certif.pix-dev.ovh/\r\n\r\n**Ce qui a été réalisé :**\r\n- Ajout d'une route /certification-courses/:certif_id/score pour retourner le score d'un certif score\r\n- Ajout d'un certification_service qui contient une méthode getScore\r\n- Cette méthode getScore contient le calcul du score\r\n\r\n**Ce qui a été compliqué :**\r\n- La récupération des différentes informations pour le calcul du score, notamment le calcul d'une note pour chaque compétence (relier answer/challenge_certif) et récupérer les pix (relier assessment/competence/challenge_certif)","created_at":"2017-11-30T09:58:25Z","updated_at":"2017-12-04T16:24:16Z","closed_at":null,"merged_at":null,"merge_commit_sha":"c34398ebdfa51b8ac4d4341799435acd364e5448","assignee":{"login":"MelanieMEB","id":31532858,"avatar_url":"https://avatars1.githubusercontent.com/u/31532858?v=4","gravatar_id":"","url":"https://api.github.com/users/MelanieMEB","html_url":"https://github.com/MelanieMEB","followers_url":"https://api.github.com/users/MelanieMEB/followers","following_url":"https://api.github.com/users/MelanieMEB/following{/other_user}","gists_url":"https://api.github.com/users/MelanieMEB/gists{/gist_id}","starred_url":"https://api.github.com/users/MelanieMEB/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/MelanieMEB/subscriptions","organizations_url":"https://api.github.com/users/MelanieMEB/orgs","repos_url":"https://api.github.com/users/MelanieMEB/repos","events_url":"https://api.github.com/users/MelanieMEB/events{/privacy}","received_events_url":"https://api.github.com/users/MelanieMEB/received_events","type":"User","site_admin":false},"assignees":[{"login":"MelanieMEB","id":31532858,"avatar_url":"https://avatars1.githubusercontent.com/u/31532858?v=4","gravatar_id":"","url":"https://api.github.com/users/MelanieMEB","html_url":"https://github.com/MelanieMEB","followers_url":"https://api.github.com/users/MelanieMEB/followers","following_url":"https://api.github.com/users/MelanieMEB/following{/other_user}","gists_url":"https://api.github.com/users/MelanieMEB/gists{/gist_id}","starred_url":"https://api.github.com/users/MelanieMEB/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/MelanieMEB/subscriptions","organizations_url":"https://api.github.com/users/MelanieMEB/orgs","repos_url":"https://api.github.com/users/MelanieMEB/repos","events_url":"https://api.github.com/users/MelanieMEB/events{/privacy}","received_events_url":"https://api.github.com/users/MelanieMEB/received_events","type":"User","site_admin":false}],"requested_reviewers":[],"milestone":null,"commits_url":"https://api.github.com/repos/sgmap/pix/pulls/610/commits","review_comments_url":"https://api.github.com/repos/sgmap/pix/pulls/610/comments","review_comment_url":"https://api.github.com/repos/sgmap/pix/pulls/comments{/number}","comments_url":"https://api.github.com/repos/sgmap/pix/issues/610/comments","statuses_url":"https://api.github.com/repos/sgmap/pix/statuses/9e32dd6d0018c058cc26d78a96b0452d5a994961","head":{"label":"sgmap:886-compute-score-for-certif","ref":"886-compute-score-for-certif","sha":"9e32dd6d0018c058cc26d78a96b0452d5a994961","user":{"login":"sgmap","id":7874148,"avatar_url":"https://avatars0.githubusercontent.com/u/7874148?v=4","gravatar_id":"","url":"https://api.github.com/users/sgmap","html_url":"https://github.com/sgmap","followers_url":"https://api.github.com/users/sgmap/followers","following_url":"https://api.github.com/users/sgmap/following{/other_user}","gists_url":"https://api.github.com/users/sgmap/gists{/gist_id}","starred_url":"https://api.github.com/users/sgmap/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sgmap/subscriptions","organizations_url":"https://api.github.com/users/sgmap/orgs","repos_url":"https://api.github.com/users/sgmap/repos","events_url":"https://api.github.com/users/sgmap/events{/privacy}","received_events_url":"https://api.github.com/users/sgmap/received_events","type":"Organization","site_admin":false},"repo":{"id":63066169,"name":"pix","full_name":"sgmap/pix","owner":{"login":"sgmap","id":7874148,"avatar_url":"https://avatars0.githubusercontent.com/u/7874148?v=4","gravatar_id":"","url":"https://api.github.com/users/sgmap","html_url":"https://github.com/sgmap","followers_url":"https://api.github.com/users/sgmap/followers","following_url":"https://api.github.com/users/sgmap/following{/other_user}","gists_url":"https://api.github.com/users/sgmap/gists{/gist_id}","starred_url":"https://api.github.com/users/sgmap/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sgmap/subscriptions","organizations_url":"https://api.github.com/users/sgmap/orgs","repos_url":"https://api.github.com/users/sgmap/repos","events_url":"https://api.github.com/users/sgmap/events{/privacy}","received_events_url":"https://api.github.com/users/sgmap/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/sgmap/pix","description":"Plateforme d'évaluation et de certification des compétences numériques à l'usage de tous les citoyens francophones.","fork":false,"url":"https://api.github.com/repos/sgmap/pix","forks_url":"https://api.github.com/repos/sgmap/pix/forks","keys_url":"https://api.github.com/repos/sgmap/pix/keys{/key_id}","collaborators_url":"https://api.github.com/repos/sgmap/pix/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/sgmap/pix/teams","hooks_url":"https://api.github.com/repos/sgmap/pix/hooks","issue_events_url":"https://api.github.com/repos/sgmap/pix/issues/events{/number}","events_url":"https://api.github.com/repos/sgmap/pix/events","assignees_url":"https://api.github.com/repos/sgmap/pix/assignees{/user}","branches_url":"https://api.github.com/repos/sgmap/pix/branches{/branch}","tags_url":"https://api.github.com/repos/sgmap/pix/tags","blobs_url":"https://api.github.com/repos/sgmap/pix/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/sgmap/pix/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/sgmap/pix/git/refs{/sha}","trees_url":"https://api.github.com/repos/sgmap/pix/git/trees{/sha}","statuses_url":"https://api.github.com/repos/sgmap/pix/statuses/{sha}","languages_url":"https://api.github.com/repos/sgmap/pix/languages","stargazers_url":"https://api.github.com/repos/sgmap/pix/stargazers","contributors_url":"https://api.github.com/repos/sgmap/pix/contributors","subscribers_url":"https://api.github.com/repos/sgmap/pix/subscribers","subscription_url":"https://api.github.com/repos/sgmap/pix/subscription","commits_url":"https://api.github.com/repos/sgmap/pix/commits{/sha}","git_commits_url":"https://api.github.com/repos/sgmap/pix/git/commits{/sha}","comments_url":"https://api.github.com/repos/sgmap/pix/comments{/number}","issue_comment_url":"https://api.github.com/repos/sgmap/pix/issues/comments{/number}","contents_url":"https://api.github.com/repos/sgmap/pix/contents/{+path}","compare_url":"https://api.github.com/repos/sgmap/pix/compare/{base}...{head}","merges_url":"https://api.github.com/repos/sgmap/pix/merges","archive_url":"https://api.github.com/repos/sgmap/pix/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/sgmap/pix/downloads","issues_url":"https://api.github.com/repos/sgmap/pix/issues{/number}","pulls_url":"https://api.github.com/repos/sgmap/pix/pulls{/number}","milestones_url":"https://api.github.com/repos/sgmap/pix/milestones{/number}","notifications_url":"https://api.github.com/repos/sgmap/pix/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/sgmap/pix/labels{/name}","releases_url":"https://api.github.com/repos/sgmap/pix/releases{/id}","deployments_url":"https://api.github.com/repos/sgmap/pix/deployments","created_at":"2016-07-11T12:31:15Z","updated_at":"2017-11-10T11:04:19Z","pushed_at":"2017-12-04T16:05:54Z","git_url":"git://github.com/sgmap/pix.git","ssh_url":"git@github.com:sgmap/pix.git","clone_url":"https://github.com/sgmap/pix.git","svn_url":"https://github.com/sgmap/pix","homepage":"https://pix.beta.gouv.fr","size":206569,"stargazers_count":38,"watchers_count":38,"language":"JavaScript","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":8,"mirror_url":null,"archived":false,"open_issues_count":30,"license":null,"forks":8,"open_issues":30,"watchers":38,"default_branch":"dev"}},"base":{"label":"sgmap:dev","ref":"dev","sha":"f25e2d422349ecc0765ceaac7f2a84c1cb0bec4f","user":{"login":"sgmap","id":7874148,"avatar_url":"https://avatars0.githubusercontent.com/u/7874148?v=4","gravatar_id":"","url":"https://api.github.com/users/sgmap","html_url":"https://github.com/sgmap","followers_url":"https://api.github.com/users/sgmap/followers","following_url":"https://api.github.com/users/sgmap/following{/other_user}","gists_url":"https://api.github.com/users/sgmap/gists{/gist_id}","starred_url":"https://api.github.com/users/sgmap/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sgmap/subscriptions","organizations_url":"https://api.github.com/users/sgmap/orgs","repos_url":"https://api.github.com/users/sgmap/repos","events_url":"https://api.github.com/users/sgmap/events{/privacy}","received_events_url":"https://api.github.com/users/sgmap/received_events","type":"Organization","site_admin":false},"repo":{"id":63066169,"name":"pix","full_name":"sgmap/pix","owner":{"login":"sgmap","id":7874148,"avatar_url":"https://avatars0.githubusercontent.com/u/7874148?v=4","gravatar_id":"","url":"https://api.github.com/users/sgmap","html_url":"https://github.com/sgmap","followers_url":"https://api.github.com/users/sgmap/followers","following_url":"https://api.github.com/users/sgmap/following{/other_user}","gists_url":"https://api.github.com/users/sgmap/gists{/gist_id}","starred_url":"https://api.github.com/users/sgmap/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sgmap/subscriptions","organizations_url":"https://api.github.com/users/sgmap/orgs","repos_url":"https://api.github.com/users/sgmap/repos","events_url":"https://api.github.com/users/sgmap/events{/privacy}","received_events_url":"https://api.github.com/users/sgmap/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/sgmap/pix","description":"Plateforme d'évaluation et de certification des compétences numériques à l'usage de tous les citoyens francophones.","fork":false,"url":"https://api.github.com/repos/sgmap/pix","forks_url":"https://api.github.com/repos/sgmap/pix/forks","keys_url":"https://api.github.com/repos/sgmap/pix/keys{/key_id}","collaborators_url":"https://api.github.com/repos/sgmap/pix/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/sgmap/pix/teams","hooks_url":"https://api.github.com/repos/sgmap/pix/hooks","issue_events_url":"https://api.github.com/repos/sgmap/pix/issues/events{/number}","events_url":"https://api.github.com/repos/sgmap/pix/events","assignees_url":"https://api.github.com/repos/sgmap/pix/assignees{/user}","branches_url":"https://api.github.com/repos/sgmap/pix/branches{/branch}","tags_url":"https://api.github.com/repos/sgmap/pix/tags","blobs_url":"https://api.github.com/repos/sgmap/pix/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/sgmap/pix/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/sgmap/pix/git/refs{/sha}","trees_url":"https://api.github.com/repos/sgmap/pix/git/trees{/sha}","statuses_url":"https://api.github.com/repos/sgmap/pix/statuses/{sha}","languages_url":"https://api.github.com/repos/sgmap/pix/languages","stargazers_url":"https://api.github.com/repos/sgmap/pix/stargazers","contributors_url":"https://api.github.com/repos/sgmap/pix/contributors","subscribers_url":"https://api.github.com/repos/sgmap/pix/subscribers","subscription_url":"https://api.github.com/repos/sgmap/pix/subscription","commits_url":"https://api.github.com/repos/sgmap/pix/commits{/sha}","git_commits_url":"https://api.github.com/repos/sgmap/pix/git/commits{/sha}","comments_url":"https://api.github.com/repos/sgmap/pix/comments{/number}","issue_comment_url":"https://api.github.com/repos/sgmap/pix/issues/comments{/number}","contents_url":"https://api.github.com/repos/sgmap/pix/contents/{+path}","compare_url":"https://api.github.com/repos/sgmap/pix/compare/{base}...{head}","merges_url":"https://api.github.com/repos/sgmap/pix/merges","archive_url":"https://api.github.com/repos/sgmap/pix/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/sgmap/pix/downloads","issues_url":"https://api.github.com/repos/sgmap/pix/issues{/number}","pulls_url":"https://api.github.com/repos/sgmap/pix/pulls{/number}","milestones_url":"https://api.github.com/repos/sgmap/pix/milestones{/number}","notifications_url":"https://api.github.com/repos/sgmap/pix/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/sgmap/pix/labels{/name}","releases_url":"https://api.github.com/repos/sgmap/pix/releases{/id}","deployments_url":"https://api.github.com/repos/sgmap/pix/deployments","created_at":"2016-07-11T12:31:15Z","updated_at":"2017-11-10T11:04:19Z","pushed_at":"2017-12-04T16:05:54Z","git_url":"git://github.com/sgmap/pix.git","ssh_url":"git@github.com:sgmap/pix.git","clone_url":"https://github.com/sgmap/pix.git","svn_url":"https://github.com/sgmap/pix","homepage":"https://pix.beta.gouv.fr","size":206569,"stargazers_count":38,"watchers_count":38,"language":"JavaScript","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":8,"mirror_url":null,"archived":false,"open_issues_count":30,"license":null,"forks":8,"open_issues":30,"watchers":38,"default_branch":"dev"}},"_links":{"self":{"href":"https://api.github.com/repos/sgmap/pix/pulls/610"},"html":{"href":"https://github.com/sgmap/pix/pull/610"},"issue":{"href":"https://api.github.com/repos/sgmap/pix/issues/610"},"comments":{"href":"https://api.github.com/repos/sgmap/pix/issues/610/comments"},"review_comments":{"href":"https://api.github.com/repos/sgmap/pix/pulls/610/comments"},"review_comment":{"href":"https://api.github.com/repos/sgmap/pix/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/sgmap/pix/pulls/610/commits"},"statuses":{"href":"https://api.github.com/repos/sgmap/pix/statuses/9e32dd6d0018c058cc26d78a96b0452d5a994961"}},"author_association":"COLLABORATOR"}}
{"actor":{"display_login":"Akhilian"}}