{"action":"created","comment":{"url":"https://api.github.com/repos/FOSSEE/online_test/pulls/comments/30121738","id":30121738,"diff_hunk":"@@ -0,0 +1,126 @@\n+#!/usr/bin/env python\n+import traceback\n+import pwd\n+import os\n+from os.path import join, isfile\n+import subprocess\n+import importlib\n+\n+# local imports\n+from code_evaluator import CodeEvaluator\n+\n+\n+class CppCodeEvaluator(CodeEvaluator):\n+    \"\"\"Tests the C code obtained from Code Server\"\"\"\n+    def __init__(self, test_case_data, test, language, user_answer, \n+                     ref_code_path=None, in_dir=None):  \n+        super(CppCodeEvaluator, self).__init__(test_case_data, test, language, user_answer, \n+                                                 ref_code_path, in_dir)\n+        self.submit_path = self.create_submit_code_file('submit.c')\n+        self.test_case_args = self._setup()      \n+\n+    # Private Protocol ##########\n+    def _setup(self):\n+        super(CppCodeEvaluator, self)._setup()\n+\n+        get_ref_path = self.ref_code_path\n+        ref_path, test_case_path = self.set_test_code_file_path(get_ref_path)\n+\n+        # Set file paths\n+        c_user_output_path = os.getcwd() + '/output'\n+        c_ref_output_path = os.getcwd() + '/executable'\n+\n+        # Set command variables\n+        compile_command = 'g++  {0} -c -o {1}'.format(self.submit_path,\n+                                                 c_user_output_path)\n+        compile_main = 'g++ {0} {1} -o {2}'.format(ref_path,\n+                                                c_user_output_path,\n+                                                c_ref_output_path)\n+        run_command_args = [c_ref_output_path]\n+        remove_user_output = c_user_output_path\n+        remove_ref_output = c_ref_output_path\n+\n+        return ref_path, self.submit_path, compile_command, compile_main, run_command_args, remove_user_output, remove_ref_output\n+\n+    def _teardown(self):\n+        # Delete the created file.\n+        super(CppCodeEvaluator, self)._teardown()\n+        os.remove(self.submit_path)\n+\n+    def _check_code(self, ref_code_path, submit_code_path, compile_command,\n+                     compile_main, run_command_args, remove_user_output,\n+                     remove_ref_output):\n+        \"\"\" Function validates student code using instructor code as\n+        reference.The first argument ref_code_path, is the path to\n+        instructor code, it is assumed to have executable permission.\n+        The second argument submit_code_path, is the path to the student\n+        code, it is assumed to have executable permission.\n+\n+        Returns\n+        --------\n+\n+        returns (True, \"Correct answer\") : If the student function returns\n+        expected output when called by reference code.\n+\n+        returns (False, error_msg): If the student function fails to return\n+        expected output when called by reference code.\n+\n+        Returns (False, error_msg): If mandatory arguments are not files or\n+        if the required permissions are not given to the file(s).\n+\n+        \"\"\"\n+        if not isfile(ref_code_path):\n+            return False, \"No file at %s or Incorrect path\" % ref_code_path\n+        if not isfile(submit_code_path):\n+            return False, 'No file at %s or Incorrect path' % submit_code_path\n+\n+        success = False\n+        # output_path = os.getcwd() + '/output'\n+        ret = self._compile_command(compile_command)\n+        proc, stdnt_stderr = ret\n+        # if self.language == \"java\":\n+        stdnt_stderr = self._remove_null_substitute_char(stdnt_stderr)\n+\n+        # Only if compilation is successful, the program is executed\n+        # And tested with testcases\n+        if stdnt_stderr == '':\n+            ret = self._compile_command(compile_main)\n+            proc, main_err = ret\n+            # if self.language == \"java\":","path":"testapp/exam/cpp_code_evaluator.py","position":89,"original_position":89,"commit_id":"3e29dc7f6df7019562b179872b43cb13c7483738","original_commit_id":"3e29dc7f6df7019562b179872b43cb13c7483738","user":{"login":"prabhuramachandran","id":272585,"avatar_url":"https://avatars.githubusercontent.com/u/272585?v=3","gravatar_id":"","url":"https://api.github.com/users/prabhuramachandran","html_url":"https://github.com/prabhuramachandran","followers_url":"https://api.github.com/users/prabhuramachandran/followers","following_url":"https://api.github.com/users/prabhuramachandran/following{/other_user}","gists_url":"https://api.github.com/users/prabhuramachandran/gists{/gist_id}","starred_url":"https://api.github.com/users/prabhuramachandran/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/prabhuramachandran/subscriptions","organizations_url":"https://api.github.com/users/prabhuramachandran/orgs","repos_url":"https://api.github.com/users/prabhuramachandran/repos","events_url":"https://api.github.com/users/prabhuramachandran/events{/privacy}","received_events_url":"https://api.github.com/users/prabhuramachandran/received_events","type":"User","site_admin":false},"body":"remove commented code.","created_at":"2015-05-12T10:35:58Z","updated_at":"2015-05-12T10:35:58Z","html_url":"https://github.com/FOSSEE/online_test/pull/41#discussion_r30121738","pull_request_url":"https://api.github.com/repos/FOSSEE/online_test/pulls/41","_links":{"self":{"href":"https://api.github.com/repos/FOSSEE/online_test/pulls/comments/30121738"},"html":{"href":"https://github.com/FOSSEE/online_test/pull/41#discussion_r30121738"},"pull_request":{"href":"https://api.github.com/repos/FOSSEE/online_test/pulls/41"}}},"pull_request":{"url":"https://api.github.com/repos/FOSSEE/online_test/pulls/41","id":31422593,"html_url":"https://github.com/FOSSEE/online_test/pull/41","diff_url":"https://github.com/FOSSEE/online_test/pull/41.diff","patch_url":"https://github.com/FOSSEE/online_test/pull/41.patch","issue_url":"https://api.github.com/repos/FOSSEE/online_test/issues/41","number":41,"state":"open","locked":false,"title":"Code server redesign","user":{"login":"ankitjavalkar","id":4957402,"avatar_url":"https://avatars.githubusercontent.com/u/4957402?v=3","gravatar_id":"","url":"https://api.github.com/users/ankitjavalkar","html_url":"https://github.com/ankitjavalkar","followers_url":"https://api.github.com/users/ankitjavalkar/followers","following_url":"https://api.github.com/users/ankitjavalkar/following{/other_user}","gists_url":"https://api.github.com/users/ankitjavalkar/gists{/gist_id}","starred_url":"https://api.github.com/users/ankitjavalkar/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ankitjavalkar/subscriptions","organizations_url":"https://api.github.com/users/ankitjavalkar/orgs","repos_url":"https://api.github.com/users/ankitjavalkar/repos","events_url":"https://api.github.com/users/ankitjavalkar/events{/privacy}","received_events_url":"https://api.github.com/users/ankitjavalkar/received_events","type":"User","site_admin":false},"body":"","created_at":"2015-03-18T12:06:15Z","updated_at":"2015-05-12T10:35:58Z","closed_at":null,"merged_at":null,"merge_commit_sha":"d75c5143a303f76b9bf0741a0685205f471ff42b","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/FOSSEE/online_test/pulls/41/commits","review_comments_url":"https://api.github.com/repos/FOSSEE/online_test/pulls/41/comments","review_comment_url":"https://api.github.com/repos/FOSSEE/online_test/pulls/comments{/number}","comments_url":"https://api.github.com/repos/FOSSEE/online_test/issues/41/comments","statuses_url":"https://api.github.com/repos/FOSSEE/online_test/statuses/3e29dc7f6df7019562b179872b43cb13c7483738","head":{"label":"ankitjavalkar:code-server-redesign-mymaster2","ref":"code-server-redesign-mymaster2","sha":"3e29dc7f6df7019562b179872b43cb13c7483738","user":{"login":"ankitjavalkar","id":4957402,"avatar_url":"https://avatars.githubusercontent.com/u/4957402?v=3","gravatar_id":"","url":"https://api.github.com/users/ankitjavalkar","html_url":"https://github.com/ankitjavalkar","followers_url":"https://api.github.com/users/ankitjavalkar/followers","following_url":"https://api.github.com/users/ankitjavalkar/following{/other_user}","gists_url":"https://api.github.com/users/ankitjavalkar/gists{/gist_id}","starred_url":"https://api.github.com/users/ankitjavalkar/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ankitjavalkar/subscriptions","organizations_url":"https://api.github.com/users/ankitjavalkar/orgs","repos_url":"https://api.github.com/users/ankitjavalkar/repos","events_url":"https://api.github.com/users/ankitjavalkar/events{/privacy}","received_events_url":"https://api.github.com/users/ankitjavalkar/received_events","type":"User","site_admin":false},"repo":{"id":30179449,"name":"online_test","full_name":"ankitjavalkar/online_test","owner":{"login":"ankitjavalkar","id":4957402,"avatar_url":"https://avatars.githubusercontent.com/u/4957402?v=3","gravatar_id":"","url":"https://api.github.com/users/ankitjavalkar","html_url":"https://github.com/ankitjavalkar","followers_url":"https://api.github.com/users/ankitjavalkar/followers","following_url":"https://api.github.com/users/ankitjavalkar/following{/other_user}","gists_url":"https://api.github.com/users/ankitjavalkar/gists{/gist_id}","starred_url":"https://api.github.com/users/ankitjavalkar/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ankitjavalkar/subscriptions","organizations_url":"https://api.github.com/users/ankitjavalkar/orgs","repos_url":"https://api.github.com/users/ankitjavalkar/repos","events_url":"https://api.github.com/users/ankitjavalkar/events{/privacy}","received_events_url":"https://api.github.com/users/ankitjavalkar/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/ankitjavalkar/online_test","description":"Online quiz/exam taking application","fork":true,"url":"https://api.github.com/repos/ankitjavalkar/online_test","forks_url":"https://api.github.com/repos/ankitjavalkar/online_test/forks","keys_url":"https://api.github.com/repos/ankitjavalkar/online_test/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ankitjavalkar/online_test/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ankitjavalkar/online_test/teams","hooks_url":"https://api.github.com/repos/ankitjavalkar/online_test/hooks","issue_events_url":"https://api.github.com/repos/ankitjavalkar/online_test/issues/events{/number}","events_url":"https://api.github.com/repos/ankitjavalkar/online_test/events","assignees_url":"https://api.github.com/repos/ankitjavalkar/online_test/assignees{/user}","branches_url":"https://api.github.com/repos/ankitjavalkar/online_test/branches{/branch}","tags_url":"https://api.github.com/repos/ankitjavalkar/online_test/tags","blobs_url":"https://api.github.com/repos/ankitjavalkar/online_test/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ankitjavalkar/online_test/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ankitjavalkar/online_test/git/refs{/sha}","trees_url":"https://api.github.com/repos/ankitjavalkar/online_test/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ankitjavalkar/online_test/statuses/{sha}","languages_url":"https://api.github.com/repos/ankitjavalkar/online_test/languages","stargazers_url":"https://api.github.com/repos/ankitjavalkar/online_test/stargazers","contributors_url":"https://api.github.com/repos/ankitjavalkar/online_test/contributors","subscribers_url":"https://api.github.com/repos/ankitjavalkar/online_test/subscribers","subscription_url":"https://api.github.com/repos/ankitjavalkar/online_test/subscription","commits_url":"https://api.github.com/repos/ankitjavalkar/online_test/commits{/sha}","git_commits_url":"https://api.github.com/repos/ankitjavalkar/online_test/git/commits{/sha}","comments_url":"https://api.github.com/repos/ankitjavalkar/online_test/comments{/number}","issue_comment_url":"https://api.github.com/repos/ankitjavalkar/online_test/issues/comments{/number}","contents_url":"https://api.github.com/repos/ankitjavalkar/online_test/contents/{+path}","compare_url":"https://api.github.com/repos/ankitjavalkar/online_test/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ankitjavalkar/online_test/merges","archive_url":"https://api.github.com/repos/ankitjavalkar/online_test/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ankitjavalkar/online_test/downloads","issues_url":"https://api.github.com/repos/ankitjavalkar/online_test/issues{/number}","pulls_url":"https://api.github.com/repos/ankitjavalkar/online_test/pulls{/number}","milestones_url":"https://api.github.com/repos/ankitjavalkar/online_test/milestones{/number}","notifications_url":"https://api.github.com/repos/ankitjavalkar/online_test/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ankitjavalkar/online_test/labels{/name}","releases_url":"https://api.github.com/repos/ankitjavalkar/online_test/releases{/id}","created_at":"2015-02-02T09:15:24Z","updated_at":"2015-02-02T09:15:24Z","pushed_at":"2015-05-11T10:40:47Z","git_url":"git://github.com/ankitjavalkar/online_test.git","ssh_url":"git@github.com:ankitjavalkar/online_test.git","clone_url":"https://github.com/ankitjavalkar/online_test.git","svn_url":"https://github.com/ankitjavalkar/online_test","homepage":"","size":1939,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"FOSSEE:master","ref":"master","sha":"cd9f2542d09db0e4a352dd410f626f27e23c37e4","user":{"login":"FOSSEE","id":703487,"avatar_url":"https://avatars.githubusercontent.com/u/703487?v=3","gravatar_id":"","url":"https://api.github.com/users/FOSSEE","html_url":"https://github.com/FOSSEE","followers_url":"https://api.github.com/users/FOSSEE/followers","following_url":"https://api.github.com/users/FOSSEE/following{/other_user}","gists_url":"https://api.github.com/users/FOSSEE/gists{/gist_id}","starred_url":"https://api.github.com/users/FOSSEE/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/FOSSEE/subscriptions","organizations_url":"https://api.github.com/users/FOSSEE/orgs","repos_url":"https://api.github.com/users/FOSSEE/repos","events_url":"https://api.github.com/users/FOSSEE/events{/privacy}","received_events_url":"https://api.github.com/users/FOSSEE/received_events","type":"Organization","site_admin":false},"repo":{"id":2734092,"name":"online_test","full_name":"FOSSEE/online_test","owner":{"login":"FOSSEE","id":703487,"avatar_url":"https://avatars.githubusercontent.com/u/703487?v=3","gravatar_id":"","url":"https://api.github.com/users/FOSSEE","html_url":"https://github.com/FOSSEE","followers_url":"https://api.github.com/users/FOSSEE/followers","following_url":"https://api.github.com/users/FOSSEE/following{/other_user}","gists_url":"https://api.github.com/users/FOSSEE/gists{/gist_id}","starred_url":"https://api.github.com/users/FOSSEE/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/FOSSEE/subscriptions","organizations_url":"https://api.github.com/users/FOSSEE/orgs","repos_url":"https://api.github.com/users/FOSSEE/repos","events_url":"https://api.github.com/users/FOSSEE/events{/privacy}","received_events_url":"https://api.github.com/users/FOSSEE/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/FOSSEE/online_test","description":"Online quiz/exam taking application","fork":false,"url":"https://api.github.com/repos/FOSSEE/online_test","forks_url":"https://api.github.com/repos/FOSSEE/online_test/forks","keys_url":"https://api.github.com/repos/FOSSEE/online_test/keys{/key_id}","collaborators_url":"https://api.github.com/repos/FOSSEE/online_test/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/FOSSEE/online_test/teams","hooks_url":"https://api.github.com/repos/FOSSEE/online_test/hooks","issue_events_url":"https://api.github.com/repos/FOSSEE/online_test/issues/events{/number}","events_url":"https://api.github.com/repos/FOSSEE/online_test/events","assignees_url":"https://api.github.com/repos/FOSSEE/online_test/assignees{/user}","branches_url":"https://api.github.com/repos/FOSSEE/online_test/branches{/branch}","tags_url":"https://api.github.com/repos/FOSSEE/online_test/tags","blobs_url":"https://api.github.com/repos/FOSSEE/online_test/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/FOSSEE/online_test/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/FOSSEE/online_test/git/refs{/sha}","trees_url":"https://api.github.com/repos/FOSSEE/online_test/git/trees{/sha}","statuses_url":"https://api.github.com/repos/FOSSEE/online_test/statuses/{sha}","languages_url":"https://api.github.com/repos/FOSSEE/online_test/languages","stargazers_url":"https://api.github.com/repos/FOSSEE/online_test/stargazers","contributors_url":"https://api.github.com/repos/FOSSEE/online_test/contributors","subscribers_url":"https://api.github.com/repos/FOSSEE/online_test/subscribers","subscription_url":"https://api.github.com/repos/FOSSEE/online_test/subscription","commits_url":"https://api.github.com/repos/FOSSEE/online_test/commits{/sha}","git_commits_url":"https://api.github.com/repos/FOSSEE/online_test/git/commits{/sha}","comments_url":"https://api.github.com/repos/FOSSEE/online_test/comments{/number}","issue_comment_url":"https://api.github.com/repos/FOSSEE/online_test/issues/comments{/number}","contents_url":"https://api.github.com/repos/FOSSEE/online_test/contents/{+path}","compare_url":"https://api.github.com/repos/FOSSEE/online_test/compare/{base}...{head}","merges_url":"https://api.github.com/repos/FOSSEE/online_test/merges","archive_url":"https://api.github.com/repos/FOSSEE/online_test/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/FOSSEE/online_test/downloads","issues_url":"https://api.github.com/repos/FOSSEE/online_test/issues{/number}","pulls_url":"https://api.github.com/repos/FOSSEE/online_test/pulls{/number}","milestones_url":"https://api.github.com/repos/FOSSEE/online_test/milestones{/number}","notifications_url":"https://api.github.com/repos/FOSSEE/online_test/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/FOSSEE/online_test/labels{/name}","releases_url":"https://api.github.com/repos/FOSSEE/online_test/releases{/id}","created_at":"2011-11-08T14:02:17Z","updated_at":"2015-04-12T19:26:23Z","pushed_at":"2015-05-11T10:40:48Z","git_url":"git://github.com/FOSSEE/online_test.git","ssh_url":"git@github.com:FOSSEE/online_test.git","clone_url":"https://github.com/FOSSEE/online_test.git","svn_url":"https://github.com/FOSSEE/online_test","homepage":"","size":2228,"stargazers_count":14,"watchers_count":14,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":15,"mirror_url":null,"open_issues_count":8,"forks":15,"open_issues":8,"watchers":14,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/FOSSEE/online_test/pulls/41"},"html":{"href":"https://github.com/FOSSEE/online_test/pull/41"},"issue":{"href":"https://api.github.com/repos/FOSSEE/online_test/issues/41"},"comments":{"href":"https://api.github.com/repos/FOSSEE/online_test/issues/41/comments"},"review_comments":{"href":"https://api.github.com/repos/FOSSEE/online_test/pulls/41/comments"},"review_comment":{"href":"https://api.github.com/repos/FOSSEE/online_test/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/FOSSEE/online_test/pulls/41/commits"},"statuses":{"href":"https://api.github.com/repos/FOSSEE/online_test/statuses/3e29dc7f6df7019562b179872b43cb13c7483738"}}}}