{"action":"created","comment":{"url":"https://api.github.com/repos/Cal-CS-61A-Staff/ok-client/pulls/comments/57024389","id":57024389,"diff_hunk":"@@ -0,0 +1,178 @@\n+from client.protocols.common import models\n+from client.utils import auth\n+from urllib.request import urlopen\n+import json\n+import os\n+import sys\n+\n+TGSERVER = \"http://tg-server.app.cs61a.org/\"\n+LOCAL_TG = \"tests/tg.ok_tg\"\n+OK_GUIDANCE = \"tests/.ok_guidance\"\n+\n+lambda_string_key_to_func = {\n+    'none': lambda info, strMisU: None, \n+    'ki': lambda info, strMisU: info['ki'],\n+    'reteach': lambda info, strMisU: info['dictMisU2ReteachMsg'].get(strMisU)\n+}\n+  \n+# If student forces guidance messages to show, we will assign treatment group number below\n+guidance_flag_dict = [1]\n+\n+class GuidanceProtocol(models.Protocol):\n+    def __init__(self,working_dir,debug = -1):\n+        self.tg_id = -1\n+        self.msg_id = -1\n+        self.misU_count = {}\n+        self.working_dir = working_dir\n+        self.debug = debug\n+        try:\n+            with open(working_dir + OK_GUIDANCE,\"r\") as f:\n+                self.guidance_json = json.load(f)\n+            self.error = False\n+        except:\n+            self.error = True\n+\n+    def guidance_msg(self,unique_id, input_lines,access_token,hash_key,guidance_flag):\n+        if self.error:\n+            print (\"-- Not quite. Try again! --\")\n+            return ({}, -1,\"\")\n+\n+        shorten_unique_id = unique_id[unique_id.index('\\n')+1:]\n+        # Try to get th info dictionary for this question\n+        wa_2_dict_info = self.guidance_json['dictAssessId2WA2DictInfo'].get(shorten_unique_id)\n+\n+        if not wa_2_dict_info: # get returns None if wa_2_dict_info doesn't have shorten_unique_id in dictionary\n+            print (\"-- Not quite. Try again! --\")\n+            return ({}, -1,\"\")\n+\n+        dict_info = wa_2_dict_info.get(repr(input_lines))\n+\n+        # If this wrong answer is not in the JSON file, display default message\n+        if not dict_info:            \n+            print (\"-- Not quite. Try again! --\")\n+            return ({}, -1,\"\")\n+        if(self.debug != -1):\n+            self.tg_id = self.debug\n+        else:\n+            self.get_tg(access_token,guidance_flag)\n+\n+        if self.tg_id == -1: \n+            # If self.tg_id == -1, some errors happen when trying to access server\n+            print (\"-- Not quite. Try again! --\")\n+            return ({}, -1,\"\")\n+\n+        lambda_string_key = self.guidance_json['dictTg2Func'].get(str(self.tg_id))\n+\n+        if not lambda_string_key:\n+            print (\"-- Not quite. Try again! --\")\n+            return ({}, -1,\"\")\n+\n+        lambda_info_misu = lambda_string_key_to_func.get(lambda_string_key)\n+\n+        lst_mis_u = dict_info.get('lstMisU')\n+\n+        # No list of misunderstandings for this wrong answer, default message\n+        if not lst_mis_u:\n+            print (\"-- Not quite. Try again! --\")\n+            return ({}, -1,\"\")\n+\n+        self.misU_count = self.update_misUcounts(hash_key, lst_mis_u, repr(input_lines),shorten_unique_id)\n+\n+        thresold = self.guidance_json['wrongAnsThresh']\n+\n+        \"\"\"\n+        Update count file using the helper. Each misunderstanding igets one count.\n+\n+        Get the updated acculamted counts as a dictionary: key: mis_u, value: counts.\n+        \n+        Called that dictionary self.misU_count\n+        \"\"\"\n+\n+        self.msg_id_set = set()\n+\n+        # If the count is higher than the thresold, we need to display the message","path":"client/protocols/guidance.py","position":93,"original_position":93,"commit_id":"f99c74105e6bbbcaaea5dcae56163fb96d306b29","original_commit_id":"f99c74105e6bbbcaaea5dcae56163fb96d306b29","user":{"login":"ksteph","id":656060,"avatar_url":"https://avatars.githubusercontent.com/u/656060?v=3","gravatar_id":"","url":"https://api.github.com/users/ksteph","html_url":"https://github.com/ksteph","followers_url":"https://api.github.com/users/ksteph/followers","following_url":"https://api.github.com/users/ksteph/following{/other_user}","gists_url":"https://api.github.com/users/ksteph/gists{/gist_id}","starred_url":"https://api.github.com/users/ksteph/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ksteph/subscriptions","organizations_url":"https://api.github.com/users/ksteph/orgs","repos_url":"https://api.github.com/users/ksteph/repos","events_url":"https://api.github.com/users/ksteph/events{/privacy}","received_events_url":"https://api.github.com/users/ksteph/received_events","type":"User","site_admin":false},"body":"Nitpick typo: thresold -> threshold","created_at":"2016-03-22T16:56:13Z","updated_at":"2016-03-22T16:56:13Z","html_url":"https://github.com/Cal-CS-61A-Staff/ok-client/pull/165#discussion_r57024389","pull_request_url":"https://api.github.com/repos/Cal-CS-61A-Staff/ok-client/pulls/165","_links":{"self":{"href":"https://api.github.com/repos/Cal-CS-61A-Staff/ok-client/pulls/comments/57024389"},"html":{"href":"https://github.com/Cal-CS-61A-Staff/ok-client/pull/165#discussion_r57024389"},"pull_request":{"href":"https://api.github.com/repos/Cal-CS-61A-Staff/ok-client/pulls/165"}}},"pull_request":{"url":"https://api.github.com/repos/Cal-CS-61A-Staff/ok-client/pulls/165","id":62482871,"html_url":"https://github.com/Cal-CS-61A-Staff/ok-client/pull/165","diff_url":"https://github.com/Cal-CS-61A-Staff/ok-client/pull/165.diff","patch_url":"https://github.com/Cal-CS-61A-Staff/ok-client/pull/165.patch","issue_url":"https://api.github.com/repos/Cal-CS-61A-Staff/ok-client/issues/165","number":165,"state":"open","locked":false,"title":"Enhancements/spenser/unlock","user":{"login":"spnchian","id":10346192,"avatar_url":"https://avatars.githubusercontent.com/u/10346192?v=3","gravatar_id":"","url":"https://api.github.com/users/spnchian","html_url":"https://github.com/spnchian","followers_url":"https://api.github.com/users/spnchian/followers","following_url":"https://api.github.com/users/spnchian/following{/other_user}","gists_url":"https://api.github.com/users/spnchian/gists{/gist_id}","starred_url":"https://api.github.com/users/spnchian/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/spnchian/subscriptions","organizations_url":"https://api.github.com/users/spnchian/orgs","repos_url":"https://api.github.com/users/spnchian/repos","events_url":"https://api.github.com/users/spnchian/events{/privacy}","received_events_url":"https://api.github.com/users/spnchian/received_events","type":"User","site_admin":false},"body":"Changed utils/auth.py and protocols/unlock.py for displaying client messages.\r\n\r\n@ksteph @Sumukh @haydensheung @knrafto ","created_at":"2016-03-11T01:02:20Z","updated_at":"2016-03-22T16:56:13Z","closed_at":null,"merged_at":null,"merge_commit_sha":"aa3cd767f01cf5c03035cd4a47c5783b1827a311","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/Cal-CS-61A-Staff/ok-client/pulls/165/commits","review_comments_url":"https://api.github.com/repos/Cal-CS-61A-Staff/ok-client/pulls/165/comments","review_comment_url":"https://api.github.com/repos/Cal-CS-61A-Staff/ok-client/pulls/comments{/number}","comments_url":"https://api.github.com/repos/Cal-CS-61A-Staff/ok-client/issues/165/comments","statuses_url":"https://api.github.com/repos/Cal-CS-61A-Staff/ok-client/statuses/f99c74105e6bbbcaaea5dcae56163fb96d306b29","head":{"label":"Cal-CS-61A-Staff:enhancements/spenser/unlock","ref":"enhancements/spenser/unlock","sha":"f99c74105e6bbbcaaea5dcae56163fb96d306b29","user":{"login":"Cal-CS-61A-Staff","id":7565272,"avatar_url":"https://avatars.githubusercontent.com/u/7565272?v=3","gravatar_id":"","url":"https://api.github.com/users/Cal-CS-61A-Staff","html_url":"https://github.com/Cal-CS-61A-Staff","followers_url":"https://api.github.com/users/Cal-CS-61A-Staff/followers","following_url":"https://api.github.com/users/Cal-CS-61A-Staff/following{/other_user}","gists_url":"https://api.github.com/users/Cal-CS-61A-Staff/gists{/gist_id}","starred_url":"https://api.github.com/users/Cal-CS-61A-Staff/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Cal-CS-61A-Staff/subscriptions","organizations_url":"https://api.github.com/users/Cal-CS-61A-Staff/orgs","repos_url":"https://api.github.com/users/Cal-CS-61A-Staff/repos","events_url":"https://api.github.com/users/Cal-CS-61A-Staff/events{/privacy}","received_events_url":"https://api.github.com/users/Cal-CS-61A-Staff/received_events","type":"Organization","site_admin":false},"repo":{"id":29032660,"name":"ok-client","full_name":"Cal-CS-61A-Staff/ok-client","owner":{"login":"Cal-CS-61A-Staff","id":7565272,"avatar_url":"https://avatars.githubusercontent.com/u/7565272?v=3","gravatar_id":"","url":"https://api.github.com/users/Cal-CS-61A-Staff","html_url":"https://github.com/Cal-CS-61A-Staff","followers_url":"https://api.github.com/users/Cal-CS-61A-Staff/followers","following_url":"https://api.github.com/users/Cal-CS-61A-Staff/following{/other_user}","gists_url":"https://api.github.com/users/Cal-CS-61A-Staff/gists{/gist_id}","starred_url":"https://api.github.com/users/Cal-CS-61A-Staff/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Cal-CS-61A-Staff/subscriptions","organizations_url":"https://api.github.com/users/Cal-CS-61A-Staff/orgs","repos_url":"https://api.github.com/users/Cal-CS-61A-Staff/repos","events_url":"https://api.github.com/users/Cal-CS-61A-Staff/events{/privacy}","received_events_url":"https://api.github.com/users/Cal-CS-61A-Staff/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/Cal-CS-61A-Staff/ok-client","description":"A Python client for the OK autograding system","fork":false,"url":"https://api.github.com/repos/Cal-CS-61A-Staff/ok-client","forks_url":"https://api.github.com/repos/Cal-CS-61A-Staff/ok-client/forks","keys_url":"https://api.github.com/repos/Cal-CS-61A-Staff/ok-client/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Cal-CS-61A-Staff/ok-client/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Cal-CS-61A-Staff/ok-client/teams","hooks_url":"https://api.github.com/repos/Cal-CS-61A-Staff/ok-client/hooks","issue_events_url":"https://api.github.com/repos/Cal-CS-61A-Staff/ok-client/issues/events{/number}","events_url":"https://api.github.com/repos/Cal-CS-61A-Staff/ok-client/events","assignees_url":"https://api.github.com/repos/Cal-CS-61A-Staff/ok-client/assignees{/user}","branches_url":"https://api.github.com/repos/Cal-CS-61A-Staff/ok-client/branches{/branch}","tags_url":"https://api.github.com/repos/Cal-CS-61A-Staff/ok-client/tags","blobs_url":"https://api.github.com/repos/Cal-CS-61A-Staff/ok-client/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Cal-CS-61A-Staff/ok-client/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Cal-CS-61A-Staff/ok-client/git/refs{/sha}","trees_url":"https://api.github.com/repos/Cal-CS-61A-Staff/ok-client/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Cal-CS-61A-Staff/ok-client/statuses/{sha}","languages_url":"https://api.github.com/repos/Cal-CS-61A-Staff/ok-client/languages","stargazers_url":"https://api.github.com/repos/Cal-CS-61A-Staff/ok-client/stargazers","contributors_url":"https://api.github.com/repos/Cal-CS-61A-Staff/ok-client/contributors","subscribers_url":"https://api.github.com/repos/Cal-CS-61A-Staff/ok-client/subscribers","subscription_url":"https://api.github.com/repos/Cal-CS-61A-Staff/ok-client/subscription","commits_url":"https://api.github.com/repos/Cal-CS-61A-Staff/ok-client/commits{/sha}","git_commits_url":"https://api.github.com/repos/Cal-CS-61A-Staff/ok-client/git/commits{/sha}","comments_url":"https://api.github.com/repos/Cal-CS-61A-Staff/ok-client/comments{/number}","issue_comment_url":"https://api.github.com/repos/Cal-CS-61A-Staff/ok-client/issues/comments{/number}","contents_url":"https://api.github.com/repos/Cal-CS-61A-Staff/ok-client/contents/{+path}","compare_url":"https://api.github.com/repos/Cal-CS-61A-Staff/ok-client/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Cal-CS-61A-Staff/ok-client/merges","archive_url":"https://api.github.com/repos/Cal-CS-61A-Staff/ok-client/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Cal-CS-61A-Staff/ok-client/downloads","issues_url":"https://api.github.com/repos/Cal-CS-61A-Staff/ok-client/issues{/number}","pulls_url":"https://api.github.com/repos/Cal-CS-61A-Staff/ok-client/pulls{/number}","milestones_url":"https://api.github.com/repos/Cal-CS-61A-Staff/ok-client/milestones{/number}","notifications_url":"https://api.github.com/repos/Cal-CS-61A-Staff/ok-client/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Cal-CS-61A-Staff/ok-client/labels{/name}","releases_url":"https://api.github.com/repos/Cal-CS-61A-Staff/ok-client/releases{/id}","deployments_url":"https://api.github.com/repos/Cal-CS-61A-Staff/ok-client/deployments","created_at":"2015-01-09T19:53:07Z","updated_at":"2016-01-25T00:48:46Z","pushed_at":"2016-03-19T01:01:47Z","git_url":"git://github.com/Cal-CS-61A-Staff/ok-client.git","ssh_url":"git@github.com:Cal-CS-61A-Staff/ok-client.git","clone_url":"https://github.com/Cal-CS-61A-Staff/ok-client.git","svn_url":"https://github.com/Cal-CS-61A-Staff/ok-client","homepage":"https://okpy.org/","size":558,"stargazers_count":8,"watchers_count":8,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":4,"mirror_url":null,"open_issues_count":20,"forks":4,"open_issues":20,"watchers":8,"default_branch":"master"}},"base":{"label":"Cal-CS-61A-Staff:master","ref":"master","sha":"a86d95c00145c76e461e2dd8bfe80119582acffe","user":{"login":"Cal-CS-61A-Staff","id":7565272,"avatar_url":"https://avatars.githubusercontent.com/u/7565272?v=3","gravatar_id":"","url":"https://api.github.com/users/Cal-CS-61A-Staff","html_url":"https://github.com/Cal-CS-61A-Staff","followers_url":"https://api.github.com/users/Cal-CS-61A-Staff/followers","following_url":"https://api.github.com/users/Cal-CS-61A-Staff/following{/other_user}","gists_url":"https://api.github.com/users/Cal-CS-61A-Staff/gists{/gist_id}","starred_url":"https://api.github.com/users/Cal-CS-61A-Staff/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Cal-CS-61A-Staff/subscriptions","organizations_url":"https://api.github.com/users/Cal-CS-61A-Staff/orgs","repos_url":"https://api.github.com/users/Cal-CS-61A-Staff/repos","events_url":"https://api.github.com/users/Cal-CS-61A-Staff/events{/privacy}","received_events_url":"https://api.github.com/users/Cal-CS-61A-Staff/received_events","type":"Organization","site_admin":false},"repo":{"id":29032660,"name":"ok-client","full_name":"Cal-CS-61A-Staff/ok-client","owner":{"login":"Cal-CS-61A-Staff","id":7565272,"avatar_url":"https://avatars.githubusercontent.com/u/7565272?v=3","gravatar_id":"","url":"https://api.github.com/users/Cal-CS-61A-Staff","html_url":"https://github.com/Cal-CS-61A-Staff","followers_url":"https://api.github.com/users/Cal-CS-61A-Staff/followers","following_url":"https://api.github.com/users/Cal-CS-61A-Staff/following{/other_user}","gists_url":"https://api.github.com/users/Cal-CS-61A-Staff/gists{/gist_id}","starred_url":"https://api.github.com/users/Cal-CS-61A-Staff/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Cal-CS-61A-Staff/subscriptions","organizations_url":"https://api.github.com/users/Cal-CS-61A-Staff/orgs","repos_url":"https://api.github.com/users/Cal-CS-61A-Staff/repos","events_url":"https://api.github.com/users/Cal-CS-61A-Staff/events{/privacy}","received_events_url":"https://api.github.com/users/Cal-CS-61A-Staff/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/Cal-CS-61A-Staff/ok-client","description":"A Python client for the OK autograding system","fork":false,"url":"https://api.github.com/repos/Cal-CS-61A-Staff/ok-client","forks_url":"https://api.github.com/repos/Cal-CS-61A-Staff/ok-client/forks","keys_url":"https://api.github.com/repos/Cal-CS-61A-Staff/ok-client/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Cal-CS-61A-Staff/ok-client/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Cal-CS-61A-Staff/ok-client/teams","hooks_url":"https://api.github.com/repos/Cal-CS-61A-Staff/ok-client/hooks","issue_events_url":"https://api.github.com/repos/Cal-CS-61A-Staff/ok-client/issues/events{/number}","events_url":"https://api.github.com/repos/Cal-CS-61A-Staff/ok-client/events","assignees_url":"https://api.github.com/repos/Cal-CS-61A-Staff/ok-client/assignees{/user}","branches_url":"https://api.github.com/repos/Cal-CS-61A-Staff/ok-client/branches{/branch}","tags_url":"https://api.github.com/repos/Cal-CS-61A-Staff/ok-client/tags","blobs_url":"https://api.github.com/repos/Cal-CS-61A-Staff/ok-client/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Cal-CS-61A-Staff/ok-client/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Cal-CS-61A-Staff/ok-client/git/refs{/sha}","trees_url":"https://api.github.com/repos/Cal-CS-61A-Staff/ok-client/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Cal-CS-61A-Staff/ok-client/statuses/{sha}","languages_url":"https://api.github.com/repos/Cal-CS-61A-Staff/ok-client/languages","stargazers_url":"https://api.github.com/repos/Cal-CS-61A-Staff/ok-client/stargazers","contributors_url":"https://api.github.com/repos/Cal-CS-61A-Staff/ok-client/contributors","subscribers_url":"https://api.github.com/repos/Cal-CS-61A-Staff/ok-client/subscribers","subscription_url":"https://api.github.com/repos/Cal-CS-61A-Staff/ok-client/subscription","commits_url":"https://api.github.com/repos/Cal-CS-61A-Staff/ok-client/commits{/sha}","git_commits_url":"https://api.github.com/repos/Cal-CS-61A-Staff/ok-client/git/commits{/sha}","comments_url":"https://api.github.com/repos/Cal-CS-61A-Staff/ok-client/comments{/number}","issue_comment_url":"https://api.github.com/repos/Cal-CS-61A-Staff/ok-client/issues/comments{/number}","contents_url":"https://api.github.com/repos/Cal-CS-61A-Staff/ok-client/contents/{+path}","compare_url":"https://api.github.com/repos/Cal-CS-61A-Staff/ok-client/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Cal-CS-61A-Staff/ok-client/merges","archive_url":"https://api.github.com/repos/Cal-CS-61A-Staff/ok-client/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Cal-CS-61A-Staff/ok-client/downloads","issues_url":"https://api.github.com/repos/Cal-CS-61A-Staff/ok-client/issues{/number}","pulls_url":"https://api.github.com/repos/Cal-CS-61A-Staff/ok-client/pulls{/number}","milestones_url":"https://api.github.com/repos/Cal-CS-61A-Staff/ok-client/milestones{/number}","notifications_url":"https://api.github.com/repos/Cal-CS-61A-Staff/ok-client/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Cal-CS-61A-Staff/ok-client/labels{/name}","releases_url":"https://api.github.com/repos/Cal-CS-61A-Staff/ok-client/releases{/id}","deployments_url":"https://api.github.com/repos/Cal-CS-61A-Staff/ok-client/deployments","created_at":"2015-01-09T19:53:07Z","updated_at":"2016-01-25T00:48:46Z","pushed_at":"2016-03-19T01:01:47Z","git_url":"git://github.com/Cal-CS-61A-Staff/ok-client.git","ssh_url":"git@github.com:Cal-CS-61A-Staff/ok-client.git","clone_url":"https://github.com/Cal-CS-61A-Staff/ok-client.git","svn_url":"https://github.com/Cal-CS-61A-Staff/ok-client","homepage":"https://okpy.org/","size":558,"stargazers_count":8,"watchers_count":8,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":4,"mirror_url":null,"open_issues_count":20,"forks":4,"open_issues":20,"watchers":8,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/Cal-CS-61A-Staff/ok-client/pulls/165"},"html":{"href":"https://github.com/Cal-CS-61A-Staff/ok-client/pull/165"},"issue":{"href":"https://api.github.com/repos/Cal-CS-61A-Staff/ok-client/issues/165"},"comments":{"href":"https://api.github.com/repos/Cal-CS-61A-Staff/ok-client/issues/165/comments"},"review_comments":{"href":"https://api.github.com/repos/Cal-CS-61A-Staff/ok-client/pulls/165/comments"},"review_comment":{"href":"https://api.github.com/repos/Cal-CS-61A-Staff/ok-client/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/Cal-CS-61A-Staff/ok-client/pulls/165/commits"},"statuses":{"href":"https://api.github.com/repos/Cal-CS-61A-Staff/ok-client/statuses/f99c74105e6bbbcaaea5dcae56163fb96d306b29"}}}}