@@ -19,6 +19,6 @@ |
||
19 | 19 | |
20 | 20 | public function contest() |
21 | 21 | { |
22 | - return $this->belongsTo('App\Models\Eloquent\ContestModel','cid','cid'); |
|
22 | + return $this->belongsTo('App\Models\Eloquent\ContestModel', 'cid', 'cid'); |
|
23 | 23 | } |
24 | 24 | } |
@@ -15,6 +15,6 @@ |
||
15 | 15 | |
16 | 16 | public function submissions() |
17 | 17 | { |
18 | - return $this->hasMany('App\Models\Eloquent\SubmissionModel','pid','pid'); |
|
18 | + return $this->hasMany('App\Models\Eloquent\SubmissionModel', 'pid', 'pid'); |
|
19 | 19 | } |
20 | 20 | } |
@@ -17,28 +17,28 @@ discard block |
||
17 | 17 | const CREATED_AT=null; |
18 | 18 | |
19 | 19 | //Repository function |
20 | - public function participants($ignore_frozen = true) |
|
20 | + public function participants($ignore_frozen=true) |
|
21 | 21 | { |
22 | - if($this->registration){ |
|
23 | - $participants = ContestParticipant::where('cid',$this->cid)->get(); |
|
22 | + if ($this->registration) { |
|
23 | + $participants=ContestParticipant::where('cid', $this->cid)->get(); |
|
24 | 24 | $participants->load('user'); |
25 | - $users = new EloquentCollection; |
|
25 | + $users=new EloquentCollection; |
|
26 | 26 | foreach ($participants as $participant) { |
27 | - $user = $participant->user; |
|
27 | + $user=$participant->user; |
|
28 | 28 | $users->add($user); |
29 | 29 | } |
30 | 30 | return $users->unique(); |
31 | - }else{ |
|
31 | + } else { |
|
32 | 32 | $this->load('submissions.user'); |
33 | - if($ignore_frozen){ |
|
34 | - $frozen_time = $this->frozen_time; |
|
35 | - $submissions = $this->submissions()->where('submission_date','<',$frozen_time)->get(); |
|
36 | - }else{ |
|
37 | - $submissions = $this->submissions; |
|
33 | + if ($ignore_frozen) { |
|
34 | + $frozen_time=$this->frozen_time; |
|
35 | + $submissions=$this->submissions()->where('submission_date', '<', $frozen_time)->get(); |
|
36 | + } else { |
|
37 | + $submissions=$this->submissions; |
|
38 | 38 | } |
39 | - $users = new EloquentCollection; |
|
39 | + $users=new EloquentCollection; |
|
40 | 40 | foreach ($submissions as $submission) { |
41 | - $user = $submission->user; |
|
41 | + $user=$submission->user; |
|
42 | 42 | $users->add($user); |
43 | 43 | } |
44 | 44 | return $users->unique(); |
@@ -48,18 +48,18 @@ discard block |
||
48 | 48 | // Repository/Service? function |
49 | 49 | public function rankRefresh() |
50 | 50 | { |
51 | - $ret = []; |
|
52 | - $participants = $this->participants(); |
|
53 | - $contest_problems = $this->problems; |
|
51 | + $ret=[]; |
|
52 | + $participants=$this->participants(); |
|
53 | + $contest_problems=$this->problems; |
|
54 | 54 | $contest_problems->load('problem'); |
55 | - if($this->rule == 1){ |
|
55 | + if ($this->rule==1) { |
|
56 | 56 | // ACM/ICPC Mode |
57 | 57 | foreach ($participants as $participant) { |
58 | 58 | $prob_detail=[]; |
59 | 59 | $totPen=0; |
60 | 60 | $totScore=0; |
61 | 61 | foreach ($contest_problems as $contest_problem) { |
62 | - $prob_stat = $contest_problem->userStatus($participant); |
|
62 | + $prob_stat=$contest_problem->userStatus($participant); |
|
63 | 63 | $prob_detail[]=[ |
64 | 64 | 'ncode'=>$contest_problem->ncode, |
65 | 65 | 'pid'=>$contest_problem->pid, |
@@ -85,7 +85,7 @@ discard block |
||
85 | 85 | "problem_detail" => $prob_detail |
86 | 86 | ]; |
87 | 87 | } |
88 | - usort($ret, function ($a, $b) { |
|
88 | + usort($ret, function($a, $b) { |
|
89 | 89 | if ($a["score"]==$b["score"]) { |
90 | 90 | if ($a["penalty"]==$b["penalty"]) { |
91 | 91 | return 0; |
@@ -102,31 +102,31 @@ discard block |
||
102 | 102 | }); |
103 | 103 | Cache::tags(['contest', 'rank'])->put($this->cid, $ret, 60); |
104 | 104 | return $ret; |
105 | - }else{ |
|
105 | + } else { |
|
106 | 106 | // IO Mode |
107 | - $c = new OutdatedContestModel(); |
|
107 | + $c=new OutdatedContestModel(); |
|
108 | 108 | return $c->contestRankCache($this->cid); |
109 | 109 | } |
110 | 110 | } |
111 | 111 | |
112 | 112 | public function problems() |
113 | 113 | { |
114 | - return $this->hasMany('App\Models\Eloquent\ContestProblem','cid','cid'); |
|
114 | + return $this->hasMany('App\Models\Eloquent\ContestProblem', 'cid', 'cid'); |
|
115 | 115 | } |
116 | 116 | |
117 | 117 | public function submissions() |
118 | 118 | { |
119 | - return $this->hasMany('App\Models\Eloquent\SubmissionModel','cid','cid'); |
|
119 | + return $this->hasMany('App\Models\Eloquent\SubmissionModel', 'cid', 'cid'); |
|
120 | 120 | } |
121 | 121 | |
122 | 122 | public function group() |
123 | 123 | { |
124 | - return $this->hasOne('App\Models\Eloquent\GroupModel','gid','gid'); |
|
124 | + return $this->hasOne('App\Models\Eloquent\GroupModel', 'gid', 'gid'); |
|
125 | 125 | } |
126 | 126 | |
127 | 127 | public function getFrozenTimeAttribute() |
128 | 128 | { |
129 | - $end_time = strtotime($this->end_time); |
|
130 | - return $end_time - $this->froze_length; |
|
129 | + $end_time=strtotime($this->end_time); |
|
130 | + return $end_time-$this->froze_length; |
|
131 | 131 | } |
132 | 132 | } |
@@ -28,12 +28,12 @@ discard block |
||
28 | 28 | $users->add($user); |
29 | 29 | } |
30 | 30 | return $users->unique(); |
31 | - }else{ |
|
31 | + } else{ |
|
32 | 32 | $this->load('submissions.user'); |
33 | 33 | if($ignore_frozen){ |
34 | 34 | $frozen_time = $this->frozen_time; |
35 | 35 | $submissions = $this->submissions()->where('submission_date','<',$frozen_time)->get(); |
36 | - }else{ |
|
36 | + } else{ |
|
37 | 37 | $submissions = $this->submissions; |
38 | 38 | } |
39 | 39 | $users = new EloquentCollection; |
@@ -102,7 +102,7 @@ discard block |
||
102 | 102 | }); |
103 | 103 | Cache::tags(['contest', 'rank'])->put($this->cid, $ret, 60); |
104 | 104 | return $ret; |
105 | - }else{ |
|
105 | + } else{ |
|
106 | 106 | // IO Mode |
107 | 107 | $c = new OutdatedContestModel(); |
108 | 108 | return $c->contestRankCache($this->cid); |
@@ -8,24 +8,24 @@ discard block |
||
8 | 8 | { |
9 | 9 | protected $table='contest_problem'; |
10 | 10 | protected $primaryKey='cpid'; |
11 | - public $timestamps = null; |
|
11 | + public $timestamps=null; |
|
12 | 12 | const DELETED_AT=null; |
13 | 13 | const UPDATED_AT=null; |
14 | 14 | const CREATED_AT=null; |
15 | 15 | |
16 | 16 | public function contest() |
17 | 17 | { |
18 | - return $this->belongsTo('App\Models\Eloquent\ContestModel','cid','cid'); |
|
18 | + return $this->belongsTo('App\Models\Eloquent\ContestModel', 'cid', 'cid'); |
|
19 | 19 | } |
20 | 20 | |
21 | 21 | public function problem() |
22 | 22 | { |
23 | - return $this->belongsTo('App\Models\Eloquent\ProblemModel','pid','pid'); |
|
23 | + return $this->belongsTo('App\Models\Eloquent\ProblemModel', 'pid', 'pid'); |
|
24 | 24 | } |
25 | 25 | |
26 | 26 | public function submissions() |
27 | 27 | { |
28 | - return $this->problem->submissions()->where('cid',$this->contest->cid); |
|
28 | + return $this->problem->submissions()->where('cid', $this->contest->cid); |
|
29 | 29 | } |
30 | 30 | |
31 | 31 | //This should be a repository...or service function ? |
@@ -38,34 +38,34 @@ discard block |
||
38 | 38 | 'wrong_doings' => 0, |
39 | 39 | 'color' => '', |
40 | 40 | ]; |
41 | - $ac_record = $this->ac_record($user); |
|
42 | - if(!empty($ac_record[0])){ |
|
43 | - $ret['solved'] = 1; |
|
44 | - $ret['solved_time'] = $ac_record[0]->submission_date - strtotime($this->contest->begin_time); |
|
45 | - $ret['solved_time_parsed'] = formatProblemSolvedTime($ret['solved_time']); |
|
46 | - $ret['wrong_doings'] = $ac_record[2]; |
|
47 | - $ret['color'] = $ac_record[1] ? 'wemd-green-text' : 'wemd-teal-text'; |
|
48 | - }else{ |
|
49 | - $ret['wrong_doings'] = $ac_record[2]; |
|
41 | + $ac_record=$this->ac_record($user); |
|
42 | + if (!empty($ac_record[0])) { |
|
43 | + $ret['solved']=1; |
|
44 | + $ret['solved_time']=$ac_record[0]->submission_date-strtotime($this->contest->begin_time); |
|
45 | + $ret['solved_time_parsed']=formatProblemSolvedTime($ret['solved_time']); |
|
46 | + $ret['wrong_doings']=$ac_record[2]; |
|
47 | + $ret['color']=$ac_record[1] ? 'wemd-green-text' : 'wemd-teal-text'; |
|
48 | + } else { |
|
49 | + $ret['wrong_doings']=$ac_record[2]; |
|
50 | 50 | } |
51 | 51 | return $ret; |
52 | 52 | } |
53 | 53 | |
54 | 54 | public function ac_record($user) |
55 | 55 | { |
56 | - $user_ac = $this->submissions()->where([ |
|
56 | + $user_ac=$this->submissions()->where([ |
|
57 | 57 | 'uid' => $user->id, |
58 | 58 | 'verdict' => 'Accepted' |
59 | 59 | ])->first(); |
60 | 60 | |
61 | - $other_ac = 1; |
|
62 | - $wrong_trys = 0; |
|
63 | - if(!empty($user_ac)){ |
|
64 | - $other_ac = $this->submissions() |
|
65 | - ->where('verdict','Accepted') |
|
61 | + $other_ac=1; |
|
62 | + $wrong_trys=0; |
|
63 | + if (!empty($user_ac)) { |
|
64 | + $other_ac=$this->submissions() |
|
65 | + ->where('verdict', 'Accepted') |
|
66 | 66 | ->where('submission_date', '<', $user_ac->submission_date) |
67 | 67 | ->count(); |
68 | - $wrong_trys = $this->submissions()->where([ |
|
68 | + $wrong_trys=$this->submissions()->where([ |
|
69 | 69 | 'uid' => $user->id, |
70 | 70 | ])->whereIn('verdict', [ |
71 | 71 | 'Runtime Error', |
@@ -76,8 +76,8 @@ discard block |
||
76 | 76 | 'Presentation Error', |
77 | 77 | 'Output Limit Exceeded' |
78 | 78 | ])->where('submission_date', '<', $user_ac->submission_date)->count(); |
79 | - }else{ |
|
80 | - $wrong_trys = $this->submissions()->where([ |
|
79 | + } else { |
|
80 | + $wrong_trys=$this->submissions()->where([ |
|
81 | 81 | 'uid' => $user->id, |
82 | 82 | ])->whereIn('verdict', [ |
83 | 83 | 'Runtime Error', |
@@ -45,7 +45,7 @@ discard block |
||
45 | 45 | $ret['solved_time_parsed'] = formatProblemSolvedTime($ret['solved_time']); |
46 | 46 | $ret['wrong_doings'] = $ac_record[2]; |
47 | 47 | $ret['color'] = $ac_record[1] ? 'wemd-green-text' : 'wemd-teal-text'; |
48 | - }else{ |
|
48 | + } else{ |
|
49 | 49 | $ret['wrong_doings'] = $ac_record[2]; |
50 | 50 | } |
51 | 51 | return $ret; |
@@ -76,7 +76,7 @@ discard block |
||
76 | 76 | 'Presentation Error', |
77 | 77 | 'Output Limit Exceeded' |
78 | 78 | ])->where('submission_date', '<', $user_ac->submission_date)->count(); |
79 | - }else{ |
|
79 | + } else{ |
|
80 | 80 | $wrong_trys = $this->submissions()->where([ |
81 | 81 | 'uid' => $user->id, |
82 | 82 | ])->whereIn('verdict', [ |
@@ -34,7 +34,7 @@ discard block |
||
34 | 34 | */ |
35 | 35 | protected function schedule(Schedule $schedule) |
36 | 36 | { |
37 | - $schedule->call(function () { |
|
37 | + $schedule->call(function() { |
|
38 | 38 | $babel=new Babel(); |
39 | 39 | for ($i=1; $i<=12; $i++) { |
40 | 40 | $babel->judge(); |
@@ -43,35 +43,35 @@ discard block |
||
43 | 43 | // file_put_contents(storage_path('app/task-schedule.output'),"Successfully Synced Judger"); |
44 | 44 | })->everyMinute()->description("Sync Judger"); |
45 | 45 | |
46 | - $schedule->call(function () { |
|
46 | + $schedule->call(function() { |
|
47 | 47 | $rankModel=new RankModel(); |
48 | 48 | $rankModel->rankList(); |
49 | 49 | // file_put_contents(storage_path('app/task-schedule.output'),"Successfully Updated Rank"); |
50 | 50 | })->dailyAt('02:00')->description("Update Rank"); |
51 | 51 | |
52 | - $schedule->call(function () { |
|
52 | + $schedule->call(function() { |
|
53 | 53 | $siteMapModel=new SiteMapModel(); |
54 | 54 | // file_put_contents(storage_path('app/task-schedule.output'),"Successfully Updated SiteMap"); |
55 | 55 | })->dailyAt('02:00')->description("Update SiteMap"); |
56 | 56 | |
57 | - $schedule->call(function () { |
|
57 | + $schedule->call(function() { |
|
58 | 58 | $groupModel=new GroupModel(); |
59 | 59 | $groupModel->cacheTrendingGroups(); |
60 | 60 | // file_put_contents(storage_path('app/task-schedule.output'),"Successfully Cached Trending Groups"); |
61 | 61 | })->dailyAt('03:00')->description("Update Trending Groups"); |
62 | 62 | |
63 | 63 | $schedule->call(function() { |
64 | - $groupModel = new GroupModel(); |
|
65 | - $ret = $groupModel->refreshAllElo(); |
|
64 | + $groupModel=new GroupModel(); |
|
65 | + $ret=$groupModel->refreshAllElo(); |
|
66 | 66 | foreach ($ret as $gid => $group) { |
67 | - if(empty($group['result'])){ |
|
67 | + if (empty($group['result'])) { |
|
68 | 68 | Log::channel('group_elo')->info('Refreshed Group Elo (Empty) : ('.$gid.')'.$group['name']); |
69 | - }else{ |
|
69 | + } else { |
|
70 | 70 | Log::channel('group_elo')->info('Refreshing Group Elo: ('.$gid.')'.$group['name']); |
71 | 71 | foreach ($group['result'] as $contest) { |
72 | - if($contest['ret'] == 'success'){ |
|
72 | + if ($contest['ret']=='success') { |
|
73 | 73 | Log::channel('group_elo')->info(' Elo Clac Successfully : ('.$contest['cid'].')'.$contest['name']); |
74 | - }else{ |
|
74 | + } else { |
|
75 | 75 | Log::channel('group_elo')->info(' Elo Clac Faild (Judge Not Over) : ('.$contest['cid'].')'.$contest['name'].' sids:'); |
76 | 76 | foreach ($contest['submissions'] as $sid) { |
77 | 77 | Log::channel('group_elo')->info(' '.$sid['sid']); |
@@ -82,46 +82,46 @@ discard block |
||
82 | 82 | } |
83 | 83 | })->dailyAt('04:00')->description("Update Group Elo"); |
84 | 84 | |
85 | - $schedule->call(function () { |
|
86 | - $contestModel = new ContestModel(); |
|
87 | - $syncList = $contestModel->runningContest(); |
|
85 | + $schedule->call(function() { |
|
86 | + $contestModel=new ContestModel(); |
|
87 | + $syncList=$contestModel->runningContest(); |
|
88 | 88 | foreach ($syncList as $syncContest) { |
89 | 89 | if (!isset($syncContest['vcid'])) { |
90 | - $contest = EloquentContestModel::find($syncContest['cid']); |
|
91 | - $contestRankRaw = $contest->rankRefresh(); |
|
90 | + $contest=EloquentContestModel::find($syncContest['cid']); |
|
91 | + $contestRankRaw=$contest->rankRefresh(); |
|
92 | 92 | $cid=$syncContest['cid']; |
93 | 93 | Cache::tags(['contest', 'rank'])->put($cid, $contestRankRaw); |
94 | 94 | Cache::tags(['contest', 'rank'])->put("contestAdmin$cid", $contestRankRaw); |
95 | - continue ; |
|
95 | + continue; |
|
96 | 96 | } |
97 | - $className = "App\\Babel\\Extension\\hdu\\Synchronizer"; // TODO Add OJ judgement. |
|
98 | - $all_data = [ |
|
97 | + $className="App\\Babel\\Extension\\hdu\\Synchronizer"; // TODO Add OJ judgement. |
|
98 | + $all_data=[ |
|
99 | 99 | 'oj'=>"hdu", |
100 | 100 | 'vcid'=>$syncContest['vcid'], |
101 | 101 | 'gid'=>$syncContest['gid'], |
102 | 102 | 'cid'=>$syncContest['cid'], |
103 | 103 | ]; |
104 | - $hduSync = new $className($all_data); |
|
104 | + $hduSync=new $className($all_data); |
|
105 | 105 | $hduSync->crawlRank(); |
106 | 106 | $hduSync->crawlClarification(); |
107 | 107 | } |
108 | 108 | // file_put_contents(storage_path('app/task-schedule.output'),"Successfully Synced Remote Rank and Clarification"); |
109 | 109 | })->everyMinute()->description("Sync Remote Rank and Clarification"); |
110 | 110 | |
111 | - $schedule->call(function () { |
|
112 | - $contestModel = new ContestModel(); |
|
113 | - $syncList = $contestModel->runningContest(); |
|
111 | + $schedule->call(function() { |
|
112 | + $contestModel=new ContestModel(); |
|
113 | + $syncList=$contestModel->runningContest(); |
|
114 | 114 | foreach ($syncList as $syncContest) { |
115 | 115 | if (isset($syncContest['crawled'])) { |
116 | 116 | if (!$syncContest['crawled']) { |
117 | - $className = "App\\Babel\\Extension\\hdu\\Synchronizer"; |
|
118 | - $all_data = [ |
|
117 | + $className="App\\Babel\\Extension\\hdu\\Synchronizer"; |
|
118 | + $all_data=[ |
|
119 | 119 | 'oj'=>"hdu", |
120 | 120 | 'vcid'=>$syncContest['vcid'], |
121 | 121 | 'gid'=>$syncContest['gid'], |
122 | 122 | 'cid'=>$syncContest['cid'], |
123 | 123 | ]; |
124 | - $hduSync = new $className($all_data); |
|
124 | + $hduSync=new $className($all_data); |
|
125 | 125 | $hduSync->scheduleCrawl(); |
126 | 126 | $contestModel->updateCrawlStatus($syncContest['cid']); |
127 | 127 | } |
@@ -129,7 +129,7 @@ discard block |
||
129 | 129 | } |
130 | 130 | })->everyMinute()->description("Sync Contest Problem"); |
131 | 131 | |
132 | - $schedule->call(function () { |
|
132 | + $schedule->call(function() { |
|
133 | 133 | $oidList=EloquentJudgeServerModel::column('oid'); |
134 | 134 | $babel=new Babel(); |
135 | 135 | foreach ($oidList as $oid) { |
@@ -25,7 +25,7 @@ discard block |
||
25 | 25 | $contestModel=new ContestModel(); |
26 | 26 | $verified=$contestModel->isVerified($cid); |
27 | 27 | $clearance=$contestModel->judgeClearance($cid, Auth::user()->id); |
28 | - if ($clearance <= 2) { |
|
28 | + if ($clearance<=2) { |
|
29 | 29 | return Redirect::route('contest_detail', ['cid' => $cid]); |
30 | 30 | } |
31 | 31 | $contest_name=$contestModel->contestName($cid); |
@@ -34,7 +34,7 @@ discard block |
||
34 | 34 | $basicInfo=$contestModel->basic($cid); |
35 | 35 | $contest_accounts=$accountModel->getContestAccount($cid); |
36 | 36 | $gcode=$contestModel->gcode($cid); |
37 | - $isEnd = $contestModel->remainingTime($cid) < 0; |
|
37 | + $isEnd=$contestModel->remainingTime($cid)<0; |
|
38 | 38 | return view('contest.board.admin', [ |
39 | 39 | 'page_title'=>"Admin", |
40 | 40 | 'navigation' => "Contest", |
@@ -55,44 +55,44 @@ discard block |
||
55 | 55 | { |
56 | 56 | $contestModel=new ContestModel(); |
57 | 57 | $clearance=$contestModel->judgeClearance($cid, Auth::user()->id); |
58 | - if ($clearance <= 2) { |
|
58 | + if ($clearance<=2) { |
|
59 | 59 | return Redirect::route('contest_detail', ['cid' => $cid]); |
60 | 60 | } |
61 | 61 | $account=$contestModel->getContestAccount($cid); |
62 | - if($account==null){ |
|
63 | - return ; |
|
64 | - }else{ |
|
62 | + if ($account==null) { |
|
63 | + return; |
|
64 | + } else { |
|
65 | 65 | $AccountExport=new AccountExport($account); |
66 | 66 | $filename="ContestAccount$cid"; |
67 | 67 | return Excel::download($AccountExport, $filename.'.xlsx'); |
68 | 68 | } |
69 | 69 | } |
70 | 70 | |
71 | - public function refreshContestRank($cid){ |
|
71 | + public function refreshContestRank($cid) { |
|
72 | 72 | $contestModel=new ContestModel(); |
73 | 73 | $clearance=$contestModel->judgeClearance($cid, Auth::user()->id); |
74 | - if ($clearance <= 2) { |
|
74 | + if ($clearance<=2) { |
|
75 | 75 | return Redirect::route('contest.detail', ['cid' => $cid]); |
76 | 76 | } |
77 | - $contest_eloquent = EloquentContestModel::find($cid); |
|
77 | + $contest_eloquent=EloquentContestModel::find($cid); |
|
78 | 78 | $contestRankRaw=$contest_eloquent->rankRefresh(); |
79 | 79 | Cache::tags(['contest', 'rank'])->put($cid, $contestRankRaw); |
80 | 80 | Cache::tags(['contest', 'rank'])->put("contestAdmin$cid", $contestRankRaw); |
81 | 81 | $end_time=strtotime(DB::table("contest")->where(["cid"=>$cid])->select("end_time")->first()["end_time"]); |
82 | - if(time() > strtotime($end_time)){ |
|
82 | + if (time()>strtotime($end_time)) { |
|
83 | 83 | $contestModel->storeContestRankInMySQL($cid, $contestRankRaw); |
84 | 84 | } |
85 | 85 | return Redirect::route('contest.rank', ['cid' => $cid]); |
86 | 86 | } |
87 | 87 | |
88 | - public function scrollBoard($cid){ |
|
88 | + public function scrollBoard($cid) { |
|
89 | 89 | $contestModel=new ContestModel(); |
90 | 90 | $clearance=$contestModel->judgeClearance($cid, Auth::user()->id); |
91 | - if ($clearance <= 2) { |
|
91 | + if ($clearance<=2) { |
|
92 | 92 | return Redirect::route('contest_detail', ['cid' => $cid]); |
93 | 93 | } |
94 | 94 | $basicInfo=$contestModel->basic($cid); |
95 | - if($basicInfo['froze_length'] == 0){ |
|
95 | + if ($basicInfo['froze_length']==0) { |
|
96 | 96 | return Redirect::route('contest.admin', ['cid' => $cid]); |
97 | 97 | } |
98 | 98 | return view('contest.board.scrollBoard', [ |
@@ -114,8 +114,8 @@ discard block |
||
114 | 114 | |
115 | 115 | public function gcode($cid) |
116 | 116 | { |
117 | - $gid = $this->gid($cid); |
|
118 | - return DB::table('group')->where('gid','=',$gid)->first()["gcode"]; |
|
117 | + $gid=$this->gid($cid); |
|
118 | + return DB::table('group')->where('gid', '=', $gid)->first()["gcode"]; |
|
119 | 119 | } |
120 | 120 | |
121 | 121 | public function runningContest() |
@@ -140,19 +140,19 @@ discard block |
||
140 | 140 | |
141 | 141 | public function listForSetting($gid) |
142 | 142 | { |
143 | - $uid = Auth::user()->id; |
|
144 | - $group_contests = DB::table('contest') |
|
145 | - ->where('gid',$gid) |
|
146 | - ->orderBy('begin_time','desc') |
|
143 | + $uid=Auth::user()->id; |
|
144 | + $group_contests=DB::table('contest') |
|
145 | + ->where('gid', $gid) |
|
146 | + ->orderBy('begin_time', 'desc') |
|
147 | 147 | ->get()->all(); |
148 | - $groupModel = new GroupModel(); |
|
149 | - $group_clearance = $groupModel->judgeClearance($gid,$uid); |
|
148 | + $groupModel=new GroupModel(); |
|
149 | + $group_clearance=$groupModel->judgeClearance($gid, $uid); |
|
150 | 150 | foreach ($group_contests as &$contest) { |
151 | - $contest['is_admin'] = ($contest['assign_uid'] == $uid || $group_clearance == 3); |
|
152 | - $contest['begin_stamps'] = strtotime($contest['begin_time']); |
|
153 | - $contest['end_stamps'] = strtotime($contest['end_time']); |
|
154 | - $contest['status'] = time() >= $contest['end_stamps'] ? 1 |
|
155 | - : (time() <= $contest['begin_stamps'] ? -1 : 0); |
|
151 | + $contest['is_admin']=($contest['assign_uid']==$uid || $group_clearance==3); |
|
152 | + $contest['begin_stamps']=strtotime($contest['begin_time']); |
|
153 | + $contest['end_stamps']=strtotime($contest['end_time']); |
|
154 | + $contest['status']=time()>=$contest['end_stamps'] ? 1 |
|
155 | + : (time()<=$contest['begin_stamps'] ? -1 : 0); |
|
156 | 156 | $contest["rule_parsed"]=$this->rule[$contest["rule"]]; |
157 | 157 | $contest["date_parsed"]=[ |
158 | 158 | "date"=>date_format(date_create($contest["begin_time"]), 'j'), |
@@ -160,11 +160,11 @@ discard block |
||
160 | 160 | ]; |
161 | 161 | $contest["length"]=$this->calcLength($contest["begin_time"], $contest["end_time"]); |
162 | 162 | } |
163 | - usort($group_contests,function($a,$b){ |
|
164 | - if($a['is_admin'] == $b['is_admin']){ |
|
165 | - return $b['begin_stamps'] - $a['begin_stamps']; |
|
163 | + usort($group_contests, function($a, $b) { |
|
164 | + if ($a['is_admin']==$b['is_admin']) { |
|
165 | + return $b['begin_stamps']-$a['begin_stamps']; |
|
166 | 166 | } |
167 | - return $b['is_admin'] - $a['is_admin']; |
|
167 | + return $b['is_admin']-$a['is_admin']; |
|
168 | 168 | }); |
169 | 169 | return $group_contests; |
170 | 170 | } |
@@ -175,9 +175,9 @@ discard block |
||
175 | 175 | // "gid"=>$gid |
176 | 176 | // ])->orderBy('begin_time', 'desc')->get()->all(); |
177 | 177 | $preQuery=DB::table($this->tableName); |
178 | - $paginator=$preQuery->where('gid','=',$gid)->orderBy('begin_time', 'desc')->paginate(10); |
|
178 | + $paginator=$preQuery->where('gid', '=', $gid)->orderBy('begin_time', 'desc')->paginate(10); |
|
179 | 179 | $contest_list=$paginator->all(); |
180 | - if(empty($contest_list)){ |
|
180 | + if (empty($contest_list)) { |
|
181 | 181 | return null; |
182 | 182 | } |
183 | 183 | |
@@ -202,7 +202,7 @@ discard block |
||
202 | 202 | ])->first()["rule"]; |
203 | 203 | } |
204 | 204 | |
205 | - public function list($filter,$uid) |
|
205 | + public function list($filter, $uid) |
|
206 | 206 | { |
207 | 207 | if ($uid) { |
208 | 208 | //$paginator=DB::select('SELECT DISTINCT contest.* FROM group_member inner join contest on group_member.gid=contest.gid left join contest_participant on contest.cid=contest_participant.cid where (public=1 and audit=1) or (group_member.uid=:uid and group_member.role>0 and (contest_participant.uid=:uidd or ISNULL(contest_participant.uid)) and (registration=0 or (registration=1 and not ISNULL(contest_participant.uid))))',["uid"=>$uid,"uidd"=>$uid])->paginate(10); |
@@ -226,15 +226,15 @@ discard block |
||
226 | 226 | if ($filter['practice']) { |
227 | 227 | $paginator=$paginator->where(["practice"=>$filter['practice']]); |
228 | 228 | } |
229 | - $paginator = $paginator ->paginate(10); |
|
230 | - }elseif($filter['public']=='0'){ |
|
229 | + $paginator=$paginator ->paginate(10); |
|
230 | + }elseif ($filter['public']=='0') { |
|
231 | 231 | $paginator=DB::table('group_member') |
232 | 232 | ->groupBy('contest.cid') |
233 | 233 | ->select('contest.*') |
234 | 234 | ->join('contest', 'group_member.gid', '=', 'contest.gid') |
235 | 235 | ->leftJoin('contest_participant', 'contest.cid', '=', 'contest_participant.cid') |
236 | 236 | ->where( |
237 | - function ($query) use ($filter,$uid) { |
|
237 | + function($query) use ($filter, $uid) { |
|
238 | 238 | if ($filter['rule']) { |
239 | 239 | $query=$query->where(["rule"=>$filter['rule']]); |
240 | 240 | } |
@@ -257,14 +257,14 @@ discard block |
||
257 | 257 | ) |
258 | 258 | ->orderBy('contest.begin_time', 'desc') |
259 | 259 | ->paginate(10); |
260 | - }else{ |
|
260 | + } else { |
|
261 | 261 | $paginator=DB::table('group_member') |
262 | 262 | ->groupBy('contest.cid') |
263 | 263 | ->select('contest.*') |
264 | 264 | ->join('contest', 'group_member.gid', '=', 'contest.gid') |
265 | 265 | ->leftJoin('contest_participant', 'contest.cid', '=', 'contest_participant.cid') |
266 | 266 | ->where( |
267 | - function ($query) use ($filter) { |
|
267 | + function($query) use ($filter) { |
|
268 | 268 | if ($filter['rule']) { |
269 | 269 | $query=$query->where(["rule"=>$filter['rule']]); |
270 | 270 | } |
@@ -285,7 +285,7 @@ discard block |
||
285 | 285 | } |
286 | 286 | ) |
287 | 287 | ->orWhere( |
288 | - function ($query) use ($filter,$uid) { |
|
288 | + function($query) use ($filter, $uid) { |
|
289 | 289 | if ($filter['rule']) { |
290 | 290 | $query=$query->where(["rule"=>$filter['rule']]); |
291 | 291 | } |
@@ -331,7 +331,7 @@ discard block |
||
331 | 331 | if ($filter['practice']) { |
332 | 332 | $paginator=$paginator->where(["practice"=>$filter['practice']]); |
333 | 333 | } |
334 | - $paginator = $paginator ->paginate(10); |
|
334 | + $paginator=$paginator ->paginate(10); |
|
335 | 335 | } |
336 | 336 | $contest_list=$paginator->all(); |
337 | 337 | foreach ($contest_list as &$c) { |
@@ -369,14 +369,14 @@ discard block |
||
369 | 369 | } |
370 | 370 | } |
371 | 371 | |
372 | - public function registContest($cid,$uid) |
|
372 | + public function registContest($cid, $uid) |
|
373 | 373 | { |
374 | 374 | $registered=DB::table("contest_participant")->where([ |
375 | 375 | "cid"=>$cid, |
376 | 376 | "uid"=>$uid |
377 | 377 | ])->first(); |
378 | 378 | |
379 | - if(empty($registered)){ |
|
379 | + if (empty($registered)) { |
|
380 | 380 | DB::table("contest_participant")->insert([ |
381 | 381 | "cid"=>$cid, |
382 | 382 | "uid"=>$uid, |
@@ -384,7 +384,7 @@ discard block |
||
384 | 384 | ]); |
385 | 385 | $name=User::find($uid)->name; |
386 | 386 | $contest=$this->basic($cid); |
387 | - $url=route('contest.detail',['cid' => $cid]); |
|
387 | + $url=route('contest.detail', ['cid' => $cid]); |
|
388 | 388 | sendMessage([ |
389 | 389 | 'receiver' => $uid, |
390 | 390 | 'sender' => 1, // potential bugs |
@@ -418,9 +418,9 @@ discard block |
||
418 | 418 | public function problems($cid) |
419 | 419 | { |
420 | 420 | return DB::table('contest_problem') |
421 | - ->join('problem','contest_problem.pid','=','problem.pid') |
|
422 | - ->where('cid',$cid) |
|
423 | - ->select('problem.pid as pid','pcode','number') |
|
421 | + ->join('problem', 'contest_problem.pid', '=', 'problem.pid') |
|
422 | + ->where('cid', $cid) |
|
423 | + ->select('problem.pid as pid', 'pcode', 'number') |
|
424 | 424 | ->orderBy('number') |
425 | 425 | ->get()->all(); |
426 | 426 | } |
@@ -442,18 +442,18 @@ discard block |
||
442 | 442 | $end_time=strtotime(DB::table("contest")->where(["cid"=>$cid])->select("end_time")->first()["end_time"]); |
443 | 443 | |
444 | 444 | foreach ($problemSet as &$p) { |
445 | - if($p['practice']){ |
|
446 | - $tags = DB::table("group_problem_tag") |
|
447 | - ->where('gid',$p['gid']) |
|
448 | - ->where('pid',$p['pid']) |
|
445 | + if ($p['practice']) { |
|
446 | + $tags=DB::table("group_problem_tag") |
|
447 | + ->where('gid', $p['gid']) |
|
448 | + ->where('pid', $p['pid']) |
|
449 | 449 | ->get()->all(); |
450 | - $tags_arr = []; |
|
451 | - if(!empty($tags)){ |
|
450 | + $tags_arr=[]; |
|
451 | + if (!empty($tags)) { |
|
452 | 452 | foreach ($tags as $value) { |
453 | - array_push($tags_arr,$value['tag']); |
|
453 | + array_push($tags_arr, $value['tag']); |
|
454 | 454 | } |
455 | 455 | } |
456 | - $p['tags'] = $tags_arr; |
|
456 | + $p['tags']=$tags_arr; |
|
457 | 457 | } |
458 | 458 | if ($contest_rule==1) { |
459 | 459 | $prob_stat=DB::table("submission")->select( |
@@ -714,7 +714,7 @@ discard block |
||
714 | 714 | "problem_detail" => $prob_detail |
715 | 715 | ]; |
716 | 716 | } |
717 | - usort($ret, function ($a, $b) { |
|
717 | + usort($ret, function($a, $b) { |
|
718 | 718 | if ($a["score"]==$b["score"]) { |
719 | 719 | if ($a["penalty"]==$b["penalty"]) { |
720 | 720 | return 0; |
@@ -761,7 +761,7 @@ discard block |
||
761 | 761 | "problem_detail" => $prob_detail |
762 | 762 | ]; |
763 | 763 | } |
764 | - usort($ret, function ($a, $b) { |
|
764 | + usort($ret, function($a, $b) { |
|
765 | 765 | if ($a["score"]==$b["score"]) { |
766 | 766 | if ($a["solved"]==$b["solved"]) { |
767 | 767 | return 0; |
@@ -783,7 +783,7 @@ discard block |
||
783 | 783 | return $ret; |
784 | 784 | } |
785 | 785 | |
786 | - public function contestRank($cid, $uid = 0) |
|
786 | + public function contestRank($cid, $uid=0) |
|
787 | 787 | { |
788 | 788 | // [ToDo] If the current user's in the organizer group show nick name |
789 | 789 | // [ToDo] The participants determination |
@@ -800,36 +800,36 @@ discard block |
||
800 | 800 | "gid" => $contest_info["gid"] |
801 | 801 | ])->where("role", ">", 0)->first()); |
802 | 802 | |
803 | - $clearance = $this -> judgeClearance($cid, $uid); |
|
803 | + $clearance=$this -> judgeClearance($cid, $uid); |
|
804 | 804 | |
805 | 805 | /** New Version With MySQL */ |
806 | 806 | $end_time=strtotime(DB::table("contest")->where(["cid"=>$cid])->select("end_time")->first()["end_time"]); |
807 | - $contest_eloquent = EloquentContestModel::find($cid); |
|
807 | + $contest_eloquent=EloquentContestModel::find($cid); |
|
808 | 808 | |
809 | - if(time() < $end_time){ |
|
810 | - if($clearance == 3){ |
|
809 | + if (time()<$end_time) { |
|
810 | + if ($clearance==3) { |
|
811 | 811 | $contestRankRaw=Cache::tags(['contest', 'rank'])->get("contestAdmin$cid"); |
812 | - }else{ |
|
812 | + } else { |
|
813 | 813 | $contestRankRaw=Cache::tags(['contest', 'rank'])->get($cid); |
814 | 814 | } |
815 | - if(!isset($contestRankRaw)){ |
|
815 | + if (!isset($contestRankRaw)) { |
|
816 | 816 | $contestRankRaw=$contest_eloquent->rankRefresh(); |
817 | 817 | } |
818 | - }else{ |
|
819 | - if($clearance == 3){ |
|
818 | + } else { |
|
819 | + if ($clearance==3) { |
|
820 | 820 | $contestRankRaw=Cache::tags(['contest', 'rank'])->get("contestAdmin$cid"); |
821 | 821 | if (!isset($contestRankRaw)) { |
822 | 822 | $contestRankRaw=$this->getContestRankFromMySQL($cid); |
823 | - if(!isset($contestRankRaw)){ |
|
823 | + if (!isset($contestRankRaw)) { |
|
824 | 824 | $contestRankRaw=$contest_eloquent->rankRefresh(); |
825 | 825 | $this->storeContestRankInMySQL($cid, $contestRankRaw); |
826 | 826 | } |
827 | 827 | } |
828 | - }else{ |
|
828 | + } else { |
|
829 | 829 | $contestRankRaw=$this->getContestRankFromMySQL($cid); |
830 | - if(!isset($contestRankRaw)){ |
|
830 | + if (!isset($contestRankRaw)) { |
|
831 | 831 | $contestRankRaw=Cache::tags(['contest', 'rank'])->get($cid); |
832 | - if(!isset($contestRankRaw)){ |
|
832 | + if (!isset($contestRankRaw)) { |
|
833 | 833 | $contestRankRaw=$contest_eloquent->rankRefresh(); |
834 | 834 | } |
835 | 835 | $this->storeContestRankInMySQL($cid, $contestRankRaw); |
@@ -847,15 +847,15 @@ discard block |
||
847 | 847 | // $contestRankRaw=$this->contestRankCache($cid); |
848 | 848 | // } |
849 | 849 | // } |
850 | - if($contest_info["rule"]==1){ |
|
850 | + if ($contest_info["rule"]==1) { |
|
851 | 851 | foreach ($contestRankRaw as &$cr) { |
852 | - $solved = 0; |
|
853 | - foreach($cr['problem_detail'] as $pd){ |
|
854 | - if(!empty($pd['solved_time_parsed'])){ |
|
855 | - $solved ++; |
|
852 | + $solved=0; |
|
853 | + foreach ($cr['problem_detail'] as $pd) { |
|
854 | + if (!empty($pd['solved_time_parsed'])) { |
|
855 | + $solved++; |
|
856 | 856 | } |
857 | 857 | } |
858 | - $cr['solved'] = $solved; |
|
858 | + $cr['solved']=$solved; |
|
859 | 859 | } |
860 | 860 | } |
861 | 861 | |
@@ -904,16 +904,16 @@ discard block |
||
904 | 904 | |
905 | 905 | public function getClarificationList($cid) |
906 | 906 | { |
907 | - $uid = Auth::user()->id; |
|
908 | - $clearance = $this -> judgeClearance($cid, $uid); |
|
909 | - if($clearance == 3){ |
|
907 | + $uid=Auth::user()->id; |
|
908 | + $clearance=$this -> judgeClearance($cid, $uid); |
|
909 | + if ($clearance==3) { |
|
910 | 910 | return DB::table("contest_clarification")->where([ |
911 | 911 | "cid"=>$cid |
912 | 912 | ])->orderBy('create_time', 'desc')->get()->all(); |
913 | - }else{ |
|
913 | + } else { |
|
914 | 914 | return DB::table("contest_clarification")->where([ |
915 | 915 | "cid"=>$cid |
916 | - ])->where(function ($query) { |
|
916 | + ])->where(function($query) { |
|
917 | 917 | $query->where([ |
918 | 918 | "public"=>1 |
919 | 919 | ])->orWhere([ |
@@ -1059,7 +1059,7 @@ discard block |
||
1059 | 1059 | public function getContestRecord($filter, $cid) |
1060 | 1060 | { |
1061 | 1061 | $basicInfo=$this->basic($cid); |
1062 | - $userInfo=DB::table('group_member')->where('gid',$basicInfo["gid"])->where('uid',Auth::user()->id)->get()->first(); |
|
1062 | + $userInfo=DB::table('group_member')->where('gid', $basicInfo["gid"])->where('uid', Auth::user()->id)->get()->first(); |
|
1063 | 1063 | $problemSet_temp=DB::table("contest_problem")->join("problem", "contest_problem.pid", "=", "problem.pid")->where([ |
1064 | 1064 | "cid"=>$cid |
1065 | 1065 | ])->orderBy('ncode', 'asc')->select("ncode", "alias", "contest_problem.pid as pid", "title", "points", "tot_score")->get()->all(); |
@@ -1072,14 +1072,14 @@ discard block |
||
1072 | 1072 | $end_time=strtotime(DB::table("contest")->where(["cid"=>$cid])->select("end_time")->first()["end_time"]); |
1073 | 1073 | $contestEnd=time()>$end_time; |
1074 | 1074 | |
1075 | - $filter['pid'] = array_search($filter['ncode'], array_column($problemSet_temp, 'ncode')); |
|
1076 | - if($filter['pid']==false){ |
|
1077 | - $filter['pid'] = null; |
|
1078 | - }else{ |
|
1079 | - $filter['pid'] = $problemSet_temp[$filter['pid']]['pid']; |
|
1075 | + $filter['pid']=array_search($filter['ncode'], array_column($problemSet_temp, 'ncode')); |
|
1076 | + if ($filter['pid']==false) { |
|
1077 | + $filter['pid']=null; |
|
1078 | + } else { |
|
1079 | + $filter['pid']=$problemSet_temp[$filter['pid']]['pid']; |
|
1080 | 1080 | } |
1081 | 1081 | |
1082 | - if($userInfo==null || $userInfo["role"]!=3){ |
|
1082 | + if ($userInfo==null || $userInfo["role"]!=3) { |
|
1083 | 1083 | if ($basicInfo["status_visibility"]==2) { |
1084 | 1084 | // View all |
1085 | 1085 | $paginator=DB::table("submission")->where([ |
@@ -1093,7 +1093,7 @@ discard block |
||
1093 | 1093 | "users.id", |
1094 | 1094 | "=", |
1095 | 1095 | "submission.uid" |
1096 | - )->where(function ($query) use ($frozen_time) { |
|
1096 | + )->where(function($query) use ($frozen_time) { |
|
1097 | 1097 | $query->where( |
1098 | 1098 | "submission_date", |
1099 | 1099 | "<", |
@@ -1120,15 +1120,15 @@ discard block |
||
1120 | 1120 | 'desc' |
1121 | 1121 | ); |
1122 | 1122 | |
1123 | - if($filter["pid"]){ |
|
1123 | + if ($filter["pid"]) { |
|
1124 | 1124 | $paginator=$paginator->where(["pid"=>$filter["pid"]]); |
1125 | 1125 | } |
1126 | 1126 | |
1127 | - if($filter["result"]){ |
|
1127 | + if ($filter["result"]) { |
|
1128 | 1128 | $paginator=$paginator->where(["verdict"=>$filter["result"]]); |
1129 | 1129 | } |
1130 | 1130 | |
1131 | - if($filter["account"]){ |
|
1131 | + if ($filter["account"]) { |
|
1132 | 1132 | $paginator=$paginator->where(["name"=>$filter["account"]]); |
1133 | 1133 | } |
1134 | 1134 | |
@@ -1164,15 +1164,15 @@ discard block |
||
1164 | 1164 | 'desc' |
1165 | 1165 | ); |
1166 | 1166 | |
1167 | - if($filter["pid"]){ |
|
1167 | + if ($filter["pid"]) { |
|
1168 | 1168 | $paginator=$paginator->where(["pid"=>$filter["pid"]]); |
1169 | 1169 | } |
1170 | 1170 | |
1171 | - if($filter["result"]){ |
|
1171 | + if ($filter["result"]) { |
|
1172 | 1172 | $paginator=$paginator->where(["verdict"=>$filter["result"]]); |
1173 | 1173 | } |
1174 | 1174 | |
1175 | - if($filter["account"]){ |
|
1175 | + if ($filter["account"]) { |
|
1176 | 1176 | $paginator=$paginator->where(["name"=>$filter["account"]]); |
1177 | 1177 | } |
1178 | 1178 | |
@@ -1183,7 +1183,7 @@ discard block |
||
1183 | 1183 | "records"=>[] |
1184 | 1184 | ]; |
1185 | 1185 | } |
1186 | - }else{ |
|
1186 | + } else { |
|
1187 | 1187 | if ($basicInfo["status_visibility"]==2) { |
1188 | 1188 | // View all |
1189 | 1189 | $paginator=DB::table("submission")->where([ |
@@ -1215,15 +1215,15 @@ discard block |
||
1215 | 1215 | 'desc' |
1216 | 1216 | ); |
1217 | 1217 | |
1218 | - if($filter["pid"]){ |
|
1218 | + if ($filter["pid"]) { |
|
1219 | 1219 | $paginator=$paginator->where(["pid"=>$filter["pid"]]); |
1220 | 1220 | } |
1221 | 1221 | |
1222 | - if($filter["result"]){ |
|
1222 | + if ($filter["result"]) { |
|
1223 | 1223 | $paginator=$paginator->where(["verdict"=>$filter["result"]]); |
1224 | 1224 | } |
1225 | 1225 | |
1226 | - if($filter["account"]){ |
|
1226 | + if ($filter["account"]) { |
|
1227 | 1227 | $paginator=$paginator->where(["name"=>$filter["account"]]); |
1228 | 1228 | } |
1229 | 1229 | |
@@ -1259,15 +1259,15 @@ discard block |
||
1259 | 1259 | 'desc' |
1260 | 1260 | ); |
1261 | 1261 | |
1262 | - if($filter["pid"]){ |
|
1262 | + if ($filter["pid"]) { |
|
1263 | 1263 | $paginator=$paginator->where(["pid"=>$filter["pid"]]); |
1264 | 1264 | } |
1265 | 1265 | |
1266 | - if($filter["result"]){ |
|
1266 | + if ($filter["result"]) { |
|
1267 | 1267 | $paginator=$paginator->where(["verdict"=>$filter["result"]]); |
1268 | 1268 | } |
1269 | 1269 | |
1270 | - if($filter["account"]){ |
|
1270 | + if ($filter["account"]) { |
|
1271 | 1271 | $paginator=$paginator->where(["name"=>$filter["account"]]); |
1272 | 1272 | } |
1273 | 1273 | |
@@ -1323,21 +1323,21 @@ discard block |
||
1323 | 1323 | if ($uid==0) { |
1324 | 1324 | return 0; |
1325 | 1325 | } |
1326 | - $groupModel = new GroupModel(); |
|
1326 | + $groupModel=new GroupModel(); |
|
1327 | 1327 | $contest_info=DB::table("contest")->where("cid", $cid)->first(); |
1328 | - $userInfo=DB::table('group_member')->where('gid',$contest_info["gid"])->where('uid',$uid)->get()->first(); |
|
1328 | + $userInfo=DB::table('group_member')->where('gid', $contest_info["gid"])->where('uid', $uid)->get()->first(); |
|
1329 | 1329 | |
1330 | - if(empty($contest_info)){ |
|
1330 | + if (empty($contest_info)) { |
|
1331 | 1331 | // contest not exist |
1332 | 1332 | return 0; |
1333 | 1333 | } |
1334 | 1334 | |
1335 | - if($uid == $contest_info['assign_uid'] || $groupModel->judgeClearance($contest_info['gid'],$uid) == 3){ |
|
1335 | + if ($uid==$contest_info['assign_uid'] || $groupModel->judgeClearance($contest_info['gid'], $uid)==3) { |
|
1336 | 1336 | return 3; |
1337 | 1337 | } |
1338 | 1338 | |
1339 | - $contest_started = strtotime($contest_info['begin_time']) < time(); |
|
1340 | - $contest_ended = strtotime($contest_info['end_time']) < time(); |
|
1339 | + $contest_started=strtotime($contest_info['begin_time'])<time(); |
|
1340 | + $contest_ended=strtotime($contest_info['end_time'])<time(); |
|
1341 | 1341 | if (!$contest_started) { |
1342 | 1342 | // not started or do not exist |
1343 | 1343 | return 0; |
@@ -1428,12 +1428,12 @@ discard block |
||
1428 | 1428 | public function updateProfessionalRate($cid) |
1429 | 1429 | { |
1430 | 1430 | $basic=$this->basic($cid); |
1431 | - if($basic["rated"]&&!$basic["is_rated"]){ |
|
1431 | + if ($basic["rated"] && !$basic["is_rated"]) { |
|
1432 | 1432 | $ratingCalculator=new RatingCalculator($cid); |
1433 | - if($ratingCalculator->calculate()){ |
|
1433 | + if ($ratingCalculator->calculate()) { |
|
1434 | 1434 | $ratingCalculator->storage(); |
1435 | 1435 | return true; |
1436 | - }else{ |
|
1436 | + } else { |
|
1437 | 1437 | return false; |
1438 | 1438 | } |
1439 | 1439 | } else { |
@@ -1441,26 +1441,26 @@ discard block |
||
1441 | 1441 | } |
1442 | 1442 | } |
1443 | 1443 | |
1444 | - public function contestUpdate($cid,$data,$problems) |
|
1444 | + public function contestUpdate($cid, $data, $problems) |
|
1445 | 1445 | { |
1446 | - if($problems !== false){ |
|
1447 | - $old_problmes = array_column( |
|
1446 | + if ($problems!==false) { |
|
1447 | + $old_problmes=array_column( |
|
1448 | 1448 | DB::table('contest_problem') |
1449 | - ->where('cid',$cid) |
|
1449 | + ->where('cid', $cid) |
|
1450 | 1450 | ->get()->all(), |
1451 | 1451 | 'pid' |
1452 | 1452 | ); |
1453 | - DB::transaction(function () use ($cid, $data, $problems,$old_problmes) { |
|
1453 | + DB::transaction(function() use ($cid, $data, $problems, $old_problmes) { |
|
1454 | 1454 | DB::table($this->tableName) |
1455 | - ->where('cid',$cid) |
|
1455 | + ->where('cid', $cid) |
|
1456 | 1456 | ->update($data); |
1457 | 1457 | DB::table('contest_problem') |
1458 | - ->where('cid',$cid) |
|
1458 | + ->where('cid', $cid) |
|
1459 | 1459 | ->delete(); |
1460 | - $new_problems = []; |
|
1460 | + $new_problems=[]; |
|
1461 | 1461 | foreach ($problems as $p) { |
1462 | 1462 | $pid=DB::table("problem")->where(["pcode"=>$p["pcode"]])->select("pid")->first()["pid"]; |
1463 | - array_push($new_problems,$pid); |
|
1463 | + array_push($new_problems, $pid); |
|
1464 | 1464 | DB::table("contest_problem")->insert([ |
1465 | 1465 | "cid"=>$cid, |
1466 | 1466 | "number"=>$p["number"], |
@@ -1470,29 +1470,29 @@ discard block |
||
1470 | 1470 | "points"=>$p["points"] |
1471 | 1471 | ]); |
1472 | 1472 | } |
1473 | - foreach($old_problmes as $op) { |
|
1474 | - if(!in_array($op,$new_problems)){ |
|
1473 | + foreach ($old_problmes as $op) { |
|
1474 | + if (!in_array($op, $new_problems)) { |
|
1475 | 1475 | DB::table('submission') |
1476 | - ->where('cid',$cid) |
|
1477 | - ->where('pid',$op) |
|
1476 | + ->where('cid', $cid) |
|
1477 | + ->where('pid', $op) |
|
1478 | 1478 | ->delete(); |
1479 | 1479 | } |
1480 | 1480 | } |
1481 | 1481 | }, 5); |
1482 | - $contestRankRaw = $this->contestRankCache($cid); |
|
1482 | + $contestRankRaw=$this->contestRankCache($cid); |
|
1483 | 1483 | Cache::tags(['contest', 'rank'])->put($cid, $contestRankRaw); |
1484 | 1484 | Cache::tags(['contest', 'rank'])->put("contestAdmin$cid", $contestRankRaw); |
1485 | - }else{ |
|
1485 | + } else { |
|
1486 | 1486 | DB::table($this->tableName) |
1487 | - ->where('cid',$cid) |
|
1487 | + ->where('cid', $cid) |
|
1488 | 1488 | ->update($data); |
1489 | 1489 | } |
1490 | 1490 | } |
1491 | 1491 | |
1492 | - public function contestUpdateProblem($cid,$problems) |
|
1492 | + public function contestUpdateProblem($cid, $problems) |
|
1493 | 1493 | { |
1494 | 1494 | DB::table('contest_problem') |
1495 | - ->where('cid',$cid) |
|
1495 | + ->where('cid', $cid) |
|
1496 | 1496 | ->delete(); |
1497 | 1497 | foreach ($problems as $p) { |
1498 | 1498 | DB::table("contest_problem")->insertGetId([ |
@@ -1508,8 +1508,8 @@ discard block |
||
1508 | 1508 | |
1509 | 1509 | public function arrangeContest($gid, $config, $problems) |
1510 | 1510 | { |
1511 | - $cid = -1; |
|
1512 | - DB::transaction(function () use ($gid, $config, $problems,&$cid) { |
|
1511 | + $cid=-1; |
|
1512 | + DB::transaction(function() use ($gid, $config, $problems, &$cid) { |
|
1513 | 1513 | $cid=DB::table($this->tableName)->insertGetId([ |
1514 | 1514 | "gid"=>$gid, |
1515 | 1515 | "name"=>$config["name"], |
@@ -1523,7 +1523,7 @@ discard block |
||
1523 | 1523 | "rule"=>1, //todo |
1524 | 1524 | "begin_time"=>$config["begin_time"], |
1525 | 1525 | "end_time"=>$config["end_time"], |
1526 | - "vcid"=>isset($config["vcid"])?$config["vcid"]:null, |
|
1526 | + "vcid"=>isset($config["vcid"]) ? $config["vcid"] : null, |
|
1527 | 1527 | "public"=>$config["public"], |
1528 | 1528 | "registration"=>0, //todo |
1529 | 1529 | "registration_due"=>null, //todo |
@@ -1531,7 +1531,7 @@ discard block |
||
1531 | 1531 | "froze_length"=>0, //todo |
1532 | 1532 | "status_visibility"=>2, //todo |
1533 | 1533 | "create_time"=>date("Y-m-d H:i:s"), |
1534 | - "crawled" => isset($config['vcid'])?$config['crawled'] : null, |
|
1534 | + "crawled" => isset($config['vcid']) ? $config['crawled'] : null, |
|
1535 | 1535 | "audit_status"=>$config["public"] ? 0 : 1 |
1536 | 1536 | ]); |
1537 | 1537 | |
@@ -1550,13 +1550,13 @@ discard block |
||
1550 | 1550 | return $cid; |
1551 | 1551 | } |
1552 | 1552 | |
1553 | - public function updateContestRankTable($cid,$sub) |
|
1553 | + public function updateContestRankTable($cid, $sub) |
|
1554 | 1554 | { |
1555 | - $lock = Cache::lock("contestrank$cid",10); |
|
1556 | - try{ |
|
1557 | - if($lock->get()){ |
|
1558 | - if(Cache::tags(['contest','rank'])->get($cid) != null){ |
|
1559 | - $ret = Cache::tags(['contest','rank'])->get($cid); |
|
1555 | + $lock=Cache::lock("contestrank$cid", 10); |
|
1556 | + try { |
|
1557 | + if ($lock->get()) { |
|
1558 | + if (Cache::tags(['contest', 'rank'])->get($cid)!=null) { |
|
1559 | + $ret=Cache::tags(['contest', 'rank'])->get($cid); |
|
1560 | 1560 | $chache=[]; |
1561 | 1561 | $chache['contest_info']=DB::table("contest")->where("cid", $cid)->first(); |
1562 | 1562 | $chache['problemSet']=DB::table("contest_problem")->join("problem", "contest_problem.pid", "=", "problem.pid")->where([ |
@@ -1565,27 +1565,27 @@ discard block |
||
1565 | 1565 | $chache['frozen_time']=DB::table("contest")->where(["cid"=>$cid])->select(DB::raw("UNIX_TIMESTAMP(end_time)-froze_length as frozen_time"))->first()["frozen_time"]; |
1566 | 1566 | $chache['end_time']=strtotime(DB::table("contest")->where(["cid"=>$cid])->select("end_time")->first()["end_time"]); |
1567 | 1567 | |
1568 | - $id = 0; |
|
1568 | + $id=0; |
|
1569 | 1569 | |
1570 | - foreach($chache['problemSet'] as $key => $p){ |
|
1571 | - if ($p['pid'] == $sub['pid']){ |
|
1572 | - $chache['problemSet'][$key]['cpid'] = $key; |
|
1573 | - $id = $key; |
|
1570 | + foreach ($chache['problemSet'] as $key => $p) { |
|
1571 | + if ($p['pid']==$sub['pid']) { |
|
1572 | + $chache['problemSet'][$key]['cpid']=$key; |
|
1573 | + $id=$key; |
|
1574 | 1574 | } |
1575 | 1575 | } |
1576 | 1576 | |
1577 | - $ret = $this->updateContestRankDetail($chache['contest_info'],$chache['problemSet'][$id],$cid,$sub['uid'],$ret); |
|
1578 | - $ret = $this->sortContestRankTable($chache['contest_info'],$cid,$ret); |
|
1577 | + $ret=$this->updateContestRankDetail($chache['contest_info'], $chache['problemSet'][$id], $cid, $sub['uid'], $ret); |
|
1578 | + $ret=$this->sortContestRankTable($chache['contest_info'], $cid, $ret); |
|
1579 | 1579 | |
1580 | - if (time() < $chache['frozen_time']){ |
|
1580 | + if (time()<$chache['frozen_time']) { |
|
1581 | 1581 | Cache::tags(['contest', 'rank'])->put($cid, $ret); |
1582 | 1582 | } |
1583 | 1583 | Cache::tags(['contest', 'rank'])->put("contestAdmin$cid", $ret); |
1584 | - if(time() > $chache['end_time']){ |
|
1584 | + if (time()>$chache['end_time']) { |
|
1585 | 1585 | $this->storeContestRankInMySQL($cid, $ret); |
1586 | 1586 | } |
1587 | 1587 | } |
1588 | - else{ |
|
1588 | + else { |
|
1589 | 1589 | $ret=[]; |
1590 | 1590 | $chache=[]; |
1591 | 1591 | $chache['contest_info']=DB::table("contest")->where("cid", $cid)->first(); |
@@ -1600,7 +1600,7 @@ discard block |
||
1600 | 1600 | "cid"=>$cid, |
1601 | 1601 | "audit"=>1 |
1602 | 1602 | ])->select('uid')->get()->all(); |
1603 | - }else{ |
|
1603 | + } else { |
|
1604 | 1604 | $submissionUsers=DB::table("submission")->where([ |
1605 | 1605 | "cid"=>$cid |
1606 | 1606 | ])->where( |
@@ -1613,39 +1613,39 @@ discard block |
||
1613 | 1613 | ])->select('uid')->groupBy('uid')->get()->all(); |
1614 | 1614 | } |
1615 | 1615 | |
1616 | - $chacheAdmin = $chache; |
|
1616 | + $chacheAdmin=$chache; |
|
1617 | 1617 | |
1618 | 1618 | foreach ($submissionUsers as $s) { |
1619 | 1619 | foreach ($chache['problemSet'] as $key => $p) { |
1620 | - $p['cpid'] = $key; |
|
1621 | - $ret = $this->updateContestRankDetail($chache['contest_info'],$p,$cid,$s['uid'],$ret); |
|
1620 | + $p['cpid']=$key; |
|
1621 | + $ret=$this->updateContestRankDetail($chache['contest_info'], $p, $cid, $s['uid'], $ret); |
|
1622 | 1622 | } |
1623 | 1623 | } |
1624 | - $ret = $this->sortContestRankTable($chache['contest_info'],$cid,$ret); |
|
1624 | + $ret=$this->sortContestRankTable($chache['contest_info'], $cid, $ret); |
|
1625 | 1625 | Cache::tags(['contest', 'rank'])->put($cid, $ret); |
1626 | 1626 | |
1627 | 1627 | $retAdmin=[]; |
1628 | 1628 | foreach ($submissionUsersAdmin as $s) { |
1629 | 1629 | foreach ($chacheAdmin['problemSet'] as $key => $p) { |
1630 | - $p['cpid'] = $key; |
|
1631 | - $retAdmin = $this->updateContestRankDetail($chacheAdmin['contest_info'],$p,$cid,$s['uid'],$retAdmin); |
|
1630 | + $p['cpid']=$key; |
|
1631 | + $retAdmin=$this->updateContestRankDetail($chacheAdmin['contest_info'], $p, $cid, $s['uid'], $retAdmin); |
|
1632 | 1632 | } |
1633 | 1633 | } |
1634 | - $retAdmin = $this->sortContestRankTable($chacheAdmin['contest_info'],$cid,$retAdmin); |
|
1634 | + $retAdmin=$this->sortContestRankTable($chacheAdmin['contest_info'], $cid, $retAdmin); |
|
1635 | 1635 | Cache::tags(['contest', 'rank'])->put("contestAdmin$cid", $retAdmin); |
1636 | 1636 | } |
1637 | 1637 | } |
1638 | - }catch(LockTimeoutException $e){ |
|
1638 | + } catch (LockTimeoutException $e) { |
|
1639 | 1639 | Log::warning("Contest Rank Lock Timed Out"); |
1640 | - }finally{ |
|
1640 | + } finally { |
|
1641 | 1641 | optional($lock)->release(); |
1642 | 1642 | } |
1643 | 1643 | } |
1644 | 1644 | |
1645 | - public function sortContestRankTable($contest_info,$cid,$ret) |
|
1645 | + public function sortContestRankTable($contest_info, $cid, $ret) |
|
1646 | 1646 | { |
1647 | - if ($contest_info["rule"]==1){ |
|
1648 | - usort($ret, function ($a, $b) { |
|
1647 | + if ($contest_info["rule"]==1) { |
|
1648 | + usort($ret, function($a, $b) { |
|
1649 | 1649 | if ($a["score"]==$b["score"]) { |
1650 | 1650 | if ($a["penalty"]==$b["penalty"]) { |
1651 | 1651 | return 0; |
@@ -1660,8 +1660,8 @@ discard block |
||
1660 | 1660 | return 1; |
1661 | 1661 | } |
1662 | 1662 | }); |
1663 | - }else if ($contest_info["rule"]==2){ |
|
1664 | - usort($ret, function ($a, $b) { |
|
1663 | + } else if ($contest_info["rule"]==2) { |
|
1664 | + usort($ret, function($a, $b) { |
|
1665 | 1665 | if ($a["score"]==$b["score"]) { |
1666 | 1666 | if ($a["solved"]==$b["solved"]) { |
1667 | 1667 | return 0; |
@@ -1680,21 +1680,21 @@ discard block |
||
1680 | 1680 | return $ret; |
1681 | 1681 | } |
1682 | 1682 | |
1683 | - public function updateContestRankDetail($contest_info,$problem,$cid,$uid,$ret) |
|
1683 | + public function updateContestRankDetail($contest_info, $problem, $cid, $uid, $ret) |
|
1684 | 1684 | { |
1685 | - $id = count($ret); |
|
1686 | - foreach($ret as $key => $r){ |
|
1687 | - if($r['uid'] == $uid) |
|
1688 | - $id = $key; |
|
1685 | + $id=count($ret); |
|
1686 | + foreach ($ret as $key => $r) { |
|
1687 | + if ($r['uid']==$uid) |
|
1688 | + $id=$key; |
|
1689 | 1689 | } |
1690 | 1690 | if ($contest_info["rule"]==1) { |
1691 | 1691 | // ACM/ICPC Mode |
1692 | - if($id == count($ret)){ |
|
1693 | - $prob_detail = []; |
|
1694 | - $totPen = 0; |
|
1695 | - $totScore = 0; |
|
1696 | - }else{ |
|
1697 | - $prob_detail = $ret[$id]['problem_detail']; |
|
1692 | + if ($id==count($ret)) { |
|
1693 | + $prob_detail=[]; |
|
1694 | + $totPen=0; |
|
1695 | + $totScore=0; |
|
1696 | + } else { |
|
1697 | + $prob_detail=$ret[$id]['problem_detail']; |
|
1698 | 1698 | $totPen=$ret[$id]['penalty']; |
1699 | 1699 | $totScore=$ret[$id]['score']; |
1700 | 1700 | }; |
@@ -1712,7 +1712,7 @@ discard block |
||
1712 | 1712 | "uid"=>$uid, |
1713 | 1713 | ])->orderBy('submission_date', 'desc')->first(); |
1714 | 1714 | |
1715 | - if ($ac_times<=1 && isset($last_record) && $last_record['verdict']!="Waiting" && $last_record['verdict']!="Submission Error" && $last_record['verdict']!="System Error"){ |
|
1715 | + if ($ac_times<=1 && isset($last_record) && $last_record['verdict']!="Waiting" && $last_record['verdict']!="Submission Error" && $last_record['verdict']!="System Error") { |
|
1716 | 1716 | $prob_stat=$this->contestProblemInfoACM($cid, $problem["pid"], $uid); |
1717 | 1717 | |
1718 | 1718 | $prob_detail[$problem['cpid']]=[ |
@@ -1744,12 +1744,12 @@ discard block |
||
1744 | 1744 | } |
1745 | 1745 | } elseif ($contest_info["rule"]==2) { |
1746 | 1746 | // IOI Mode |
1747 | - if($id == count($ret)){ |
|
1748 | - $prob_detail = []; |
|
1749 | - $totSolved = 0; |
|
1750 | - $totScore = 0; |
|
1751 | - }else{ |
|
1752 | - $prob_detail = $ret[$id]['problem_detail']; |
|
1747 | + if ($id==count($ret)) { |
|
1748 | + $prob_detail=[]; |
|
1749 | + $totSolved=0; |
|
1750 | + $totScore=0; |
|
1751 | + } else { |
|
1752 | + $prob_detail=$ret[$id]['problem_detail']; |
|
1753 | 1753 | $totSolved=$ret[$id]['solved']; |
1754 | 1754 | $totScore=$ret[$id]['score']; |
1755 | 1755 | }; |
@@ -1782,47 +1782,47 @@ discard block |
||
1782 | 1782 | return $ret; |
1783 | 1783 | } |
1784 | 1784 | |
1785 | - public function assignMember($cid,$uid){ |
|
1785 | + public function assignMember($cid, $uid) { |
|
1786 | 1786 | return DB::table("contest")->where(["cid"=>$cid])->update([ |
1787 | 1787 | "assign_uid"=>$uid |
1788 | 1788 | ]); |
1789 | 1789 | } |
1790 | 1790 | |
1791 | - public function canUpdateContestTime($cid,$time = []) |
|
1791 | + public function canUpdateContestTime($cid, $time=[]) |
|
1792 | 1792 | { |
1793 | - $begin_time_new = $time['begin'] ?? null; |
|
1794 | - $end_time_new = $time['end'] ?? null; |
|
1793 | + $begin_time_new=$time['begin'] ?? null; |
|
1794 | + $end_time_new=$time['end'] ?? null; |
|
1795 | 1795 | |
1796 | - $hold_time = DB::table('contest') |
|
1797 | - ->where('cid',$cid) |
|
1798 | - ->select('begin_time','end_time') |
|
1796 | + $hold_time=DB::table('contest') |
|
1797 | + ->where('cid', $cid) |
|
1798 | + ->select('begin_time', 'end_time') |
|
1799 | 1799 | ->first(); |
1800 | - $begin_stamps = strtotime($hold_time['begin_time']); |
|
1801 | - $end_stamps = strtotime($hold_time['end_time']); |
|
1800 | + $begin_stamps=strtotime($hold_time['begin_time']); |
|
1801 | + $end_stamps=strtotime($hold_time['end_time']); |
|
1802 | 1802 | /* |
1803 | 1803 | -1 : have not begun |
1804 | 1804 | 0 : ing |
1805 | 1805 | 1 : end |
1806 | 1806 | */ |
1807 | - $status = time() >= $end_stamps ? 1 |
|
1808 | - : (time() <= $begin_stamps ? -1 : 0); |
|
1809 | - if($status === -1){ |
|
1810 | - if(time() > $begin_time_new){ |
|
1807 | + $status=time()>=$end_stamps ? 1 |
|
1808 | + : (time()<=$begin_stamps ? -1 : 0); |
|
1809 | + if ($status===-1) { |
|
1810 | + if (time()>$begin_time_new) { |
|
1811 | 1811 | return false; |
1812 | 1812 | } |
1813 | 1813 | return true; |
1814 | - }else if($status === 0){ |
|
1815 | - if($begin_time_new !== null){ |
|
1814 | + } else if ($status===0) { |
|
1815 | + if ($begin_time_new!==null) { |
|
1816 | 1816 | return false; |
1817 | 1817 | } |
1818 | - if($end_time_new !== null){ |
|
1819 | - if(strtotime($end_time_new) <= time()){ |
|
1818 | + if ($end_time_new!==null) { |
|
1819 | + if (strtotime($end_time_new)<=time()) { |
|
1820 | 1820 | return false; |
1821 | - }else{ |
|
1821 | + } else { |
|
1822 | 1822 | return true; |
1823 | 1823 | } |
1824 | 1824 | } |
1825 | - }else{ |
|
1825 | + } else { |
|
1826 | 1826 | return false; |
1827 | 1827 | } |
1828 | 1828 | |
@@ -1831,22 +1831,22 @@ discard block |
||
1831 | 1831 | |
1832 | 1832 | public function replyClarification($ccid, $content) |
1833 | 1833 | { |
1834 | - return DB::table("contest_clarification")->where('ccid','=',$ccid)->update([ |
|
1834 | + return DB::table("contest_clarification")->where('ccid', '=', $ccid)->update([ |
|
1835 | 1835 | "reply"=>$content |
1836 | 1836 | ]); |
1837 | 1837 | } |
1838 | 1838 | |
1839 | 1839 | public function setClarificationPublic($ccid, $public) |
1840 | 1840 | { |
1841 | - if($public) |
|
1841 | + if ($public) |
|
1842 | 1842 | { |
1843 | - return DB::table("contest_clarification")->where('ccid','=',$ccid)->update([ |
|
1843 | + return DB::table("contest_clarification")->where('ccid', '=', $ccid)->update([ |
|
1844 | 1844 | "public"=>1 |
1845 | 1845 | ]); |
1846 | 1846 | } |
1847 | 1847 | else |
1848 | 1848 | { |
1849 | - return DB::table("contest_clarification")->where('ccid','=',$ccid)->update([ |
|
1849 | + return DB::table("contest_clarification")->where('ccid', '=', $ccid)->update([ |
|
1850 | 1850 | "public"=>0 |
1851 | 1851 | ]); |
1852 | 1852 | } |
@@ -1859,90 +1859,90 @@ discard block |
||
1859 | 1859 | |
1860 | 1860 | public function praticeAnalysis($cid) |
1861 | 1861 | { |
1862 | - $gid = DB::table('contest') |
|
1863 | - ->where('cid',$cid) |
|
1862 | + $gid=DB::table('contest') |
|
1863 | + ->where('cid', $cid) |
|
1864 | 1864 | ->first()['gid']; |
1865 | - $contestRank = $this->contestRank($cid,Auth::user()->id); |
|
1866 | - if(!empty($contestRank)){ |
|
1867 | - $all_problems = DB::table('problem') |
|
1868 | - ->whereIn('pid',array_column($contestRank[0]['problem_detail'],'pid')) |
|
1869 | - ->select('pid','title') |
|
1865 | + $contestRank=$this->contestRank($cid, Auth::user()->id); |
|
1866 | + if (!empty($contestRank)) { |
|
1867 | + $all_problems=DB::table('problem') |
|
1868 | + ->whereIn('pid', array_column($contestRank[0]['problem_detail'], 'pid')) |
|
1869 | + ->select('pid', 'title') |
|
1870 | 1870 | ->get()->all(); |
1871 | - }else{ |
|
1872 | - $all_problems = []; |
|
1871 | + } else { |
|
1872 | + $all_problems=[]; |
|
1873 | 1873 | } |
1874 | - $tags = DB::table('group_problem_tag') |
|
1874 | + $tags=DB::table('group_problem_tag') |
|
1875 | 1875 | ->where('gid', $gid) |
1876 | - ->whereIn('pid', array_column($all_problems,'pid')) |
|
1876 | + ->whereIn('pid', array_column($all_problems, 'pid')) |
|
1877 | 1877 | ->get()->all(); |
1878 | - $all_tags = array_unique(array_column($tags,'tag')); |
|
1879 | - $memberData = []; |
|
1880 | - foreach($contestRank as $member){ |
|
1881 | - $m = [ |
|
1878 | + $all_tags=array_unique(array_column($tags, 'tag')); |
|
1879 | + $memberData=[]; |
|
1880 | + foreach ($contestRank as $member) { |
|
1881 | + $m=[ |
|
1882 | 1882 | 'uid' => $member['uid'], |
1883 | 1883 | 'name' => $member['name'], |
1884 | 1884 | 'nick_name' => $member['nick_name'], |
1885 | 1885 | ]; |
1886 | - $completion = []; |
|
1887 | - foreach ($all_tags as $tag){ |
|
1888 | - $completion[$tag] = []; |
|
1886 | + $completion=[]; |
|
1887 | + foreach ($all_tags as $tag) { |
|
1888 | + $completion[$tag]=[]; |
|
1889 | 1889 | foreach ($tags as $t) { |
1890 | - if($t['tag'] == $tag){ |
|
1890 | + if ($t['tag']==$tag) { |
|
1891 | 1891 | foreach ($member['problem_detail'] as $pd) { |
1892 | - if($pd['pid'] == $t['pid']){ |
|
1893 | - $completion[$tag][$t['pid']] = $pd['solved_time_parsed'] == "" ? 0 : 1; |
|
1892 | + if ($pd['pid']==$t['pid']) { |
|
1893 | + $completion[$tag][$t['pid']]=$pd['solved_time_parsed']=="" ? 0 : 1; |
|
1894 | 1894 | } |
1895 | 1895 | } |
1896 | 1896 | } |
1897 | 1897 | } |
1898 | 1898 | } |
1899 | - $m['completion'] = $completion; |
|
1900 | - $memberData[] = $m; |
|
1899 | + $m['completion']=$completion; |
|
1900 | + $memberData[]=$m; |
|
1901 | 1901 | } |
1902 | 1902 | return $memberData; |
1903 | 1903 | } |
1904 | 1904 | |
1905 | 1905 | public function storeContestRankInMySQL($cid, $data) |
1906 | 1906 | { |
1907 | - $contestRankJson = json_encode($data); |
|
1908 | - return DB::table('contest')->where('cid','=',$cid)->update([ |
|
1907 | + $contestRankJson=json_encode($data); |
|
1908 | + return DB::table('contest')->where('cid', '=', $cid)->update([ |
|
1909 | 1909 | 'rank' => $contestRankJson |
1910 | 1910 | ]); |
1911 | 1911 | } |
1912 | 1912 | |
1913 | 1913 | public function getContestRankFromMySQL($cid) |
1914 | 1914 | { |
1915 | - $contestRankJson = DB::table('contest')->where('cid','=',$cid)->pluck('rank')->first(); |
|
1916 | - $data = json_decode($contestRankJson, true); |
|
1915 | + $contestRankJson=DB::table('contest')->where('cid', '=', $cid)->pluck('rank')->first(); |
|
1916 | + $data=json_decode($contestRankJson, true); |
|
1917 | 1917 | return $data; |
1918 | 1918 | } |
1919 | 1919 | |
1920 | 1920 | public function isVerified($cid) |
1921 | 1921 | { |
1922 | - return DB::table('contest')->where('cid','=',$cid)->pluck('verified')->first(); |
|
1922 | + return DB::table('contest')->where('cid', '=', $cid)->pluck('verified')->first(); |
|
1923 | 1923 | } |
1924 | 1924 | |
1925 | 1925 | public function getScrollBoardData($cid) |
1926 | 1926 | { |
1927 | - $members = DB::table("submission") |
|
1928 | - ->join('users','users.id','=','submission.uid') |
|
1927 | + $members=DB::table("submission") |
|
1928 | + ->join('users', 'users.id', '=', 'submission.uid') |
|
1929 | 1929 | ->join('contest', 'contest.cid', '=', 'submission.cid') |
1930 | 1930 | ->join('group_member', 'users.id', '=', 'group_member.uid') |
1931 | - ->where('submission.cid', $cid)->select('users.id as uid','users.name as name','group_member.nick_name as nick_name') |
|
1931 | + ->where('submission.cid', $cid)->select('users.id as uid', 'users.name as name', 'group_member.nick_name as nick_name') |
|
1932 | 1932 | ->groupBy('uid')->get()->all(); |
1933 | - $submissions = DB::table("submission") |
|
1933 | + $submissions=DB::table("submission") |
|
1934 | 1934 | ->where('cid', $cid) |
1935 | 1935 | ->select('sid', 'verdict', 'submission_date', 'pid', 'uid') |
1936 | 1936 | ->orderBy('submission_date') |
1937 | 1937 | ->get()->all(); |
1938 | - $problems = DB::table('contest_problem') |
|
1938 | + $problems=DB::table('contest_problem') |
|
1939 | 1939 | ->where('cid', $cid) |
1940 | - ->select('ncode','pid') |
|
1940 | + ->select('ncode', 'pid') |
|
1941 | 1941 | ->orderBy('ncode') |
1942 | 1942 | ->get()->all(); |
1943 | - $contest = DB::table('contest') |
|
1944 | - ->where('cid',$cid) |
|
1945 | - ->select('begin_time','end_time','froze_length') |
|
1943 | + $contest=DB::table('contest') |
|
1944 | + ->where('cid', $cid) |
|
1945 | + ->select('begin_time', 'end_time', 'froze_length') |
|
1946 | 1946 | ->first(); |
1947 | 1947 | return [ |
1948 | 1948 | 'members' => $members, |
@@ -1954,16 +1954,16 @@ discard block |
||
1954 | 1954 | |
1955 | 1955 | public function judgeOver($cid) |
1956 | 1956 | { |
1957 | - $submissions = DB::table('submission') |
|
1957 | + $submissions=DB::table('submission') |
|
1958 | 1958 | ->where(['cid' => $cid]) |
1959 | - ->whereIn('verdict',['Waiting','Pending']) |
|
1959 | + ->whereIn('verdict', ['Waiting', 'Pending']) |
|
1960 | 1960 | ->select('sid') |
1961 | 1961 | ->get()->all(); |
1962 | - if(empty($submissions)){ |
|
1962 | + if (empty($submissions)) { |
|
1963 | 1963 | return [ |
1964 | 1964 | 'result' => true |
1965 | 1965 | ]; |
1966 | - }else{ |
|
1966 | + } else { |
|
1967 | 1967 | return [ |
1968 | 1968 | 'result' => false, |
1969 | 1969 | 'sid' => $submissions |
@@ -227,7 +227,7 @@ discard block |
||
227 | 227 | $paginator=$paginator->where(["practice"=>$filter['practice']]); |
228 | 228 | } |
229 | 229 | $paginator = $paginator ->paginate(10); |
230 | - }elseif($filter['public']=='0'){ |
|
230 | + } elseif($filter['public']=='0'){ |
|
231 | 231 | $paginator=DB::table('group_member') |
232 | 232 | ->groupBy('contest.cid') |
233 | 233 | ->select('contest.*') |
@@ -257,7 +257,7 @@ discard block |
||
257 | 257 | ) |
258 | 258 | ->orderBy('contest.begin_time', 'desc') |
259 | 259 | ->paginate(10); |
260 | - }else{ |
|
260 | + } else{ |
|
261 | 261 | $paginator=DB::table('group_member') |
262 | 262 | ->groupBy('contest.cid') |
263 | 263 | ->select('contest.*') |
@@ -809,13 +809,13 @@ discard block |
||
809 | 809 | if(time() < $end_time){ |
810 | 810 | if($clearance == 3){ |
811 | 811 | $contestRankRaw=Cache::tags(['contest', 'rank'])->get("contestAdmin$cid"); |
812 | - }else{ |
|
812 | + } else{ |
|
813 | 813 | $contestRankRaw=Cache::tags(['contest', 'rank'])->get($cid); |
814 | 814 | } |
815 | 815 | if(!isset($contestRankRaw)){ |
816 | 816 | $contestRankRaw=$contest_eloquent->rankRefresh(); |
817 | 817 | } |
818 | - }else{ |
|
818 | + } else{ |
|
819 | 819 | if($clearance == 3){ |
820 | 820 | $contestRankRaw=Cache::tags(['contest', 'rank'])->get("contestAdmin$cid"); |
821 | 821 | if (!isset($contestRankRaw)) { |
@@ -825,7 +825,7 @@ discard block |
||
825 | 825 | $this->storeContestRankInMySQL($cid, $contestRankRaw); |
826 | 826 | } |
827 | 827 | } |
828 | - }else{ |
|
828 | + } else{ |
|
829 | 829 | $contestRankRaw=$this->getContestRankFromMySQL($cid); |
830 | 830 | if(!isset($contestRankRaw)){ |
831 | 831 | $contestRankRaw=Cache::tags(['contest', 'rank'])->get($cid); |
@@ -910,7 +910,7 @@ discard block |
||
910 | 910 | return DB::table("contest_clarification")->where([ |
911 | 911 | "cid"=>$cid |
912 | 912 | ])->orderBy('create_time', 'desc')->get()->all(); |
913 | - }else{ |
|
913 | + } else{ |
|
914 | 914 | return DB::table("contest_clarification")->where([ |
915 | 915 | "cid"=>$cid |
916 | 916 | ])->where(function ($query) { |
@@ -1075,7 +1075,7 @@ discard block |
||
1075 | 1075 | $filter['pid'] = array_search($filter['ncode'], array_column($problemSet_temp, 'ncode')); |
1076 | 1076 | if($filter['pid']==false){ |
1077 | 1077 | $filter['pid'] = null; |
1078 | - }else{ |
|
1078 | + } else{ |
|
1079 | 1079 | $filter['pid'] = $problemSet_temp[$filter['pid']]['pid']; |
1080 | 1080 | } |
1081 | 1081 | |
@@ -1183,7 +1183,7 @@ discard block |
||
1183 | 1183 | "records"=>[] |
1184 | 1184 | ]; |
1185 | 1185 | } |
1186 | - }else{ |
|
1186 | + } else{ |
|
1187 | 1187 | if ($basicInfo["status_visibility"]==2) { |
1188 | 1188 | // View all |
1189 | 1189 | $paginator=DB::table("submission")->where([ |
@@ -1433,7 +1433,7 @@ discard block |
||
1433 | 1433 | if($ratingCalculator->calculate()){ |
1434 | 1434 | $ratingCalculator->storage(); |
1435 | 1435 | return true; |
1436 | - }else{ |
|
1436 | + } else{ |
|
1437 | 1437 | return false; |
1438 | 1438 | } |
1439 | 1439 | } else { |
@@ -1482,7 +1482,7 @@ discard block |
||
1482 | 1482 | $contestRankRaw = $this->contestRankCache($cid); |
1483 | 1483 | Cache::tags(['contest', 'rank'])->put($cid, $contestRankRaw); |
1484 | 1484 | Cache::tags(['contest', 'rank'])->put("contestAdmin$cid", $contestRankRaw); |
1485 | - }else{ |
|
1485 | + } else{ |
|
1486 | 1486 | DB::table($this->tableName) |
1487 | 1487 | ->where('cid',$cid) |
1488 | 1488 | ->update($data); |
@@ -1584,8 +1584,7 @@ discard block |
||
1584 | 1584 | if(time() > $chache['end_time']){ |
1585 | 1585 | $this->storeContestRankInMySQL($cid, $ret); |
1586 | 1586 | } |
1587 | - } |
|
1588 | - else{ |
|
1587 | + } else{ |
|
1589 | 1588 | $ret=[]; |
1590 | 1589 | $chache=[]; |
1591 | 1590 | $chache['contest_info']=DB::table("contest")->where("cid", $cid)->first(); |
@@ -1600,7 +1599,7 @@ discard block |
||
1600 | 1599 | "cid"=>$cid, |
1601 | 1600 | "audit"=>1 |
1602 | 1601 | ])->select('uid')->get()->all(); |
1603 | - }else{ |
|
1602 | + } else{ |
|
1604 | 1603 | $submissionUsers=DB::table("submission")->where([ |
1605 | 1604 | "cid"=>$cid |
1606 | 1605 | ])->where( |
@@ -1635,9 +1634,9 @@ discard block |
||
1635 | 1634 | Cache::tags(['contest', 'rank'])->put("contestAdmin$cid", $retAdmin); |
1636 | 1635 | } |
1637 | 1636 | } |
1638 | - }catch(LockTimeoutException $e){ |
|
1637 | + } catch(LockTimeoutException $e){ |
|
1639 | 1638 | Log::warning("Contest Rank Lock Timed Out"); |
1640 | - }finally{ |
|
1639 | + } finally{ |
|
1641 | 1640 | optional($lock)->release(); |
1642 | 1641 | } |
1643 | 1642 | } |
@@ -1660,7 +1659,7 @@ discard block |
||
1660 | 1659 | return 1; |
1661 | 1660 | } |
1662 | 1661 | }); |
1663 | - }else if ($contest_info["rule"]==2){ |
|
1662 | + } else if ($contest_info["rule"]==2){ |
|
1664 | 1663 | usort($ret, function ($a, $b) { |
1665 | 1664 | if ($a["score"]==$b["score"]) { |
1666 | 1665 | if ($a["solved"]==$b["solved"]) { |
@@ -1684,8 +1683,9 @@ discard block |
||
1684 | 1683 | { |
1685 | 1684 | $id = count($ret); |
1686 | 1685 | foreach($ret as $key => $r){ |
1687 | - if($r['uid'] == $uid) |
|
1688 | - $id = $key; |
|
1686 | + if($r['uid'] == $uid) { |
|
1687 | + $id = $key; |
|
1688 | + } |
|
1689 | 1689 | } |
1690 | 1690 | if ($contest_info["rule"]==1) { |
1691 | 1691 | // ACM/ICPC Mode |
@@ -1693,7 +1693,7 @@ discard block |
||
1693 | 1693 | $prob_detail = []; |
1694 | 1694 | $totPen = 0; |
1695 | 1695 | $totScore = 0; |
1696 | - }else{ |
|
1696 | + } else{ |
|
1697 | 1697 | $prob_detail = $ret[$id]['problem_detail']; |
1698 | 1698 | $totPen=$ret[$id]['penalty']; |
1699 | 1699 | $totScore=$ret[$id]['score']; |
@@ -1748,7 +1748,7 @@ discard block |
||
1748 | 1748 | $prob_detail = []; |
1749 | 1749 | $totSolved = 0; |
1750 | 1750 | $totScore = 0; |
1751 | - }else{ |
|
1751 | + } else{ |
|
1752 | 1752 | $prob_detail = $ret[$id]['problem_detail']; |
1753 | 1753 | $totSolved=$ret[$id]['solved']; |
1754 | 1754 | $totScore=$ret[$id]['score']; |
@@ -1811,18 +1811,18 @@ discard block |
||
1811 | 1811 | return false; |
1812 | 1812 | } |
1813 | 1813 | return true; |
1814 | - }else if($status === 0){ |
|
1814 | + } else if($status === 0){ |
|
1815 | 1815 | if($begin_time_new !== null){ |
1816 | 1816 | return false; |
1817 | 1817 | } |
1818 | 1818 | if($end_time_new !== null){ |
1819 | 1819 | if(strtotime($end_time_new) <= time()){ |
1820 | 1820 | return false; |
1821 | - }else{ |
|
1821 | + } else{ |
|
1822 | 1822 | return true; |
1823 | 1823 | } |
1824 | 1824 | } |
1825 | - }else{ |
|
1825 | + } else{ |
|
1826 | 1826 | return false; |
1827 | 1827 | } |
1828 | 1828 | |
@@ -1843,8 +1843,7 @@ discard block |
||
1843 | 1843 | return DB::table("contest_clarification")->where('ccid','=',$ccid)->update([ |
1844 | 1844 | "public"=>1 |
1845 | 1845 | ]); |
1846 | - } |
|
1847 | - else |
|
1846 | + } else |
|
1848 | 1847 | { |
1849 | 1848 | return DB::table("contest_clarification")->where('ccid','=',$ccid)->update([ |
1850 | 1849 | "public"=>0 |
@@ -1868,7 +1867,7 @@ discard block |
||
1868 | 1867 | ->whereIn('pid',array_column($contestRank[0]['problem_detail'],'pid')) |
1869 | 1868 | ->select('pid','title') |
1870 | 1869 | ->get()->all(); |
1871 | - }else{ |
|
1870 | + } else{ |
|
1872 | 1871 | $all_problems = []; |
1873 | 1872 | } |
1874 | 1873 | $tags = DB::table('group_problem_tag') |
@@ -1963,7 +1962,7 @@ discard block |
||
1963 | 1962 | return [ |
1964 | 1963 | 'result' => true |
1965 | 1964 | ]; |
1966 | - }else{ |
|
1965 | + } else{ |
|
1967 | 1966 | return [ |
1968 | 1967 | 'result' => false, |
1969 | 1968 | 'sid' => $submissions |