{"action":"created","comment":{"url":"https://api.github.com/repos/knpuniversity/oo/pulls/comments/40280789","id":40280789,"diff_hunk":"@@ -0,0 +1,130 @@\n+<?php\n+\n+namespace Challenges\\Override;\n+\n+use KnpU\\ActivityRunner\\Activity\\CodingChallenge\\CodingContext;\n+use KnpU\\ActivityRunner\\Activity\\CodingChallenge\\CorrectAnswer;\n+use KnpU\\ActivityRunner\\Activity\\CodingChallengeInterface;\n+use KnpU\\ActivityRunner\\Activity\\CodingChallenge\\CodingExecutionResult;\n+use KnpU\\ActivityRunner\\Activity\\CodingChallenge\\FileBuilder;\n+use KnpU\\ActivityRunner\\Activity\\Exception\\GradingException;\n+\n+class OverrideInheritMethodCoding implements CodingChallengeInterface\n+{\n+    /**\n+     * @return string\n+     */\n+    public function getQuestion()\n+    {\n+        return <<<EOF\n+Well, we learned some hard lessons after the destruction of the original `DeathStar`,\n+and we don't want to repeat them! Override the `getWeakness()` method in `DeathStarII`\n+and make it return `null`. Phew, problem solved!\n+EOF;\n+    }\n+\n+    public function getFileBuilder()\n+    {\n+        $fileBuilder = new FileBuilder();\n+\n+        $fileBuilder->addFileContents('index.php', <<<EOF\n+<?php\n+\n+require 'DeathStar.php';\n+require 'DeathStarII.php';\n+\n+\\$original = new DeathStar();\n+\\$new = new DeathStarII();\n+\n+?>\n+\n+<h2>Original DeathStar Weakness: <?php echo \\$original->getWeakness(); ?></h2>\n+<h2>New DeathStar Weakness: <?php echo \\$new->getWeakness(); ?></h2>\n+EOF\n+        );\n+\n+        $fileBuilder->addFileContents('DeathStarII.php', <<<EOF\n+<?php\n+\n+class DeathStarII extends DeathStar\n+{\n+}\n+EOF\n+        );\n+\n+        $fileBuilder->addFileContents('DeathStar.php', <<<EOF\n+<?php\n+\n+class DeathStar\n+{\n+    public function blastPlanet(\\$planetName)\n+    {\n+        echo 'BOOM '.\\$planetName;\n+    }\n+\n+    public function getWeakness()\n+    {\n+        return 'Thermal Exhaust Port';\n+    }\n+}\n+EOF\n+        );\n+\n+        $fileBuilder->setEntryPointFilename('index.php');\n+\n+        return $fileBuilder;\n+    }\n+\n+    public function getExecutionMode()\n+    {\n+        return self::EXECUTION_MODE_PHP_NORMAL;\n+    }\n+\n+    public function setupContext(CodingContext $context)\n+    {\n+    }\n+\n+    public function grade(CodingExecutionResult $result)\n+    {\n+        $result->assertVariableExists('original');\n+        $result->assertVariableExists('new');\n+        $original = $result->getDeclaredVariableValue('original');\n+        $new = $result->getDeclaredVariableValue('new');\n+        if (!$original instanceof \\DeathStar) {\n+            throw new GradingException('The `$original` variable exists, but is not set to a `DeathStar` object.');\n+        }\n+        if (!$new instanceof \\DeathStarII) {\n+            throw new GradingException('The `$new` variable exists, but is not set to a `DeathStarII` object.');\n+        }\n+        if (!$new instanceof \\DeathStar) {\n+            throw new GradingException('The `DeathStarII` class is not extending `DeathStar` one.');\n+        }","path":"knpu/episode3/Challenges/Override/OverrideInheritMethodCoding.php","position":101,"original_position":101,"commit_id":"2d304d79663f9e8f5c4a099c10e16b36d9da9c7d","original_commit_id":"2d304d79663f9e8f5c4a099c10e16b36d9da9c7d","user":{"login":"weaverryan","id":121003,"avatar_url":"https://avatars.githubusercontent.com/u/121003?v=3","gravatar_id":"","url":"https://api.github.com/users/weaverryan","html_url":"https://github.com/weaverryan","followers_url":"https://api.github.com/users/weaverryan/followers","following_url":"https://api.github.com/users/weaverryan/following{/other_user}","gists_url":"https://api.github.com/users/weaverryan/gists{/gist_id}","starred_url":"https://api.github.com/users/weaverryan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/weaverryan/subscriptions","organizations_url":"https://api.github.com/users/weaverryan/orgs","repos_url":"https://api.github.com/users/weaverryan/repos","events_url":"https://api.github.com/users/weaverryan/events{/privacy}","received_events_url":"https://api.github.com/users/weaverryan/received_events","type":"User","site_admin":false},"body":"This is an odd case where we don't expect them to change `index.php` at all. So, we don't really want to grade things in this file. Still, you're totally right that we *do* need to check a few basic things, to make sure our grading code below doesn't explode because (for example) they deleted the `$new` variable. In other words, this initially looked like \"over-grading\" to me, but it makes sense.\r\n\r\nOne missing feature is to make some files readonly - i.e. we could make `index.php` and `Deathstar.php` readonly in this case - because we don't mean for the user to tweak these (then we wouldn't need to check for so many things).","created_at":"2015-09-24T02:36:59Z","updated_at":"2015-09-24T02:36:59Z","html_url":"https://github.com/knpuniversity/oo/pull/3#discussion_r40280789","pull_request_url":"https://api.github.com/repos/knpuniversity/oo/pulls/3","_links":{"self":{"href":"https://api.github.com/repos/knpuniversity/oo/pulls/comments/40280789"},"html":{"href":"https://github.com/knpuniversity/oo/pull/3#discussion_r40280789"},"pull_request":{"href":"https://api.github.com/repos/knpuniversity/oo/pulls/3"}}},"pull_request":{"url":"https://api.github.com/repos/knpuniversity/oo/pulls/3","id":45834081,"html_url":"https://github.com/knpuniversity/oo/pull/3","diff_url":"https://github.com/knpuniversity/oo/pull/3.diff","patch_url":"https://github.com/knpuniversity/oo/pull/3.patch","issue_url":"https://api.github.com/repos/knpuniversity/oo/issues/3","number":3,"state":"open","locked":false,"title":"Add activities for 2nd chapter of 3rd episode","user":{"login":"bocharsky-bw","id":3317635,"avatar_url":"https://avatars.githubusercontent.com/u/3317635?v=3","gravatar_id":"","url":"https://api.github.com/users/bocharsky-bw","html_url":"https://github.com/bocharsky-bw","followers_url":"https://api.github.com/users/bocharsky-bw/followers","following_url":"https://api.github.com/users/bocharsky-bw/following{/other_user}","gists_url":"https://api.github.com/users/bocharsky-bw/gists{/gist_id}","starred_url":"https://api.github.com/users/bocharsky-bw/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bocharsky-bw/subscriptions","organizations_url":"https://api.github.com/users/bocharsky-bw/orgs","repos_url":"https://api.github.com/users/bocharsky-bw/repos","events_url":"https://api.github.com/users/bocharsky-bw/events{/privacy}","received_events_url":"https://api.github.com/users/bocharsky-bw/received_events","type":"User","site_admin":false},"body":"","created_at":"2015-09-23T21:29:01Z","updated_at":"2015-09-24T02:36:59Z","closed_at":null,"merged_at":null,"merge_commit_sha":"a31a797e084521fa1fee9700b1f611b699ec65b2","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/knpuniversity/oo/pulls/3/commits","review_comments_url":"https://api.github.com/repos/knpuniversity/oo/pulls/3/comments","review_comment_url":"https://api.github.com/repos/knpuniversity/oo/pulls/comments{/number}","comments_url":"https://api.github.com/repos/knpuniversity/oo/issues/3/comments","statuses_url":"https://api.github.com/repos/knpuniversity/oo/statuses/2d304d79663f9e8f5c4a099c10e16b36d9da9c7d","head":{"label":"knpuniversity:activities-ch-2","ref":"activities-ch-2","sha":"2d304d79663f9e8f5c4a099c10e16b36d9da9c7d","user":{"login":"knpuniversity","id":4474785,"avatar_url":"https://avatars.githubusercontent.com/u/4474785?v=3","gravatar_id":"","url":"https://api.github.com/users/knpuniversity","html_url":"https://github.com/knpuniversity","followers_url":"https://api.github.com/users/knpuniversity/followers","following_url":"https://api.github.com/users/knpuniversity/following{/other_user}","gists_url":"https://api.github.com/users/knpuniversity/gists{/gist_id}","starred_url":"https://api.github.com/users/knpuniversity/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/knpuniversity/subscriptions","organizations_url":"https://api.github.com/users/knpuniversity/orgs","repos_url":"https://api.github.com/users/knpuniversity/repos","events_url":"https://api.github.com/users/knpuniversity/events{/privacy}","received_events_url":"https://api.github.com/users/knpuniversity/received_events","type":"Organization","site_admin":false},"repo":{"id":28870708,"name":"oo","full_name":"knpuniversity/oo","owner":{"login":"knpuniversity","id":4474785,"avatar_url":"https://avatars.githubusercontent.com/u/4474785?v=3","gravatar_id":"","url":"https://api.github.com/users/knpuniversity","html_url":"https://github.com/knpuniversity","followers_url":"https://api.github.com/users/knpuniversity/followers","following_url":"https://api.github.com/users/knpuniversity/following{/other_user}","gists_url":"https://api.github.com/users/knpuniversity/gists{/gist_id}","starred_url":"https://api.github.com/users/knpuniversity/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/knpuniversity/subscriptions","organizations_url":"https://api.github.com/users/knpuniversity/orgs","repos_url":"https://api.github.com/users/knpuniversity/repos","events_url":"https://api.github.com/users/knpuniversity/events{/privacy}","received_events_url":"https://api.github.com/users/knpuniversity/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/knpuniversity/oo","description":"Screencast code, script and spare parts for classes (e.g. extra interfaces, refurbished class constants, etc) for the intro OO course","fork":false,"url":"https://api.github.com/repos/knpuniversity/oo","forks_url":"https://api.github.com/repos/knpuniversity/oo/forks","keys_url":"https://api.github.com/repos/knpuniversity/oo/keys{/key_id}","collaborators_url":"https://api.github.com/repos/knpuniversity/oo/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/knpuniversity/oo/teams","hooks_url":"https://api.github.com/repos/knpuniversity/oo/hooks","issue_events_url":"https://api.github.com/repos/knpuniversity/oo/issues/events{/number}","events_url":"https://api.github.com/repos/knpuniversity/oo/events","assignees_url":"https://api.github.com/repos/knpuniversity/oo/assignees{/user}","branches_url":"https://api.github.com/repos/knpuniversity/oo/branches{/branch}","tags_url":"https://api.github.com/repos/knpuniversity/oo/tags","blobs_url":"https://api.github.com/repos/knpuniversity/oo/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/knpuniversity/oo/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/knpuniversity/oo/git/refs{/sha}","trees_url":"https://api.github.com/repos/knpuniversity/oo/git/trees{/sha}","statuses_url":"https://api.github.com/repos/knpuniversity/oo/statuses/{sha}","languages_url":"https://api.github.com/repos/knpuniversity/oo/languages","stargazers_url":"https://api.github.com/repos/knpuniversity/oo/stargazers","contributors_url":"https://api.github.com/repos/knpuniversity/oo/contributors","subscribers_url":"https://api.github.com/repos/knpuniversity/oo/subscribers","subscription_url":"https://api.github.com/repos/knpuniversity/oo/subscription","commits_url":"https://api.github.com/repos/knpuniversity/oo/commits{/sha}","git_commits_url":"https://api.github.com/repos/knpuniversity/oo/git/commits{/sha}","comments_url":"https://api.github.com/repos/knpuniversity/oo/comments{/number}","issue_comment_url":"https://api.github.com/repos/knpuniversity/oo/issues/comments{/number}","contents_url":"https://api.github.com/repos/knpuniversity/oo/contents/{+path}","compare_url":"https://api.github.com/repos/knpuniversity/oo/compare/{base}...{head}","merges_url":"https://api.github.com/repos/knpuniversity/oo/merges","archive_url":"https://api.github.com/repos/knpuniversity/oo/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/knpuniversity/oo/downloads","issues_url":"https://api.github.com/repos/knpuniversity/oo/issues{/number}","pulls_url":"https://api.github.com/repos/knpuniversity/oo/pulls{/number}","milestones_url":"https://api.github.com/repos/knpuniversity/oo/milestones{/number}","notifications_url":"https://api.github.com/repos/knpuniversity/oo/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/knpuniversity/oo/labels{/name}","releases_url":"https://api.github.com/repos/knpuniversity/oo/releases{/id}","created_at":"2015-01-06T15:58:52Z","updated_at":"2015-07-15T12:21:17Z","pushed_at":"2015-09-23T21:30:00Z","git_url":"git://github.com/knpuniversity/oo.git","ssh_url":"git@github.com:knpuniversity/oo.git","clone_url":"https://github.com/knpuniversity/oo.git","svn_url":"https://github.com/knpuniversity/oo","homepage":"https://knpuniversity.com/screencast/oo","size":1660,"stargazers_count":1,"watchers_count":1,"language":"PHP","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":2,"forks":0,"open_issues":2,"watchers":1,"default_branch":"master"}},"base":{"label":"knpuniversity:master","ref":"master","sha":"4ebf9baea6503b0519e692af68d656ce1466b602","user":{"login":"knpuniversity","id":4474785,"avatar_url":"https://avatars.githubusercontent.com/u/4474785?v=3","gravatar_id":"","url":"https://api.github.com/users/knpuniversity","html_url":"https://github.com/knpuniversity","followers_url":"https://api.github.com/users/knpuniversity/followers","following_url":"https://api.github.com/users/knpuniversity/following{/other_user}","gists_url":"https://api.github.com/users/knpuniversity/gists{/gist_id}","starred_url":"https://api.github.com/users/knpuniversity/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/knpuniversity/subscriptions","organizations_url":"https://api.github.com/users/knpuniversity/orgs","repos_url":"https://api.github.com/users/knpuniversity/repos","events_url":"https://api.github.com/users/knpuniversity/events{/privacy}","received_events_url":"https://api.github.com/users/knpuniversity/received_events","type":"Organization","site_admin":false},"repo":{"id":28870708,"name":"oo","full_name":"knpuniversity/oo","owner":{"login":"knpuniversity","id":4474785,"avatar_url":"https://avatars.githubusercontent.com/u/4474785?v=3","gravatar_id":"","url":"https://api.github.com/users/knpuniversity","html_url":"https://github.com/knpuniversity","followers_url":"https://api.github.com/users/knpuniversity/followers","following_url":"https://api.github.com/users/knpuniversity/following{/other_user}","gists_url":"https://api.github.com/users/knpuniversity/gists{/gist_id}","starred_url":"https://api.github.com/users/knpuniversity/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/knpuniversity/subscriptions","organizations_url":"https://api.github.com/users/knpuniversity/orgs","repos_url":"https://api.github.com/users/knpuniversity/repos","events_url":"https://api.github.com/users/knpuniversity/events{/privacy}","received_events_url":"https://api.github.com/users/knpuniversity/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/knpuniversity/oo","description":"Screencast code, script and spare parts for classes (e.g. extra interfaces, refurbished class constants, etc) for the intro OO course","fork":false,"url":"https://api.github.com/repos/knpuniversity/oo","forks_url":"https://api.github.com/repos/knpuniversity/oo/forks","keys_url":"https://api.github.com/repos/knpuniversity/oo/keys{/key_id}","collaborators_url":"https://api.github.com/repos/knpuniversity/oo/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/knpuniversity/oo/teams","hooks_url":"https://api.github.com/repos/knpuniversity/oo/hooks","issue_events_url":"https://api.github.com/repos/knpuniversity/oo/issues/events{/number}","events_url":"https://api.github.com/repos/knpuniversity/oo/events","assignees_url":"https://api.github.com/repos/knpuniversity/oo/assignees{/user}","branches_url":"https://api.github.com/repos/knpuniversity/oo/branches{/branch}","tags_url":"https://api.github.com/repos/knpuniversity/oo/tags","blobs_url":"https://api.github.com/repos/knpuniversity/oo/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/knpuniversity/oo/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/knpuniversity/oo/git/refs{/sha}","trees_url":"https://api.github.com/repos/knpuniversity/oo/git/trees{/sha}","statuses_url":"https://api.github.com/repos/knpuniversity/oo/statuses/{sha}","languages_url":"https://api.github.com/repos/knpuniversity/oo/languages","stargazers_url":"https://api.github.com/repos/knpuniversity/oo/stargazers","contributors_url":"https://api.github.com/repos/knpuniversity/oo/contributors","subscribers_url":"https://api.github.com/repos/knpuniversity/oo/subscribers","subscription_url":"https://api.github.com/repos/knpuniversity/oo/subscription","commits_url":"https://api.github.com/repos/knpuniversity/oo/commits{/sha}","git_commits_url":"https://api.github.com/repos/knpuniversity/oo/git/commits{/sha}","comments_url":"https://api.github.com/repos/knpuniversity/oo/comments{/number}","issue_comment_url":"https://api.github.com/repos/knpuniversity/oo/issues/comments{/number}","contents_url":"https://api.github.com/repos/knpuniversity/oo/contents/{+path}","compare_url":"https://api.github.com/repos/knpuniversity/oo/compare/{base}...{head}","merges_url":"https://api.github.com/repos/knpuniversity/oo/merges","archive_url":"https://api.github.com/repos/knpuniversity/oo/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/knpuniversity/oo/downloads","issues_url":"https://api.github.com/repos/knpuniversity/oo/issues{/number}","pulls_url":"https://api.github.com/repos/knpuniversity/oo/pulls{/number}","milestones_url":"https://api.github.com/repos/knpuniversity/oo/milestones{/number}","notifications_url":"https://api.github.com/repos/knpuniversity/oo/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/knpuniversity/oo/labels{/name}","releases_url":"https://api.github.com/repos/knpuniversity/oo/releases{/id}","created_at":"2015-01-06T15:58:52Z","updated_at":"2015-07-15T12:21:17Z","pushed_at":"2015-09-23T21:30:00Z","git_url":"git://github.com/knpuniversity/oo.git","ssh_url":"git@github.com:knpuniversity/oo.git","clone_url":"https://github.com/knpuniversity/oo.git","svn_url":"https://github.com/knpuniversity/oo","homepage":"https://knpuniversity.com/screencast/oo","size":1660,"stargazers_count":1,"watchers_count":1,"language":"PHP","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"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/knpuniversity/oo/pulls/3"},"html":{"href":"https://github.com/knpuniversity/oo/pull/3"},"issue":{"href":"https://api.github.com/repos/knpuniversity/oo/issues/3"},"comments":{"href":"https://api.github.com/repos/knpuniversity/oo/issues/3/comments"},"review_comments":{"href":"https://api.github.com/repos/knpuniversity/oo/pulls/3/comments"},"review_comment":{"href":"https://api.github.com/repos/knpuniversity/oo/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/knpuniversity/oo/pulls/3/commits"},"statuses":{"href":"https://api.github.com/repos/knpuniversity/oo/statuses/2d304d79663f9e8f5c4a099c10e16b36d9da9c7d"}}}}