@@ -15,24 +15,24 @@ |
||
15 | 15 | $request->validate([ |
16 | 16 | 'uid' => 'required|integer' |
17 | 17 | ]); |
18 | - $uid = $request->input('uid'); |
|
19 | - if(!Auth::check() || Auth::user()->id != $uid){ |
|
18 | + $uid=$request->input('uid'); |
|
19 | + if (!Auth::check() || Auth::user()->id!=$uid) { |
|
20 | 20 | return ResponseModel::err(2001); |
21 | 21 | } |
22 | - $ret = MessageModel::unread($uid); |
|
23 | - return ResponseModel::success(200,null,$ret); |
|
22 | + $ret=MessageModel::unread($uid); |
|
23 | + return ResponseModel::success(200, null, $ret); |
|
24 | 24 | } |
25 | 25 | |
26 | 26 | public function allRead() |
27 | 27 | { |
28 | - $uid = Auth::user()->id; |
|
28 | + $uid=Auth::user()->id; |
|
29 | 29 | MessageModel::allRead($uid); |
30 | 30 | return ResponseModel::success(200); |
31 | 31 | } |
32 | 32 | |
33 | 33 | public function deleteAll() |
34 | 34 | { |
35 | - $uid = Auth::user()->id; |
|
35 | + $uid=Auth::user()->id; |
|
36 | 36 | MessageModel::removeAllRead($uid); |
37 | 37 | return ResponseModel::success(200); |
38 | 38 | } |
@@ -110,8 +110,8 @@ discard block |
||
110 | 110 | if (empty($basic)) { |
111 | 111 | return ResponseModel::err(3001); |
112 | 112 | } |
113 | - $ret=$problemModel->addSolution($pid,Auth::user()->id,$content); |
|
114 | - return $ret?ResponseModel::success(200):ResponseModel::err(3003); |
|
113 | + $ret=$problemModel->addSolution($pid, Auth::user()->id, $content); |
|
114 | + return $ret ?ResponseModel::success(200) : ResponseModel::err(3003); |
|
115 | 115 | } |
116 | 116 | /** |
117 | 117 | * The Ajax Problem Solution Discussion Update. |
@@ -126,8 +126,8 @@ discard block |
||
126 | 126 | $problemModel=new ProblemModel(); |
127 | 127 | $psoid=$all_data["psoid"]; |
128 | 128 | $content=$all_data["content"]; |
129 | - $ret=$problemModel->updateSolution($psoid,Auth::user()->id,$content); |
|
130 | - return $ret?ResponseModel::success(200):ResponseModel::err(3004); |
|
129 | + $ret=$problemModel->updateSolution($psoid, Auth::user()->id, $content); |
|
130 | + return $ret ?ResponseModel::success(200) : ResponseModel::err(3004); |
|
131 | 131 | } |
132 | 132 | /** |
133 | 133 | * The Ajax Problem Solution Discussion Delete. |
@@ -141,8 +141,8 @@ discard block |
||
141 | 141 | $all_data=$request->all(); |
142 | 142 | $problemModel=new ProblemModel(); |
143 | 143 | $psoid=$all_data["psoid"]; |
144 | - $ret=$problemModel->removeSolution($psoid,Auth::user()->id); |
|
145 | - return $ret?ResponseModel::success(200):ResponseModel::err(3004); |
|
144 | + $ret=$problemModel->removeSolution($psoid, Auth::user()->id); |
|
145 | + return $ret ?ResponseModel::success(200) : ResponseModel::err(3004); |
|
146 | 146 | } |
147 | 147 | /** |
148 | 148 | * The Ajax Problem Solution Discussion Vote. |
@@ -157,8 +157,8 @@ discard block |
||
157 | 157 | $problemModel=new ProblemModel(); |
158 | 158 | $psoid=$all_data["psoid"]; |
159 | 159 | $type=$all_data["type"]; |
160 | - $ret=$problemModel->voteSolution($psoid,Auth::user()->id,$type); |
|
161 | - return $ret["ret"]?ResponseModel::success(200,null,["votes"=>$ret["votes"],"select"=>$ret["select"]]):ResponseModel::err(3004); |
|
160 | + $ret=$problemModel->voteSolution($psoid, Auth::user()->id, $type); |
|
161 | + return $ret["ret"] ?ResponseModel::success(200, null, ["votes"=>$ret["votes"], "select"=>$ret["select"]]) : ResponseModel::err(3004); |
|
162 | 162 | } |
163 | 163 | /** |
164 | 164 | * The Ajax Problem Solution Submit. |
@@ -252,8 +252,8 @@ discard block |
||
252 | 252 | if (empty($basic)) { |
253 | 253 | return ResponseModel::err(3001); |
254 | 254 | } |
255 | - $ret=$problemModel->addDiscussion(Auth::user()->id,$pid,$title,$content); |
|
256 | - return $ret?ResponseModel::success(200, null, $ret):ResponseModel::err(3003); |
|
255 | + $ret=$problemModel->addDiscussion(Auth::user()->id, $pid, $title, $content); |
|
256 | + return $ret ?ResponseModel::success(200, null, $ret) : ResponseModel::err(3003); |
|
257 | 257 | } |
258 | 258 | |
259 | 259 | public function addComment(Request $request) |
@@ -272,8 +272,8 @@ discard block |
||
272 | 272 | if (empty($basic)) { |
273 | 273 | return ResponseModel::err(3001); |
274 | 274 | } |
275 | - $ret=$problemModel->addComment(Auth::user()->id,$pdid,$content,$reply_id); |
|
276 | - return $ret?ResponseModel::success(200, null, $ret):ResponseModel::err(3003); |
|
275 | + $ret=$problemModel->addComment(Auth::user()->id, $pdid, $content, $reply_id); |
|
276 | + return $ret ?ResponseModel::success(200, null, $ret) : ResponseModel::err(3003); |
|
277 | 277 | } |
278 | 278 | |
279 | 279 | /** |
@@ -292,15 +292,15 @@ discard block |
||
292 | 292 | |
293 | 293 | $submissionData=$submissionModel->basic($all_data["sid"]); |
294 | 294 | |
295 | - if($submissionData["uid"]!=Auth::user()->id){ |
|
295 | + if ($submissionData["uid"]!=Auth::user()->id) { |
|
296 | 296 | return ResponseModel::err(2001); |
297 | 297 | } |
298 | 298 | |
299 | - if($submissionData["verdict"]!="Submission Error"){ |
|
299 | + if ($submissionData["verdict"]!="Submission Error") { |
|
300 | 300 | return ResponseModel::err(6003); |
301 | 301 | } |
302 | 302 | |
303 | - $submissionModel->updateSubmission($all_data["sid"],[ |
|
303 | + $submissionModel->updateSubmission($all_data["sid"], [ |
|
304 | 304 | "verdict"=>"Pending", |
305 | 305 | "time"=>0, |
306 | 306 | "memory"=>0 |
@@ -132,7 +132,7 @@ discard block |
||
132 | 132 | { |
133 | 133 | $extensionList=ExtensionModel::list(); |
134 | 134 | |
135 | - if(empty($extensionList)){ |
|
135 | + if (empty($extensionList)) { |
|
136 | 136 | return view('admin::babel.empty'); |
137 | 137 | } |
138 | 138 | |
@@ -145,7 +145,7 @@ discard block |
||
145 | 145 | { |
146 | 146 | $details=ExtensionModel::remoteDetail($code); |
147 | 147 | |
148 | - if(empty($details)){ |
|
148 | + if (empty($details)) { |
|
149 | 149 | return view('admin::babel.empty'); |
150 | 150 | } |
151 | 151 | |
@@ -158,7 +158,7 @@ discard block |
||
158 | 158 | { |
159 | 159 | $details=ExtensionModel::remoteDetail($extension); |
160 | 160 | |
161 | - if(empty($details)){ |
|
161 | + if (empty($details)) { |
|
162 | 162 | return view('admin::babel.empty'); |
163 | 163 | } |
164 | 164 | |
@@ -169,15 +169,15 @@ discard block |
||
169 | 169 | |
170 | 170 | private static function executeArtisan($command) |
171 | 171 | { |
172 | - $fp = popen('php "'.base_path('artisan').'" '.$command, "r"); |
|
173 | - while($b = fgets($fp, 2048)) { |
|
172 | + $fp=popen('php "'.base_path('artisan').'" '.$command, "r"); |
|
173 | + while ($b=fgets($fp, 2048)) { |
|
174 | 174 | echo str_pad(json_encode([ |
175 | 175 | "ret"=>200, |
176 | 176 | "desc"=>"Succeed", |
177 | 177 | "data"=>[ |
178 | 178 | "message"=>$b |
179 | 179 | ] |
180 | - ])."\n",4096); |
|
180 | + ])."\n", 4096); |
|
181 | 181 | @ob_flush(); |
182 | 182 | flush(); |
183 | 183 | } |
@@ -34,10 +34,10 @@ discard block |
||
34 | 34 | $contestModel=new ContestModel(); |
35 | 35 | $clearance=$contestModel->judgeClearance($cid, Auth::user()->id); |
36 | 36 | $basicInfo=$contestModel->basic($cid); |
37 | - if (!$clearance || time() < strtotime($basicInfo['begin_time'])) { |
|
38 | - if($clearance == 3){ |
|
37 | + if (!$clearance || time()<strtotime($basicInfo['begin_time'])) { |
|
38 | + if ($clearance==3) { |
|
39 | 39 | return Redirect::route('contest.admin', ['cid' => $cid]); |
40 | - }else{ |
|
40 | + } else { |
|
41 | 41 | return Redirect::route('contest.detail', ['cid' => $cid]); |
42 | 42 | } |
43 | 43 | } |
@@ -50,7 +50,7 @@ discard block |
||
50 | 50 | if ($remainingTime<=0) { |
51 | 51 | $remainingTime=0; |
52 | 52 | } |
53 | - if($basicInfo['public'] && !$basicInfo['audit_status']){ |
|
53 | + if ($basicInfo['public'] && !$basicInfo['audit_status']) { |
|
54 | 54 | return Redirect::route('contest.detail', ['cid' => $cid]); |
55 | 55 | } |
56 | 56 | return view('contest.board.challenge', [ |
@@ -83,15 +83,15 @@ discard block |
||
83 | 83 | $accountModel=new AccountModel(); |
84 | 84 | $clearance=$contestModel->judgeClearance($cid, Auth::user()->id); |
85 | 85 | $basicInfo=$contestModel->basic($cid); |
86 | - if (!$clearance || time() < strtotime($basicInfo['begin_time'])) { |
|
87 | - if($clearance == 3){ |
|
86 | + if (!$clearance || time()<strtotime($basicInfo['begin_time'])) { |
|
87 | + if ($clearance==3) { |
|
88 | 88 | return Redirect::route('contest.admin', ['cid' => $cid]); |
89 | - }else{ |
|
89 | + } else { |
|
90 | 90 | return Redirect::route('contest.detail', ['cid' => $cid]); |
91 | 91 | } |
92 | 92 | } |
93 | 93 | $basicInfo=$contestModel->basic($cid); |
94 | - if($basicInfo['public'] && !$basicInfo['audit_status']){ |
|
94 | + if ($basicInfo['public'] && !$basicInfo['audit_status']) { |
|
95 | 95 | return Redirect::route('contest.detail', ['cid' => $cid]); |
96 | 96 | } |
97 | 97 | $contest_name=$contestModel->contestName($cid); |
@@ -122,8 +122,8 @@ discard block |
||
122 | 122 | ]; |
123 | 123 | } |
124 | 124 | |
125 | - $editor_left_width = $accountModel->getExtra(Auth::user()->id, 'editor_left_width'); |
|
126 | - if(empty($editor_left_width)) $editor_left_width='40'; |
|
125 | + $editor_left_width=$accountModel->getExtra(Auth::user()->id, 'editor_left_width'); |
|
126 | + if (empty($editor_left_width)) $editor_left_width='40'; |
|
127 | 127 | |
128 | 128 | return view('contest.board.editor', [ |
129 | 129 | 'page_title'=>"Problem Detail", |
@@ -157,15 +157,15 @@ discard block |
||
157 | 157 | $contestModel=new ContestModel(); |
158 | 158 | $clearance=$contestModel->judgeClearance($cid, Auth::user()->id); |
159 | 159 | $basicInfo=$contestModel->basic($cid); |
160 | - if (!$clearance || time() < strtotime($basicInfo['begin_time'])) { |
|
161 | - if($clearance == 3){ |
|
160 | + if (!$clearance || time()<strtotime($basicInfo['begin_time'])) { |
|
161 | + if ($clearance==3) { |
|
162 | 162 | return Redirect::route('contest.admin', ['cid' => $cid]); |
163 | - }else{ |
|
163 | + } else { |
|
164 | 164 | return Redirect::route('contest.detail', ['cid' => $cid]); |
165 | 165 | } |
166 | 166 | } |
167 | 167 | $basicInfo=$contestModel->basic($cid); |
168 | - if($basicInfo['public'] && !$basicInfo['audit_status']){ |
|
168 | + if ($basicInfo['public'] && !$basicInfo['audit_status']) { |
|
169 | 169 | return Redirect::route('contest.detail', ['cid' => $cid]); |
170 | 170 | } |
171 | 171 | $contest_name=$contestModel->contestName($cid); |
@@ -176,14 +176,14 @@ discard block |
||
176 | 176 | |
177 | 177 | // To determine the ranking |
178 | 178 | foreach ($contestRank as $i => &$r) { |
179 | - if($i != 0) { |
|
180 | - if($r['score'] == $contestRank[$i-1]['score'] && ($contest_rule == 1 ? ($r['penalty'] == $contestRank[$i-1]['penalty']) : 1) ){ |
|
181 | - $r['rank'] = $contestRank[$i-1]['rank']; |
|
182 | - }else{ |
|
183 | - $r['rank'] = $i + 1; |
|
179 | + if ($i!=0) { |
|
180 | + if ($r['score']==$contestRank[$i-1]['score'] && ($contest_rule==1 ? ($r['penalty']==$contestRank[$i-1]['penalty']) : 1)) { |
|
181 | + $r['rank']=$contestRank[$i-1]['rank']; |
|
182 | + } else { |
|
183 | + $r['rank']=$i+1; |
|
184 | 184 | } |
185 | - }else{ |
|
186 | - $r['rank'] = 1; |
|
185 | + } else { |
|
186 | + $r['rank']=1; |
|
187 | 187 | } |
188 | 188 | } |
189 | 189 | $rankFrozen=$contestModel->isFrozen($cid); |
@@ -220,15 +220,15 @@ discard block |
||
220 | 220 | $contestModel=new ContestModel(); |
221 | 221 | $clearance=$contestModel->judgeClearance($cid, Auth::user()->id); |
222 | 222 | $basicInfo=$contestModel->basic($cid); |
223 | - if (!$clearance || time() < strtotime($basicInfo['begin_time'])) { |
|
224 | - if($clearance == 3){ |
|
223 | + if (!$clearance || time()<strtotime($basicInfo['begin_time'])) { |
|
224 | + if ($clearance==3) { |
|
225 | 225 | return Redirect::route('contest.admin', ['cid' => $cid]); |
226 | - }else{ |
|
226 | + } else { |
|
227 | 227 | return Redirect::route('contest.detail', ['cid' => $cid]); |
228 | 228 | } |
229 | 229 | } |
230 | 230 | $basicInfo=$contestModel->basic($cid); |
231 | - if($basicInfo['public'] && !$basicInfo['audit_status']){ |
|
231 | + if ($basicInfo['public'] && !$basicInfo['audit_status']) { |
|
232 | 232 | return Redirect::route('contest.detail', ['cid' => $cid]); |
233 | 233 | } |
234 | 234 | $contest_name=$contestModel->contestName($cid); |
@@ -262,14 +262,14 @@ discard block |
||
262 | 262 | $contestModel=new ContestModel(); |
263 | 263 | $clearance=$contestModel->judgeClearance($cid, Auth::user()->id); |
264 | 264 | $basicInfo=$contestModel->basic($cid); |
265 | - if (!$clearance || time() < strtotime($basicInfo['begin_time'])) { |
|
266 | - if($clearance == 3){ |
|
265 | + if (!$clearance || time()<strtotime($basicInfo['begin_time'])) { |
|
266 | + if ($clearance==3) { |
|
267 | 267 | return Redirect::route('contest.admin', ['cid' => $cid]); |
268 | - }else{ |
|
268 | + } else { |
|
269 | 269 | return Redirect::route('contest.detail', ['cid' => $cid]); |
270 | 270 | } |
271 | 271 | } |
272 | - if($basicInfo['public'] && !$basicInfo['audit_status']){ |
|
272 | + if ($basicInfo['public'] && !$basicInfo['audit_status']) { |
|
273 | 273 | return Redirect::route('contest.detail', ['cid' => $cid]); |
274 | 274 | } |
275 | 275 | $contest_name=$contestModel->contestName($cid); |
@@ -300,14 +300,14 @@ discard block |
||
300 | 300 | $contestModel=new ContestModel(); |
301 | 301 | $clearance=$contestModel->judgeClearance($cid, Auth::user()->id); |
302 | 302 | $basicInfo=$contestModel->basic($cid); |
303 | - if (!$clearance || time() < strtotime($basicInfo['begin_time'])) { |
|
304 | - if($clearance == 3){ |
|
303 | + if (!$clearance || time()<strtotime($basicInfo['begin_time'])) { |
|
304 | + if ($clearance==3) { |
|
305 | 305 | return Redirect::route('contest.admin', ['cid' => $cid]); |
306 | - }else{ |
|
306 | + } else { |
|
307 | 307 | return Redirect::route('contest.detail', ['cid' => $cid]); |
308 | 308 | } |
309 | 309 | } |
310 | - if($basicInfo['public'] && !$basicInfo['audit_status']){ |
|
310 | + if ($basicInfo['public'] && !$basicInfo['audit_status']) { |
|
311 | 311 | return Redirect::route('contest.detail', ['cid' => $cid]); |
312 | 312 | } |
313 | 313 | $contest_name=$contestModel->contestName($cid); |
@@ -324,19 +324,19 @@ discard block |
||
324 | 324 | ]); |
325 | 325 | } |
326 | 326 | |
327 | - public function analysis($cid){ |
|
327 | + public function analysis($cid) { |
|
328 | 328 | $contestModel=new ContestModel(); |
329 | 329 | $clearance=$contestModel->judgeClearance($cid, Auth::user()->id); |
330 | 330 | $basicInfo=$contestModel->basic($cid); |
331 | - if (!$clearance || time() < strtotime($basicInfo['begin_time'])) { |
|
332 | - if($clearance == 3){ |
|
331 | + if (!$clearance || time()<strtotime($basicInfo['begin_time'])) { |
|
332 | + if ($clearance==3) { |
|
333 | 333 | return Redirect::route('contest.admin', ['cid' => $cid]); |
334 | - }else{ |
|
334 | + } else { |
|
335 | 335 | return Redirect::route('contest.detail', ['cid' => $cid]); |
336 | 336 | } |
337 | 337 | } |
338 | 338 | $basicInfo=$contestModel->basic($cid); |
339 | - if($basicInfo['public'] && !$basicInfo['audit_status']){ |
|
339 | + if ($basicInfo['public'] && !$basicInfo['audit_status']) { |
|
340 | 340 | return Redirect::route('contest.detail', ['cid' => $cid]); |
341 | 341 | } |
342 | 342 | $contest_name=$contestModel->contestName($cid); |
@@ -37,7 +37,7 @@ discard block |
||
37 | 37 | if (!$clearance || time() < strtotime($basicInfo['begin_time'])) { |
38 | 38 | if($clearance == 3){ |
39 | 39 | return Redirect::route('contest.admin', ['cid' => $cid]); |
40 | - }else{ |
|
40 | + } else{ |
|
41 | 41 | return Redirect::route('contest.detail', ['cid' => $cid]); |
42 | 42 | } |
43 | 43 | } |
@@ -86,7 +86,7 @@ discard block |
||
86 | 86 | if (!$clearance || time() < strtotime($basicInfo['begin_time'])) { |
87 | 87 | if($clearance == 3){ |
88 | 88 | return Redirect::route('contest.admin', ['cid' => $cid]); |
89 | - }else{ |
|
89 | + } else{ |
|
90 | 90 | return Redirect::route('contest.detail', ['cid' => $cid]); |
91 | 91 | } |
92 | 92 | } |
@@ -123,7 +123,9 @@ discard block |
||
123 | 123 | } |
124 | 124 | |
125 | 125 | $editor_left_width = $accountModel->getExtra(Auth::user()->id, 'editor_left_width'); |
126 | - if(empty($editor_left_width)) $editor_left_width='40'; |
|
126 | + if(empty($editor_left_width)) { |
|
127 | + $editor_left_width='40'; |
|
128 | + } |
|
127 | 129 | |
128 | 130 | return view('contest.board.editor', [ |
129 | 131 | 'page_title'=>"Problem Detail", |
@@ -160,7 +162,7 @@ discard block |
||
160 | 162 | if (!$clearance || time() < strtotime($basicInfo['begin_time'])) { |
161 | 163 | if($clearance == 3){ |
162 | 164 | return Redirect::route('contest.admin', ['cid' => $cid]); |
163 | - }else{ |
|
165 | + } else{ |
|
164 | 166 | return Redirect::route('contest.detail', ['cid' => $cid]); |
165 | 167 | } |
166 | 168 | } |
@@ -179,10 +181,10 @@ discard block |
||
179 | 181 | if($i != 0) { |
180 | 182 | if($r['score'] == $contestRank[$i-1]['score'] && ($contest_rule == 1 ? ($r['penalty'] == $contestRank[$i-1]['penalty']) : 1) ){ |
181 | 183 | $r['rank'] = $contestRank[$i-1]['rank']; |
182 | - }else{ |
|
184 | + } else{ |
|
183 | 185 | $r['rank'] = $i + 1; |
184 | 186 | } |
185 | - }else{ |
|
187 | + } else{ |
|
186 | 188 | $r['rank'] = 1; |
187 | 189 | } |
188 | 190 | } |
@@ -223,7 +225,7 @@ discard block |
||
223 | 225 | if (!$clearance || time() < strtotime($basicInfo['begin_time'])) { |
224 | 226 | if($clearance == 3){ |
225 | 227 | return Redirect::route('contest.admin', ['cid' => $cid]); |
226 | - }else{ |
|
228 | + } else{ |
|
227 | 229 | return Redirect::route('contest.detail', ['cid' => $cid]); |
228 | 230 | } |
229 | 231 | } |
@@ -265,7 +267,7 @@ discard block |
||
265 | 267 | if (!$clearance || time() < strtotime($basicInfo['begin_time'])) { |
266 | 268 | if($clearance == 3){ |
267 | 269 | return Redirect::route('contest.admin', ['cid' => $cid]); |
268 | - }else{ |
|
270 | + } else{ |
|
269 | 271 | return Redirect::route('contest.detail', ['cid' => $cid]); |
270 | 272 | } |
271 | 273 | } |
@@ -303,7 +305,7 @@ discard block |
||
303 | 305 | if (!$clearance || time() < strtotime($basicInfo['begin_time'])) { |
304 | 306 | if($clearance == 3){ |
305 | 307 | return Redirect::route('contest.admin', ['cid' => $cid]); |
306 | - }else{ |
|
308 | + } else{ |
|
307 | 309 | return Redirect::route('contest.detail', ['cid' => $cid]); |
308 | 310 | } |
309 | 311 | } |
@@ -331,7 +333,7 @@ discard block |
||
331 | 333 | if (!$clearance || time() < strtotime($basicInfo['begin_time'])) { |
332 | 334 | if($clearance == 3){ |
333 | 335 | return Redirect::route('contest.admin', ['cid' => $cid]); |
334 | - }else{ |
|
336 | + } else{ |
|
335 | 337 | return Redirect::route('contest.detail', ['cid' => $cid]); |
336 | 338 | } |
337 | 339 | } |
@@ -371,7 +371,7 @@ discard block |
||
371 | 371 | ->where(['verdict'=>'Waiting']) |
372 | 372 | ->get() |
373 | 373 | ->all(); |
374 | - foreach($ret as &$r){ |
|
374 | + foreach ($ret as &$r) { |
|
375 | 375 | $r["ocode"]=DB::table("oj")->where(["oid"=>$r["oid"]])->first()["ocode"]; |
376 | 376 | } |
377 | 377 | return $ret; |
@@ -389,14 +389,14 @@ discard block |
||
389 | 389 | if (isset($sub['verdict'])) { |
390 | 390 | $sub["color"]=$this->colorScheme[$sub['verdict']]; |
391 | 391 | } |
392 | - $result = DB::table($this->tableName)->where(['sid'=>$sid])->update($sub); |
|
393 | - $contestModel = new ContestModel(); |
|
394 | - $submission_info = DB::table($this->tableName) -> where(['sid'=>$sid]) -> get() -> first(); |
|
395 | - if ($result==1 && $submission_info['cid'] && $contestModel->isContestRunning($submission_info['cid'])){ |
|
396 | - $sub['pid'] = $submission_info['pid']; |
|
397 | - $sub['uid'] = $submission_info['uid']; |
|
398 | - $sub['cid'] = $submission_info['cid']; |
|
399 | - $sub['sid'] = $sid; |
|
392 | + $result=DB::table($this->tableName)->where(['sid'=>$sid])->update($sub); |
|
393 | + $contestModel=new ContestModel(); |
|
394 | + $submission_info=DB::table($this->tableName) -> where(['sid'=>$sid]) -> get() -> first(); |
|
395 | + if ($result==1 && $submission_info['cid'] && $contestModel->isContestRunning($submission_info['cid'])) { |
|
396 | + $sub['pid']=$submission_info['pid']; |
|
397 | + $sub['uid']=$submission_info['uid']; |
|
398 | + $sub['cid']=$submission_info['cid']; |
|
399 | + $sub['sid']=$sid; |
|
400 | 400 | // $contestModel->updateContestRankTable($submission_info['cid'],$sub); |
401 | 401 | } |
402 | 402 | return $result; |
@@ -468,15 +468,15 @@ discard block |
||
468 | 468 | 'desc' |
469 | 469 | ); |
470 | 470 | |
471 | - if($filter["pcode"]){ |
|
471 | + if ($filter["pcode"]) { |
|
472 | 472 | $paginator=$paginator->where(["pcode"=>$filter["pcode"]]); |
473 | 473 | } |
474 | 474 | |
475 | - if($filter["result"]){ |
|
475 | + if ($filter["result"]) { |
|
476 | 476 | $paginator=$paginator->where(["verdict"=>$filter["result"]]); |
477 | 477 | } |
478 | 478 | |
479 | - if($filter["account"]){ |
|
479 | + if ($filter["account"]) { |
|
480 | 480 | $paginator=$paginator->where(["name"=>$filter["account"]]); |
481 | 481 | } |
482 | 482 |
@@ -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', [ |