Passed
Pull Request — master (#570)
by
unknown
10:34
created
app/Http/Controllers/Api/ContestController.php 2 patches
Spacing   +133 added lines, -133 removed lines patch added patch discarded remove patch
@@ -11,7 +11,7 @@  discard block
 block discarded – undo
11 11
 class ContestController extends Controller
12 12
 {
13 13
     public function info(Request $request) {
14
-        $contest = $request->contest;
14
+        $contest=$request->contest;
15 15
         return response()->json([
16 16
             'success' => true,
17 17
             'message' => 'Succeed',
@@ -39,80 +39,80 @@  discard block
 block discarded – undo
39 39
     }
40 40
 
41 41
     public function status(Request $request) {
42
-        $page = $request->page ?? 1;
43
-        $filter = $request->filter;
44
-        $contest = $request->contest;
42
+        $page=$request->page ?? 1;
43
+        $filter=$request->filter;
44
+        $contest=$request->contest;
45 45
 
46
-        $account = $filter['account'] ?? null;
47
-        $problem = $filter['problem'] ?? null;
48
-        $result = $filter['result'] ?? null;
46
+        $account=$filter['account'] ?? null;
47
+        $problem=$filter['problem'] ?? null;
48
+        $result=$filter['result'] ?? null;
49 49
 
50 50
         //filter
51
-        $builder = $contest->submissions()->orderBy('submission_date', 'desc')->with(['user', 'contest.group', 'problem']);
52
-        if($account !== null) {
53
-            $participants = $contest->participants();
54
-            $user = null;
55
-            foreach($participants as $participant) {
56
-                if($participant->name == $account){
57
-                    $user = $participant;
51
+        $builder=$contest->submissions()->orderBy('submission_date', 'desc')->with(['user', 'contest.group', 'problem']);
52
+        if ($account!==null) {
53
+            $participants=$contest->participants();
54
+            $user=null;
55
+            foreach ($participants as $participant) {
56
+                if ($participant->name==$account) {
57
+                    $user=$participant;
58 58
                     break;
59 59
                 }
60 60
             }
61
-            $builder = $builder->where('uid', $user == null ? -1 : $user->id);
61
+            $builder=$builder->where('uid', $user==null ? -1 : $user->id);
62 62
         }
63
-        if($problem !== null){
64
-            $problem = $contest->problems()->where('ncode', $problem)->first();
65
-            $builder = $builder->where('pid', $problem->pid ?? null);
63
+        if ($problem!==null) {
64
+            $problem=$contest->problems()->where('ncode', $problem)->first();
65
+            $builder=$builder->where('pid', $problem->pid ?? null);
66 66
         }
67
-        if($result !== null) {
68
-            $builder = $builder->where('verdict', $result);
67
+        if ($result!==null) {
68
+            $builder=$builder->where('verdict', $result);
69 69
         }
70 70
 
71 71
         //status_visibility
72
-        if($contest->status_visibility == 1){
73
-            if(auth()->check()){
74
-                $builder = $builder->where('uid', auth()->user()->id);
75
-            }else{
76
-                $builder = $builder->where('uid', -1);
72
+        if ($contest->status_visibility==1) {
73
+            if (auth()->check()) {
74
+                $builder=$builder->where('uid', auth()->user()->id);
75
+            } else {
76
+                $builder=$builder->where('uid', -1);
77 77
             }
78 78
         }
79
-        if($contest->status_visibility == 0){
80
-            $builder = $builder->where('uid', -1);
79
+        if ($contest->status_visibility==0) {
80
+            $builder=$builder->where('uid', -1);
81 81
         }
82 82
 
83
-        $submissions = $builder->paginate(50);
83
+        $submissions=$builder->paginate(50);
84 84
 
85
-        $regex = '/\?page=([\d+])$/';
86
-        $matches = [];
87
-        $pagination = [
85
+        $regex='/\?page=([\d+])$/';
86
+        $matches=[];
87
+        $pagination=[
88 88
             'current_page' => $submissions->currentPage(),
89
-            'has_next_page' => $submissions->nextPageUrl() === null ? false : true,
90
-            'has_previous_page' => $submissions->previousPageUrl() === null ? false : true,
89
+            'has_next_page' => $submissions->nextPageUrl()===null ? false : true,
90
+            'has_previous_page' => $submissions->previousPageUrl()===null ? false : true,
91 91
             'next_page' => null,
92 92
             'previous_page' => null,
93 93
             'num_pages' => $submissions->lastPage(),
94 94
             'num_items' => $submissions->count(),
95 95
         ];
96
-        if($pagination['has_next_page']) {
97
-            $next_page = preg_match($regex, $submissions->nextPageUrl(), $matches);
98
-            $pagination['next_page'] = intval($matches[1]);
96
+        if ($pagination['has_next_page']) {
97
+            $next_page=preg_match($regex, $submissions->nextPageUrl(), $matches);
98
+            $pagination['next_page']=intval($matches[1]);
99 99
         }
100
-        if($pagination['has_previous_page']) {
101
-            $next_page = preg_match($regex, $submissions->previousPageUrl(), $matches);
102
-            $pagination['previous_page'] = intval($matches[1]);
100
+        if ($pagination['has_previous_page']) {
101
+            $next_page=preg_match($regex, $submissions->previousPageUrl(), $matches);
102
+            $pagination['previous_page']=intval($matches[1]);
103 103
         }
104 104
 
105
-        $data = [];
106
-        foreach($submissions->items() as $submission) {
107
-            $score_parse = 0;
108
-            if($contest->rule == 2){
109
-                if($submission->verdict == 'Accepted') {
110
-                    $score_parse = 100;
111
-                }else if($submission->verdict == 'Partially Accepted') {
112
-                    $score_parse = round($submission->score / $submission->problem->tot_score * $contest->problems()->where('pid', $submission->problem->pid)->first()->points, 1);
105
+        $data=[];
106
+        foreach ($submissions->items() as $submission) {
107
+            $score_parse=0;
108
+            if ($contest->rule==2) {
109
+                if ($submission->verdict=='Accepted') {
110
+                    $score_parse=100;
111
+                } else if ($submission->verdict=='Partially Accepted') {
112
+                    $score_parse=round($submission->score / $submission->problem->tot_score * $contest->problems()->where('pid', $submission->problem->pid)->first()->points, 1);
113 113
                 }
114 114
             }
115
-            $data[] = [
115
+            $data[]=[
116 116
                 'sid' => $submission->sid,
117 117
                 'name' => $submission->user->name,
118 118
                 'nickname' => $submission->nick_name,
@@ -139,26 +139,26 @@  discard block
 block discarded – undo
139 139
     }
140 140
 
141 141
     public function scoreboard(Request $request) {
142
-        $contest = $request->contest;
143
-        $contestModel = new OutdatedContestModel();
144
-        $contestRank = $contestModel->contestRank($contest->cid, auth()->check() ? auth()->user()->id : 0);
142
+        $contest=$request->contest;
143
+        $contestModel=new OutdatedContestModel();
144
+        $contestRank=$contestModel->contestRank($contest->cid, auth()->check() ? auth()->user()->id : 0);
145 145
 
146 146
         //frozen about
147
-        if($contest->forze_length != 0) {
148
-            $frozen = [
147
+        if ($contest->forze_length!=0) {
148
+            $frozen=[
149 149
                 'enable' => true,
150 150
                 'frozen_length' => $contest->forze_length
151 151
             ];
152
-        }else{
153
-            $frozen = [
152
+        } else {
153
+            $frozen=[
154 154
                 'enable' => false,
155 155
                 'frozen_length' => 0
156 156
             ];
157 157
         }
158 158
 
159 159
         //header
160
-        if($contest->rule == 1){
161
-            $header = [
160
+        if ($contest->rule==1) {
161
+            $header=[
162 162
                 'rank' => 'Rank',
163 163
                 'normal' => [
164 164
                     'Account', 'Score', 'Penalty'
@@ -167,14 +167,14 @@  discard block
 block discarded – undo
167 167
                 'problems' => [],
168 168
                 'problemsSubHeader' => []
169 169
             ];
170
-            $problems = $contest->problems()->orderBy('ncode', 'asc')->get();
171
-            foreach($problems as $problem) {
172
-                $header['problems'][] = $problem->ncode;
173
-                $header['problemsSubHeader'][] = $problem->submissions()->where('submission_date', '<=', $contest->frozen_time)->where('verdict', 'Accepted')->count()
174
-                                                . ' / ' . $problem->submissions()->where('submission_date', '<=', $contest->frozen_time)->count();
170
+            $problems=$contest->problems()->orderBy('ncode', 'asc')->get();
171
+            foreach ($problems as $problem) {
172
+                $header['problems'][]=$problem->ncode;
173
+                $header['problemsSubHeader'][]=$problem->submissions()->where('submission_date', '<=', $contest->frozen_time)->where('verdict', 'Accepted')->count()
174
+                                                . ' / '.$problem->submissions()->where('submission_date', '<=', $contest->frozen_time)->count();
175 175
             }
176
-        }else if($contest->rule == 2){
177
-            $header = [
176
+        } else if ($contest->rule==2) {
177
+            $header=[
178 178
                 'rank' => 'Rank',
179 179
                 'normal' => [
180 180
                     'Account', 'Score', 'Solved'
@@ -182,76 +182,76 @@  discard block
 block discarded – undo
182 182
                 'subHeader' => false,
183 183
                 'problems' => []
184 184
             ];
185
-            $problems = $contest->problems()->orderBy('ncode', 'asc')->get();
186
-            foreach($problems as $problem) {
187
-                $header['problems'][] = $problem->ncode;
185
+            $problems=$contest->problems()->orderBy('ncode', 'asc')->get();
186
+            foreach ($problems as $problem) {
187
+                $header['problems'][]=$problem->ncode;
188 188
             }
189 189
         }
190
-        $user = auth()->user();
190
+        $user=auth()->user();
191 191
         //body
192
-        if($contest->rule == 1){
193
-            $body = [];
194
-            $lastRank = null;
195
-            $rank = 1;
196
-            foreach($contestRank as $userRank) {
197
-                if(!empty($lastRank)) {
198
-                    if($lastRank['score'] != $userRank['score'] || $lastRank['penalty'] != $userRank['penalty']) {
199
-                        $rank += 1;
192
+        if ($contest->rule==1) {
193
+            $body=[];
194
+            $lastRank=null;
195
+            $rank=1;
196
+            foreach ($contestRank as $userRank) {
197
+                if (!empty($lastRank)) {
198
+                    if ($lastRank['score']!=$userRank['score'] || $lastRank['penalty']!=$userRank['penalty']) {
199
+                        $rank+=1;
200 200
                     }
201 201
                 }
202
-                $lastRank = $userRank;
203
-                $userBody = [
202
+                $lastRank=$userRank;
203
+                $userBody=[
204 204
                     'rank'   => $rank,
205 205
                     'normal' => [
206 206
                         $userRank['name'], $userRank['score'], intval($userRank['penalty'])
207 207
                     ],
208 208
                     'problems' => []
209 209
                 ];
210
-                foreach($userRank['problem_detail'] as $problem) {
211
-                    $userBody['problems'][] = [
212
-                        'mainColor' => $problem['color'] === "" ? null : $problem['color'],
213
-                        'mainScore' => $problem['solved_time_parsed'] === "" ? null : $problem['solved_time_parsed'],
210
+                foreach ($userRank['problem_detail'] as $problem) {
211
+                    $userBody['problems'][]=[
212
+                        'mainColor' => $problem['color']==="" ? null : $problem['color'],
213
+                        'mainScore' => $problem['solved_time_parsed']==="" ? null : $problem['solved_time_parsed'],
214 214
                         'subColor' => null,
215
-                        'subScore' => $problem['wrong_doings'] == 0 ? null : '-'.$problem['wrong_doings']
215
+                        'subScore' => $problem['wrong_doings']==0 ? null : '-'.$problem['wrong_doings']
216 216
                     ];
217 217
                 }
218
-                $userBody['extra'] = [
219
-                    'owner' => isset($userBody['remote']) && $userBody['remote'] ? false : $user->id == $userRank['uid'],
218
+                $userBody['extra']=[
219
+                    'owner' => isset($userBody['remote']) && $userBody['remote'] ? false : $user->id==$userRank['uid'],
220 220
                     'remote' => $userBody['remote'] ?? false
221 221
                 ];
222
-                $body[] = $userBody;
222
+                $body[]=$userBody;
223 223
             }
224
-        }else if($contest->rule == 2){
225
-            $body = [];
226
-            $lastRank = null;
227
-            $rank = 1;
228
-            foreach($contestRank as $userRank) {
229
-                if(!empty($lastRank)) {
230
-                    if($lastRank['score'] != $userRank['score'] || $lastRank['solved'] != $userRank['solved']) {
231
-                        $rank += 1;
224
+        } else if ($contest->rule==2) {
225
+            $body=[];
226
+            $lastRank=null;
227
+            $rank=1;
228
+            foreach ($contestRank as $userRank) {
229
+                if (!empty($lastRank)) {
230
+                    if ($lastRank['score']!=$userRank['score'] || $lastRank['solved']!=$userRank['solved']) {
231
+                        $rank+=1;
232 232
                     }
233 233
                 }
234
-                $lastRank = $userRank;
235
-                $userBody = [
234
+                $lastRank=$userRank;
235
+                $userBody=[
236 236
                     'rank'   => $rank,
237 237
                     'normal' => [
238 238
                         $userRank['name'], $userRank['score'], intval($userRank['solved'])
239 239
                     ],
240 240
                     'problems' => []
241 241
                 ];
242
-                foreach($userRank['problem_detail'] as $problem) {
243
-                    $userBody['problems'][] = [
244
-                        'mainColor' => $problem['color'] === "" ? null : $problem['color'],
245
-                        'mainScore' => $problem['score'] === "" ? null : $problem['score_parsed'],
242
+                foreach ($userRank['problem_detail'] as $problem) {
243
+                    $userBody['problems'][]=[
244
+                        'mainColor' => $problem['color']==="" ? null : $problem['color'],
245
+                        'mainScore' => $problem['score']==="" ? null : $problem['score_parsed'],
246 246
                         'subColor' => null,
247 247
                         'subScore' => null
248 248
                     ];
249 249
                 }
250
-                $userBody['extra'] = [
251
-                    'owner' => isset($userBody['remote']) && $userBody['remote'] ? false : $user->id == $userRank['uid'],
250
+                $userBody['extra']=[
251
+                    'owner' => isset($userBody['remote']) && $userBody['remote'] ? false : $user->id==$userRank['uid'],
252 252
                     'remote' => $userBody['remote'] ?? false
253 253
                 ];
254
-                $body[] = $userBody;
254
+                $body[]=$userBody;
255 255
             }
256 256
         }
257 257
 
@@ -268,7 +268,7 @@  discard block
 block discarded – undo
268 268
     }
269 269
 
270 270
     public function clarification(Request $request) {
271
-        $contest = $request->contest;
271
+        $contest=$request->contest;
272 272
         return response()->json([
273 273
             'success' => true,
274 274
             'message' => 'Succeed',
@@ -280,7 +280,7 @@  discard block
 block discarded – undo
280 280
     }
281 281
 
282 282
     public function requestClarification(Request $request) {
283
-        if(empty($request->title) || empty($request->contest)) {
283
+        if (empty($request->title) || empty($request->contest)) {
284 284
             return response()->json([
285 285
                 'success' => false,
286 286
                 'message' => 'Parameter Missing',
@@ -292,8 +292,8 @@  discard block
 block discarded – undo
292 292
                 ]
293 293
             ]);
294 294
         }
295
-        $contest = $request->contest;
296
-        $clarification = $contest->clarifications()->create([
295
+        $contest=$request->contest;
296
+        $clarification=$contest->clarifications()->create([
297 297
             'cid' => $contest->cid,
298 298
             'type' => 1,
299 299
             'title' => $request->title,
@@ -312,18 +312,18 @@  discard block
 block discarded – undo
312 312
     }
313 313
 
314 314
     public function problems(Request $request) {
315
-        $contest = $request->contest;
316
-        $contestProblems = $contest->problems()->with('problem')->orderBy('ncode', 'asc')->get();
317
-        $problems = [];
318
-        foreach($contestProblems as $contestProblem) {
315
+        $contest=$request->contest;
316
+        $contestProblems=$contest->problems()->with('problem')->orderBy('ncode', 'asc')->get();
317
+        $problems=[];
318
+        foreach ($contestProblems as $contestProblem) {
319 319
             //get status
320
-            $ac_submission = $contestProblem->submissions()->where('uid', auth()->user()->id)->where('verdict', 'Accepted')->orderBy('submission_date', 'desc')->first();
321
-            $last_submission = $contestProblem->submissions()->where('uid', auth()->user()->id)->orderBy('submission_date', 'desc')->first();
320
+            $ac_submission=$contestProblem->submissions()->where('uid', auth()->user()->id)->where('verdict', 'Accepted')->orderBy('submission_date', 'desc')->first();
321
+            $last_submission=$contestProblem->submissions()->where('uid', auth()->user()->id)->orderBy('submission_date', 'desc')->first();
322 322
             //get compilers
323
-            $compilers_info = [];
324
-            $compilers = $contestProblem->compilers->get();
325
-            foreach($compilers as $compiler) {
326
-                $compilers_info[] = [
323
+            $compilers_info=[];
324
+            $compilers=$contestProblem->compilers->get();
325
+            foreach ($compilers as $compiler) {
326
+                $compilers_info[]=[
327 327
                     'coid' => $compiler->coid,
328 328
                     'oid' => $compiler->oid,
329 329
                     'comp' => $compiler->comp,
@@ -333,8 +333,8 @@  discard block
 block discarded – undo
333 333
                     'display_name' => $compiler->display_name
334 334
                 ];
335 335
             }
336
-            $highest_submit = $contestProblem->submissions()->where('uid', auth()->user()->id)->orderBy('score', 'desc')->first();
337
-            $problems[] = [
336
+            $highest_submit=$contestProblem->submissions()->where('uid', auth()->user()->id)->orderBy('score', 'desc')->first();
337
+            $problems[]=[
338 338
                 'pid' => $contestProblem->pid,
339 339
                 'pcode' => $contestProblem->problem->pcode,
340 340
                 'ncode' => $contestProblem->ncode,
@@ -343,7 +343,7 @@  discard block
 block discarded – undo
343 343
                     'time_limit' => $contestProblem->problem->time_limit,
344 344
                     'memory_limit' => $contestProblem->problem->memory_limit,
345 345
                 ],
346
-                'statistics' => $contest->rule == 1 ? [
346
+                'statistics' => $contest->rule==1 ? [
347 347
                     'accepted' => $contestProblem->submissions()->where('submission_date', '<=', $contest->frozen_time)->where('verdict', 'Accepted')->count(),
348 348
                     'attempted' => $contestProblem->submissions()->where('submission_date', '<=', $contest->frozen_time)->count(),
349 349
                     'score' => null,
@@ -387,12 +387,12 @@  discard block
 block discarded – undo
387 387
     }
388 388
 
389 389
     public function submitSolution(Request $request) {
390
-        $contest = $request->contest;
391
-        $contest_problem = $request->contest_problem;
392
-        $problem = $request->problem;
393
-        $compiler = $request->compiler;
390
+        $contest=$request->contest;
391
+        $contest_problem=$request->contest_problem;
392
+        $problem=$request->problem;
393
+        $compiler=$request->compiler;
394 394
 
395
-        if(empty($request->solution) || strlen($request->solution) > 65535) {
395
+        if (empty($request->solution) || strlen($request->solution)>65535) {
396 396
             return response()->json([
397 397
                 'success' => false,
398 398
                 'message' => 'Parameter \'solution\' Invalid',
@@ -404,7 +404,7 @@  discard block
 block discarded – undo
404 404
                 ]
405 405
             ]);
406 406
         }
407
-        $submission = Submission::create([
407
+        $submission=Submission::create([
408 408
             'time'=>'0',
409 409
             'memory'=>'0',
410 410
             'verdict'=>'Pending',
@@ -420,7 +420,7 @@  discard block
 block discarded – undo
420 420
             'jid'=>null,
421 421
             'score'=>0
422 422
         ]);
423
-        $all_data = [
423
+        $all_data=[
424 424
             'lang' => $compiler->lcode,
425 425
             'pid' => $problem->pid,
426 426
             'pcode' => $problem->pcode,
@@ -433,9 +433,9 @@  discard block
 block discarded – undo
433 433
             'contest' => $contest->cid,
434 434
             'sid' => $submission->sid
435 435
         ];
436
-        try{
436
+        try {
437 437
             dispatch(new ProcessSubmission($all_data))->onQueue($problem->oj);
438
-        }catch(\Throwable $e){
438
+        } catch (\Throwable $e) {
439 439
             return response()->json([
440 440
                 'success' => false,
441 441
                 'message' => $e->getMessage(),
@@ -457,10 +457,10 @@  discard block
 block discarded – undo
457 457
         ]);
458 458
     }
459 459
 
460
-    public function fetchAnnouncement(Request $request){
461
-        $contest = $request->contest;
462
-        $clarification = $contest->clarifications()->where(['type' => 0, 'public' => 1])
463
-            ->whereBetween('created_at',[date("Y-m-d H:i:s", time()-59), date("Y-m-d H:i:s")])
460
+    public function fetchAnnouncement(Request $request) {
461
+        $contest=$request->contest;
462
+        $clarification=$contest->clarifications()->where(['type' => 0, 'public' => 1])
463
+            ->whereBetween('created_at', [date("Y-m-d H:i:s", time()-59), date("Y-m-d H:i:s")])
464 464
             ->first();
465 465
         return response()->json([
466 466
             'success' => true,
Please login to merge, or discard this patch.
Braces   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -72,7 +72,7 @@  discard block
 block discarded – undo
72 72
         if($contest->status_visibility == 1){
73 73
             if(auth()->check()){
74 74
                 $builder = $builder->where('uid', auth()->user()->id);
75
-            }else{
75
+            } else{
76 76
                 $builder = $builder->where('uid', -1);
77 77
             }
78 78
         }
@@ -108,7 +108,7 @@  discard block
 block discarded – undo
108 108
             if($contest->rule == 2){
109 109
                 if($submission->verdict == 'Accepted') {
110 110
                     $score_parse = 100;
111
-                }else if($submission->verdict == 'Partially Accepted') {
111
+                } else if($submission->verdict == 'Partially Accepted') {
112 112
                     $score_parse = round($submission->score / $submission->problem->tot_score * $contest->problems()->where('pid', $submission->problem->pid)->first()->points, 1);
113 113
                 }
114 114
             }
@@ -149,7 +149,7 @@  discard block
 block discarded – undo
149 149
                 'enable' => true,
150 150
                 'frozen_length' => $contest->forze_length
151 151
             ];
152
-        }else{
152
+        } else{
153 153
             $frozen = [
154 154
                 'enable' => false,
155 155
                 'frozen_length' => 0
@@ -173,7 +173,7 @@  discard block
 block discarded – undo
173 173
                 $header['problemsSubHeader'][] = $problem->submissions()->where('submission_date', '<=', $contest->frozen_time)->where('verdict', 'Accepted')->count()
174 174
                                                 . ' / ' . $problem->submissions()->where('submission_date', '<=', $contest->frozen_time)->count();
175 175
             }
176
-        }else if($contest->rule == 2){
176
+        } else if($contest->rule == 2){
177 177
             $header = [
178 178
                 'rank' => 'Rank',
179 179
                 'normal' => [
@@ -221,7 +221,7 @@  discard block
 block discarded – undo
221 221
                 ];
222 222
                 $body[] = $userBody;
223 223
             }
224
-        }else if($contest->rule == 2){
224
+        } else if($contest->rule == 2){
225 225
             $body = [];
226 226
             $lastRank = null;
227 227
             $rank = 1;
@@ -435,7 +435,7 @@  discard block
 block discarded – undo
435 435
         ];
436 436
         try{
437 437
             dispatch(new ProcessSubmission($all_data))->onQueue($problem->oj);
438
-        }catch(\Throwable $e){
438
+        } catch(\Throwable $e){
439 439
             return response()->json([
440 440
                 'success' => false,
441 441
                 'message' => $e->getMessage(),
Please login to merge, or discard this patch.
app/Http/Controllers/Api/SubmissionController.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -12,8 +12,8 @@
 block discarded – undo
12 12
         return response()->json([
13 13
             'success' => true,
14 14
             'message' => 'Succeed',
15
-            'ret' => array_merge($request->submission->toArray(),[
16
-                'owner' => $request->submission->user->id == auth()->user()->id,
15
+            'ret' => array_merge($request->submission->toArray(), [
16
+                'owner' => $request->submission->user->id==auth()->user()->id,
17 17
                 'lang' => $request->submission->compiler->lang
18 18
             ]),
19 19
             'err' => []
Please login to merge, or discard this patch.
app/Http/Controllers/UserController.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -27,12 +27,12 @@
 block discarded – undo
27 27
     {
28 28
         $accountModel=new AccountModel();
29 29
         $info=$accountModel->detail($uid);
30
-        if($info == null) {
30
+        if ($info==null) {
31 31
             return redirect("/");
32 32
         }
33 33
         $feed=$accountModel->feed($uid);
34
-        $extraInfo = $accountModel->getExtra($uid, ['gender', 'contanct', 'school', 'country', 'location'],0);
35
-        $socialiteInfo = $accountModel->getSocialiteInfo($uid,0);
34
+        $extraInfo=$accountModel->getExtra($uid, ['gender', 'contanct', 'school', 'country', 'location'], 0);
35
+        $socialiteInfo=$accountModel->getSocialiteInfo($uid, 0);
36 36
         return view("account.dashboard", [
37 37
             'page_title'=>$info["name"],
38 38
             'site_title'=>config("app.name"),
Please login to merge, or discard this patch.
app/Admin/Controllers/DashboardController.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -13,15 +13,15 @@
 block discarded – undo
13 13
     {
14 14
         $version=UpdateModel::checkUpdate();
15 15
 
16
-        $status = [
17
-            ['name' => 'NOJ Version',       'value' => version()],
18
-            ['name' => 'Lastest Version',   'value' => is_null($version)?'Failed to fetch latest version':$version["name"]],
19
-            ['name' => 'Problems',          'value' => \App\Models\Eloquent\Problem::count()],
20
-            ['name' => 'Solutions',         'value' => \App\Models\Eloquent\ProblemSolutionModel::count()],
21
-            ['name' => 'Submissions',       'value' => \App\Models\Eloquent\Submission::count()],
22
-            ['name' => 'Contests',          'value' => \App\Models\Eloquent\Contest::count()],
23
-            ['name' => 'Users',             'value' => \App\Models\Eloquent\UserModel::count()],
24
-            ['name' => 'Groups',            'value' => \App\Models\Eloquent\Group::count()],
16
+        $status=[
17
+            ['name' => 'NOJ Version', 'value' => version()],
18
+            ['name' => 'Lastest Version', 'value' => is_null($version) ? 'Failed to fetch latest version' : $version["name"]],
19
+            ['name' => 'Problems', 'value' => \App\Models\Eloquent\Problem::count()],
20
+            ['name' => 'Solutions', 'value' => \App\Models\Eloquent\ProblemSolutionModel::count()],
21
+            ['name' => 'Submissions', 'value' => \App\Models\Eloquent\Submission::count()],
22
+            ['name' => 'Contests', 'value' => \App\Models\Eloquent\Contest::count()],
23
+            ['name' => 'Users', 'value' => \App\Models\Eloquent\UserModel::count()],
24
+            ['name' => 'Groups', 'value' => \App\Models\Eloquent\Group::count()],
25 25
         ];
26 26
 
27 27
         return view('admin::dashboard.general', [
Please login to merge, or discard this patch.
app/Models/Eloquent/Submission.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -13,7 +13,7 @@  discard block
 block discarded – undo
13 13
     const UPDATED_AT=null;
14 14
     const CREATED_AT=null;
15 15
 
16
-    protected $guarded = [];
16
+    protected $guarded=[];
17 17
 
18 18
     public function compiler()
19 19
     {
@@ -37,14 +37,14 @@  discard block
 block discarded – undo
37 37
 
38 38
     public function getNcodeAttribute()
39 39
     {
40
-        $contest = $this->contest;
40
+        $contest=$this->contest;
41 41
         return $contest->problems->where('pid', $this->pid)->first()->ncode;
42 42
     }
43 43
 
44 44
     public function getNickNameAttribute()
45 45
     {
46
-        $member = $this->contest->group->members()->where('uid', $this->user->id)->first();
47
-        if(!empty($member)) {
46
+        $member=$this->contest->group->members()->where('uid', $this->user->id)->first();
47
+        if (!empty($member)) {
48 48
             return $member->nickname;
49 49
         }
50 50
         return null;
@@ -81,7 +81,7 @@  discard block
 block discarded – undo
81 81
 
82 82
     public function getSubmissionDateParsedAttribute()
83 83
     {
84
-        $submission_date = date('Y-m-d H:i:s', $this->submission_date);
84
+        $submission_date=date('Y-m-d H:i:s', $this->submission_date);
85 85
         return formatHumanReadableTime($submission_date);
86 86
     }
87 87
 
Please login to merge, or discard this patch.
app/Models/Eloquent/ContestParticipant.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -19,6 +19,6 @@
 block discarded – undo
19 19
 
20 20
     public function contest()
21 21
     {
22
-        return $this->belongsTo('App\Models\Eloquent\Contest','cid','cid');
22
+        return $this->belongsTo('App\Models\Eloquent\Contest', 'cid', 'cid');
23 23
     }
24 24
 }
Please login to merge, or discard this patch.
app/Models/Eloquent/Contest.php 2 patches
Spacing   +33 added lines, -33 removed lines patch added patch discarded remove patch
@@ -18,28 +18,28 @@  discard block
 block discarded – undo
18 18
     const CREATED_AT=null;
19 19
 
20 20
     //Repository function
21
-    public function participants($ignore_frozen = true)
21
+    public function participants($ignore_frozen=true)
22 22
     {
23
-        if($this->registration){
24
-            $participants = ContestParticipant::where('cid',$this->cid)->get();
23
+        if ($this->registration) {
24
+            $participants=ContestParticipant::where('cid', $this->cid)->get();
25 25
             $participants->load('user');
26
-            $users = new EloquentCollection;
26
+            $users=new EloquentCollection;
27 27
             foreach ($participants as $participant) {
28
-                $user = $participant->user;
28
+                $user=$participant->user;
29 29
                 $users->add($user);
30 30
             }
31 31
             return $users->unique();
32
-        }else{
32
+        } else {
33 33
             $this->load('submissions.user');
34
-            if($ignore_frozen){
35
-                $frozen_time = $this->frozen_time;
36
-                $submissions = $this->submissions()->where('submission_date','<',$frozen_time)->get();
37
-            }else{
38
-                $submissions = $this->submissions;
34
+            if ($ignore_frozen) {
35
+                $frozen_time=$this->frozen_time;
36
+                $submissions=$this->submissions()->where('submission_date', '<', $frozen_time)->get();
37
+            } else {
38
+                $submissions=$this->submissions;
39 39
             }
40
-            $users = new EloquentCollection;
40
+            $users=new EloquentCollection;
41 41
             foreach ($submissions as $submission) {
42
-                $user = $submission->user;
42
+                $user=$submission->user;
43 43
                 $users->add($user);
44 44
             }
45 45
             return $users->unique();
@@ -49,18 +49,18 @@  discard block
 block discarded – undo
49 49
     // Repository/Service? function
50 50
     public function rankRefresh()
51 51
     {
52
-        $ret = [];
53
-        $participants = $this->participants();
54
-        $contest_problems = $this->problems;
52
+        $ret=[];
53
+        $participants=$this->participants();
54
+        $contest_problems=$this->problems;
55 55
         $contest_problems->load('problem');
56
-        if($this->rule == 1){
56
+        if ($this->rule==1) {
57 57
             // ACM/ICPC Mode
58 58
             foreach ($participants as $participant) {
59 59
                 $prob_detail=[];
60 60
                 $totPen=0;
61 61
                 $totScore=0;
62 62
                 foreach ($contest_problems as $contest_problem) {
63
-                    $prob_stat = $contest_problem->userStatus($participant);
63
+                    $prob_stat=$contest_problem->userStatus($participant);
64 64
                     $prob_detail[]=[
65 65
                         'ncode'=>$contest_problem->ncode,
66 66
                         'pid'=>$contest_problem->pid,
@@ -86,7 +86,7 @@  discard block
 block discarded – undo
86 86
                     "problem_detail" => $prob_detail
87 87
                 ];
88 88
             }
89
-            usort($ret, function ($a, $b) {
89
+            usort($ret, function($a, $b) {
90 90
                 if ($a["score"]==$b["score"]) {
91 91
                     if ($a["penalty"]==$b["penalty"]) {
92 92
                         return 0;
@@ -103,53 +103,53 @@  discard block
 block discarded – undo
103 103
             });
104 104
             Cache::tags(['contest', 'rank'])->put($this->cid, $ret, 60);
105 105
             return $ret;
106
-        }else{
106
+        } else {
107 107
             // IO Mode
108
-            $c = new OutdatedContestModel();
108
+            $c=new OutdatedContestModel();
109 109
             return $c->contestRankCache($this->cid);
110 110
         }
111 111
     }
112 112
 
113 113
     public function clarifications()
114 114
     {
115
-        return $this->hasMany('App\Models\Eloquent\ContestClarification','cid','cid');
115
+        return $this->hasMany('App\Models\Eloquent\ContestClarification', 'cid', 'cid');
116 116
     }
117 117
 
118 118
     public function problems()
119 119
     {
120
-        return $this->hasMany('App\Models\Eloquent\ContestProblem','cid','cid');
120
+        return $this->hasMany('App\Models\Eloquent\ContestProblem', 'cid', 'cid');
121 121
     }
122 122
 
123 123
     public function submissions()
124 124
     {
125
-        return $this->hasMany('App\Models\Eloquent\Submission','cid','cid');
125
+        return $this->hasMany('App\Models\Eloquent\Submission', 'cid', 'cid');
126 126
     }
127 127
 
128 128
     public function group()
129 129
     {
130
-        return $this->hasOne('App\Models\Eloquent\Group','gid','gid');
130
+        return $this->hasOne('App\Models\Eloquent\Group', 'gid', 'gid');
131 131
     }
132 132
 
133 133
     public function getFrozenTimeAttribute()
134 134
     {
135
-        $end_time = strtotime($this->end_time);
136
-        return $end_time - $this->froze_length;
135
+        $end_time=strtotime($this->end_time);
136
+        return $end_time-$this->froze_length;
137 137
     }
138 138
 
139 139
     public function getIsEndAttribute()
140 140
     {
141
-        return strtotime($this->end_time) < time();
141
+        return strtotime($this->end_time)<time();
142 142
     }
143 143
 
144 144
     public static function getProblemSet($cid, $renderLatex=false)
145 145
     {
146 146
         $ret=[];
147
-        $problemset=ContestProblemModel::where('cid', $cid)->orderBy('number','asc')->get();
148
-        foreach($problemset as $problem){
147
+        $problemset=ContestProblemModel::where('cid', $cid)->orderBy('number', 'asc')->get();
148
+        foreach ($problemset as $problem) {
149 149
             $problemDetail=ProblemModel::find($problem->pid);
150 150
             $problemRet=(new OutdatedProblemModel())->detail($problemDetail->pcode);
151
-            if ($renderLatex){
152
-                foreach (['description','input','output','note'] as $section){
151
+            if ($renderLatex) {
152
+                foreach (['description', 'input', 'output', 'note'] as $section) {
153 153
                     $problemRet['parsed'][$section]=latex2Image($problemRet['parsed'][$section]);
154 154
                 }
155 155
             }
@@ -163,6 +163,6 @@  discard block
 block discarded – undo
163 163
 
164 164
     public function isJudgingComplete()
165 165
     {
166
-        return $this->submissions->whereIn('verdict',['Waiting','Pending'])->count()==0;
166
+        return $this->submissions->whereIn('verdict', ['Waiting', 'Pending'])->count()==0;
167 167
     }
168 168
 }
Please login to merge, or discard this patch.
Braces   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -28,12 +28,12 @@  discard block
 block discarded – undo
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
 block discarded – undo
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);
Please login to merge, or discard this patch.
app/Exceptions/Handler.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -46,7 +46,7 @@  discard block
 block discarded – undo
46 46
      */
47 47
     public function render($request, Exception $exception)
48 48
     {
49
-        if(!env("APP_DEBUG") && $request->is('api/*')) {
49
+        if (!env("APP_DEBUG") && $request->is('api/*')) {
50 50
             return response(json_encode([
51 51
                 'success' => false,
52 52
                 'message' => 'Server Error',
@@ -56,7 +56,7 @@  discard block
 block discarded – undo
56 56
                     'msg' => 'Server Error',
57 57
                     'data'=>[]
58 58
                 ]
59
-            ]),500)->header('Content-Type','application/json');
59
+            ]), 500)->header('Content-Type', 'application/json');
60 60
         };
61 61
         return parent::render($request, $exception);
62 62
     }
Please login to merge, or discard this patch.
app/Helpers/functions.php 1 patch
Spacing   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -64,20 +64,20 @@  discard block
 block discarded – undo
64 64
     }
65 65
 }
66 66
 
67
-if (! function_exists('babel_path')) {
67
+if (!function_exists('babel_path')) {
68 68
     /**
69 69
      * Get the path to the application folder.
70 70
      *
71 71
      * @param  string  $path
72 72
      * @return string
73 73
      */
74
-    function babel_path($path = '')
74
+    function babel_path($path='')
75 75
     {
76 76
         return app('path').DIRECTORY_SEPARATOR.'Babel'.($path ? DIRECTORY_SEPARATOR.$path : $path);
77 77
     }
78 78
 }
79 79
 
80
-if (! function_exists('glob_recursive')) {
80
+if (!function_exists('glob_recursive')) {
81 81
     /**
82 82
      * Find pathnames matching a pattern recursively.
83 83
      *
@@ -85,11 +85,11 @@  discard block
 block discarded – undo
85 85
      * @param  int     $flags   Valid flags: GLOB_MARK
86 86
      * @return array|false      an array containing the matched files/directories, an empty array if no file matched or false on error.
87 87
      */
88
-    function glob_recursive($pattern, $flags = 0)
88
+    function glob_recursive($pattern, $flags=0)
89 89
     {
90
-        $files = glob($pattern, $flags);
91
-        foreach (glob(dirname($pattern).'/*', GLOB_ONLYDIR|GLOB_NOSORT) as $dir) {
92
-            $files = array_merge($files, glob_recursive($dir.'/'.basename($pattern), $flags));
90
+        $files=glob($pattern, $flags);
91
+        foreach (glob(dirname($pattern).'/*', GLOB_ONLYDIR | GLOB_NOSORT) as $dir) {
92
+            $files=array_merge($files, glob_recursive($dir.'/'.basename($pattern), $flags));
93 93
         }
94 94
         return $files;
95 95
     }
@@ -123,8 +123,8 @@  discard block
 block discarded – undo
123 123
     function delFile($dirName)
124 124
     {
125 125
         if (file_exists($dirName) && $handle=opendir($dirName)) {
126
-            while (false!==($item = readdir($handle))) {
127
-                if ($item!= "." && $item != "..") {
126
+            while (false!==($item=readdir($handle))) {
127
+                if ($item!="." && $item!="..") {
128 128
                     if (file_exists($dirName.'/'.$item) && is_dir($dirName.'/'.$item)) {
129 129
                         delFile($dirName.'/'.$item);
130 130
                     } else {
@@ -142,7 +142,7 @@  discard block
 block discarded – undo
142 142
 if (!function_exists('convertMarkdownToHtml')) {
143 143
     function convertMarkdownToHtml($md)
144 144
     {
145
-        return is_string($md)?Markdown::convertToHtml($md):'';
145
+        return is_string($md) ?Markdown::convertToHtml($md) : '';
146 146
     }
147 147
 }
148 148
 
@@ -186,7 +186,7 @@  discard block
 block discarded – undo
186 186
             $periods[$j]=__("helper.time.singular.$periods[$j]");
187 187
         }
188 188
 
189
-        return __("helper.time.formatter",[
189
+        return __("helper.time.formatter", [
190 190
             "time" => $difference,
191 191
             "unit" => $periods[$j],
192 192
             "tense" => $tense,
@@ -211,18 +211,18 @@  discard block
 block discarded – undo
211 211
 if (!function_exists('latex2Image')) {
212 212
     function latex2Image($content)
213 213
     {
214
-        $callback = function ($matches) use (&$patch, &$display) {
215
-            [$url,$width,$height]=LatexModel::info("$patch$matches[1]$patch");
214
+        $callback=function($matches) use (&$patch, &$display) {
215
+            [$url, $width, $height]=LatexModel::info("$patch$matches[1]$patch");
216 216
             return "<img src=\"$url\" style=\"display: $display;\" class=\"rendered-tex\" width=\"$width\" height=\"$height\">";
217 217
         };
218
-        $patch = '$';
219
-        $display = 'inline-block';
220
-        $content = preg_replace_callback('/\\$\\$\\$(.*?)\\$\\$\\$/', $callback, $content);
221
-        $content = preg_replace_callback('/\\\\\\((.*?)\\\\\\)/', $callback, $content);
222
-        $patch = '$$';
223
-        $display = 'block';
224
-        $content = preg_replace_callback('/\\$\\$(.*?)\\$\\$/', $callback, $content);
225
-        $content = preg_replace_callback('/\\\\\\[(.*?)\\\\\\]/', $callback, $content);
218
+        $patch='$';
219
+        $display='inline-block';
220
+        $content=preg_replace_callback('/\\$\\$\\$(.*?)\\$\\$\\$/', $callback, $content);
221
+        $content=preg_replace_callback('/\\\\\\((.*?)\\\\\\)/', $callback, $content);
222
+        $patch='$$';
223
+        $display='block';
224
+        $content=preg_replace_callback('/\\$\\$(.*?)\\$\\$/', $callback, $content);
225
+        $content=preg_replace_callback('/\\\\\\[(.*?)\\\\\\]/', $callback, $content);
226 226
         return $content;
227 227
     }
228 228
 }
Please login to merge, or discard this patch.