{"action":"created","comment":{"url":"https://api.github.com/repos/omegaup/omegaup/pulls/comments/188158019","pull_request_review_id":120076712,"id":188158019,"diff_hunk":"@@ -936,6 +947,41 @@ public static function apiCreate(Request $r) {\n         return ['status' => 'ok'];\n     }\n \n+    private static function validateCreateVirtual(Request $r) {\n+        $real_contest = $r['contest'];\n+        self::canAccessContest($r);\n+        try {\n+            $r['contest'] = ContestsDAO::getVirtualByContestAndUser($real_contest, $r['current_user']);\n+        } catch (Exception $e) {\n+            throw new InvalidDatabaseOperationException($e);\n+        }\n+\n+        if (!ContestsDAO::hasFinished($real_contest)) {\n+            throw new ForbiddenAccessException('realContestHasNotBeenEnded');\n+        } elseif (isset($r['contest']) and ContestsDAO::isVirtual($r['contest']) and !ContestsDAO::hasFinished($r['contest'])) {\n+            throw new ForbiddenAccessException('unfinishedVirtualContest');\n+        }\n+\n+        $r['public'] = 0;\n+        $r['title'] = $real_contest->title;\n+        $r['description'] = $real_contest->description;\n+        $r['problems'] = ProblemsetProblemsDAO::getProblems($real_contest->problemset_id);\n+        $r['start_time'] = time();\n+        $r['finish_time'] = time() + strtotime($real_contest->finish_time) - strtotime($real_contest->start_time);\n+        $r['window_length'] = $real_contest->window_length;\n+        $r['rerun_id'] = $real_contest->contest_id;\n+        $r['alias'] = null;","path":"frontend/server/controllers/ContestController.php","position":81,"original_position":81,"commit_id":"d848696a6adfff5980e026cc09aa99a5af3ee5e0","original_commit_id":"d848696a6adfff5980e026cc09aa99a5af3ee5e0","user":{"login":"lhchavez","id":168028,"avatar_url":"https://avatars0.githubusercontent.com/u/168028?v=4","gravatar_id":"","url":"https://api.github.com/users/lhchavez","html_url":"https://github.com/lhchavez","followers_url":"https://api.github.com/users/lhchavez/followers","following_url":"https://api.github.com/users/lhchavez/following{/other_user}","gists_url":"https://api.github.com/users/lhchavez/gists{/gist_id}","starred_url":"https://api.github.com/users/lhchavez/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lhchavez/subscriptions","organizations_url":"https://api.github.com/users/lhchavez/orgs","repos_url":"https://api.github.com/users/lhchavez/repos","events_url":"https://api.github.com/users/lhchavez/events{/privacy}","received_events_url":"https://api.github.com/users/lhchavez/received_events","type":"User","site_admin":false},"body":"can you generate an alias? otherwise how can the user invite their friends to the new contest?","created_at":"2018-05-15T03:42:36Z","updated_at":"2018-05-15T03:56:23Z","html_url":"https://github.com/omegaup/omegaup/pull/2004#discussion_r188158019","pull_request_url":"https://api.github.com/repos/omegaup/omegaup/pulls/2004","author_association":"MEMBER","_links":{"self":{"href":"https://api.github.com/repos/omegaup/omegaup/pulls/comments/188158019"},"html":{"href":"https://github.com/omegaup/omegaup/pull/2004#discussion_r188158019"},"pull_request":{"href":"https://api.github.com/repos/omegaup/omegaup/pulls/2004"}}},"pull_request":{"url":"https://api.github.com/repos/omegaup/omegaup/pulls/2004","id":187995090,"html_url":"https://github.com/omegaup/omegaup/pull/2004","diff_url":"https://github.com/omegaup/omegaup/pull/2004.diff","patch_url":"https://github.com/omegaup/omegaup/pull/2004.patch","issue_url":"https://api.github.com/repos/omegaup/omegaup/issues/2004","number":2004,"state":"open","locked":false,"title":"[Ghost mode] Server side development","user":{"login":"SpaceWhite","id":15065085,"avatar_url":"https://avatars2.githubusercontent.com/u/15065085?v=4","gravatar_id":"","url":"https://api.github.com/users/SpaceWhite","html_url":"https://github.com/SpaceWhite","followers_url":"https://api.github.com/users/SpaceWhite/followers","following_url":"https://api.github.com/users/SpaceWhite/following{/other_user}","gists_url":"https://api.github.com/users/SpaceWhite/gists{/gist_id}","starred_url":"https://api.github.com/users/SpaceWhite/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/SpaceWhite/subscriptions","organizations_url":"https://api.github.com/users/SpaceWhite/orgs","repos_url":"https://api.github.com/users/SpaceWhite/repos","events_url":"https://api.github.com/users/SpaceWhite/events{/privacy}","received_events_url":"https://api.github.com/users/SpaceWhite/received_events","type":"User","site_admin":false},"body":"## Description\r\nThis PR enable OmegaUp server side to create ghost mode (aka virtual contest) for contestant.\r\nNB : client side ghost mode will be in another PR\r\n\r\n### API create\r\nTo create ghost mode trigger the `apiCreate` by the following:\r\n`domain.com/api/contest/create?auth_token=(put your token here)&contest_alias=cont1&virtual=1`\r\n\r\nThis API will trigger `validateCreateVirtual` if `virtual` query exists. Then it will recreate a contest from the real contest and also changing the `ACL`, `Problemset`, and etc\r\n\r\n### Ghost mode restriction\r\nGhost mode will utilize the API like the real contest (eg. `apiRuns`, `apiDetails`, etc). But there are some API that need to be restricted in ghost mode.\r\n\r\n### Scoreboard event\r\nGhost mode will simulate scoreboard, hence scoreboard event is needed in order to do so. Scoreboard event will find the real contest scoreboard and merge with contestant runs.\r\n\r\n### Future works\r\nCurrently `apiRuns` doesn't show the list of runs from real contest, should we simulate the @lhchavez  apiRuns too?","created_at":"2018-05-15T02:01:21Z","updated_at":"2018-05-15T03:56:23Z","closed_at":null,"merged_at":null,"merge_commit_sha":"bf6435902bc4e38cef52983ba3c675f5fb8b6204","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/omegaup/omegaup/pulls/2004/commits","review_comments_url":"https://api.github.com/repos/omegaup/omegaup/pulls/2004/comments","review_comment_url":"https://api.github.com/repos/omegaup/omegaup/pulls/comments{/number}","comments_url":"https://api.github.com/repos/omegaup/omegaup/issues/2004/comments","statuses_url":"https://api.github.com/repos/omegaup/omegaup/statuses/d848696a6adfff5980e026cc09aa99a5af3ee5e0","head":{"label":"SpaceWhite:dev-issue-1","ref":"dev-issue-1","sha":"d848696a6adfff5980e026cc09aa99a5af3ee5e0","user":{"login":"SpaceWhite","id":15065085,"avatar_url":"https://avatars2.githubusercontent.com/u/15065085?v=4","gravatar_id":"","url":"https://api.github.com/users/SpaceWhite","html_url":"https://github.com/SpaceWhite","followers_url":"https://api.github.com/users/SpaceWhite/followers","following_url":"https://api.github.com/users/SpaceWhite/following{/other_user}","gists_url":"https://api.github.com/users/SpaceWhite/gists{/gist_id}","starred_url":"https://api.github.com/users/SpaceWhite/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/SpaceWhite/subscriptions","organizations_url":"https://api.github.com/users/SpaceWhite/orgs","repos_url":"https://api.github.com/users/SpaceWhite/repos","events_url":"https://api.github.com/users/SpaceWhite/events{/privacy}","received_events_url":"https://api.github.com/users/SpaceWhite/received_events","type":"User","site_admin":false},"repo":{"id":125608941,"name":"omegaup","full_name":"SpaceWhite/omegaup","owner":{"login":"SpaceWhite","id":15065085,"avatar_url":"https://avatars2.githubusercontent.com/u/15065085?v=4","gravatar_id":"","url":"https://api.github.com/users/SpaceWhite","html_url":"https://github.com/SpaceWhite","followers_url":"https://api.github.com/users/SpaceWhite/followers","following_url":"https://api.github.com/users/SpaceWhite/following{/other_user}","gists_url":"https://api.github.com/users/SpaceWhite/gists{/gist_id}","starred_url":"https://api.github.com/users/SpaceWhite/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/SpaceWhite/subscriptions","organizations_url":"https://api.github.com/users/SpaceWhite/orgs","repos_url":"https://api.github.com/users/SpaceWhite/repos","events_url":"https://api.github.com/users/SpaceWhite/events{/privacy}","received_events_url":"https://api.github.com/users/SpaceWhite/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/SpaceWhite/omegaup","description":"omegaUp automatic programming contest evaluator & arena","fork":true,"url":"https://api.github.com/repos/SpaceWhite/omegaup","forks_url":"https://api.github.com/repos/SpaceWhite/omegaup/forks","keys_url":"https://api.github.com/repos/SpaceWhite/omegaup/keys{/key_id}","collaborators_url":"https://api.github.com/repos/SpaceWhite/omegaup/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/SpaceWhite/omegaup/teams","hooks_url":"https://api.github.com/repos/SpaceWhite/omegaup/hooks","issue_events_url":"https://api.github.com/repos/SpaceWhite/omegaup/issues/events{/number}","events_url":"https://api.github.com/repos/SpaceWhite/omegaup/events","assignees_url":"https://api.github.com/repos/SpaceWhite/omegaup/assignees{/user}","branches_url":"https://api.github.com/repos/SpaceWhite/omegaup/branches{/branch}","tags_url":"https://api.github.com/repos/SpaceWhite/omegaup/tags","blobs_url":"https://api.github.com/repos/SpaceWhite/omegaup/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/SpaceWhite/omegaup/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/SpaceWhite/omegaup/git/refs{/sha}","trees_url":"https://api.github.com/repos/SpaceWhite/omegaup/git/trees{/sha}","statuses_url":"https://api.github.com/repos/SpaceWhite/omegaup/statuses/{sha}","languages_url":"https://api.github.com/repos/SpaceWhite/omegaup/languages","stargazers_url":"https://api.github.com/repos/SpaceWhite/omegaup/stargazers","contributors_url":"https://api.github.com/repos/SpaceWhite/omegaup/contributors","subscribers_url":"https://api.github.com/repos/SpaceWhite/omegaup/subscribers","subscription_url":"https://api.github.com/repos/SpaceWhite/omegaup/subscription","commits_url":"https://api.github.com/repos/SpaceWhite/omegaup/commits{/sha}","git_commits_url":"https://api.github.com/repos/SpaceWhite/omegaup/git/commits{/sha}","comments_url":"https://api.github.com/repos/SpaceWhite/omegaup/comments{/number}","issue_comment_url":"https://api.github.com/repos/SpaceWhite/omegaup/issues/comments{/number}","contents_url":"https://api.github.com/repos/SpaceWhite/omegaup/contents/{+path}","compare_url":"https://api.github.com/repos/SpaceWhite/omegaup/compare/{base}...{head}","merges_url":"https://api.github.com/repos/SpaceWhite/omegaup/merges","archive_url":"https://api.github.com/repos/SpaceWhite/omegaup/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/SpaceWhite/omegaup/downloads","issues_url":"https://api.github.com/repos/SpaceWhite/omegaup/issues{/number}","pulls_url":"https://api.github.com/repos/SpaceWhite/omegaup/pulls{/number}","milestones_url":"https://api.github.com/repos/SpaceWhite/omegaup/milestones{/number}","notifications_url":"https://api.github.com/repos/SpaceWhite/omegaup/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/SpaceWhite/omegaup/labels{/name}","releases_url":"https://api.github.com/repos/SpaceWhite/omegaup/releases{/id}","deployments_url":"https://api.github.com/repos/SpaceWhite/omegaup/deployments","created_at":"2018-03-17T08:05:32Z","updated_at":"2018-05-15T02:10:25Z","pushed_at":"2018-05-15T02:30:08Z","git_url":"git://github.com/SpaceWhite/omegaup.git","ssh_url":"git@github.com:SpaceWhite/omegaup.git","clone_url":"https://github.com/SpaceWhite/omegaup.git","svn_url":"https://github.com/SpaceWhite/omegaup","homepage":"https://omegaup.com","size":226544,"stargazers_count":0,"watchers_count":0,"language":"PHP","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":9,"license":{"key":"other","name":"Other","spdx_id":null,"url":null},"forks":0,"open_issues":9,"watchers":0,"default_branch":"master"}},"base":{"label":"omegaup:master","ref":"master","sha":"6ce61ccea1ad58e8a76e0ac3c695dd73b003f3ab","user":{"login":"omegaup","id":558429,"avatar_url":"https://avatars0.githubusercontent.com/u/558429?v=4","gravatar_id":"","url":"https://api.github.com/users/omegaup","html_url":"https://github.com/omegaup","followers_url":"https://api.github.com/users/omegaup/followers","following_url":"https://api.github.com/users/omegaup/following{/other_user}","gists_url":"https://api.github.com/users/omegaup/gists{/gist_id}","starred_url":"https://api.github.com/users/omegaup/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/omegaup/subscriptions","organizations_url":"https://api.github.com/users/omegaup/orgs","repos_url":"https://api.github.com/users/omegaup/repos","events_url":"https://api.github.com/users/omegaup/events{/privacy}","received_events_url":"https://api.github.com/users/omegaup/received_events","type":"Organization","site_admin":false},"repo":{"id":1243685,"name":"omegaup","full_name":"omegaup/omegaup","owner":{"login":"omegaup","id":558429,"avatar_url":"https://avatars0.githubusercontent.com/u/558429?v=4","gravatar_id":"","url":"https://api.github.com/users/omegaup","html_url":"https://github.com/omegaup","followers_url":"https://api.github.com/users/omegaup/followers","following_url":"https://api.github.com/users/omegaup/following{/other_user}","gists_url":"https://api.github.com/users/omegaup/gists{/gist_id}","starred_url":"https://api.github.com/users/omegaup/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/omegaup/subscriptions","organizations_url":"https://api.github.com/users/omegaup/orgs","repos_url":"https://api.github.com/users/omegaup/repos","events_url":"https://api.github.com/users/omegaup/events{/privacy}","received_events_url":"https://api.github.com/users/omegaup/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/omegaup/omegaup","description":"omegaUp automatic programming contest evaluator & arena","fork":false,"url":"https://api.github.com/repos/omegaup/omegaup","forks_url":"https://api.github.com/repos/omegaup/omegaup/forks","keys_url":"https://api.github.com/repos/omegaup/omegaup/keys{/key_id}","collaborators_url":"https://api.github.com/repos/omegaup/omegaup/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/omegaup/omegaup/teams","hooks_url":"https://api.github.com/repos/omegaup/omegaup/hooks","issue_events_url":"https://api.github.com/repos/omegaup/omegaup/issues/events{/number}","events_url":"https://api.github.com/repos/omegaup/omegaup/events","assignees_url":"https://api.github.com/repos/omegaup/omegaup/assignees{/user}","branches_url":"https://api.github.com/repos/omegaup/omegaup/branches{/branch}","tags_url":"https://api.github.com/repos/omegaup/omegaup/tags","blobs_url":"https://api.github.com/repos/omegaup/omegaup/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/omegaup/omegaup/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/omegaup/omegaup/git/refs{/sha}","trees_url":"https://api.github.com/repos/omegaup/omegaup/git/trees{/sha}","statuses_url":"https://api.github.com/repos/omegaup/omegaup/statuses/{sha}","languages_url":"https://api.github.com/repos/omegaup/omegaup/languages","stargazers_url":"https://api.github.com/repos/omegaup/omegaup/stargazers","contributors_url":"https://api.github.com/repos/omegaup/omegaup/contributors","subscribers_url":"https://api.github.com/repos/omegaup/omegaup/subscribers","subscription_url":"https://api.github.com/repos/omegaup/omegaup/subscription","commits_url":"https://api.github.com/repos/omegaup/omegaup/commits{/sha}","git_commits_url":"https://api.github.com/repos/omegaup/omegaup/git/commits{/sha}","comments_url":"https://api.github.com/repos/omegaup/omegaup/comments{/number}","issue_comment_url":"https://api.github.com/repos/omegaup/omegaup/issues/comments{/number}","contents_url":"https://api.github.com/repos/omegaup/omegaup/contents/{+path}","compare_url":"https://api.github.com/repos/omegaup/omegaup/compare/{base}...{head}","merges_url":"https://api.github.com/repos/omegaup/omegaup/merges","archive_url":"https://api.github.com/repos/omegaup/omegaup/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/omegaup/omegaup/downloads","issues_url":"https://api.github.com/repos/omegaup/omegaup/issues{/number}","pulls_url":"https://api.github.com/repos/omegaup/omegaup/pulls{/number}","milestones_url":"https://api.github.com/repos/omegaup/omegaup/milestones{/number}","notifications_url":"https://api.github.com/repos/omegaup/omegaup/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/omegaup/omegaup/labels{/name}","releases_url":"https://api.github.com/repos/omegaup/omegaup/releases{/id}","deployments_url":"https://api.github.com/repos/omegaup/omegaup/deployments","created_at":"2011-01-12T00:11:21Z","updated_at":"2018-05-14T04:00:17Z","pushed_at":"2018-05-15T02:30:09Z","git_url":"git://github.com/omegaup/omegaup.git","ssh_url":"git@github.com:omegaup/omegaup.git","clone_url":"https://github.com/omegaup/omegaup.git","svn_url":"https://github.com/omegaup/omegaup","homepage":"https://omegaup.com","size":226418,"stargazers_count":61,"watchers_count":61,"language":"PHP","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":90,"mirror_url":null,"archived":false,"open_issues_count":227,"license":{"key":"other","name":"Other","spdx_id":null,"url":null},"forks":90,"open_issues":227,"watchers":61,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/omegaup/omegaup/pulls/2004"},"html":{"href":"https://github.com/omegaup/omegaup/pull/2004"},"issue":{"href":"https://api.github.com/repos/omegaup/omegaup/issues/2004"},"comments":{"href":"https://api.github.com/repos/omegaup/omegaup/issues/2004/comments"},"review_comments":{"href":"https://api.github.com/repos/omegaup/omegaup/pulls/2004/comments"},"review_comment":{"href":"https://api.github.com/repos/omegaup/omegaup/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/omegaup/omegaup/pulls/2004/commits"},"statuses":{"href":"https://api.github.com/repos/omegaup/omegaup/statuses/d848696a6adfff5980e026cc09aa99a5af3ee5e0"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"lhchavez"}}