1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace App\Http\Controllers\Contest; |
4
|
|
|
|
5
|
|
|
use App\Models\ContestModel; |
6
|
|
|
use App\Models\ProblemModel; |
7
|
|
|
use App\Models\CompilerModel; |
8
|
|
|
use App\Models\SubmissionModel; |
9
|
|
|
use App\Models\AccountModel; |
10
|
|
|
use App\Http\Controllers\Controller; |
11
|
|
|
use Illuminate\Http\Request; |
12
|
|
|
use Auth; |
13
|
|
|
use Redirect; |
14
|
|
|
|
15
|
|
|
class BoardController extends Controller |
16
|
|
|
{ |
17
|
|
|
/** |
18
|
|
|
* Redirect the Contest Board Page. |
19
|
|
|
* |
20
|
|
|
* @return Response |
|
|
|
|
21
|
|
|
*/ |
22
|
|
|
public function board($cid) |
23
|
|
|
{ |
24
|
|
|
return Redirect::route('contest.challenge', ['cid' => $cid]); |
|
|
|
|
25
|
|
|
} |
26
|
|
|
|
27
|
|
|
/** |
28
|
|
|
* Show the Contest Challenge Page. |
29
|
|
|
* |
30
|
|
|
* @return Response |
31
|
|
|
*/ |
32
|
|
|
public function challenge($cid) |
33
|
|
|
{ |
34
|
|
|
$contestModel=new ContestModel(); |
35
|
|
|
$clearance=$contestModel->judgeClearance($cid, Auth::user()->id); |
36
|
|
|
if (!$clearance) { |
37
|
|
|
return Redirect::route('contest.detail', ['cid' => $cid]); |
|
|
|
|
38
|
|
|
} |
39
|
|
|
$contest_name=$contestModel->contestName($cid); |
40
|
|
|
$contest_rule=$contestModel->contestRule($cid); |
41
|
|
|
$problemSet=$contestModel->contestProblems($cid, Auth::user()->id); |
42
|
|
|
$remainingTime=$contestModel->remainingTime($cid); |
43
|
|
|
$customInfo=$contestModel->getCustomInfo($cid); |
44
|
|
|
$clarificationList=$contestModel->getLatestClarification($cid); |
45
|
|
|
$basicInfo=$contestModel->basic($cid); |
46
|
|
|
if ($remainingTime<=0) { |
47
|
|
|
$remainingTime=0; |
48
|
|
|
} |
49
|
|
|
return view('contest.board.challenge', [ |
|
|
|
|
50
|
|
|
'page_title'=>"Challenge", |
51
|
|
|
'navigation' => "Contest", |
52
|
|
|
'site_title'=>$contest_name, |
53
|
|
|
'cid'=>$cid, |
54
|
|
|
'contest_name'=>$contest_name, |
55
|
|
|
'contest_rule'=>$contest_rule, |
56
|
|
|
'problem_set'=> $problemSet, |
57
|
|
|
'remaining_time'=>$remainingTime, |
58
|
|
|
'custom_info' => $customInfo, |
59
|
|
|
'clarification_list' => $clarificationList, |
60
|
|
|
'clearance'=> $clearance, |
61
|
|
|
'basic'=>$basicInfo, |
62
|
|
|
]); |
63
|
|
|
} |
64
|
|
|
|
65
|
|
|
/** |
66
|
|
|
* Show the Contest Editor Page. |
67
|
|
|
* |
68
|
|
|
* @return Response |
69
|
|
|
*/ |
70
|
|
|
public function editor($cid, $ncode) |
71
|
|
|
{ |
72
|
|
|
$contestModel=new ContestModel(); |
73
|
|
|
$problemModel=new ProblemModel(); |
74
|
|
|
$compilerModel=new CompilerModel(); |
75
|
|
|
$submissionModel=new SubmissionModel(); |
76
|
|
|
$accountModel=new AccountModel(); |
77
|
|
|
$clearance=$contestModel->judgeClearance($cid, Auth::user()->id); |
78
|
|
|
if (!$clearance) { |
79
|
|
|
return Redirect::route('contest.detail', ['cid' => $cid]); |
|
|
|
|
80
|
|
|
} |
81
|
|
|
$contest_name=$contestModel->contestName($cid); |
82
|
|
|
$contest_rule=$contestModel->rule($cid); |
83
|
|
|
$contest_ended=$contestModel->isContestEnded($cid); |
84
|
|
|
$pid=$contestModel->getPid($cid, $ncode); |
85
|
|
|
if (empty($pid)) { |
86
|
|
|
return Redirect::route('contest.board', ['cid' => $cid]); |
|
|
|
|
87
|
|
|
} |
88
|
|
|
$pcode=$problemModel->pcode($pid); |
89
|
|
|
|
90
|
|
|
$prob_detail=$problemModel->detail($pcode, $cid); |
91
|
|
|
if ($problemModel->isBlocked($prob_detail["pid"], $cid)) { |
92
|
|
|
return abort('403'); |
|
|
|
|
93
|
|
|
} |
94
|
|
|
$compiler_list=$compilerModel->list($prob_detail["OJ"], $prob_detail["pid"]); |
95
|
|
|
$prob_status=$submissionModel->getProblemStatus($prob_detail["pid"], Auth::user()->id, $cid); |
96
|
|
|
$problemSet=$contestModel->contestProblems($cid, Auth::user()->id); |
97
|
|
|
$compiler_pref=$compilerModel->pref($compiler_list, $prob_detail["pid"], Auth::user()->id, $cid); |
98
|
|
|
$pref=$compiler_pref["pref"]; |
99
|
|
|
$submit_code=$compiler_pref["code"]; |
100
|
|
|
$oj_detail=$problemModel->ojdetail($prob_detail["OJ"]); |
101
|
|
|
|
102
|
|
|
if (empty($prob_status)) { |
103
|
|
|
$prob_status=[ |
104
|
|
|
"verdict"=>"NOT SUBMIT", |
105
|
|
|
"color"=>"" |
106
|
|
|
]; |
107
|
|
|
} |
108
|
|
|
|
109
|
|
|
$editor_left_width = $accountModel->getExtra(Auth::user()->id, 'editor_left_width'); |
110
|
|
|
if(empty($editor_left_width)) $editor_left_width='40'; |
111
|
|
|
|
112
|
|
|
return view('contest.board.editor', [ |
|
|
|
|
113
|
|
|
'page_title'=>"Problem Detail", |
114
|
|
|
'navigation' => "Contest", |
115
|
|
|
'site_title'=>$contest_name, |
116
|
|
|
'contest_name'=>$contest_name, |
117
|
|
|
'cid'=> $cid, |
118
|
|
|
'detail' => $prob_detail, |
119
|
|
|
'compiler_list' => $compiler_list, |
120
|
|
|
'status' => $prob_status, |
121
|
|
|
'pref' => $pref<0 ? 0 : $pref, |
122
|
|
|
'submit_code' => $submit_code, |
123
|
|
|
'contest_mode' => true, |
124
|
|
|
'contest_ended' => $contest_ended, |
125
|
|
|
'ncode' => $ncode, |
126
|
|
|
'contest_rule' => $contest_rule, |
127
|
|
|
'problem_set' => $problemSet, |
128
|
|
|
'clearance' => $clearance, |
129
|
|
|
'oj_detail' => $oj_detail, |
130
|
|
|
'editor_left_width'=>$editor_left_width, |
131
|
|
|
]); |
132
|
|
|
} |
133
|
|
|
|
134
|
|
|
/** |
135
|
|
|
* Show the Contest Rank Page. |
136
|
|
|
* |
137
|
|
|
* @return Response |
138
|
|
|
*/ |
139
|
|
|
public function rank($cid) |
140
|
|
|
{ |
141
|
|
|
$contestModel=new ContestModel(); |
142
|
|
|
$clearance=$contestModel->judgeClearance($cid, Auth::user()->id); |
143
|
|
|
if (!$clearance) { |
144
|
|
|
return Redirect::route('contest.detail', ['cid' => $cid]); |
|
|
|
|
145
|
|
|
} |
146
|
|
|
$contest_name=$contestModel->contestName($cid); |
147
|
|
|
$contest_rule=$contestModel->contestRule($cid); |
148
|
|
|
$problemSet=$contestModel->contestProblems($cid, Auth::user()->id); |
149
|
|
|
$customInfo=$contestModel->getCustomInfo($cid); |
150
|
|
|
$contestRank=$contestModel->contestRank($cid, Auth::user()->id); |
151
|
|
|
$rankFrozen=$contestModel->isFrozen($cid); |
152
|
|
|
$frozenTime=$contestModel->frozenTime($cid); |
153
|
|
|
$basicInfo=$contestModel->basic($cid); |
154
|
|
|
return view('contest.board.rank', [ |
|
|
|
|
155
|
|
|
'page_title'=>"Rank", |
156
|
|
|
'navigation' => "Contest", |
157
|
|
|
'site_title'=>$contest_name, |
158
|
|
|
'contest_name'=>$contest_name, |
159
|
|
|
'contest_rule'=>$contest_rule, |
160
|
|
|
'cid'=>$cid, |
161
|
|
|
'problem_set'=>$problemSet, |
162
|
|
|
'custom_info' => $customInfo, |
163
|
|
|
'contest_rank' => $contestRank, |
164
|
|
|
'rank_frozen' => $rankFrozen, |
165
|
|
|
'frozen_time' => $frozenTime, |
166
|
|
|
'clearance'=> $clearance, |
167
|
|
|
'basic'=>$basicInfo, |
168
|
|
|
]); |
169
|
|
|
} |
170
|
|
|
|
171
|
|
|
/** |
172
|
|
|
* Show the Contest Status Page. |
173
|
|
|
* |
174
|
|
|
* @return Response |
175
|
|
|
*/ |
176
|
|
|
public function status(Request $request) |
177
|
|
|
{ |
178
|
|
|
$all_data=$request->all(); |
179
|
|
|
$filter["ncode"]=isset($all_data["ncode"]) ? $all_data["ncode"] : null; |
|
|
|
|
180
|
|
|
$filter["result"]=isset($all_data["result"]) ? $all_data["result"] : null; |
181
|
|
|
$filter["account"]=isset($all_data["account"]) ? $all_data["account"] : null; |
182
|
|
|
$cid=$request->cid; |
183
|
|
|
$contestModel=new ContestModel(); |
184
|
|
|
$clearance=$contestModel->judgeClearance($cid, Auth::user()->id); |
185
|
|
|
if (!$clearance) { |
186
|
|
|
return Redirect::route('contest.detail', ['cid' => $cid]); |
|
|
|
|
187
|
|
|
} |
188
|
|
|
$contest_name=$contestModel->contestName($cid); |
189
|
|
|
$customInfo=$contestModel->getCustomInfo($cid); |
190
|
|
|
$basicInfo=$contestModel->basic($cid); |
191
|
|
|
$submissionRecordSet=$contestModel->getContestRecord($filter, $cid); |
192
|
|
|
$rankFrozen=$contestModel->isFrozen($cid); |
193
|
|
|
$frozenTime=$contestModel->frozenTime($cid); |
194
|
|
|
return view('contest.board.status', [ |
|
|
|
|
195
|
|
|
'page_title'=>"Status", |
196
|
|
|
'navigation' => "Contest", |
197
|
|
|
'site_title'=>$contest_name, |
198
|
|
|
'contest_name'=>$contest_name, |
199
|
|
|
'basic_info'=>$basicInfo, |
200
|
|
|
'cid'=>$cid, |
201
|
|
|
'custom_info' => $customInfo, |
202
|
|
|
'submission_record' => $submissionRecordSet, |
203
|
|
|
'rank_frozen' => $rankFrozen, |
204
|
|
|
'frozen_time' => $frozenTime, |
205
|
|
|
'clearance'=> $clearance, |
206
|
|
|
'filter' => $filter, |
207
|
|
|
]); |
208
|
|
|
} |
209
|
|
|
|
210
|
|
|
/** |
211
|
|
|
* Show the Contest Clarification Page. |
212
|
|
|
* |
213
|
|
|
* @return Response |
214
|
|
|
*/ |
215
|
|
|
public function clarification($cid) |
216
|
|
|
{ |
217
|
|
|
$contestModel=new ContestModel(); |
218
|
|
|
$clearance=$contestModel->judgeClearance($cid, Auth::user()->id); |
219
|
|
|
if (!$clearance) { |
220
|
|
|
return Redirect::route('contest.detail', ['cid' => $cid]); |
|
|
|
|
221
|
|
|
} |
222
|
|
|
$basicInfo=$contestModel->basic($cid); |
223
|
|
|
$contest_name=$contestModel->contestName($cid); |
224
|
|
|
$customInfo=$contestModel->getCustomInfo($cid); |
225
|
|
|
$clarificationList=$contestModel->getClarificationList($cid); |
226
|
|
|
$contest_ended=$contestModel->isContestEnded($cid); |
227
|
|
|
return view('contest.board.clarification', [ |
|
|
|
|
228
|
|
|
'page_title'=>"Clarification", |
229
|
|
|
'navigation' => "Contest", |
230
|
|
|
'site_title'=>$contest_name, |
231
|
|
|
'contest_name'=>$contest_name, |
232
|
|
|
'cid'=>$cid, |
233
|
|
|
'custom_info' => $customInfo, |
234
|
|
|
'clarification_list' => $clarificationList, |
235
|
|
|
'contest_ended' => $contest_ended, |
236
|
|
|
'clearance'=> $clearance, |
237
|
|
|
'basic'=>$basicInfo, |
238
|
|
|
]); |
239
|
|
|
} |
240
|
|
|
|
241
|
|
|
/** |
242
|
|
|
* Show the Contest Print Page. |
243
|
|
|
* |
244
|
|
|
* @return Response |
245
|
|
|
*/ |
246
|
|
|
public function print($cid) |
247
|
|
|
{ |
248
|
|
|
$contestModel=new ContestModel(); |
249
|
|
|
$clearance=$contestModel->judgeClearance($cid, Auth::user()->id); |
250
|
|
|
if (!$clearance) { |
251
|
|
|
return Redirect::route('contest.detail', ['cid' => $cid]); |
|
|
|
|
252
|
|
|
} |
253
|
|
|
$basicInfo=$contestModel->basic($cid); |
254
|
|
|
$contest_name=$contestModel->contestName($cid); |
255
|
|
|
$customInfo=$contestModel->getCustomInfo($cid); |
256
|
|
|
return view('contest.board.print', [ |
|
|
|
|
257
|
|
|
'page_title'=>"Print", |
258
|
|
|
'navigation' => "Contest", |
259
|
|
|
'site_title'=>$contest_name, |
260
|
|
|
'contest_name'=>$contest_name, |
261
|
|
|
'cid'=>$cid, |
262
|
|
|
'custom_info' => $customInfo, |
263
|
|
|
'clearance'=> $clearance, |
264
|
|
|
'basic'=>$basicInfo, |
265
|
|
|
]); |
266
|
|
|
} |
267
|
|
|
|
268
|
|
|
public function analysis($cid){ |
269
|
|
|
$contestModel=new ContestModel(); |
270
|
|
|
$clearance=$contestModel->judgeClearance($cid, Auth::user()->id); |
271
|
|
|
if (!$clearance) { |
272
|
|
|
return Redirect::route('contest.detail', ['cid' => $cid]); |
273
|
|
|
} |
274
|
|
|
$contest_name=$contestModel->contestName($cid); |
275
|
|
|
$customInfo=$contestModel->getCustomInfo($cid); |
276
|
|
|
$basicInfo=$contestModel->basic($cid); |
277
|
|
|
return view('contest.board.analysis', [ |
278
|
|
|
'page_title'=>"Analysis", |
279
|
|
|
'navigation' => "Contest", |
280
|
|
|
'site_title'=>$contest_name, |
281
|
|
|
'contest_name'=>$contest_name, |
282
|
|
|
'cid'=>$cid, |
283
|
|
|
'custom_info' => $customInfo, |
284
|
|
|
'clearance'=> $clearance, |
285
|
|
|
'basic'=>$basicInfo, |
286
|
|
|
]); |
287
|
|
|
} |
288
|
|
|
} |
289
|
|
|
|