{"action":"created","comment":{"url":"https://api.github.com/repos/edx/edx-platform/pulls/comments/36615339","id":36615339,"diff_hunk":"@@ -0,0 +1,48 @@\n+\"\"\"\n+Implementation of \"Instructor\" service\n+\"\"\"\n+\n+import logging\n+\n+from opaque_keys import InvalidKeyError\n+from opaque_keys.edx.locations import SlashSeparatedCourseKey\n+from courseware.models import StudentModule\n+from instructor.views.tools import get_student_from_identifier\n+import instructor.enrollment as enrollment\n+\n+\n+log = logging.getLogger(__name__)\n+\n+\n+class InstructorService(object):\n+    \"\"\"\n+    Instructor service for deleting the students attempt(s) of an exam. This service has been created\n+    for the edx_proctoring's dependency injection to cater for a requirement where edx_proctoring\n+    needs to call into edx-platform's functions to delete the students' existing answers, grades\n+    and attempt counts if there had been an earlier attempt.\n+    \"\"\"\n+\n+    def delete_student_attempt(self, student_identifier, course_id, content_id):\n+        \"\"\"\n+        Deletes student state for a problem.\n+\n+        Takes some of the following query parameters\n+            - content_id is a url-name of a problem\n+            - unique_student_identifier is an email or username\n+            - course_id is the id for the course\n+        \"\"\"\n+        course_id = SlashSeparatedCourseKey.from_deprecated_string(course_id)\n+        student = get_student_from_identifier(student_identifier)\n+        try:\n+            module_state_key = course_id.make_usage_key_from_deprecated_string(content_id)","path":"lms/djangoapps/instructor/services.py","position":37,"original_position":37,"commit_id":"a4d26962a6e8a8c1f039d6f0b5c784855e970491","original_commit_id":"db9a88860d9a226ff109f72177a7668dc8f23b38","user":{"login":"muhhshoaib","id":7291787,"avatar_url":"https://avatars.githubusercontent.com/u/7291787?v=3","gravatar_id":"","url":"https://api.github.com/users/muhhshoaib","html_url":"https://github.com/muhhshoaib","followers_url":"https://api.github.com/users/muhhshoaib/followers","following_url":"https://api.github.com/users/muhhshoaib/following{/other_user}","gists_url":"https://api.github.com/users/muhhshoaib/gists{/gist_id}","starred_url":"https://api.github.com/users/muhhshoaib/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/muhhshoaib/subscriptions","organizations_url":"https://api.github.com/users/muhhshoaib/orgs","repos_url":"https://api.github.com/users/muhhshoaib/repos","events_url":"https://api.github.com/users/muhhshoaib/events{/privacy}","received_events_url":"https://api.github.com/users/muhhshoaib/received_events","type":"User","site_admin":false},"body":"done https://github.com/edx/edx-platform/pull/9249/files","created_at":"2015-08-10T09:43:24Z","updated_at":"2015-08-10T09:43:24Z","html_url":"https://github.com/edx/edx-platform/pull/9069#discussion_r36615339","pull_request_url":"https://api.github.com/repos/edx/edx-platform/pulls/9069","_links":{"self":{"href":"https://api.github.com/repos/edx/edx-platform/pulls/comments/36615339"},"html":{"href":"https://github.com/edx/edx-platform/pull/9069#discussion_r36615339"},"pull_request":{"href":"https://api.github.com/repos/edx/edx-platform/pulls/9069"}}},"pull_request":{"url":"https://api.github.com/repos/edx/edx-platform/pulls/9069","id":40825804,"html_url":"https://github.com/edx/edx-platform/pull/9069","diff_url":"https://github.com/edx/edx-platform/pull/9069.diff","patch_url":"https://github.com/edx/edx-platform/pull/9069.patch","issue_url":"https://api.github.com/repos/edx/edx-platform/issues/9069","number":9069,"state":"open","locked":false,"title":"Integration of Proctoring into the LMS","user":{"login":"chrisndodge","id":2362917,"avatar_url":"https://avatars.githubusercontent.com/u/2362917?v=3","gravatar_id":"","url":"https://api.github.com/users/chrisndodge","html_url":"https://github.com/chrisndodge","followers_url":"https://api.github.com/users/chrisndodge/followers","following_url":"https://api.github.com/users/chrisndodge/following{/other_user}","gists_url":"https://api.github.com/users/chrisndodge/gists{/gist_id}","starred_url":"https://api.github.com/users/chrisndodge/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/chrisndodge/subscriptions","organizations_url":"https://api.github.com/users/chrisndodge/orgs","repos_url":"https://api.github.com/users/chrisndodge/repos","events_url":"https://api.github.com/users/chrisndodge/events{/privacy}","received_events_url":"https://api.github.com/users/chrisndodge/received_events","type":"User","site_admin":false},"body":"","created_at":"2015-07-24T23:50:57Z","updated_at":"2015-08-10T09:43:24Z","closed_at":null,"merged_at":null,"merge_commit_sha":"2037496027262f2a774245988b62db608daf66cf","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/edx/edx-platform/pulls/9069/commits","review_comments_url":"https://api.github.com/repos/edx/edx-platform/pulls/9069/comments","review_comment_url":"https://api.github.com/repos/edx/edx-platform/pulls/comments{/number}","comments_url":"https://api.github.com/repos/edx/edx-platform/issues/9069/comments","statuses_url":"https://api.github.com/repos/edx/edx-platform/statuses/a4d26962a6e8a8c1f039d6f0b5c784855e970491","head":{"label":"edx:cdodge/proctoring-lms-integration","ref":"cdodge/proctoring-lms-integration","sha":"a4d26962a6e8a8c1f039d6f0b5c784855e970491","user":{"login":"edx","id":3179841,"avatar_url":"https://avatars.githubusercontent.com/u/3179841?v=3","gravatar_id":"","url":"https://api.github.com/users/edx","html_url":"https://github.com/edx","followers_url":"https://api.github.com/users/edx/followers","following_url":"https://api.github.com/users/edx/following{/other_user}","gists_url":"https://api.github.com/users/edx/gists{/gist_id}","starred_url":"https://api.github.com/users/edx/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/edx/subscriptions","organizations_url":"https://api.github.com/users/edx/orgs","repos_url":"https://api.github.com/users/edx/repos","events_url":"https://api.github.com/users/edx/events{/privacy}","received_events_url":"https://api.github.com/users/edx/received_events","type":"Organization","site_admin":false},"repo":{"id":10391073,"name":"edx-platform","full_name":"edx/edx-platform","owner":{"login":"edx","id":3179841,"avatar_url":"https://avatars.githubusercontent.com/u/3179841?v=3","gravatar_id":"","url":"https://api.github.com/users/edx","html_url":"https://github.com/edx","followers_url":"https://api.github.com/users/edx/followers","following_url":"https://api.github.com/users/edx/following{/other_user}","gists_url":"https://api.github.com/users/edx/gists{/gist_id}","starred_url":"https://api.github.com/users/edx/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/edx/subscriptions","organizations_url":"https://api.github.com/users/edx/orgs","repos_url":"https://api.github.com/users/edx/repos","events_url":"https://api.github.com/users/edx/events{/privacy}","received_events_url":"https://api.github.com/users/edx/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/edx/edx-platform","description":"The Open edX platform, the software that powers edX!","fork":false,"url":"https://api.github.com/repos/edx/edx-platform","forks_url":"https://api.github.com/repos/edx/edx-platform/forks","keys_url":"https://api.github.com/repos/edx/edx-platform/keys{/key_id}","collaborators_url":"https://api.github.com/repos/edx/edx-platform/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/edx/edx-platform/teams","hooks_url":"https://api.github.com/repos/edx/edx-platform/hooks","issue_events_url":"https://api.github.com/repos/edx/edx-platform/issues/events{/number}","events_url":"https://api.github.com/repos/edx/edx-platform/events","assignees_url":"https://api.github.com/repos/edx/edx-platform/assignees{/user}","branches_url":"https://api.github.com/repos/edx/edx-platform/branches{/branch}","tags_url":"https://api.github.com/repos/edx/edx-platform/tags","blobs_url":"https://api.github.com/repos/edx/edx-platform/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/edx/edx-platform/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/edx/edx-platform/git/refs{/sha}","trees_url":"https://api.github.com/repos/edx/edx-platform/git/trees{/sha}","statuses_url":"https://api.github.com/repos/edx/edx-platform/statuses/{sha}","languages_url":"https://api.github.com/repos/edx/edx-platform/languages","stargazers_url":"https://api.github.com/repos/edx/edx-platform/stargazers","contributors_url":"https://api.github.com/repos/edx/edx-platform/contributors","subscribers_url":"https://api.github.com/repos/edx/edx-platform/subscribers","subscription_url":"https://api.github.com/repos/edx/edx-platform/subscription","commits_url":"https://api.github.com/repos/edx/edx-platform/commits{/sha}","git_commits_url":"https://api.github.com/repos/edx/edx-platform/git/commits{/sha}","comments_url":"https://api.github.com/repos/edx/edx-platform/comments{/number}","issue_comment_url":"https://api.github.com/repos/edx/edx-platform/issues/comments{/number}","contents_url":"https://api.github.com/repos/edx/edx-platform/contents/{+path}","compare_url":"https://api.github.com/repos/edx/edx-platform/compare/{base}...{head}","merges_url":"https://api.github.com/repos/edx/edx-platform/merges","archive_url":"https://api.github.com/repos/edx/edx-platform/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/edx/edx-platform/downloads","issues_url":"https://api.github.com/repos/edx/edx-platform/issues{/number}","pulls_url":"https://api.github.com/repos/edx/edx-platform/pulls{/number}","milestones_url":"https://api.github.com/repos/edx/edx-platform/milestones{/number}","notifications_url":"https://api.github.com/repos/edx/edx-platform/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/edx/edx-platform/labels{/name}","releases_url":"https://api.github.com/repos/edx/edx-platform/releases{/id}","created_at":"2013-05-30T20:20:38Z","updated_at":"2015-08-09T21:21:33Z","pushed_at":"2015-08-10T09:39:42Z","git_url":"git://github.com/edx/edx-platform.git","ssh_url":"git@github.com:edx/edx-platform.git","clone_url":"https://github.com/edx/edx-platform.git","svn_url":"https://github.com/edx/edx-platform","homepage":"http://open.edx.org/","size":2083128,"stargazers_count":2068,"watchers_count":2068,"language":"Python","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":1209,"mirror_url":null,"open_issues_count":147,"forks":1209,"open_issues":147,"watchers":2068,"default_branch":"master"}},"base":{"label":"edx:master","ref":"master","sha":"24bca27b46a0e65c00628716a77d19a6c5aecd55","user":{"login":"edx","id":3179841,"avatar_url":"https://avatars.githubusercontent.com/u/3179841?v=3","gravatar_id":"","url":"https://api.github.com/users/edx","html_url":"https://github.com/edx","followers_url":"https://api.github.com/users/edx/followers","following_url":"https://api.github.com/users/edx/following{/other_user}","gists_url":"https://api.github.com/users/edx/gists{/gist_id}","starred_url":"https://api.github.com/users/edx/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/edx/subscriptions","organizations_url":"https://api.github.com/users/edx/orgs","repos_url":"https://api.github.com/users/edx/repos","events_url":"https://api.github.com/users/edx/events{/privacy}","received_events_url":"https://api.github.com/users/edx/received_events","type":"Organization","site_admin":false},"repo":{"id":10391073,"name":"edx-platform","full_name":"edx/edx-platform","owner":{"login":"edx","id":3179841,"avatar_url":"https://avatars.githubusercontent.com/u/3179841?v=3","gravatar_id":"","url":"https://api.github.com/users/edx","html_url":"https://github.com/edx","followers_url":"https://api.github.com/users/edx/followers","following_url":"https://api.github.com/users/edx/following{/other_user}","gists_url":"https://api.github.com/users/edx/gists{/gist_id}","starred_url":"https://api.github.com/users/edx/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/edx/subscriptions","organizations_url":"https://api.github.com/users/edx/orgs","repos_url":"https://api.github.com/users/edx/repos","events_url":"https://api.github.com/users/edx/events{/privacy}","received_events_url":"https://api.github.com/users/edx/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/edx/edx-platform","description":"The Open edX platform, the software that powers edX!","fork":false,"url":"https://api.github.com/repos/edx/edx-platform","forks_url":"https://api.github.com/repos/edx/edx-platform/forks","keys_url":"https://api.github.com/repos/edx/edx-platform/keys{/key_id}","collaborators_url":"https://api.github.com/repos/edx/edx-platform/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/edx/edx-platform/teams","hooks_url":"https://api.github.com/repos/edx/edx-platform/hooks","issue_events_url":"https://api.github.com/repos/edx/edx-platform/issues/events{/number}","events_url":"https://api.github.com/repos/edx/edx-platform/events","assignees_url":"https://api.github.com/repos/edx/edx-platform/assignees{/user}","branches_url":"https://api.github.com/repos/edx/edx-platform/branches{/branch}","tags_url":"https://api.github.com/repos/edx/edx-platform/tags","blobs_url":"https://api.github.com/repos/edx/edx-platform/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/edx/edx-platform/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/edx/edx-platform/git/refs{/sha}","trees_url":"https://api.github.com/repos/edx/edx-platform/git/trees{/sha}","statuses_url":"https://api.github.com/repos/edx/edx-platform/statuses/{sha}","languages_url":"https://api.github.com/repos/edx/edx-platform/languages","stargazers_url":"https://api.github.com/repos/edx/edx-platform/stargazers","contributors_url":"https://api.github.com/repos/edx/edx-platform/contributors","subscribers_url":"https://api.github.com/repos/edx/edx-platform/subscribers","subscription_url":"https://api.github.com/repos/edx/edx-platform/subscription","commits_url":"https://api.github.com/repos/edx/edx-platform/commits{/sha}","git_commits_url":"https://api.github.com/repos/edx/edx-platform/git/commits{/sha}","comments_url":"https://api.github.com/repos/edx/edx-platform/comments{/number}","issue_comment_url":"https://api.github.com/repos/edx/edx-platform/issues/comments{/number}","contents_url":"https://api.github.com/repos/edx/edx-platform/contents/{+path}","compare_url":"https://api.github.com/repos/edx/edx-platform/compare/{base}...{head}","merges_url":"https://api.github.com/repos/edx/edx-platform/merges","archive_url":"https://api.github.com/repos/edx/edx-platform/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/edx/edx-platform/downloads","issues_url":"https://api.github.com/repos/edx/edx-platform/issues{/number}","pulls_url":"https://api.github.com/repos/edx/edx-platform/pulls{/number}","milestones_url":"https://api.github.com/repos/edx/edx-platform/milestones{/number}","notifications_url":"https://api.github.com/repos/edx/edx-platform/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/edx/edx-platform/labels{/name}","releases_url":"https://api.github.com/repos/edx/edx-platform/releases{/id}","created_at":"2013-05-30T20:20:38Z","updated_at":"2015-08-09T21:21:33Z","pushed_at":"2015-08-10T09:39:42Z","git_url":"git://github.com/edx/edx-platform.git","ssh_url":"git@github.com:edx/edx-platform.git","clone_url":"https://github.com/edx/edx-platform.git","svn_url":"https://github.com/edx/edx-platform","homepage":"http://open.edx.org/","size":2083128,"stargazers_count":2068,"watchers_count":2068,"language":"Python","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":1209,"mirror_url":null,"open_issues_count":147,"forks":1209,"open_issues":147,"watchers":2068,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/edx/edx-platform/pulls/9069"},"html":{"href":"https://github.com/edx/edx-platform/pull/9069"},"issue":{"href":"https://api.github.com/repos/edx/edx-platform/issues/9069"},"comments":{"href":"https://api.github.com/repos/edx/edx-platform/issues/9069/comments"},"review_comments":{"href":"https://api.github.com/repos/edx/edx-platform/pulls/9069/comments"},"review_comment":{"href":"https://api.github.com/repos/edx/edx-platform/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/edx/edx-platform/pulls/9069/commits"},"statuses":{"href":"https://api.github.com/repos/edx/edx-platform/statuses/a4d26962a6e8a8c1f039d6f0b5c784855e970491"}}}}