{"action":"created","comment":{"url":"https://api.github.com/repos/open-craft/xblock-eoc-journal/pulls/comments/126771394","pull_request_review_id":49288121,"id":126771394,"diff_hunk":"@@ -196,6 +200,62 @@ def _get_current_anonymous_user_id(self):\n         \"\"\"\n         return self.runtime.anonymous_student_id\n \n+    def get_progress_metrics(self):\n+        \"\"\"\n+        Fetches and returns dict with progress metrics for the current user\n+        in the course.\n+        \"\"\"\n+        user = self._get_current_user()\n+        course_id = getattr(self.runtime, 'course_id', 'course_id')\n+        course_id = unicode(normalize_id(course_id))\n+        client = ApiClient(user, course_id)\n+\n+        metrics = client.get_user_progress_metrics()\n+\n+        user_progress = metrics.get('completions', 0)\n+        cohort_average = metrics.get('course_avg', 0)\n+\n+        return {\n+            'user': round(user_progress, 0),\n+            'cohort_average': round(cohort_average, 0),\n+        }\n+\n+    def get_engagement_metrics(self):\n+        \"\"\"\n+        Fetches and returns dict with engagement metrics for the current user\n+        and course.\n+        \"\"\"\n+        user = self._get_current_user()\n+        course_id = getattr(self.runtime, 'course_id', 'course_id')\n+        course_id = unicode(normalize_id(course_id))\n+        client = ApiClient(user, course_id)\n+\n+        user_engagement = client.get_user_engagement_metrics()\n+        course_engagement = client.get_cohort_engagement_metrics()\n+\n+        course_point_sum = [\n+            calculate_engagement_score(metrics[1])\n+            for metrics in course_engagement['users'].iteritems()","path":"eoc_journal/eoc_journal.py","position":57,"original_position":57,"commit_id":"3eefb9fcad0690f46de5d4221860cdda80f73771","original_commit_id":"3eefb9fcad0690f46de5d4221860cdda80f73771","user":{"login":"snowcrshd","id":831084,"avatar_url":"https://avatars2.githubusercontent.com/u/831084?v=3","gravatar_id":"","url":"https://api.github.com/users/snowcrshd","html_url":"https://github.com/snowcrshd","followers_url":"https://api.github.com/users/snowcrshd/followers","following_url":"https://api.github.com/users/snowcrshd/following{/other_user}","gists_url":"https://api.github.com/users/snowcrshd/gists{/gist_id}","starred_url":"https://api.github.com/users/snowcrshd/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/snowcrshd/subscriptions","organizations_url":"https://api.github.com/users/snowcrshd/orgs","repos_url":"https://api.github.com/users/snowcrshd/repos","events_url":"https://api.github.com/users/snowcrshd/events{/privacy}","received_events_url":"https://api.github.com/users/snowcrshd/received_events","type":"User","site_admin":false},"body":"done","created_at":"2017-07-11T18:28:42Z","updated_at":"2017-07-11T18:28:42Z","html_url":"https://github.com/open-craft/xblock-eoc-journal/pull/6#discussion_r126771394","pull_request_url":"https://api.github.com/repos/open-craft/xblock-eoc-journal/pulls/6","_links":{"self":{"href":"https://api.github.com/repos/open-craft/xblock-eoc-journal/pulls/comments/126771394"},"html":{"href":"https://github.com/open-craft/xblock-eoc-journal/pull/6#discussion_r126771394"},"pull_request":{"href":"https://api.github.com/repos/open-craft/xblock-eoc-journal/pulls/6"}}},"pull_request":{"url":"https://api.github.com/repos/open-craft/xblock-eoc-journal/pulls/6","id":129236099,"html_url":"https://github.com/open-craft/xblock-eoc-journal/pull/6","diff_url":"https://github.com/open-craft/xblock-eoc-journal/pull/6.diff","patch_url":"https://github.com/open-craft/xblock-eoc-journal/pull/6.patch","issue_url":"https://api.github.com/repos/open-craft/xblock-eoc-journal/issues/6","number":6,"state":"open","locked":false,"title":"Show progress and engagement in EOC journal","user":{"login":"snowcrshd","id":831084,"avatar_url":"https://avatars2.githubusercontent.com/u/831084?v=3","gravatar_id":"","url":"https://api.github.com/users/snowcrshd","html_url":"https://github.com/snowcrshd","followers_url":"https://api.github.com/users/snowcrshd/followers","following_url":"https://api.github.com/users/snowcrshd/following{/other_user}","gists_url":"https://api.github.com/users/snowcrshd/gists{/gist_id}","starred_url":"https://api.github.com/users/snowcrshd/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/snowcrshd/subscriptions","organizations_url":"https://api.github.com/users/snowcrshd/orgs","repos_url":"https://api.github.com/users/snowcrshd/repos","events_url":"https://api.github.com/users/snowcrshd/events{/privacy}","received_events_url":"https://api.github.com/users/snowcrshd/received_events","type":"User","site_admin":false},"body":"This PR adds user progress and engagement metrics in a course.\r\n\r\n**Testing**\r\n\r\n- Setup course with xblock-eoc-journal\r\n- Make comments and posts in the discussion forum\r\n- Complete tasks in the course\r\n- Go to the EOC journal, check that the user and cohort progress display matches the one shown in the course home\r\n- Checkt that the engagement metrics are displayed in a table.\r\n\r\n<img width=\"1056\" alt=\"screen shot 2017-07-10 at 20 32 48\" src=\"https://user-images.githubusercontent.com/831084/28044660-1001dd04-65af-11e7-8bca-61885e1d63cf.png\">\r\n\r\n**Reviewers**\r\n\r\n- [ ] @mtyaka  ","created_at":"2017-07-06T17:08:10Z","updated_at":"2017-07-11T18:28:42Z","closed_at":null,"merged_at":null,"merge_commit_sha":"22b72746d103c1dc817e377d871df4dbba0fe38c","assignee":null,"assignees":[],"requested_reviewers":[],"milestone":null,"commits_url":"https://api.github.com/repos/open-craft/xblock-eoc-journal/pulls/6/commits","review_comments_url":"https://api.github.com/repos/open-craft/xblock-eoc-journal/pulls/6/comments","review_comment_url":"https://api.github.com/repos/open-craft/xblock-eoc-journal/pulls/comments{/number}","comments_url":"https://api.github.com/repos/open-craft/xblock-eoc-journal/issues/6/comments","statuses_url":"https://api.github.com/repos/open-craft/xblock-eoc-journal/statuses/3eefb9fcad0690f46de5d4221860cdda80f73771","head":{"label":"open-craft:lucas/show-progress","ref":"lucas/show-progress","sha":"3eefb9fcad0690f46de5d4221860cdda80f73771","user":{"login":"open-craft","id":7414786,"avatar_url":"https://avatars3.githubusercontent.com/u/7414786?v=3","gravatar_id":"","url":"https://api.github.com/users/open-craft","html_url":"https://github.com/open-craft","followers_url":"https://api.github.com/users/open-craft/followers","following_url":"https://api.github.com/users/open-craft/following{/other_user}","gists_url":"https://api.github.com/users/open-craft/gists{/gist_id}","starred_url":"https://api.github.com/users/open-craft/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/open-craft/subscriptions","organizations_url":"https://api.github.com/users/open-craft/orgs","repos_url":"https://api.github.com/users/open-craft/repos","events_url":"https://api.github.com/users/open-craft/events{/privacy}","received_events_url":"https://api.github.com/users/open-craft/received_events","type":"Organization","site_admin":false},"repo":{"id":95081214,"name":"xblock-eoc-journal","full_name":"open-craft/xblock-eoc-journal","owner":{"login":"open-craft","id":7414786,"avatar_url":"https://avatars3.githubusercontent.com/u/7414786?v=3","gravatar_id":"","url":"https://api.github.com/users/open-craft","html_url":"https://github.com/open-craft","followers_url":"https://api.github.com/users/open-craft/followers","following_url":"https://api.github.com/users/open-craft/following{/other_user}","gists_url":"https://api.github.com/users/open-craft/gists{/gist_id}","starred_url":"https://api.github.com/users/open-craft/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/open-craft/subscriptions","organizations_url":"https://api.github.com/users/open-craft/orgs","repos_url":"https://api.github.com/users/open-craft/repos","events_url":"https://api.github.com/users/open-craft/events{/privacy}","received_events_url":"https://api.github.com/users/open-craft/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/open-craft/xblock-eoc-journal","description":"\"End of Course\" Journal XBlock","fork":false,"url":"https://api.github.com/repos/open-craft/xblock-eoc-journal","forks_url":"https://api.github.com/repos/open-craft/xblock-eoc-journal/forks","keys_url":"https://api.github.com/repos/open-craft/xblock-eoc-journal/keys{/key_id}","collaborators_url":"https://api.github.com/repos/open-craft/xblock-eoc-journal/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/open-craft/xblock-eoc-journal/teams","hooks_url":"https://api.github.com/repos/open-craft/xblock-eoc-journal/hooks","issue_events_url":"https://api.github.com/repos/open-craft/xblock-eoc-journal/issues/events{/number}","events_url":"https://api.github.com/repos/open-craft/xblock-eoc-journal/events","assignees_url":"https://api.github.com/repos/open-craft/xblock-eoc-journal/assignees{/user}","branches_url":"https://api.github.com/repos/open-craft/xblock-eoc-journal/branches{/branch}","tags_url":"https://api.github.com/repos/open-craft/xblock-eoc-journal/tags","blobs_url":"https://api.github.com/repos/open-craft/xblock-eoc-journal/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/open-craft/xblock-eoc-journal/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/open-craft/xblock-eoc-journal/git/refs{/sha}","trees_url":"https://api.github.com/repos/open-craft/xblock-eoc-journal/git/trees{/sha}","statuses_url":"https://api.github.com/repos/open-craft/xblock-eoc-journal/statuses/{sha}","languages_url":"https://api.github.com/repos/open-craft/xblock-eoc-journal/languages","stargazers_url":"https://api.github.com/repos/open-craft/xblock-eoc-journal/stargazers","contributors_url":"https://api.github.com/repos/open-craft/xblock-eoc-journal/contributors","subscribers_url":"https://api.github.com/repos/open-craft/xblock-eoc-journal/subscribers","subscription_url":"https://api.github.com/repos/open-craft/xblock-eoc-journal/subscription","commits_url":"https://api.github.com/repos/open-craft/xblock-eoc-journal/commits{/sha}","git_commits_url":"https://api.github.com/repos/open-craft/xblock-eoc-journal/git/commits{/sha}","comments_url":"https://api.github.com/repos/open-craft/xblock-eoc-journal/comments{/number}","issue_comment_url":"https://api.github.com/repos/open-craft/xblock-eoc-journal/issues/comments{/number}","contents_url":"https://api.github.com/repos/open-craft/xblock-eoc-journal/contents/{+path}","compare_url":"https://api.github.com/repos/open-craft/xblock-eoc-journal/compare/{base}...{head}","merges_url":"https://api.github.com/repos/open-craft/xblock-eoc-journal/merges","archive_url":"https://api.github.com/repos/open-craft/xblock-eoc-journal/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/open-craft/xblock-eoc-journal/downloads","issues_url":"https://api.github.com/repos/open-craft/xblock-eoc-journal/issues{/number}","pulls_url":"https://api.github.com/repos/open-craft/xblock-eoc-journal/pulls{/number}","milestones_url":"https://api.github.com/repos/open-craft/xblock-eoc-journal/milestones{/number}","notifications_url":"https://api.github.com/repos/open-craft/xblock-eoc-journal/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/open-craft/xblock-eoc-journal/labels{/name}","releases_url":"https://api.github.com/repos/open-craft/xblock-eoc-journal/releases{/id}","deployments_url":"https://api.github.com/repos/open-craft/xblock-eoc-journal/deployments","created_at":"2017-06-22T06:15:08Z","updated_at":"2017-06-27T06:18:28Z","pushed_at":"2017-07-10T23:37:09Z","git_url":"git://github.com/open-craft/xblock-eoc-journal.git","ssh_url":"git@github.com:open-craft/xblock-eoc-journal.git","clone_url":"https://github.com/open-craft/xblock-eoc-journal.git","svn_url":"https://github.com/open-craft/xblock-eoc-journal","homepage":null,"size":37,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":1,"forks":1,"open_issues":1,"watchers":0,"default_branch":"master"}},"base":{"label":"open-craft:master","ref":"master","sha":"f2749cf50adf1ed053d71d907357e1d3e76e9e37","user":{"login":"open-craft","id":7414786,"avatar_url":"https://avatars3.githubusercontent.com/u/7414786?v=3","gravatar_id":"","url":"https://api.github.com/users/open-craft","html_url":"https://github.com/open-craft","followers_url":"https://api.github.com/users/open-craft/followers","following_url":"https://api.github.com/users/open-craft/following{/other_user}","gists_url":"https://api.github.com/users/open-craft/gists{/gist_id}","starred_url":"https://api.github.com/users/open-craft/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/open-craft/subscriptions","organizations_url":"https://api.github.com/users/open-craft/orgs","repos_url":"https://api.github.com/users/open-craft/repos","events_url":"https://api.github.com/users/open-craft/events{/privacy}","received_events_url":"https://api.github.com/users/open-craft/received_events","type":"Organization","site_admin":false},"repo":{"id":95081214,"name":"xblock-eoc-journal","full_name":"open-craft/xblock-eoc-journal","owner":{"login":"open-craft","id":7414786,"avatar_url":"https://avatars3.githubusercontent.com/u/7414786?v=3","gravatar_id":"","url":"https://api.github.com/users/open-craft","html_url":"https://github.com/open-craft","followers_url":"https://api.github.com/users/open-craft/followers","following_url":"https://api.github.com/users/open-craft/following{/other_user}","gists_url":"https://api.github.com/users/open-craft/gists{/gist_id}","starred_url":"https://api.github.com/users/open-craft/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/open-craft/subscriptions","organizations_url":"https://api.github.com/users/open-craft/orgs","repos_url":"https://api.github.com/users/open-craft/repos","events_url":"https://api.github.com/users/open-craft/events{/privacy}","received_events_url":"https://api.github.com/users/open-craft/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/open-craft/xblock-eoc-journal","description":"\"End of Course\" Journal XBlock","fork":false,"url":"https://api.github.com/repos/open-craft/xblock-eoc-journal","forks_url":"https://api.github.com/repos/open-craft/xblock-eoc-journal/forks","keys_url":"https://api.github.com/repos/open-craft/xblock-eoc-journal/keys{/key_id}","collaborators_url":"https://api.github.com/repos/open-craft/xblock-eoc-journal/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/open-craft/xblock-eoc-journal/teams","hooks_url":"https://api.github.com/repos/open-craft/xblock-eoc-journal/hooks","issue_events_url":"https://api.github.com/repos/open-craft/xblock-eoc-journal/issues/events{/number}","events_url":"https://api.github.com/repos/open-craft/xblock-eoc-journal/events","assignees_url":"https://api.github.com/repos/open-craft/xblock-eoc-journal/assignees{/user}","branches_url":"https://api.github.com/repos/open-craft/xblock-eoc-journal/branches{/branch}","tags_url":"https://api.github.com/repos/open-craft/xblock-eoc-journal/tags","blobs_url":"https://api.github.com/repos/open-craft/xblock-eoc-journal/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/open-craft/xblock-eoc-journal/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/open-craft/xblock-eoc-journal/git/refs{/sha}","trees_url":"https://api.github.com/repos/open-craft/xblock-eoc-journal/git/trees{/sha}","statuses_url":"https://api.github.com/repos/open-craft/xblock-eoc-journal/statuses/{sha}","languages_url":"https://api.github.com/repos/open-craft/xblock-eoc-journal/languages","stargazers_url":"https://api.github.com/repos/open-craft/xblock-eoc-journal/stargazers","contributors_url":"https://api.github.com/repos/open-craft/xblock-eoc-journal/contributors","subscribers_url":"https://api.github.com/repos/open-craft/xblock-eoc-journal/subscribers","subscription_url":"https://api.github.com/repos/open-craft/xblock-eoc-journal/subscription","commits_url":"https://api.github.com/repos/open-craft/xblock-eoc-journal/commits{/sha}","git_commits_url":"https://api.github.com/repos/open-craft/xblock-eoc-journal/git/commits{/sha}","comments_url":"https://api.github.com/repos/open-craft/xblock-eoc-journal/comments{/number}","issue_comment_url":"https://api.github.com/repos/open-craft/xblock-eoc-journal/issues/comments{/number}","contents_url":"https://api.github.com/repos/open-craft/xblock-eoc-journal/contents/{+path}","compare_url":"https://api.github.com/repos/open-craft/xblock-eoc-journal/compare/{base}...{head}","merges_url":"https://api.github.com/repos/open-craft/xblock-eoc-journal/merges","archive_url":"https://api.github.com/repos/open-craft/xblock-eoc-journal/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/open-craft/xblock-eoc-journal/downloads","issues_url":"https://api.github.com/repos/open-craft/xblock-eoc-journal/issues{/number}","pulls_url":"https://api.github.com/repos/open-craft/xblock-eoc-journal/pulls{/number}","milestones_url":"https://api.github.com/repos/open-craft/xblock-eoc-journal/milestones{/number}","notifications_url":"https://api.github.com/repos/open-craft/xblock-eoc-journal/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/open-craft/xblock-eoc-journal/labels{/name}","releases_url":"https://api.github.com/repos/open-craft/xblock-eoc-journal/releases{/id}","deployments_url":"https://api.github.com/repos/open-craft/xblock-eoc-journal/deployments","created_at":"2017-06-22T06:15:08Z","updated_at":"2017-06-27T06:18:28Z","pushed_at":"2017-07-10T23:37:09Z","git_url":"git://github.com/open-craft/xblock-eoc-journal.git","ssh_url":"git@github.com:open-craft/xblock-eoc-journal.git","clone_url":"https://github.com/open-craft/xblock-eoc-journal.git","svn_url":"https://github.com/open-craft/xblock-eoc-journal","homepage":null,"size":37,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":1,"forks":1,"open_issues":1,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/open-craft/xblock-eoc-journal/pulls/6"},"html":{"href":"https://github.com/open-craft/xblock-eoc-journal/pull/6"},"issue":{"href":"https://api.github.com/repos/open-craft/xblock-eoc-journal/issues/6"},"comments":{"href":"https://api.github.com/repos/open-craft/xblock-eoc-journal/issues/6/comments"},"review_comments":{"href":"https://api.github.com/repos/open-craft/xblock-eoc-journal/pulls/6/comments"},"review_comment":{"href":"https://api.github.com/repos/open-craft/xblock-eoc-journal/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/open-craft/xblock-eoc-journal/pulls/6/commits"},"statuses":{"href":"https://api.github.com/repos/open-craft/xblock-eoc-journal/statuses/3eefb9fcad0690f46de5d4221860cdda80f73771"}}}}
{"actor":{"display_login":"snowcrshd"}}