{"action":"created","comment":{"url":"https://api.github.com/repos/raccoongang/edx-platform/pulls/comments/35491062","id":35491062,"diff_hunk":"@@ -0,0 +1,230 @@\n+from courseware.model_data import ScoresClient\n+from courseware.grades import (\n+    MaxScoresCache, field_data_cache_for_grading, manual_transaction, get_score,\n+)\n+from courseware.module_render import get_module_for_descriptor\n+from util.module_utils import yield_dynamic_descriptor_descendants\n+from student.models import anonymous_id_for_user\n+from xmodule import graders\n+from xmodule.graders import Score\n+from xmodule.exceptions import UndefinedContext\n+from submissions import api as sub_api  # installed from the edx-submissions repository\n+\n+\n+class CourseGrading(object):\n+    \"\"\"Base class, that provides methods to grade courses.\"\"\"\n+    GRADING_TYPE = None\n+\n+    @classmethod\n+    def progress_summary(cls, *args, **kwargs):\n+        \"\"\"Wraps \"_progress_summary\" and passes GRADING_TYPE.\"\"\"\n+        return _progress_summary(cls.GRADING_TYPE, *args, **kwargs)\n+\n+    @classmethod\n+    def grading_context(cls, *args, **kwargs):\n+        \"\"\"Wraps \"_grading_context\" and passes GRADING_TYPE.\"\"\"\n+        return _grading_context(cls.GRADING_TYPE, *args, **kwargs)\n+\n+\n+class VerticalGrading(CourseGrading):\n+    \"\"\"Provides methods to grade courses by verticals.\"\"\"\n+    GRADING_TYPE = 'vertical'\n+\n+\n+class SequentialGrading(CourseGrading):\n+    \"\"\"Provides methods to grade courses by sequentials.\"\"\"\n+    GRADING_TYPE = 'sequential'\n+\n+\n+def _progress_summary(grading_type, student, request, course, field_data_cache=None, scores_client=None):\n+    \"\"\"\n+    Unwrapped version of \"progress_summary\".\n+\n+    This pulls a summary of all problems in the course.\n+\n+    Returns\n+    - courseware_summary is a summary of all sections with problems in the course.\n+    It is organized as an array of chapters, each containing an array of sections,\n+    each containing an array of scores. This contains information for graded and\n+    ungraded problems, and is good for displaying a course summary with due dates,\n+    etc.\n+\n+    Arguments:\n+        student: A User object for the student to grade\n+        course: A Descriptor containing the course to grade\n+\n+    If the student does not have access to load the course module, this function\n+    will return None.\n+\n+    \"\"\"\n+\n+    with manual_transaction():\n+        if field_data_cache is None:\n+            field_data_cache = field_data_cache_for_grading(course, student)\n+        if scores_client is None:\n+            scores_client = ScoresClient.from_field_data_cache(field_data_cache)\n+\n+        course_module = get_module_for_descriptor(\n+            student, request, course, field_data_cache, course.id, course=course\n+        )\n+        if not course_module:\n+            return None\n+\n+        course_module = getattr(course_module, '_x_module', course_module)\n+\n+    submissions_scores = sub_api.get_scores(\n+        course.id.to_deprecated_string(), anonymous_id_for_user(student, course.id)\n+    )\n+    max_scores_cache = MaxScoresCache.create_for_course(course)\n+    # For the moment, we have to get scorable_locations from field_data_cache\n+    # and not from scores_client, because scores_client is ignorant of things\n+    # in the submissions API. As a further refactoring step, submissions should\n+    # be hidden behind the ScoresClient.\n+    max_scores_cache.fetch_from_remote(field_data_cache.scorable_locations)\n+\n+    blocks_stack = [course]\n+    blocks_dict = {}\n+\n+    while blocks_stack:\n+        curr_block = blocks_stack.pop()\n+        with manual_transaction():\n+            # Skip if the block is hidden\n+            if curr_block.hide_from_toc:\n+                continue\n+\n+            key = unicode(curr_block.scope_ids.usage_id)\n+            children = curr_block.get_display_items() if curr_block.category != grading_type else []\n+            block = {\n+                'display_name': curr_block.display_name_with_default,\n+                'block_type': curr_block.category,\n+                'url_name': curr_block.url_name,\n+                'children': [unicode(child.scope_ids.usage_id) for child in children],\n+            }\n+\n+            if curr_block.category == grading_type:\n+                graded = curr_block.graded\n+                scores = []\n+\n+                module_creator = curr_block.xmodule_runtime.get_module\n+                for module_descriptor in yield_dynamic_descriptor_descendants(\n+                        curr_block, student.id, module_creator\n+                ):\n+                    course_id = course.id","path":"openedx/core/djangoapps/grading_policy/grading.py","position":null,"original_position":112,"commit_id":"4def1a0736e634b1c126573118f05e0e83304ef2","original_commit_id":"2449d7980a09c5995ea196a96267d77bc5b30eec","user":{"login":"polesye","id":1247491,"avatar_url":"https://avatars.githubusercontent.com/u/1247491?v=3","gravatar_id":"","url":"https://api.github.com/users/polesye","html_url":"https://github.com/polesye","followers_url":"https://api.github.com/users/polesye/followers","following_url":"https://api.github.com/users/polesye/following{/other_user}","gists_url":"https://api.github.com/users/polesye/gists{/gist_id}","starred_url":"https://api.github.com/users/polesye/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/polesye/subscriptions","organizations_url":"https://api.github.com/users/polesye/orgs","repos_url":"https://api.github.com/users/polesye/repos","events_url":"https://api.github.com/users/polesye/events{/privacy}","received_events_url":"https://api.github.com/users/polesye/received_events","type":"User","site_admin":false},"body":"> unused variable\r\n\r\nRemoved","created_at":"2015-07-26T09:55:51Z","updated_at":"2015-07-26T09:55:51Z","html_url":"https://github.com/raccoongang/edx-platform/pull/8#discussion_r35491062","pull_request_url":"https://api.github.com/repos/raccoongang/edx-platform/pulls/8","_links":{"self":{"href":"https://api.github.com/repos/raccoongang/edx-platform/pulls/comments/35491062"},"html":{"href":"https://github.com/raccoongang/edx-platform/pull/8#discussion_r35491062"},"pull_request":{"href":"https://api.github.com/repos/raccoongang/edx-platform/pulls/8"}}},"pull_request":{"url":"https://api.github.com/repos/raccoongang/edx-platform/pulls/8","id":40566622,"html_url":"https://github.com/raccoongang/edx-platform/pull/8","diff_url":"https://github.com/raccoongang/edx-platform/pull/8.diff","patch_url":"https://github.com/raccoongang/edx-platform/pull/8.patch","issue_url":"https://api.github.com/repos/raccoongang/edx-platform/issues/8","number":8,"state":"open","locked":false,"title":"Оценивание по вертикалям","user":{"login":"polesye","id":1247491,"avatar_url":"https://avatars.githubusercontent.com/u/1247491?v=3","gravatar_id":"","url":"https://api.github.com/users/polesye","html_url":"https://github.com/polesye","followers_url":"https://api.github.com/users/polesye/followers","following_url":"https://api.github.com/users/polesye/following{/other_user}","gists_url":"https://api.github.com/users/polesye/gists{/gist_id}","starred_url":"https://api.github.com/users/polesye/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/polesye/subscriptions","organizations_url":"https://api.github.com/users/polesye/orgs","repos_url":"https://api.github.com/users/polesye/repos","events_url":"https://api.github.com/users/polesye/events{/privacy}","received_events_url":"https://api.github.com/users/polesye/received_events","type":"User","site_admin":false},"body":"Story: [CORER-53](http://jira.npoed.ru/browse/CORER-53)\r\n\r\nAdditional info:\r\nhttp://confluence.npoed.ru/pages/viewpage.action?pageId=557119\r\n\r\n\r\n@auraz please review.","created_at":"2015-07-22T13:50:00Z","updated_at":"2015-07-26T09:55:51Z","closed_at":null,"merged_at":null,"merge_commit_sha":"897457ea33602820f2e8744f9cc554cf5d1f4744","assignee":{"login":"auraz","id":67241,"avatar_url":"https://avatars.githubusercontent.com/u/67241?v=3","gravatar_id":"","url":"https://api.github.com/users/auraz","html_url":"https://github.com/auraz","followers_url":"https://api.github.com/users/auraz/followers","following_url":"https://api.github.com/users/auraz/following{/other_user}","gists_url":"https://api.github.com/users/auraz/gists{/gist_id}","starred_url":"https://api.github.com/users/auraz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/auraz/subscriptions","organizations_url":"https://api.github.com/users/auraz/orgs","repos_url":"https://api.github.com/users/auraz/repos","events_url":"https://api.github.com/users/auraz/events{/privacy}","received_events_url":"https://api.github.com/users/auraz/received_events","type":"User","site_admin":false},"milestone":null,"commits_url":"https://api.github.com/repos/raccoongang/edx-platform/pulls/8/commits","review_comments_url":"https://api.github.com/repos/raccoongang/edx-platform/pulls/8/comments","review_comment_url":"https://api.github.com/repos/raccoongang/edx-platform/pulls/comments{/number}","comments_url":"https://api.github.com/repos/raccoongang/edx-platform/issues/8/comments","statuses_url":"https://api.github.com/repos/raccoongang/edx-platform/statuses/4def1a0736e634b1c126573118f05e0e83304ef2","head":{"label":"raccoongang:anton/grading-v2","ref":"anton/grading-v2","sha":"4def1a0736e634b1c126573118f05e0e83304ef2","user":{"login":"raccoongang","id":11388447,"avatar_url":"https://avatars.githubusercontent.com/u/11388447?v=3","gravatar_id":"","url":"https://api.github.com/users/raccoongang","html_url":"https://github.com/raccoongang","followers_url":"https://api.github.com/users/raccoongang/followers","following_url":"https://api.github.com/users/raccoongang/following{/other_user}","gists_url":"https://api.github.com/users/raccoongang/gists{/gist_id}","starred_url":"https://api.github.com/users/raccoongang/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/raccoongang/subscriptions","organizations_url":"https://api.github.com/users/raccoongang/orgs","repos_url":"https://api.github.com/users/raccoongang/repos","events_url":"https://api.github.com/users/raccoongang/events{/privacy}","received_events_url":"https://api.github.com/users/raccoongang/received_events","type":"Organization","site_admin":false},"repo":{"id":26811891,"name":"edx-platform","full_name":"raccoongang/edx-platform","owner":{"login":"raccoongang","id":11388447,"avatar_url":"https://avatars.githubusercontent.com/u/11388447?v=3","gravatar_id":"","url":"https://api.github.com/users/raccoongang","html_url":"https://github.com/raccoongang","followers_url":"https://api.github.com/users/raccoongang/followers","following_url":"https://api.github.com/users/raccoongang/following{/other_user}","gists_url":"https://api.github.com/users/raccoongang/gists{/gist_id}","starred_url":"https://api.github.com/users/raccoongang/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/raccoongang/subscriptions","organizations_url":"https://api.github.com/users/raccoongang/orgs","repos_url":"https://api.github.com/users/raccoongang/repos","events_url":"https://api.github.com/users/raccoongang/events{/privacy}","received_events_url":"https://api.github.com/users/raccoongang/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/raccoongang/edx-platform","description":"Open edX, the edX platform that powers http://edx.org","fork":true,"url":"https://api.github.com/repos/raccoongang/edx-platform","forks_url":"https://api.github.com/repos/raccoongang/edx-platform/forks","keys_url":"https://api.github.com/repos/raccoongang/edx-platform/keys{/key_id}","collaborators_url":"https://api.github.com/repos/raccoongang/edx-platform/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/raccoongang/edx-platform/teams","hooks_url":"https://api.github.com/repos/raccoongang/edx-platform/hooks","issue_events_url":"https://api.github.com/repos/raccoongang/edx-platform/issues/events{/number}","events_url":"https://api.github.com/repos/raccoongang/edx-platform/events","assignees_url":"https://api.github.com/repos/raccoongang/edx-platform/assignees{/user}","branches_url":"https://api.github.com/repos/raccoongang/edx-platform/branches{/branch}","tags_url":"https://api.github.com/repos/raccoongang/edx-platform/tags","blobs_url":"https://api.github.com/repos/raccoongang/edx-platform/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/raccoongang/edx-platform/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/raccoongang/edx-platform/git/refs{/sha}","trees_url":"https://api.github.com/repos/raccoongang/edx-platform/git/trees{/sha}","statuses_url":"https://api.github.com/repos/raccoongang/edx-platform/statuses/{sha}","languages_url":"https://api.github.com/repos/raccoongang/edx-platform/languages","stargazers_url":"https://api.github.com/repos/raccoongang/edx-platform/stargazers","contributors_url":"https://api.github.com/repos/raccoongang/edx-platform/contributors","subscribers_url":"https://api.github.com/repos/raccoongang/edx-platform/subscribers","subscription_url":"https://api.github.com/repos/raccoongang/edx-platform/subscription","commits_url":"https://api.github.com/repos/raccoongang/edx-platform/commits{/sha}","git_commits_url":"https://api.github.com/repos/raccoongang/edx-platform/git/commits{/sha}","comments_url":"https://api.github.com/repos/raccoongang/edx-platform/comments{/number}","issue_comment_url":"https://api.github.com/repos/raccoongang/edx-platform/issues/comments{/number}","contents_url":"https://api.github.com/repos/raccoongang/edx-platform/contents/{+path}","compare_url":"https://api.github.com/repos/raccoongang/edx-platform/compare/{base}...{head}","merges_url":"https://api.github.com/repos/raccoongang/edx-platform/merges","archive_url":"https://api.github.com/repos/raccoongang/edx-platform/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/raccoongang/edx-platform/downloads","issues_url":"https://api.github.com/repos/raccoongang/edx-platform/issues{/number}","pulls_url":"https://api.github.com/repos/raccoongang/edx-platform/pulls{/number}","milestones_url":"https://api.github.com/repos/raccoongang/edx-platform/milestones{/number}","notifications_url":"https://api.github.com/repos/raccoongang/edx-platform/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/raccoongang/edx-platform/labels{/name}","releases_url":"https://api.github.com/repos/raccoongang/edx-platform/releases{/id}","created_at":"2014-11-18T14:05:58Z","updated_at":"2015-04-28T10:58:20Z","pushed_at":"2015-07-26T09:54:38Z","git_url":"git://github.com/raccoongang/edx-platform.git","ssh_url":"git@github.com:raccoongang/edx-platform.git","clone_url":"https://github.com/raccoongang/edx-platform.git","svn_url":"https://github.com/raccoongang/edx-platform","homepage":"http://openedx.org/","size":493785,"stargazers_count":1,"watchers_count":1,"language":"Python","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":0,"mirror_url":null,"open_issues_count":2,"forks":0,"open_issues":2,"watchers":1,"default_branch":"master"}},"base":{"label":"raccoongang:anton/grading","ref":"anton/grading","sha":"4facd069a5616f88ebc6b49c0d17bca5a7e3967c","user":{"login":"raccoongang","id":11388447,"avatar_url":"https://avatars.githubusercontent.com/u/11388447?v=3","gravatar_id":"","url":"https://api.github.com/users/raccoongang","html_url":"https://github.com/raccoongang","followers_url":"https://api.github.com/users/raccoongang/followers","following_url":"https://api.github.com/users/raccoongang/following{/other_user}","gists_url":"https://api.github.com/users/raccoongang/gists{/gist_id}","starred_url":"https://api.github.com/users/raccoongang/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/raccoongang/subscriptions","organizations_url":"https://api.github.com/users/raccoongang/orgs","repos_url":"https://api.github.com/users/raccoongang/repos","events_url":"https://api.github.com/users/raccoongang/events{/privacy}","received_events_url":"https://api.github.com/users/raccoongang/received_events","type":"Organization","site_admin":false},"repo":{"id":26811891,"name":"edx-platform","full_name":"raccoongang/edx-platform","owner":{"login":"raccoongang","id":11388447,"avatar_url":"https://avatars.githubusercontent.com/u/11388447?v=3","gravatar_id":"","url":"https://api.github.com/users/raccoongang","html_url":"https://github.com/raccoongang","followers_url":"https://api.github.com/users/raccoongang/followers","following_url":"https://api.github.com/users/raccoongang/following{/other_user}","gists_url":"https://api.github.com/users/raccoongang/gists{/gist_id}","starred_url":"https://api.github.com/users/raccoongang/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/raccoongang/subscriptions","organizations_url":"https://api.github.com/users/raccoongang/orgs","repos_url":"https://api.github.com/users/raccoongang/repos","events_url":"https://api.github.com/users/raccoongang/events{/privacy}","received_events_url":"https://api.github.com/users/raccoongang/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/raccoongang/edx-platform","description":"Open edX, the edX platform that powers http://edx.org","fork":true,"url":"https://api.github.com/repos/raccoongang/edx-platform","forks_url":"https://api.github.com/repos/raccoongang/edx-platform/forks","keys_url":"https://api.github.com/repos/raccoongang/edx-platform/keys{/key_id}","collaborators_url":"https://api.github.com/repos/raccoongang/edx-platform/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/raccoongang/edx-platform/teams","hooks_url":"https://api.github.com/repos/raccoongang/edx-platform/hooks","issue_events_url":"https://api.github.com/repos/raccoongang/edx-platform/issues/events{/number}","events_url":"https://api.github.com/repos/raccoongang/edx-platform/events","assignees_url":"https://api.github.com/repos/raccoongang/edx-platform/assignees{/user}","branches_url":"https://api.github.com/repos/raccoongang/edx-platform/branches{/branch}","tags_url":"https://api.github.com/repos/raccoongang/edx-platform/tags","blobs_url":"https://api.github.com/repos/raccoongang/edx-platform/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/raccoongang/edx-platform/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/raccoongang/edx-platform/git/refs{/sha}","trees_url":"https://api.github.com/repos/raccoongang/edx-platform/git/trees{/sha}","statuses_url":"https://api.github.com/repos/raccoongang/edx-platform/statuses/{sha}","languages_url":"https://api.github.com/repos/raccoongang/edx-platform/languages","stargazers_url":"https://api.github.com/repos/raccoongang/edx-platform/stargazers","contributors_url":"https://api.github.com/repos/raccoongang/edx-platform/contributors","subscribers_url":"https://api.github.com/repos/raccoongang/edx-platform/subscribers","subscription_url":"https://api.github.com/repos/raccoongang/edx-platform/subscription","commits_url":"https://api.github.com/repos/raccoongang/edx-platform/commits{/sha}","git_commits_url":"https://api.github.com/repos/raccoongang/edx-platform/git/commits{/sha}","comments_url":"https://api.github.com/repos/raccoongang/edx-platform/comments{/number}","issue_comment_url":"https://api.github.com/repos/raccoongang/edx-platform/issues/comments{/number}","contents_url":"https://api.github.com/repos/raccoongang/edx-platform/contents/{+path}","compare_url":"https://api.github.com/repos/raccoongang/edx-platform/compare/{base}...{head}","merges_url":"https://api.github.com/repos/raccoongang/edx-platform/merges","archive_url":"https://api.github.com/repos/raccoongang/edx-platform/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/raccoongang/edx-platform/downloads","issues_url":"https://api.github.com/repos/raccoongang/edx-platform/issues{/number}","pulls_url":"https://api.github.com/repos/raccoongang/edx-platform/pulls{/number}","milestones_url":"https://api.github.com/repos/raccoongang/edx-platform/milestones{/number}","notifications_url":"https://api.github.com/repos/raccoongang/edx-platform/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/raccoongang/edx-platform/labels{/name}","releases_url":"https://api.github.com/repos/raccoongang/edx-platform/releases{/id}","created_at":"2014-11-18T14:05:58Z","updated_at":"2015-04-28T10:58:20Z","pushed_at":"2015-07-26T09:54:38Z","git_url":"git://github.com/raccoongang/edx-platform.git","ssh_url":"git@github.com:raccoongang/edx-platform.git","clone_url":"https://github.com/raccoongang/edx-platform.git","svn_url":"https://github.com/raccoongang/edx-platform","homepage":"http://openedx.org/","size":493785,"stargazers_count":1,"watchers_count":1,"language":"Python","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":0,"mirror_url":null,"open_issues_count":2,"forks":0,"open_issues":2,"watchers":1,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/raccoongang/edx-platform/pulls/8"},"html":{"href":"https://github.com/raccoongang/edx-platform/pull/8"},"issue":{"href":"https://api.github.com/repos/raccoongang/edx-platform/issues/8"},"comments":{"href":"https://api.github.com/repos/raccoongang/edx-platform/issues/8/comments"},"review_comments":{"href":"https://api.github.com/repos/raccoongang/edx-platform/pulls/8/comments"},"review_comment":{"href":"https://api.github.com/repos/raccoongang/edx-platform/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/raccoongang/edx-platform/pulls/8/commits"},"statuses":{"href":"https://api.github.com/repos/raccoongang/edx-platform/statuses/4def1a0736e634b1c126573118f05e0e83304ef2"}}}}