Passed
Pull Request — master (#583)
by
unknown
10:53
created
app/Http/Controllers/Api/AccountController.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -8,19 +8,19 @@
 block discarded – undo
8 8
 class AccountController extends Controller
9 9
 {
10 10
     public function login(Request $request) {
11
-        $credentials = [
11
+        $credentials=[
12 12
             'email' => $request->email,
13 13
             'password' => $request->password
14 14
         ];
15 15
 
16
-        if(auth()->attempt($credentials)) {
17
-            $user = auth()->user();
18
-            if(!empty($user->tokens)){
19
-                foreach($user->tokens as $token){
16
+        if (auth()->attempt($credentials)) {
17
+            $user=auth()->user();
18
+            if (!empty($user->tokens)) {
19
+                foreach ($user->tokens as $token) {
20 20
                     $token->delete();
21 21
                 }
22 22
             }
23
-            $token = $user->createToken('NOJ Password Grant Client')->accessToken;
23
+            $token=$user->createToken('NOJ Password Grant Client')->accessToken;
24 24
             return response()->json([
25 25
                 'success' => true,
26 26
                 'message' => 'Successfully Login',
Please login to merge, or discard this patch.
app/Http/Controllers/Api/ProblemController.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -8,10 +8,10 @@  discard block
 block discarded – undo
8 8
 class ProblemController extends Controller
9 9
 {
10 10
     public function fetchVerdict(Request $request) {
11
-        $submission = $request->submission;
12
-        $problem = $submission->problem;
13
-        $contest = $submission->contest;
14
-        $contest_problem = !empty($contest) ? $submission->contest->problems()->where('pid', $problem->pid)->first() : null;
11
+        $submission=$request->submission;
12
+        $problem=$submission->problem;
13
+        $contest=$submission->contest;
14
+        $contest_problem=!empty($contest) ? $submission->contest->problems()->where('pid', $problem->pid)->first() : null;
15 15
         return response()->json([
16 16
             'success' => true,
17 17
             'message' => 'Succeed',
@@ -28,11 +28,11 @@  discard block
 block discarded – undo
28 28
                     "lang" => $submission->compiler->lang,
29 29
                     "language" => $submission->language,
30 30
                     "memory" => $submission->memory,
31
-                    "owner" => $submission->user->id == auth()->user()->id,
31
+                    "owner" => $submission->user->id==auth()->user()->id,
32 32
                     "pid" => $problem->pid,
33 33
                     "remote_id" => $submission->remote_id,
34 34
                     "score" => $submission->score,
35
-                    "score_parsed" => (!empty($contest) && $contest->rule == 2) ? $submission->score / $problem->tot_score * $contest_problem->points : 0, // if has ioi contest set to score parsed, else 0
35
+                    "score_parsed" => (!empty($contest) && $contest->rule==2) ? $submission->score / $problem->tot_score * $contest_problem->points : 0, // if has ioi contest set to score parsed, else 0
36 36
                     "share" => $submission->share,
37 37
                     "sid" => $submission->sid,
38 38
                     "solution" => $submission->solution,
Please login to merge, or discard this patch.
app/Http/Controllers/Api/ContestController.php 1 patch
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.
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/ProblemModel.php 1 patch
Spacing   +35 added lines, -35 removed lines patch added patch discarded remove patch
@@ -48,11 +48,11 @@  discard block
 block discarded – undo
48 48
             $prob_detail["pdf"]=false;
49 49
             $prob_detail["viewerShow"]=false;
50 50
             $prob_detail["file_ext"]=null;
51
-            if($prob_detail['file'] && !blank($prob_detail['file_url'])){
52
-                $prob_detail["file_ext"]=explode('.',basename($prob_detail['file_url']));
51
+            if ($prob_detail['file'] && !blank($prob_detail['file_url'])) {
52
+                $prob_detail["file_ext"]=explode('.', basename($prob_detail['file_url']));
53 53
                 $prob_detail["file_ext"]=end($prob_detail["file_ext"]);
54 54
                 $prob_detail["pdf"]=Str::is("*.pdf", basename($prob_detail['file_url']));
55
-                $prob_detail["viewerShow"]= blank($prob_detail["parsed"]["description"]) &&
55
+                $prob_detail["viewerShow"]=blank($prob_detail["parsed"]["description"]) &&
56 56
                                             blank($prob_detail["parsed"]["input"]) &&
57 57
                                             blank($prob_detail["parsed"]["output"]) &&
58 58
                                             blank($prob_detail["parsed"]["note"]);
@@ -194,9 +194,9 @@  discard block
 block discarded – undo
194 194
 
195 195
     private function inteliAudit($uid, $content)
196 196
     {
197
-        if (strpos($content, '```')!==false){
197
+        if (strpos($content, '```')!==false) {
198 198
             $userSolutionHistory=DB::table("problem_solution")->where(['uid'=>$uid])->orderByDesc('updated_at')->first();
199
-            if (!empty($userSolutionHistory) && $userSolutionHistory["audit"]==1){
199
+            if (!empty($userSolutionHistory) && $userSolutionHistory["audit"]==1) {
200 200
                 return 1;
201 201
             }
202 202
         }
@@ -292,7 +292,7 @@  discard block
 block discarded – undo
292 292
     {
293 293
         // $prob_list = DB::table($this->table)->select("pid","pcode","title")->get()->all(); // return a array
294 294
         $submissionModel=new SubmissionModel();
295
-        $preQuery=DB::table($this->table)->where('hide','=',0);
295
+        $preQuery=DB::table($this->table)->where('hide', '=', 0);
296 296
         if ($filter['oj']) {
297 297
             $preQuery=$preQuery->where(["OJ"=>$filter['oj']]);
298 298
         }
@@ -454,7 +454,7 @@  discard block
 block discarded – undo
454 454
 
455 455
         if (!empty($data["sample"])) {
456 456
             foreach ($data["sample"] as $d) {
457
-                if(!isset($d['sample_note'])) $d['sample_note']=null;
457
+                if (!isset($d['sample_note'])) $d['sample_note']=null;
458 458
                 DB::table("problem_sample")->insert([
459 459
                     'pid'=>$pid,
460 460
                     'sample_input'=>$d['sample_input'],
@@ -503,7 +503,7 @@  discard block
 block discarded – undo
503 503
 
504 504
         if (!empty($data["sample"])) {
505 505
             foreach ($data["sample"] as $d) {
506
-                if(!isset($d['sample_note'])) $d['sample_note']=null;
506
+                if (!isset($d['sample_note'])) $d['sample_note']=null;
507 507
                 DB::table("problem_sample")->insert([
508 508
                     'pid'=>$pid,
509 509
                     'sample_input'=>$d['sample_input'],
@@ -518,7 +518,7 @@  discard block
 block discarded – undo
518 518
 
519 519
     public function discussionList($pid)
520 520
     {
521
-        $paginator = DB::table('problem_discussion')->join(
521
+        $paginator=DB::table('problem_discussion')->join(
522 522
             "users",
523 523
             "id",
524 524
             "=",
@@ -537,10 +537,10 @@  discard block
 block discarded – undo
537 537
             'users.name',
538 538
             'users.id as uid'
539 539
         ])->paginate(15);
540
-        $list = $paginator->all();
541
-        foreach($list as &$l){
542
-            $l['updated_at'] = formatHumanReadableTime($l['updated_at']);
543
-            $l['comment_count'] = DB::table('problem_discussion_comment')->where('pdid','=',$l['pdid'])->count();
540
+        $list=$paginator->all();
541
+        foreach ($list as &$l) {
542
+            $l['updated_at']=formatHumanReadableTime($l['updated_at']);
543
+            $l['comment_count']=DB::table('problem_discussion_comment')->where('pdid', '=', $l['pdid'])->count();
544 544
         }
545 545
         return [
546 546
             'paginator' => $paginator,
@@ -550,7 +550,7 @@  discard block
 block discarded – undo
550 550
 
551 551
     public function discussionDetail($pdid)
552 552
     {
553
-        $main = DB::table('problem_discussion')->join(
553
+        $main=DB::table('problem_discussion')->join(
554 554
             "users",
555 555
             "id",
556 556
             "=",
@@ -569,12 +569,12 @@  discard block
 block discarded – undo
569 569
             'users.name',
570 570
             'users.id as uid'
571 571
         ])->get()->first();
572
-        $main['created_at'] = formatHumanReadableTime($main['created_at']);
572
+        $main['created_at']=formatHumanReadableTime($main['created_at']);
573 573
         $main['content']=clean(Markdown::convertToHtml($main["content"]));
574 574
 
575
-        $comment_count = DB::table('problem_discussion_comment')->where('pdid','=',$pdid)->count();
575
+        $comment_count=DB::table('problem_discussion_comment')->where('pdid', '=', $pdid)->count();
576 576
 
577
-        $paginator = DB::table('problem_discussion_comment')->join(
577
+        $paginator=DB::table('problem_discussion_comment')->join(
578 578
             "users",
579 579
             "id",
580 580
             "=",
@@ -593,11 +593,11 @@  discard block
 block discarded – undo
593 593
             'users.name',
594 594
             'users.id as uid'
595 595
         ])->paginate(10);
596
-        $comment = $paginator->all();
597
-        foreach($comment as &$c){
596
+        $comment=$paginator->all();
597
+        foreach ($comment as &$c) {
598 598
             $c['content']=clean(Markdown::convertToHtml($c["content"]));
599
-            $c['created_at'] = formatHumanReadableTime($c['created_at']);
600
-            $c['reply'] = DB::table('problem_discussion_comment')->join(
599
+            $c['created_at']=formatHumanReadableTime($c['created_at']);
600
+            $c['reply']=DB::table('problem_discussion_comment')->join(
601 601
                 "users",
602 602
                 "id",
603 603
                 "=",
@@ -625,20 +625,20 @@  discard block
 block discarded – undo
625 625
                 'users.name',
626 626
                 'users.id as uid'
627 627
             ])->get()->all();
628
-            foreach($c['reply'] as $k=>&$cr){
628
+            foreach ($c['reply'] as $k=>&$cr) {
629 629
                 $cr['content']=clean(Markdown::convertToHtml($cr["content"]));
630
-                $cr['reply_uid'] = DB::table('problem_discussion_comment')->where(
630
+                $cr['reply_uid']=DB::table('problem_discussion_comment')->where(
631 631
                     'pdcid',
632 632
                     '=',
633 633
                     $cr['reply_id']
634 634
                 )->get()->first()['uid'];
635
-                $cr['reply_name'] = DB::table('users')->where(
635
+                $cr['reply_name']=DB::table('users')->where(
636 636
                     'id',
637 637
                     '=',
638 638
                     $cr['reply_uid']
639 639
                 )->get()->first()['name'];
640
-                $cr['created_at'] = formatHumanReadableTime($cr['created_at']);
641
-                if($this->replyParent($cr['pdcid'])!=$c['pdcid']){
640
+                $cr['created_at']=formatHumanReadableTime($cr['created_at']);
641
+                if ($this->replyParent($cr['pdcid'])!=$c['pdcid']) {
642 642
                     unset($c['reply'][$k]);
643 643
                 }
644 644
             }
@@ -653,19 +653,19 @@  discard block
 block discarded – undo
653 653
 
654 654
     public function replyParent($pdcid)
655 655
     {
656
-        $reply_id=DB::table('problem_discussion_comment')->where('pdcid','=',$pdcid)->get()->first()['reply_id'];
657
-        $top=DB::table('problem_discussion_comment')->where('pdcid','=',$reply_id)->get()->first()['reply_id'];
658
-        if(isset($top)){
656
+        $reply_id=DB::table('problem_discussion_comment')->where('pdcid', '=', $pdcid)->get()->first()['reply_id'];
657
+        $top=DB::table('problem_discussion_comment')->where('pdcid', '=', $reply_id)->get()->first()['reply_id'];
658
+        if (isset($top)) {
659 659
             return $this->replyParent($reply_id);
660
-        }else{
660
+        } else {
661 661
             return $reply_id;
662 662
         }
663 663
     }
664 664
 
665 665
     public function pcodeByPdid($dcode)
666 666
     {
667
-        $pid = DB::table('problem_discussion')->where('pdid','=',$dcode)->get()->first()['pid'];
668
-        $pcode = $this->pcode($pid);
667
+        $pid=DB::table('problem_discussion')->where('pdid', '=', $dcode)->get()->first()['pid'];
668
+        $pcode=$this->pcode($pid);
669 669
         return $pcode;
670 670
     }
671 671
 
@@ -686,11 +686,11 @@  discard block
 block discarded – undo
686 686
 
687 687
     public function pidByPdid($pdid)
688 688
     {
689
-        $pid = DB::table('problem_discussion')->where('pdid','=',$pdid)->get()->first()['pid'];
689
+        $pid=DB::table('problem_discussion')->where('pdid', '=', $pdid)->get()->first()['pid'];
690 690
         return $pid;
691 691
     }
692 692
 
693
-    public function addComment($uid,$pdid,$content,$reply_id)
693
+    public function addComment($uid, $pdid, $content, $reply_id)
694 694
     {
695 695
         $pid=$this->pidByPdid($pdid);
696 696
         $pdcid=DB::table('problem_discussion_comment')->insertGetId([
@@ -709,6 +709,6 @@  discard block
 block discarded – undo
709 709
 
710 710
     public function isHidden($pid)
711 711
     {
712
-        return DB::table('problem')->where('pid','=',$pid)->get()->first()['hide'];
712
+        return DB::table('problem')->where('pid', '=', $pid)->get()->first()['hide'];
713 713
     }
714 714
 }
Please login to merge, or discard this patch.
app/Models/Eloquent/ContestProblem.php 1 patch
Spacing   +26 added lines, -26 removed lines patch added patch discarded remove patch
@@ -9,36 +9,36 @@  discard block
 block discarded – undo
9 9
 {
10 10
     protected $table='contest_problem';
11 11
     protected $primaryKey='cpid';
12
-    public $timestamps = null;
12
+    public $timestamps=null;
13 13
     const DELETED_AT=null;
14 14
     const UPDATED_AT=null;
15 15
     const CREATED_AT=null;
16 16
 
17 17
     public function contest()
18 18
     {
19
-        return $this->belongsTo('App\Models\Eloquent\Contest','cid','cid');
19
+        return $this->belongsTo('App\Models\Eloquent\Contest', 'cid', 'cid');
20 20
     }
21 21
 
22 22
     public function problem()
23 23
     {
24
-        return $this->belongsTo('App\Models\Eloquent\Problem','pid','pid');
24
+        return $this->belongsTo('App\Models\Eloquent\Problem', 'pid', 'pid');
25 25
     }
26 26
 
27 27
     public function submissions()
28 28
     {
29
-        return $this->problem->submissions()->where('cid',$this->contest->cid);
29
+        return $this->problem->submissions()->where('cid', $this->contest->cid);
30 30
     }
31 31
 
32 32
     public function getCompilersAttribute()
33 33
     {
34
-        $special = $this->problem->special_compiler;
35
-        $compilers = Compiler::where([
34
+        $special=$this->problem->special_compiler;
35
+        $compilers=Compiler::where([
36 36
             'oid' => $this->problem->OJ,
37 37
             'available' => 1,
38 38
             'deleted' => 0
39 39
         ]);
40
-        if(!empty($special)) {
41
-            $compilers = $compilers->whereIn('coid', explode(',', $special));
40
+        if (!empty($special)) {
41
+            $compilers=$compilers->whereIn('coid', explode(',', $special));
42 42
         }
43 43
         return $compilers;
44 44
     }
@@ -53,34 +53,34 @@  discard block
 block discarded – undo
53 53
             'wrong_doings'       => 0,
54 54
             'color'              => '',
55 55
         ];
56
-        $ac_record = $this->ac_record($user);
57
-        if(!empty($ac_record[0])){
58
-            $ret['solved']             = 1;
59
-            $ret['solved_time']        = $ac_record[0]->submission_date - strtotime($this->contest->begin_time);
60
-            $ret['solved_time_parsed'] = formatProblemSolvedTime($ret['solved_time']);
61
-            $ret['wrong_doings']       = $ac_record[2];
62
-            $ret['color']              = $ac_record[1] ? 'wemd-green-text' : 'wemd-teal-text';
63
-        }else{
64
-            $ret['wrong_doings']       = $ac_record[2];
56
+        $ac_record=$this->ac_record($user);
57
+        if (!empty($ac_record[0])) {
58
+            $ret['solved']=1;
59
+            $ret['solved_time']=$ac_record[0]->submission_date-strtotime($this->contest->begin_time);
60
+            $ret['solved_time_parsed']=formatProblemSolvedTime($ret['solved_time']);
61
+            $ret['wrong_doings']=$ac_record[2];
62
+            $ret['color']=$ac_record[1] ? 'wemd-green-text' : 'wemd-teal-text';
63
+        } else {
64
+            $ret['wrong_doings']=$ac_record[2];
65 65
         }
66 66
         return $ret;
67 67
     }
68 68
 
69 69
     public function ac_record($user)
70 70
     {
71
-        $user_ac = $this->submissions()->where([
71
+        $user_ac=$this->submissions()->where([
72 72
             'uid'     => $user->id,
73 73
             'verdict' => 'Accepted'
74 74
         ])->first();
75 75
 
76
-        $other_ac = 1;
77
-        $wrong_trys = 0;
78
-        if(!empty($user_ac)){
79
-            $other_ac = $this->submissions()
80
-                ->where('verdict','Accepted')
76
+        $other_ac=1;
77
+        $wrong_trys=0;
78
+        if (!empty($user_ac)) {
79
+            $other_ac=$this->submissions()
80
+                ->where('verdict', 'Accepted')
81 81
                 ->where('submission_date', '<', $user_ac->submission_date)
82 82
                 ->count();
83
-            $wrong_trys = $this->submissions()->where([
83
+            $wrong_trys=$this->submissions()->where([
84 84
                     'uid'     => $user->id,
85 85
                 ])->whereIn('verdict', [
86 86
                     'Runtime Error',
@@ -91,8 +91,8 @@  discard block
 block discarded – undo
91 91
                     'Presentation Error',
92 92
                     'Output Limit Exceeded'
93 93
                 ])->where('submission_date', '<', $user_ac->submission_date)->count();
94
-        }else{
95
-            $wrong_trys = $this->submissions()->where([
94
+        } else {
95
+            $wrong_trys=$this->submissions()->where([
96 96
                 'uid'     => $user->id,
97 97
             ])->whereIn('verdict', [
98 98
                 'Runtime Error',
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.