GitHub PullRequestReviewCommentEvent at 2014-06-27 11:18:52
Repository: edx-ora2
Actor: wedaly
Payload: {"action":"created","comment":{"url":"https://api.github.com/repos/edx/edx-ora2/pulls/comments/14288344","id":14288344,"diff_hunk":"@@ -240,4 +241,128 @@ def parse_assessment_dictionaries(input_assessments):\n         # Update the list of assessments\n         assessments_list.append(assessment_dict)\n \n-    return assessments_list\n\\ No newline at end of file\n+    return assessments_list\n+\n+\n+def verify_rubric_format(rubric):\n+    \"\"\"\n+    Verifies that the rubric that was passed in follows the conventions that we expect, including\n+    types and structure. The code documents itself well here.\n+\n+    Args:\n+        rubric (dict): Unsanitized version of our rubric.  Usually taken from the GUI.\n+\n+    Returns:\n+        rubric (dict): Sanitized version of the same form.\n+\n+    Raises:\n+        UpdateFromXMLError\n+    \"\"\"\n+\n+    # import pudb, sys as __sys;__sys.stdout=__sys.__stdout__;pudb.set_trace() # -={XX}=-={XX}=-={XX}=\n+\n+    if not isinstance(rubric, dict):\n+        # import pudb,sys as __sys;__sys.stdout=__sys.__stdout__;pudb.set_trace() # -={XX}=-={XX}=-={XX}=\n+        raise UpdateFromXmlError(_(\"The given rubric was not a dictionary of the form {criteria: [criteria1, criteria2...]}\"))\n+\n+    if \"criteria\" not in rubric.keys():\n+        raise UpdateFromXmlError(_(\"The given rubric did not contain a key for a list of criteria, and is invalid\"))\n+\n+    if len((set(rubric.keys()) - {'prompt', 'criteria'})) > 0:\n+        unexpected_keys = list(set(rubric.keys()) - {\"prompt\", \"criteria\"})\n+        raise UpdateFromXmlError(_(\"The following keys were included in the rubric when they were not allowed to be: {}\".format(unexpected_keys)))\n+\n+    if rubric.get('prompt', False):\n+        if not isinstance(rubric['prompt'], basestring):\n+            # import pudb,sys as __sys;__sys.stdout=__sys.__stdout__;pudb.set_trace() # -={XX}=-={XX}=-={XX}=\n+            raise UpdateFromXmlError(_(\"The given rubric's feedback prompt was invalid, it must be a string.\"))\n+\n+    criteria = rubric[\"criteria\"]\n+\n+    if not isinstance(criteria, list):\n+        raise UpdateFromXmlError(_(\"The criteria term in the rubric dictionary corresponds to a non-list object.\"))\n+\n+    sanitized_criteria = []\n+\n+    for criterion in criteria:\n+        if not isinstance(criterion, dict):\n+            raise UpdateFromXmlError(_(\"A criterion given was not a dictionary.\"))\n+\n+        criterion = dict(criterion)\n+\n+        expected_keys = {'order_num', 'name', 'prompt', 'options', 'feedback'}\n+        unexpected_keys = list(set(criterion.keys()) - expected_keys)\n+        missing_keys = list(expected_keys - set(criterion.keys()))\n+\n+        if missing_keys:\n+            raise UpdateFromXmlError(_(\"The following keys were missing from the Definition of one or more criteria: {}\".format(missing_keys)))\n+\n+        if unexpected_keys:\n+            raise UpdateFromXmlError(_(\"The following extraneous keys were found in the definition for one or more criteria: {}\".format(unexpected_keys)))\n+\n+        name = str(criterion['name'])\n+        prompt = str(criterion['prompt'])\n+        feedback = str(criterion['feedback'])\n+\n+        try:\n+            order_num = int(criterion['order_num'])\n+        except (TypeError, ValueError):\n+            raise UpdateFromXmlError(_(\"The order_num value must be an integer.\"))\n+\n+        if not isinstance(criterion['options'], list):\n+            raise UpdateFromXmlError(_(\"The dictionary entry for 'options' in a criteria's dictionary definition must be a list.\"))\n+\n+        options = criterion['options']\n+\n+        sanitized_options = []\n+\n+        for option in options:\n+\n+            if not isinstance(option, dict):\n+                raise UpdateFromXmlError(_(\"An option given was not a dictionary.\"))\n+\n+            expected_keys = {'order_num','name', 'points', 'explanation'}\n+            unexpected_keys = list(set(option.keys()) - expected_keys)\n+            missing_keys = list(expected_keys - set(option.keys()))\n+\n+            if missing_keys:\n+                raise UpdateFromXmlError(_(\"The following keys were missing from the Definition of one or more options: {}\".format(missing_keys)))\n+\n+            if unexpected_keys:\n+                raise UpdateFromXmlError(_(\"The following extraneous keys were found in the definition for one or more options: {}\".format(unexpected_keys)))","path":"openassessment/xblock/studio_mixin.py","position":143,"original_position":143,"commit_id":"4ed6ed7ae652dfcbe866591797e8675f89257600","original_commit_id":"4ed6ed7ae652dfcbe866591797e8675f89257600","user":{"login":"wedaly","id":2948394,"avatar_url":"https://avatars.githubusercontent.com/u/2948394?","gravatar_id":"44480ae60bb8231a1e95497a562aa0b7","url":"https://api.github.com/users/wedaly","html_url":"https://github.com/wedaly","followers_url":"https://api.github.com/users/wedaly/followers","following_url":"https://api.github.com/users/wedaly/following{/other_user}","gists_url":"https://api.github.com/users/wedaly/gists{/gist_id}","starred_url":"https://api.github.com/users/wedaly/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wedaly/subscriptions","organizations_url":"https://api.github.com/users/wedaly/orgs","repos_url":"https://api.github.com/users/wedaly/repos","events_url":"https://api.github.com/users/wedaly/events{/privacy}","received_events_url":"https://api.github.com/users/wedaly/received_events","type":"User","site_admin":false},"body":"Why do we need to raise an error for this?  Why not simply drop the keys from the returned dictionary?","created_at":"2014-06-27T11:18:52Z","updated_at":"2014-06-27T11:18:52Z","html_url":"https://github.com/edx/edx-ora2/pull/465#discussion_r14288344","pull_request_url":"https://api.github.com/repos/edx/edx-ora2/pulls/465","_links":{"self":{"href":"https://api.github.com/repos/edx/edx-ora2/pulls/comments/14288344"},"html":{"href":"https://github.com/edx/edx-ora2/pull/465#discussion_r14288344"},"pull_request":{"href":"https://api.github.com/repos/edx/edx-ora2/pulls/465"}}},"pull_request":{"url":"https://api.github.com/repos/edx/edx-ora2/pulls/465","id":17679669,"html_url":"https://github.com/edx/edx-ora2/pull/465","diff_url":"https://github.com/edx/edx-ora2/pull/465.diff","patch_url":"https://github.com/edx/edx-ora2/pull/465.patch","issue_url":"https://api.github.com/repos/edx/edx-ora2/issues/465","number":465,"state":"open","title":"Grady/authoring/rubric gui","user":{"login":"gradyward","id":7501476,"avatar_url":"https://avatars.githubusercontent.com/u/7501476?","gravatar_id":"61b6c624538fd38df299e53f04ff4176","url":"https://api.github.com/users/gradyward","html_url":"https://github.com/gradyward","followers_url":"https://api.github.com/users/gradyward/followers","following_url":"https://api.github.com/users/gradyward/following{/other_user}","gists_url":"https://api.github.com/users/gradyward/gists{/gist_id}","starred_url":"https://api.github.com/users/gradyward/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gradyward/subscriptions","organizations_url":"https://api.github.com/users/gradyward/orgs","repos_url":"https://api.github.com/users/gradyward/repos","events_url":"https://api.github.com/users/gradyward/events{/privacy}","received_events_url":"https://api.github.com/users/gradyward/received_events","type":"User","site_admin":false},"body":"Very Close (not complete front end work, and some deletion JS needs to be tweaked.  Other than that, it is ready for code review!  Going to be done tomorrow!","created_at":"2014-06-26T23:41:11Z","updated_at":"2014-06-27T11:18:52Z","closed_at":null,"merged_at":null,"merge_commit_sha":"242b747c8c4b55397ceb82e0e42bb38fa8850c9f","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/edx/edx-ora2/pulls/465/commits","review_comments_url":"https://api.github.com/repos/edx/edx-ora2/pulls/465/comments","review_comment_url":"https://api.github.com/repos/edx/edx-ora2/pulls/comments/{number}","comments_url":"https://api.github.com/repos/edx/edx-ora2/issues/465/comments","statuses_url":"https://api.github.com/repos/edx/edx-ora2/statuses/4ed6ed7ae652dfcbe866591797e8675f89257600","head":{"label":"edx:grady/authoring/Rubric-GUI","ref":"grady/authoring/Rubric-GUI","sha":"4ed6ed7ae652dfcbe866591797e8675f89257600","user":{"login":"edx","id":3179841,"avatar_url":"https://avatars.githubusercontent.com/u/3179841?","gravatar_id":"e1f6c6dc8772c47c0261cd5df2ed2814","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":15404425,"name":"edx-ora2","full_name":"edx/edx-ora2","owner":{"login":"edx","id":3179841,"avatar_url":"https://avatars.githubusercontent.com/u/3179841?","gravatar_id":"e1f6c6dc8772c47c0261cd5df2ed2814","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-ora2","description":"Open Response Assessment Suite","fork":false,"url":"https://api.github.com/repos/edx/edx-ora2","forks_url":"https://api.github.com/repos/edx/edx-ora2/forks","keys_url":"https://api.github.com/repos/edx/edx-ora2/keys{/key_id}","collaborators_url":"https://api.github.com/repos/edx/edx-ora2/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/edx/edx-ora2/teams","hooks_url":"https://api.github.com/repos/edx/edx-ora2/hooks","issue_events_url":"https://api.github.com/repos/edx/edx-ora2/issues/events{/number}","events_url":"https://api.github.com/repos/edx/edx-ora2/events","assignees_url":"https://api.github.com/repos/edx/edx-ora2/assignees{/user}","branches_url":"https://api.github.com/repos/edx/edx-ora2/branches{/branch}","tags_url":"https://api.github.com/repos/edx/edx-ora2/tags","blobs_url":"https://api.github.com/repos/edx/edx-ora2/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/edx/edx-ora2/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/edx/edx-ora2/git/refs{/sha}","trees_url":"https://api.github.com/repos/edx/edx-ora2/git/trees{/sha}","statuses_url":"https://api.github.com/repos/edx/edx-ora2/statuses/{sha}","languages_url":"https://api.github.com/repos/edx/edx-ora2/languages","stargazers_url":"https://api.github.com/repos/edx/edx-ora2/stargazers","contributors_url":"https://api.github.com/repos/edx/edx-ora2/contributors","subscribers_url":"https://api.github.com/repos/edx/edx-ora2/subscribers","subscription_url":"https://api.github.com/repos/edx/edx-ora2/subscription","commits_url":"https://api.github.com/repos/edx/edx-ora2/commits{/sha}","git_commits_url":"https://api.github.com/repos/edx/edx-ora2/git/commits{/sha}","comments_url":"https://api.github.com/repos/edx/edx-ora2/comments{/number}","issue_comment_url":"https://api.github.com/repos/edx/edx-ora2/issues/comments/{number}","contents_url":"https://api.github.com/repos/edx/edx-ora2/contents/{+path}","compare_url":"https://api.github.com/repos/edx/edx-ora2/compare/{base}...{head}","merges_url":"https://api.github.com/repos/edx/edx-ora2/merges","archive_url":"https://api.github.com/repos/edx/edx-ora2/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/edx/edx-ora2/downloads","issues_url":"https://api.github.com/repos/edx/edx-ora2/issues{/number}","pulls_url":"https://api.github.com/repos/edx/edx-ora2/pulls{/number}","milestones_url":"https://api.github.com/repos/edx/edx-ora2/milestones{/number}","notifications_url":"https://api.github.com/repos/edx/edx-ora2/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/edx/edx-ora2/labels{/name}","releases_url":"https://api.github.com/repos/edx/edx-ora2/releases{/id}","created_at":"2013-12-23T20:54:54Z","updated_at":"2014-06-25T19:22:37Z","pushed_at":"2014-06-27T10:45:40Z","git_url":"git://github.com/edx/edx-ora2.git","ssh_url":"git@github.com:edx/edx-ora2.git","clone_url":"https://github.com/edx/edx-ora2.git","svn_url":"https://github.com/edx/edx-ora2","homepage":"","size":60646,"stargazers_count":9,"watchers_count":9,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"forks_count":17,"mirror_url":null,"open_issues_count":5,"forks":17,"open_issues":5,"watchers":9,"default_branch":"master"}},"base":{"label":"edx:authoring","ref":"authoring","sha":"795b9ab932ce558f1624f7940d2315240ddd27df","user":{"login":"edx","id":3179841,"avatar_url":"https://avatars.githubusercontent.com/u/3179841?","gravatar_id":"e1f6c6dc8772c47c0261cd5df2ed2814","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":15404425,"name":"edx-ora2","full_name":"edx/edx-ora2","owner":{"login":"edx","id":3179841,"avatar_url":"https://avatars.githubusercontent.com/u/3179841?","gravatar_id":"e1f6c6dc8772c47c0261cd5df2ed2814","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-ora2","description":"Open Response Assessment Suite","fork":false,"url":"https://api.github.com/repos/edx/edx-ora2","forks_url":"https://api.github.com/repos/edx/edx-ora2/forks","keys_url":"https://api.github.com/repos/edx/edx-ora2/keys{/key_id}","collaborators_url":"https://api.github.com/repos/edx/edx-ora2/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/edx/edx-ora2/teams","hooks_url":"https://api.github.com/repos/edx/edx-ora2/hooks","issue_events_url":"https://api.github.com/repos/edx/edx-ora2/issues/events{/number}","events_url":"https://api.github.com/repos/edx/edx-ora2/events","assignees_url":"https://api.github.com/repos/edx/edx-ora2/assignees{/user}","branches_url":"https://api.github.com/repos/edx/edx-ora2/branches{/branch}","tags_url":"https://api.github.com/repos/edx/edx-ora2/tags","blobs_url":"https://api.github.com/repos/edx/edx-ora2/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/edx/edx-ora2/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/edx/edx-ora2/git/refs{/sha}","trees_url":"https://api.github.com/repos/edx/edx-ora2/git/trees{/sha}","statuses_url":"https://api.github.com/repos/edx/edx-ora2/statuses/{sha}","languages_url":"https://api.github.com/repos/edx/edx-ora2/languages","stargazers_url":"https://api.github.com/repos/edx/edx-ora2/stargazers","contributors_url":"https://api.github.com/repos/edx/edx-ora2/contributors","subscribers_url":"https://api.github.com/repos/edx/edx-ora2/subscribers","subscription_url":"https://api.github.com/repos/edx/edx-ora2/subscription","commits_url":"https://api.github.com/repos/edx/edx-ora2/commits{/sha}","git_commits_url":"https://api.github.com/repos/edx/edx-ora2/git/commits{/sha}","comments_url":"https://api.github.com/repos/edx/edx-ora2/comments{/number}","issue_comment_url":"https://api.github.com/repos/edx/edx-ora2/issues/comments/{number}","contents_url":"https://api.github.com/repos/edx/edx-ora2/contents/{+path}","compare_url":"https://api.github.com/repos/edx/edx-ora2/compare/{base}...{head}","merges_url":"https://api.github.com/repos/edx/edx-ora2/merges","archive_url":"https://api.github.com/repos/edx/edx-ora2/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/edx/edx-ora2/downloads","issues_url":"https://api.github.com/repos/edx/edx-ora2/issues{/number}","pulls_url":"https://api.github.com/repos/edx/edx-ora2/pulls{/number}","milestones_url":"https://api.github.com/repos/edx/edx-ora2/milestones{/number}","notifications_url":"https://api.github.com/repos/edx/edx-ora2/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/edx/edx-ora2/labels{/name}","releases_url":"https://api.github.com/repos/edx/edx-ora2/releases{/id}","created_at":"2013-12-23T20:54:54Z","updated_at":"2014-06-25T19:22:37Z","pushed_at":"2014-06-27T10:45:40Z","git_url":"git://github.com/edx/edx-ora2.git","ssh_url":"git@github.com:edx/edx-ora2.git","clone_url":"https://github.com/edx/edx-ora2.git","svn_url":"https://github.com/edx/edx-ora2","homepage":"","size":60646,"stargazers_count":9,"watchers_count":9,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"forks_count":17,"mirror_url":null,"open_issues_count":5,"forks":17,"open_issues":5,"watchers":9,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/edx/edx-ora2/pulls/465"},"html":{"href":"https://github.com/edx/edx-ora2/pull/465"},"issue":{"href":"https://api.github.com/repos/edx/edx-ora2/issues/465"},"comments":{"href":"https://api.github.com/repos/edx/edx-ora2/issues/465/comments"},"review_comments":{"href":"https://api.github.com/repos/edx/edx-ora2/pulls/465/comments"},"review_comment":{"href":"https://api.github.com/repos/edx/edx-ora2/pulls/comments/{number}"},"commits":{"href":"https://api.github.com/repos/edx/edx-ora2/pulls/465/commits"},"statuses":{"href":"https://api.github.com/repos/edx/edx-ora2/statuses/4ed6ed7ae652dfcbe866591797e8675f89257600"}}}}