Completed
Push — master ( c106d2...7c3edb )
by John
14s queued 10s
created
app/Http/Controllers/ProblemController.php 3 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -131,8 +131,8 @@
 block discarded – undo
131 131
             ];
132 132
         }
133 133
 
134
-        $editor_left_width = $account->getExtra(Auth::user()->id, 'editor_left_width');
135
-        if(empty($editor_left_width)) $editor_left_width='40';
134
+        $editor_left_width=$account->getExtra(Auth::user()->id, 'editor_left_width');
135
+        if (empty($editor_left_width)) $editor_left_width='40';
136 136
 
137 137
         return is_null($prob_detail) ?  redirect("/problem") : view('problem.editor', [
138 138
                                             'page_title'=>$prob_detail["title"],
Please login to merge, or discard this patch.
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -132,7 +132,9 @@
 block discarded – undo
132 132
         }
133 133
 
134 134
         $editor_left_width = $account->getExtra(Auth::user()->id, 'editor_left_width');
135
-        if(empty($editor_left_width)) $editor_left_width='40';
135
+        if(empty($editor_left_width)) {
136
+            $editor_left_width='40';
137
+        }
136 138
 
137 139
         return is_null($prob_detail) ?  redirect("/problem") : view('problem.editor', [
138 140
                                             'page_title'=>$prob_detail["title"],
Please login to merge, or discard this patch.
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -150,10 +150,10 @@
 block discarded – undo
150 150
     }
151 151
 
152 152
         /**
153
-     * Show the Problem Discussion Page.
154
-     *
155
-     * @return Response
156
-     */
153
+         * Show the Problem Discussion Page.
154
+         *
155
+         * @return Response
156
+         */
157 157
     public function discussion($pcode)
158 158
     {
159 159
         //TODO
Please login to merge, or discard this patch.
app/Models/Rating/GroupRatingCalculator.php 2 patches
Braces   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -78,7 +78,7 @@
 block discarded – undo
78 78
             $mid = floor(($right + $left)/2);
79 79
             if($this->getSeed($mid) < $rank){
80 80
                 $right = $mid;
81
-            }else{
81
+            } else{
82 82
                 $left = $mid;
83 83
             }
84 84
         }
Please login to merge, or discard this patch.
Spacing   +85 added lines, -85 removed lines patch added patch discarded remove patch
@@ -14,36 +14,36 @@  discard block
 block discarded – undo
14 14
     public $totParticipants=0;
15 15
     public $INITIAL_RATING=1500;
16 16
 
17
-    public function __construct($cid){
18
-        $contestModel = new ContestModel();
19
-        $this->cid = $cid;
20
-        $this->gid = $contestModel->gid($cid);
17
+    public function __construct($cid) {
18
+        $contestModel=new ContestModel();
19
+        $this->cid=$cid;
20
+        $this->gid=$contestModel->gid($cid);
21 21
         // get rank
22 22
         $this->getRecord();
23 23
     }
24 24
 
25
-    private function getRecord(){
26
-        $contestModel = new ContestModel();
27
-        $contestRankRaw = $contestModel->contestRank($this->cid);
28
-        foreach($contestRankRaw as $key => $contestRank){
29
-            if(isset($contestRank['remote']) && $contestRank['remote']){
25
+    private function getRecord() {
26
+        $contestModel=new ContestModel();
27
+        $contestRankRaw=$contestModel->contestRank($this->cid);
28
+        foreach ($contestRankRaw as $key => $contestRank) {
29
+            if (isset($contestRank['remote']) && $contestRank['remote']) {
30 30
                 unset($contestRankRaw[$key]);
31 31
             }
32 32
         }
33
-        $contestRankRaw = array_values($contestRankRaw);
34
-        $members = array_column($contestRankRaw,'uid');
35
-        $ratings_temp = DB::table('group_member')
33
+        $contestRankRaw=array_values($contestRankRaw);
34
+        $members=array_column($contestRankRaw, 'uid');
35
+        $ratings_temp=DB::table('group_member')
36 36
             ->where([
37 37
                 'gid' => $this->gid,
38
-            ])->whereIn('uid',$members)
39
-            ->select('uid','ranking')
38
+            ])->whereIn('uid', $members)
39
+            ->select('uid', 'ranking')
40 40
             ->get()->all();
41
-        $ratings = [];
41
+        $ratings=[];
42 42
         foreach ($ratings_temp as $rating) {
43
-            $ratings[$rating['uid']] = $rating['ranking'];
43
+            $ratings[$rating['uid']]=$rating['ranking'];
44 44
         }
45
-        foreach($contestRankRaw as $c){
46
-            if(!isset($ratings[$c['uid']])){
45
+        foreach ($contestRankRaw as $c) {
46
+            if (!isset($ratings[$c['uid']])) {
47 47
                 continue;
48 48
             }
49 49
             $this->contestants[]=[
@@ -52,87 +52,87 @@  discard block
 block discarded – undo
52 52
                 "rating"=>$ratings[$c['uid']],
53 53
             ];
54 54
         }
55
-        $this->totParticipants = count($this->contestants);
55
+        $this->totParticipants=count($this->contestants);
56 56
     }
57 57
 
58
-    private function reassignRank(){
58
+    private function reassignRank() {
59 59
         $this->sort("points");
60
-        $idx = 0;
61
-        $points = $this->contestants[0]["points"];
62
-        $i = 1;
63
-        while($i < $this->totParticipants){
64
-            if($this->contestants[$i]["points"] < $points){
65
-                $j = $idx;
66
-                while($j < $i){
67
-                    $this->contestants[$j]["rank"] = $i;
68
-                    $j += 1;
60
+        $idx=0;
61
+        $points=$this->contestants[0]["points"];
62
+        $i=1;
63
+        while ($i<$this->totParticipants) {
64
+            if ($this->contestants[$i]["points"]<$points) {
65
+                $j=$idx;
66
+                while ($j<$i) {
67
+                    $this->contestants[$j]["rank"]=$i;
68
+                    $j+=1;
69 69
                 }
70
-                $idx = $i;
71
-                $points = $this->contestants[$i]["points"];
70
+                $idx=$i;
71
+                $points=$this->contestants[$i]["points"];
72 72
             }
73
-            $i += 1;
73
+            $i+=1;
74 74
         }
75
-        $j = $idx;
76
-        while($j < $this->totParticipants){
77
-            $this->contestants[$j]["rank"] = $this->totParticipants;
78
-            $j += 1;
75
+        $j=$idx;
76
+        while ($j<$this->totParticipants) {
77
+            $this->contestants[$j]["rank"]=$this->totParticipants;
78
+            $j+=1;
79 79
         }
80 80
     }
81 81
 
82
-    private function getEloWinProbability($Ra, $Rb){
83
-        return 1.0 / (1 + pow(10, ($Rb-$Ra)/400.0));
82
+    private function getEloWinProbability($Ra, $Rb) {
83
+        return 1.0 / (1+pow(10, ($Rb-$Ra) / 400.0));
84 84
     }
85 85
 
86
-    private function getSeed($rating){
87
-        $result = 1.0;
88
-        foreach($this->contestants as $other){
89
-            $result += $this->getEloWinProbability($other["rating"], $rating);
86
+    private function getSeed($rating) {
87
+        $result=1.0;
88
+        foreach ($this->contestants as $other) {
89
+            $result+=$this->getEloWinProbability($other["rating"], $rating);
90 90
         }
91 91
         return $result;
92 92
     }
93 93
 
94
-    private function getRatingToRank($rank){
94
+    private function getRatingToRank($rank) {
95 95
         $left=1;
96 96
         $right=8000;
97
-        while($right - $left > 1){
98
-            $mid = floor(($right + $left)/2);
99
-            if($this->getSeed($mid) < $rank){
100
-                $right = $mid;
101
-            }else{
102
-                $left = $mid;
97
+        while ($right-$left>1) {
98
+            $mid=floor(($right+$left) / 2);
99
+            if ($this->getSeed($mid)<$rank) {
100
+                $right=$mid;
101
+            } else {
102
+                $left=$mid;
103 103
             }
104 104
         }
105 105
         return $left;
106 106
     }
107 107
 
108
-    private function sort($key){
109
-        usort($this->contestants, function ($a, $b) use ($key) {
108
+    private function sort($key) {
109
+        usort($this->contestants, function($a, $b) use ($key) {
110 110
             return $b[$key] <=> $a[$key];
111 111
         });
112 112
     }
113 113
 
114
-    public function calculate(){
115
-        if(empty($this->contestants)){
114
+    public function calculate() {
115
+        if (empty($this->contestants)) {
116 116
             return;
117 117
         }
118 118
 
119 119
         // recalc rank
120 120
         $this->reassignRank();
121 121
 
122
-        foreach($this->contestants as &$member){
123
-            $member["seed"] = 1.0;
124
-            foreach($this->contestants as $other){
125
-                if($member["uid"] != $other["uid"]){
126
-                    $member["seed"] += $this->getEloWinProbability($other["rating"], $member["rating"]);
122
+        foreach ($this->contestants as &$member) {
123
+            $member["seed"]=1.0;
124
+            foreach ($this->contestants as $other) {
125
+                if ($member["uid"]!=$other["uid"]) {
126
+                    $member["seed"]+=$this->getEloWinProbability($other["rating"], $member["rating"]);
127 127
                 }
128 128
             }
129 129
         }
130 130
         unset($member);
131 131
 
132
-        foreach($this->contestants as &$contestant){
133
-            $midRank = sqrt($contestant["rank"] * $contestant["seed"]);
134
-            $contestant["needRating"] = $this->getRatingToRank($midRank);
135
-            $contestant["delta"] = floor(($contestant["needRating"] - $contestant["rating"])/2);
132
+        foreach ($this->contestants as &$contestant) {
133
+            $midRank=sqrt($contestant["rank"] * $contestant["seed"]);
134
+            $contestant["needRating"]=$this->getRatingToRank($midRank);
135
+            $contestant["delta"]=floor(($contestant["needRating"]-$contestant["rating"]) / 2);
136 136
         }
137 137
         unset($contestant);
138 138
 
@@ -140,39 +140,39 @@  discard block
 block discarded – undo
140 140
 
141 141
         // DO some adjuct
142 142
         // Total sum should not be more than ZERO.
143
-        $sum = 0;
143
+        $sum=0;
144 144
 
145
-        foreach($this->contestants as $contestant){
146
-            $sum += $contestant["delta"];
145
+        foreach ($this->contestants as $contestant) {
146
+            $sum+=$contestant["delta"];
147 147
         }
148
-        $inc = -floor($sum / $this->totParticipants) - 1;
149
-        foreach($this->contestants as &$contestant){
150
-            $contestant["delta"] += $inc;
148
+        $inc=-floor($sum / $this->totParticipants)-1;
149
+        foreach ($this->contestants as &$contestant) {
150
+            $contestant["delta"]+=$inc;
151 151
         }
152 152
         unset($contestant);
153 153
 
154 154
         // Sum of top-4*sqrt should be adjusted to ZERO.
155 155
 
156
-        $sum = 0;
157
-        $zeroSumCount = min(intval(4*round(sqrt($this->totParticipants))), $this->totParticipants);
156
+        $sum=0;
157
+        $zeroSumCount=min(intval(4 * round(sqrt($this->totParticipants))), $this->totParticipants);
158 158
 
159
-        for($i=0;$i<$zeroSumCount;$i++){
160
-            $sum += $this->contestants[$i]["delta"];
159
+        for ($i=0; $i<$zeroSumCount; $i++) {
160
+            $sum+=$this->contestants[$i]["delta"];
161 161
         }
162 162
 
163
-        $inc = min(max(-floor($sum / $zeroSumCount), -10), 0);
163
+        $inc=min(max(-floor($sum / $zeroSumCount), -10), 0);
164 164
 
165
-        for($i=0;$i<$zeroSumCount;$i++){
166
-            $this->contestants[$i]["delta"] += $inc;
165
+        for ($i=0; $i<$zeroSumCount; $i++) {
166
+            $this->contestants[$i]["delta"]+=$inc;
167 167
         }
168 168
 
169 169
         return $this->validateDeltas();
170 170
     }
171 171
 
172
-    public function storage(){
172
+    public function storage() {
173 173
         $contestants=$this->contestants;
174
-        DB::transaction(function () use ($contestants) {
175
-            foreach($contestants as $contestant){
174
+        DB::transaction(function() use ($contestants) {
175
+            foreach ($contestants as $contestant) {
176 176
                 $newRating=$contestant["rating"]+$contestant["delta"];
177 177
                 DB::table("group_member")->where([
178 178
                     'gid' => $this->gid,
@@ -190,20 +190,20 @@  discard block
 block discarded – undo
190 190
         }, 5);
191 191
     }
192 192
 
193
-    private function validateDeltas(){
193
+    private function validateDeltas() {
194 194
         $this->sort("points");
195 195
 
196
-        for($i=0;$i<$this->totParticipants;$i++){
197
-            for($j=$i+1;$j<$this->totParticipants;$j++){
198
-                if($this->contestants[$i]["rating"] > $this->contestants[$j]["rating"]){
199
-                    if($this->contestants[$i]["rating"] + $this->contestants[$i]["delta"] < $this->contestants[$j]["rating"] + $this->contestants[$j]["delta"]){
196
+        for ($i=0; $i<$this->totParticipants; $i++) {
197
+            for ($j=$i+1; $j<$this->totParticipants; $j++) {
198
+                if ($this->contestants[$i]["rating"]>$this->contestants[$j]["rating"]) {
199
+                    if ($this->contestants[$i]["rating"]+$this->contestants[$i]["delta"]<$this->contestants[$j]["rating"]+$this->contestants[$j]["delta"]) {
200 200
                         Log::warning("First rating invariant failed: {$this->contestants[$i]["uid"]} vs. {$this->contestants[$j]["uid"]}.");
201 201
                         return false;
202 202
                     }
203 203
                 }
204 204
 
205
-                if($this->contestants[$i]["rating"] < $this->contestants[$j]["rating"]){
206
-                    if($this->contestants[$i]["delta"] < $this->contestants[$j]["delta"]){
205
+                if ($this->contestants[$i]["rating"]<$this->contestants[$j]["rating"]) {
206
+                    if ($this->contestants[$i]["delta"]<$this->contestants[$j]["delta"]) {
207 207
                         Log::warning("Second rating invariant failed: {$this->contestants[$i]["uid"]} vs.  {$this->contestants[$j]["uid"]}.");
208 208
                         return false;
209 209
                     }
Please login to merge, or discard this patch.
app/Models/CompilerModel.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -100,11 +100,11 @@
 block discarded – undo
100 100
 
101 101
     public static function add($row)
102 102
     {
103
-        if(self::checkExist([
103
+        if (self::checkExist([
104 104
             "oid"=>$row["oid"],
105 105
             "lcode"=>$row["lcode"],
106 106
             "deleted"=>0
107
-        ])){
107
+        ])) {
108 108
             throw new Exception("Duplicate Language Code");
109 109
         }
110 110
         return DB::table('compiler')->insert($row);
Please login to merge, or discard this patch.
app/Models/ContestModel.php 3 patches
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -265,7 +265,7 @@
 block discarded – undo
265 265
                             $query=$query->where(["practice"=>$filter['practice']]);
266 266
                         }
267 267
                         $query->where('public', 1)
268
-                              ->where('audit_status', 1);
268
+                                ->where('audit_status', 1);
269 269
                     }
270 270
                 )
271 271
                 ->orWhere(
Please login to merge, or discard this patch.
Spacing   +232 added lines, -232 removed lines patch added patch discarded remove patch
@@ -114,8 +114,8 @@  discard block
 block discarded – undo
114 114
 
115 115
     public function gcode($cid)
116 116
     {
117
-        $gid = $this->gid($cid);
118
-        return DB::table('group')->where('gid','=',$gid)->first()["gcode"];
117
+        $gid=$this->gid($cid);
118
+        return DB::table('group')->where('gid', '=', $gid)->first()["gcode"];
119 119
     }
120 120
 
121 121
     public function runningContest()
@@ -140,19 +140,19 @@  discard block
 block discarded – undo
140 140
 
141 141
     public function listForSetting($gid)
142 142
     {
143
-        $uid = Auth::user()->id;
144
-        $group_contests = DB::table('contest')
145
-            ->where('gid',$gid)
146
-            ->orderBy('begin_time','desc')
143
+        $uid=Auth::user()->id;
144
+        $group_contests=DB::table('contest')
145
+            ->where('gid', $gid)
146
+            ->orderBy('begin_time', 'desc')
147 147
             ->get()->all();
148
-        $groupModel = new GroupModel();
149
-        $group_clearance = $groupModel->judgeClearance($gid,$uid);
148
+        $groupModel=new GroupModel();
149
+        $group_clearance=$groupModel->judgeClearance($gid, $uid);
150 150
         foreach ($group_contests as &$contest) {
151
-            $contest['is_admin'] = ($contest['assign_uid'] == $uid || $group_clearance == 3);
152
-            $contest['begin_stamps'] = strtotime($contest['begin_time']);
153
-            $contest['end_stamps'] = strtotime($contest['end_time']);
154
-            $contest['status'] = time() >= $contest['end_stamps'] ? 1
155
-                : (time() <= $contest['begin_stamps'] ? -1 : 0);
151
+            $contest['is_admin']=($contest['assign_uid']==$uid || $group_clearance==3);
152
+            $contest['begin_stamps']=strtotime($contest['begin_time']);
153
+            $contest['end_stamps']=strtotime($contest['end_time']);
154
+            $contest['status']=time()>=$contest['end_stamps'] ? 1
155
+                : (time()<=$contest['begin_stamps'] ? -1 : 0);
156 156
             $contest["rule_parsed"]=$this->rule[$contest["rule"]];
157 157
             $contest["date_parsed"]=[
158 158
                 "date"=>date_format(date_create($contest["begin_time"]), 'j'),
@@ -160,11 +160,11 @@  discard block
 block discarded – undo
160 160
             ];
161 161
             $contest["length"]=$this->calcLength($contest["begin_time"], $contest["end_time"]);
162 162
         }
163
-        usort($group_contests,function($a,$b){
164
-            if($a['is_admin'] == $b['is_admin']){
165
-                return $b['begin_stamps'] - $a['begin_stamps'];
163
+        usort($group_contests, function($a, $b) {
164
+            if ($a['is_admin']==$b['is_admin']) {
165
+                return $b['begin_stamps']-$a['begin_stamps'];
166 166
             }
167
-            return $b['is_admin'] - $a['is_admin'];
167
+            return $b['is_admin']-$a['is_admin'];
168 168
         });
169 169
         return $group_contests;
170 170
     }
@@ -175,9 +175,9 @@  discard block
 block discarded – undo
175 175
         //     "gid"=>$gid
176 176
         // ])->orderBy('begin_time', 'desc')->get()->all();
177 177
         $preQuery=DB::table($this->tableName);
178
-        $paginator=$preQuery->where('gid','=',$gid)->orderBy('begin_time', 'desc')->paginate(10);
178
+        $paginator=$preQuery->where('gid', '=', $gid)->orderBy('begin_time', 'desc')->paginate(10);
179 179
         $contest_list=$paginator->all();
180
-        if(empty($contest_list)){
180
+        if (empty($contest_list)) {
181 181
             return null;
182 182
         }
183 183
 
@@ -202,7 +202,7 @@  discard block
 block discarded – undo
202 202
         ])->first()["rule"];
203 203
     }
204 204
 
205
-    public function list($filter,$uid)
205
+    public function list($filter, $uid)
206 206
     {
207 207
         if ($uid) {
208 208
             //$paginator=DB::select('SELECT DISTINCT contest.* FROM group_member inner join contest on group_member.gid=contest.gid left join contest_participant on contest.cid=contest_participant.cid where (public=1 and audit=1) or (group_member.uid=:uid and group_member.role>0 and (contest_participant.uid=:uidd or ISNULL(contest_participant.uid)) and (registration=0 or (registration=1 and not ISNULL(contest_participant.uid))))',["uid"=>$uid,"uidd"=>$uid])->paginate(10);
@@ -226,15 +226,15 @@  discard block
 block discarded – undo
226 226
                 if ($filter['practice']) {
227 227
                     $paginator=$paginator->where(["practice"=>$filter['practice']]);
228 228
                 }
229
-                $paginator = $paginator ->paginate(10);
230
-            }elseif($filter['public']=='0'){
229
+                $paginator=$paginator ->paginate(10);
230
+            }elseif ($filter['public']=='0') {
231 231
                 $paginator=DB::table('group_member')
232 232
                 ->groupBy('contest.cid')
233 233
                 ->select('contest.*')
234 234
                 ->join('contest', 'group_member.gid', '=', 'contest.gid')
235 235
                 ->leftJoin('contest_participant', 'contest.cid', '=', 'contest_participant.cid')
236 236
                 ->where(
237
-                    function ($query) use ($filter,$uid) {
237
+                    function($query) use ($filter, $uid) {
238 238
                         if ($filter['rule']) {
239 239
                             $query=$query->where(["rule"=>$filter['rule']]);
240 240
                         }
@@ -257,14 +257,14 @@  discard block
 block discarded – undo
257 257
                 )
258 258
                 ->orderBy('contest.begin_time', 'desc')
259 259
                 ->paginate(10);
260
-            }else{
260
+            } else {
261 261
                 $paginator=DB::table('group_member')
262 262
                 ->groupBy('contest.cid')
263 263
                 ->select('contest.*')
264 264
                 ->join('contest', 'group_member.gid', '=', 'contest.gid')
265 265
                 ->leftJoin('contest_participant', 'contest.cid', '=', 'contest_participant.cid')
266 266
                 ->where(
267
-                    function ($query) use ($filter) {
267
+                    function($query) use ($filter) {
268 268
                         if ($filter['rule']) {
269 269
                             $query=$query->where(["rule"=>$filter['rule']]);
270 270
                         }
@@ -285,7 +285,7 @@  discard block
 block discarded – undo
285 285
                     }
286 286
                 )
287 287
                 ->orWhere(
288
-                    function ($query) use ($filter,$uid) {
288
+                    function($query) use ($filter, $uid) {
289 289
                         if ($filter['rule']) {
290 290
                             $query=$query->where(["rule"=>$filter['rule']]);
291 291
                         }
@@ -331,7 +331,7 @@  discard block
 block discarded – undo
331 331
             if ($filter['practice']) {
332 332
                 $paginator=$paginator->where(["practice"=>$filter['practice']]);
333 333
             }
334
-            $paginator = $paginator ->paginate(10);
334
+            $paginator=$paginator ->paginate(10);
335 335
         }
336 336
         $contest_list=$paginator->all();
337 337
         foreach ($contest_list as &$c) {
@@ -369,14 +369,14 @@  discard block
 block discarded – undo
369 369
         }
370 370
     }
371 371
 
372
-    public function registContest($cid,$uid)
372
+    public function registContest($cid, $uid)
373 373
     {
374 374
         $registered=DB::table("contest_participant")->where([
375 375
             "cid"=>$cid,
376 376
             "uid"=>$uid
377 377
         ])->first();
378 378
 
379
-        if(empty($registered)){
379
+        if (empty($registered)) {
380 380
             DB::table("contest_participant")->insert([
381 381
                 "cid"=>$cid,
382 382
                 "uid"=>$uid,
@@ -384,7 +384,7 @@  discard block
 block discarded – undo
384 384
             ]);
385 385
             $name=User::find($uid)->name;
386 386
             $contest=$this->basic($cid);
387
-            $url=route('contest.detail',['cid' => $cid]);
387
+            $url=route('contest.detail', ['cid' => $cid]);
388 388
             sendMessage([
389 389
                 'receiver' => $uid,
390 390
                 'sender' => 1, // potential bugs
@@ -418,9 +418,9 @@  discard block
 block discarded – undo
418 418
     public function problems($cid)
419 419
     {
420 420
         return DB::table('contest_problem')
421
-            ->join('problem','contest_problem.pid','=','problem.pid')
422
-            ->where('cid',$cid)
423
-            ->select('problem.pid as pid','pcode','number')
421
+            ->join('problem', 'contest_problem.pid', '=', 'problem.pid')
422
+            ->where('cid', $cid)
423
+            ->select('problem.pid as pid', 'pcode', 'number')
424 424
             ->orderBy('number')
425 425
             ->get()->all();
426 426
     }
@@ -442,18 +442,18 @@  discard block
 block discarded – undo
442 442
         $end_time=strtotime(DB::table("contest")->where(["cid"=>$cid])->select("end_time")->first()["end_time"]);
443 443
 
444 444
         foreach ($problemSet as &$p) {
445
-            if($p['practice']){
446
-                $tags = DB::table("group_problem_tag")
447
-                ->where('gid',$p['gid'])
448
-                ->where('pid',$p['pid'])
445
+            if ($p['practice']) {
446
+                $tags=DB::table("group_problem_tag")
447
+                ->where('gid', $p['gid'])
448
+                ->where('pid', $p['pid'])
449 449
                 ->get()->all();
450
-                $tags_arr = [];
451
-                if(!empty($tags)){
450
+                $tags_arr=[];
451
+                if (!empty($tags)) {
452 452
                     foreach ($tags as $value) {
453
-                        array_push($tags_arr,$value['tag']);
453
+                        array_push($tags_arr, $value['tag']);
454 454
                     }
455 455
                 }
456
-                $p['tags'] = $tags_arr;
456
+                $p['tags']=$tags_arr;
457 457
             }
458 458
             if ($contest_rule==1) {
459 459
                 $prob_stat=DB::table("submission")->select(
@@ -714,7 +714,7 @@  discard block
 block discarded – undo
714 714
                     "problem_detail" => $prob_detail
715 715
                 ];
716 716
             }
717
-            usort($ret, function ($a, $b) {
717
+            usort($ret, function($a, $b) {
718 718
                 if ($a["score"]==$b["score"]) {
719 719
                     if ($a["penalty"]==$b["penalty"]) {
720 720
                         return 0;
@@ -761,7 +761,7 @@  discard block
 block discarded – undo
761 761
                     "problem_detail" => $prob_detail
762 762
                 ];
763 763
             }
764
-            usort($ret, function ($a, $b) {
764
+            usort($ret, function($a, $b) {
765 765
                 if ($a["score"]==$b["score"]) {
766 766
                     if ($a["solved"]==$b["solved"]) {
767 767
                         return 0;
@@ -783,7 +783,7 @@  discard block
 block discarded – undo
783 783
         return $ret;
784 784
     }
785 785
 
786
-    public function contestRank($cid, $uid = 0)
786
+    public function contestRank($cid, $uid=0)
787 787
     {
788 788
         // [ToDo] If the current user's in the organizer group show nick name
789 789
         // [ToDo] The participants determination
@@ -800,36 +800,36 @@  discard block
 block discarded – undo
800 800
             "gid" => $contest_info["gid"]
801 801
         ])->where("role", ">", 0)->first());
802 802
 
803
-        $clearance = $this -> judgeClearance($cid, $uid);
803
+        $clearance=$this -> judgeClearance($cid, $uid);
804 804
 
805 805
         /** New Version With MySQL */
806 806
         $end_time=strtotime(DB::table("contest")->where(["cid"=>$cid])->select("end_time")->first()["end_time"]);
807
-        $contest_eloquent = EloquentContestModel::find($cid);
807
+        $contest_eloquent=EloquentContestModel::find($cid);
808 808
 
809
-        if(time() < $end_time){
810
-            if($clearance == 3){
809
+        if (time()<$end_time) {
810
+            if ($clearance==3) {
811 811
                 $contestRankRaw=Cache::tags(['contest', 'rank'])->get("contestAdmin$cid");
812
-            }else{
812
+            } else {
813 813
                 $contestRankRaw=Cache::tags(['contest', 'rank'])->get($cid);
814 814
             }
815
-            if(!isset($contestRankRaw)){
815
+            if (!isset($contestRankRaw)) {
816 816
                 $contestRankRaw=$contest_eloquent->rankRefresh();
817 817
             }
818
-        }else{
819
-            if($clearance == 3){
818
+        } else {
819
+            if ($clearance==3) {
820 820
                 $contestRankRaw=Cache::tags(['contest', 'rank'])->get("contestAdmin$cid");
821 821
                 if (!isset($contestRankRaw)) {
822 822
                     $contestRankRaw=$this->getContestRankFromMySQL($cid);
823
-                    if(!isset($contestRankRaw)){
823
+                    if (!isset($contestRankRaw)) {
824 824
                         $contestRankRaw=$contest_eloquent->rankRefresh();
825 825
                         $this->storeContestRankInMySQL($cid, $contestRankRaw);
826 826
                     }
827 827
                 }
828
-            }else{
828
+            } else {
829 829
                 $contestRankRaw=$this->getContestRankFromMySQL($cid);
830
-                if(!isset($contestRankRaw)){
830
+                if (!isset($contestRankRaw)) {
831 831
                     $contestRankRaw=Cache::tags(['contest', 'rank'])->get($cid);
832
-                    if(!isset($contestRankRaw)){
832
+                    if (!isset($contestRankRaw)) {
833 833
                         $contestRankRaw=$contest_eloquent->rankRefresh();
834 834
                     }
835 835
                     $this->storeContestRankInMySQL($cid, $contestRankRaw);
@@ -847,15 +847,15 @@  discard block
 block discarded – undo
847 847
         //         $contestRankRaw=$this->contestRankCache($cid);
848 848
         //     }
849 849
         // }
850
-        if($contest_info["rule"]==1){
850
+        if ($contest_info["rule"]==1) {
851 851
             foreach ($contestRankRaw as &$cr) {
852
-                $solved = 0;
853
-                foreach($cr['problem_detail'] as $pd){
854
-                    if(!empty($pd['solved_time_parsed'])){
855
-                        $solved ++;
852
+                $solved=0;
853
+                foreach ($cr['problem_detail'] as $pd) {
854
+                    if (!empty($pd['solved_time_parsed'])) {
855
+                        $solved++;
856 856
                     }
857 857
                 }
858
-                $cr['solved'] = $solved;
858
+                $cr['solved']=$solved;
859 859
             }
860 860
         }
861 861
 
@@ -904,16 +904,16 @@  discard block
 block discarded – undo
904 904
 
905 905
     public function getClarificationList($cid)
906 906
     {
907
-        $uid = Auth::user()->id;
908
-        $clearance = $this -> judgeClearance($cid, $uid);
909
-        if($clearance == 3){
907
+        $uid=Auth::user()->id;
908
+        $clearance=$this -> judgeClearance($cid, $uid);
909
+        if ($clearance==3) {
910 910
             return DB::table("contest_clarification")->where([
911 911
                 "cid"=>$cid
912 912
             ])->orderBy('create_time', 'desc')->get()->all();
913
-        }else{
913
+        } else {
914 914
             return DB::table("contest_clarification")->where([
915 915
                 "cid"=>$cid
916
-            ])->where(function ($query) {
916
+            ])->where(function($query) {
917 917
                 $query->where([
918 918
                     "public"=>1
919 919
                 ])->orWhere([
@@ -1059,7 +1059,7 @@  discard block
 block discarded – undo
1059 1059
     public function getContestRecord($filter, $cid)
1060 1060
     {
1061 1061
         $basicInfo=$this->basic($cid);
1062
-        $userInfo=DB::table('group_member')->where('gid',$basicInfo["gid"])->where('uid',Auth::user()->id)->get()->first();
1062
+        $userInfo=DB::table('group_member')->where('gid', $basicInfo["gid"])->where('uid', Auth::user()->id)->get()->first();
1063 1063
         $problemSet_temp=DB::table("contest_problem")->join("problem", "contest_problem.pid", "=", "problem.pid")->where([
1064 1064
             "cid"=>$cid
1065 1065
         ])->orderBy('ncode', 'asc')->select("ncode", "alias", "contest_problem.pid as pid", "title", "points", "tot_score")->get()->all();
@@ -1072,14 +1072,14 @@  discard block
 block discarded – undo
1072 1072
         $end_time=strtotime(DB::table("contest")->where(["cid"=>$cid])->select("end_time")->first()["end_time"]);
1073 1073
         $contestEnd=time()>$end_time;
1074 1074
 
1075
-        $filter['pid'] = array_search($filter['ncode'], array_column($problemSet_temp, 'ncode'));
1076
-        if($filter['pid']==false){
1077
-            $filter['pid'] = null;
1078
-        }else{
1079
-            $filter['pid'] = $problemSet_temp[$filter['pid']]['pid'];
1075
+        $filter['pid']=array_search($filter['ncode'], array_column($problemSet_temp, 'ncode'));
1076
+        if ($filter['pid']==false) {
1077
+            $filter['pid']=null;
1078
+        } else {
1079
+            $filter['pid']=$problemSet_temp[$filter['pid']]['pid'];
1080 1080
         }
1081 1081
 
1082
-        if($userInfo==null || $userInfo["role"]!=3){
1082
+        if ($userInfo==null || $userInfo["role"]!=3) {
1083 1083
             if ($basicInfo["status_visibility"]==2) {
1084 1084
                 // View all
1085 1085
                 $paginator=DB::table("submission")->where([
@@ -1093,7 +1093,7 @@  discard block
 block discarded – undo
1093 1093
                     "users.id",
1094 1094
                     "=",
1095 1095
                     "submission.uid"
1096
-                )->where(function ($query) use ($frozen_time) {
1096
+                )->where(function($query) use ($frozen_time) {
1097 1097
                     $query->where(
1098 1098
                         "submission_date",
1099 1099
                         "<",
@@ -1120,15 +1120,15 @@  discard block
 block discarded – undo
1120 1120
                     'desc'
1121 1121
                 );
1122 1122
 
1123
-                if($filter["pid"]){
1123
+                if ($filter["pid"]) {
1124 1124
                     $paginator=$paginator->where(["pid"=>$filter["pid"]]);
1125 1125
                 }
1126 1126
 
1127
-                if($filter["result"]){
1127
+                if ($filter["result"]) {
1128 1128
                     $paginator=$paginator->where(["verdict"=>$filter["result"]]);
1129 1129
                 }
1130 1130
 
1131
-                if($filter["account"]){
1131
+                if ($filter["account"]) {
1132 1132
                     $paginator=$paginator->where(["name"=>$filter["account"]]);
1133 1133
                 }
1134 1134
 
@@ -1164,15 +1164,15 @@  discard block
 block discarded – undo
1164 1164
                     'desc'
1165 1165
                 );
1166 1166
 
1167
-                if($filter["pid"]){
1167
+                if ($filter["pid"]) {
1168 1168
                     $paginator=$paginator->where(["pid"=>$filter["pid"]]);
1169 1169
                 }
1170 1170
 
1171
-                if($filter["result"]){
1171
+                if ($filter["result"]) {
1172 1172
                     $paginator=$paginator->where(["verdict"=>$filter["result"]]);
1173 1173
                 }
1174 1174
 
1175
-                if($filter["account"]){
1175
+                if ($filter["account"]) {
1176 1176
                     $paginator=$paginator->where(["name"=>$filter["account"]]);
1177 1177
                 }
1178 1178
 
@@ -1183,7 +1183,7 @@  discard block
 block discarded – undo
1183 1183
                     "records"=>[]
1184 1184
                 ];
1185 1185
             }
1186
-        }else{
1186
+        } else {
1187 1187
             if ($basicInfo["status_visibility"]==2) {
1188 1188
                 // View all
1189 1189
                 $paginator=DB::table("submission")->where([
@@ -1215,15 +1215,15 @@  discard block
 block discarded – undo
1215 1215
                     'desc'
1216 1216
                 );
1217 1217
 
1218
-                if($filter["pid"]){
1218
+                if ($filter["pid"]) {
1219 1219
                     $paginator=$paginator->where(["pid"=>$filter["pid"]]);
1220 1220
                 }
1221 1221
 
1222
-                if($filter["result"]){
1222
+                if ($filter["result"]) {
1223 1223
                     $paginator=$paginator->where(["verdict"=>$filter["result"]]);
1224 1224
                 }
1225 1225
 
1226
-                if($filter["account"]){
1226
+                if ($filter["account"]) {
1227 1227
                     $paginator=$paginator->where(["name"=>$filter["account"]]);
1228 1228
                 }
1229 1229
 
@@ -1259,15 +1259,15 @@  discard block
 block discarded – undo
1259 1259
                     'desc'
1260 1260
                 );
1261 1261
 
1262
-                if($filter["pid"]){
1262
+                if ($filter["pid"]) {
1263 1263
                     $paginator=$paginator->where(["pid"=>$filter["pid"]]);
1264 1264
                 }
1265 1265
 
1266
-                if($filter["result"]){
1266
+                if ($filter["result"]) {
1267 1267
                     $paginator=$paginator->where(["verdict"=>$filter["result"]]);
1268 1268
                 }
1269 1269
 
1270
-                if($filter["account"]){
1270
+                if ($filter["account"]) {
1271 1271
                     $paginator=$paginator->where(["name"=>$filter["account"]]);
1272 1272
                 }
1273 1273
 
@@ -1323,21 +1323,21 @@  discard block
 block discarded – undo
1323 1323
         if ($uid==0) {
1324 1324
             return 0;
1325 1325
         }
1326
-        $groupModel = new GroupModel();
1326
+        $groupModel=new GroupModel();
1327 1327
         $contest_info=DB::table("contest")->where("cid", $cid)->first();
1328
-        $userInfo=DB::table('group_member')->where('gid',$contest_info["gid"])->where('uid',$uid)->get()->first();
1328
+        $userInfo=DB::table('group_member')->where('gid', $contest_info["gid"])->where('uid', $uid)->get()->first();
1329 1329
 
1330
-        if(empty($contest_info)){
1330
+        if (empty($contest_info)) {
1331 1331
             // contest not exist
1332 1332
             return 0;
1333 1333
         }
1334 1334
 
1335
-        if($uid == $contest_info['assign_uid'] || $groupModel->judgeClearance($contest_info['gid'],$uid) == 3){
1335
+        if ($uid==$contest_info['assign_uid'] || $groupModel->judgeClearance($contest_info['gid'], $uid)==3) {
1336 1336
             return 3;
1337 1337
         }
1338 1338
 
1339
-        $contest_started = strtotime($contest_info['begin_time']) < time();
1340
-        $contest_ended = strtotime($contest_info['end_time']) < time();
1339
+        $contest_started=strtotime($contest_info['begin_time'])<time();
1340
+        $contest_ended=strtotime($contest_info['end_time'])<time();
1341 1341
         if (!$contest_started) {
1342 1342
             // not started or do not exist
1343 1343
             return 0;
@@ -1428,12 +1428,12 @@  discard block
 block discarded – undo
1428 1428
     public function updateProfessionalRate($cid)
1429 1429
     {
1430 1430
         $basic=$this->basic($cid);
1431
-        if($basic["rated"]&&!$basic["is_rated"]){
1431
+        if ($basic["rated"] && !$basic["is_rated"]) {
1432 1432
             $ratingCalculator=new RatingCalculator($cid);
1433
-            if($ratingCalculator->calculate()){
1433
+            if ($ratingCalculator->calculate()) {
1434 1434
                 $ratingCalculator->storage();
1435 1435
                 return true;
1436
-            }else{
1436
+            } else {
1437 1437
                 return false;
1438 1438
             }
1439 1439
         } else {
@@ -1441,26 +1441,26 @@  discard block
 block discarded – undo
1441 1441
         }
1442 1442
     }
1443 1443
 
1444
-    public function contestUpdate($cid,$data,$problems)
1444
+    public function contestUpdate($cid, $data, $problems)
1445 1445
     {
1446
-        if($problems !== false){
1447
-            $old_problmes = array_column(
1446
+        if ($problems!==false) {
1447
+            $old_problmes=array_column(
1448 1448
                 DB::table('contest_problem')
1449
-                ->where('cid',$cid)
1449
+                ->where('cid', $cid)
1450 1450
                 ->get()->all(),
1451 1451
                 'pid'
1452 1452
             );
1453
-            DB::transaction(function () use ($cid, $data, $problems,$old_problmes) {
1453
+            DB::transaction(function() use ($cid, $data, $problems, $old_problmes) {
1454 1454
                 DB::table($this->tableName)
1455
-                    ->where('cid',$cid)
1455
+                    ->where('cid', $cid)
1456 1456
                     ->update($data);
1457 1457
                 DB::table('contest_problem')
1458
-                    ->where('cid',$cid)
1458
+                    ->where('cid', $cid)
1459 1459
                     ->delete();
1460
-                $new_problems = [];
1460
+                $new_problems=[];
1461 1461
                 foreach ($problems as $p) {
1462 1462
                     $pid=DB::table("problem")->where(["pcode"=>$p["pcode"]])->select("pid")->first()["pid"];
1463
-                    array_push($new_problems,$pid);
1463
+                    array_push($new_problems, $pid);
1464 1464
                     DB::table("contest_problem")->insert([
1465 1465
                         "cid"=>$cid,
1466 1466
                         "number"=>$p["number"],
@@ -1470,29 +1470,29 @@  discard block
 block discarded – undo
1470 1470
                         "points"=>$p["points"]
1471 1471
                     ]);
1472 1472
                 }
1473
-                foreach($old_problmes as $op) {
1474
-                    if(!in_array($op,$new_problems)){
1473
+                foreach ($old_problmes as $op) {
1474
+                    if (!in_array($op, $new_problems)) {
1475 1475
                         DB::table('submission')
1476
-                            ->where('cid',$cid)
1477
-                            ->where('pid',$op)
1476
+                            ->where('cid', $cid)
1477
+                            ->where('pid', $op)
1478 1478
                             ->delete();
1479 1479
                     }
1480 1480
                 }
1481 1481
             }, 5);
1482
-            $contestRankRaw = $this->contestRankCache($cid);
1482
+            $contestRankRaw=$this->contestRankCache($cid);
1483 1483
             Cache::tags(['contest', 'rank'])->put($cid, $contestRankRaw);
1484 1484
             Cache::tags(['contest', 'rank'])->put("contestAdmin$cid", $contestRankRaw);
1485
-        }else{
1485
+        } else {
1486 1486
             DB::table($this->tableName)
1487
-                ->where('cid',$cid)
1487
+                ->where('cid', $cid)
1488 1488
                 ->update($data);
1489 1489
         }
1490 1490
     }
1491 1491
 
1492
-    public function contestUpdateProblem($cid,$problems)
1492
+    public function contestUpdateProblem($cid, $problems)
1493 1493
     {
1494 1494
         DB::table('contest_problem')
1495
-                ->where('cid',$cid)
1495
+                ->where('cid', $cid)
1496 1496
                 ->delete();
1497 1497
         foreach ($problems as $p) {
1498 1498
             DB::table("contest_problem")->insertGetId([
@@ -1508,8 +1508,8 @@  discard block
 block discarded – undo
1508 1508
 
1509 1509
     public function arrangeContest($gid, $config, $problems)
1510 1510
     {
1511
-        $cid = -1;
1512
-        DB::transaction(function () use ($gid, $config, $problems,&$cid) {
1511
+        $cid=-1;
1512
+        DB::transaction(function() use ($gid, $config, $problems, &$cid) {
1513 1513
             $cid=DB::table($this->tableName)->insertGetId([
1514 1514
                 "gid"=>$gid,
1515 1515
                 "name"=>$config["name"],
@@ -1523,7 +1523,7 @@  discard block
 block discarded – undo
1523 1523
                 "rule"=>1, //todo
1524 1524
                 "begin_time"=>$config["begin_time"],
1525 1525
                 "end_time"=>$config["end_time"],
1526
-                "vcid"=>isset($config["vcid"])?$config["vcid"]:null,
1526
+                "vcid"=>isset($config["vcid"]) ? $config["vcid"] : null,
1527 1527
                 "public"=>$config["public"],
1528 1528
                 "registration"=>0, //todo
1529 1529
                 "registration_due"=>null, //todo
@@ -1531,7 +1531,7 @@  discard block
 block discarded – undo
1531 1531
                 "froze_length"=>0, //todo
1532 1532
                 "status_visibility"=>2, //todo
1533 1533
                 "create_time"=>date("Y-m-d H:i:s"),
1534
-                "crawled" => isset($config['vcid'])?$config['crawled'] : null,
1534
+                "crawled" => isset($config['vcid']) ? $config['crawled'] : null,
1535 1535
                 "audit_status"=>$config["public"] ? 0 : 1
1536 1536
             ]);
1537 1537
 
@@ -1550,13 +1550,13 @@  discard block
 block discarded – undo
1550 1550
         return $cid;
1551 1551
     }
1552 1552
 
1553
-    public function updateContestRankTable($cid,$sub)
1553
+    public function updateContestRankTable($cid, $sub)
1554 1554
     {
1555
-        $lock = Cache::lock("contestrank$cid",10);
1556
-        try{
1557
-            if($lock->get()){
1558
-                if(Cache::tags(['contest','rank'])->get($cid) != null){
1559
-                    $ret = Cache::tags(['contest','rank'])->get($cid);
1555
+        $lock=Cache::lock("contestrank$cid", 10);
1556
+        try {
1557
+            if ($lock->get()) {
1558
+                if (Cache::tags(['contest', 'rank'])->get($cid)!=null) {
1559
+                    $ret=Cache::tags(['contest', 'rank'])->get($cid);
1560 1560
                     $chache=[];
1561 1561
                     $chache['contest_info']=DB::table("contest")->where("cid", $cid)->first();
1562 1562
                     $chache['problemSet']=DB::table("contest_problem")->join("problem", "contest_problem.pid", "=", "problem.pid")->where([
@@ -1565,27 +1565,27 @@  discard block
 block discarded – undo
1565 1565
                     $chache['frozen_time']=DB::table("contest")->where(["cid"=>$cid])->select(DB::raw("UNIX_TIMESTAMP(end_time)-froze_length as frozen_time"))->first()["frozen_time"];
1566 1566
                     $chache['end_time']=strtotime(DB::table("contest")->where(["cid"=>$cid])->select("end_time")->first()["end_time"]);
1567 1567
 
1568
-                    $id = 0;
1568
+                    $id=0;
1569 1569
 
1570
-                    foreach($chache['problemSet'] as $key => $p){
1571
-                        if ($p['pid'] == $sub['pid']){
1572
-                            $chache['problemSet'][$key]['cpid'] = $key;
1573
-                            $id = $key;
1570
+                    foreach ($chache['problemSet'] as $key => $p) {
1571
+                        if ($p['pid']==$sub['pid']) {
1572
+                            $chache['problemSet'][$key]['cpid']=$key;
1573
+                            $id=$key;
1574 1574
                         }
1575 1575
                     }
1576 1576
 
1577
-                    $ret = $this->updateContestRankDetail($chache['contest_info'],$chache['problemSet'][$id],$cid,$sub['uid'],$ret);
1578
-                    $ret = $this->sortContestRankTable($chache['contest_info'],$cid,$ret);
1577
+                    $ret=$this->updateContestRankDetail($chache['contest_info'], $chache['problemSet'][$id], $cid, $sub['uid'], $ret);
1578
+                    $ret=$this->sortContestRankTable($chache['contest_info'], $cid, $ret);
1579 1579
 
1580
-                    if (time() < $chache['frozen_time']){
1580
+                    if (time()<$chache['frozen_time']) {
1581 1581
                         Cache::tags(['contest', 'rank'])->put($cid, $ret);
1582 1582
                     }
1583 1583
                     Cache::tags(['contest', 'rank'])->put("contestAdmin$cid", $ret);
1584
-                    if(time() > $chache['end_time']){
1584
+                    if (time()>$chache['end_time']) {
1585 1585
                         $this->storeContestRankInMySQL($cid, $ret);
1586 1586
                     }
1587 1587
                 }
1588
-                else{
1588
+                else {
1589 1589
                     $ret=[];
1590 1590
                     $chache=[];
1591 1591
                     $chache['contest_info']=DB::table("contest")->where("cid", $cid)->first();
@@ -1600,7 +1600,7 @@  discard block
 block discarded – undo
1600 1600
                             "cid"=>$cid,
1601 1601
                             "audit"=>1
1602 1602
                         ])->select('uid')->get()->all();
1603
-                    }else{
1603
+                    } else {
1604 1604
                         $submissionUsers=DB::table("submission")->where([
1605 1605
                             "cid"=>$cid
1606 1606
                         ])->where(
@@ -1613,39 +1613,39 @@  discard block
 block discarded – undo
1613 1613
                         ])->select('uid')->groupBy('uid')->get()->all();
1614 1614
                     }
1615 1615
 
1616
-                    $chacheAdmin = $chache;
1616
+                    $chacheAdmin=$chache;
1617 1617
 
1618 1618
                     foreach ($submissionUsers as $s) {
1619 1619
                         foreach ($chache['problemSet'] as $key => $p) {
1620
-                            $p['cpid'] = $key;
1621
-                            $ret = $this->updateContestRankDetail($chache['contest_info'],$p,$cid,$s['uid'],$ret);
1620
+                            $p['cpid']=$key;
1621
+                            $ret=$this->updateContestRankDetail($chache['contest_info'], $p, $cid, $s['uid'], $ret);
1622 1622
                         }
1623 1623
                     }
1624
-                    $ret = $this->sortContestRankTable($chache['contest_info'],$cid,$ret);
1624
+                    $ret=$this->sortContestRankTable($chache['contest_info'], $cid, $ret);
1625 1625
                     Cache::tags(['contest', 'rank'])->put($cid, $ret);
1626 1626
 
1627 1627
                     $retAdmin=[];
1628 1628
                     foreach ($submissionUsersAdmin as $s) {
1629 1629
                         foreach ($chacheAdmin['problemSet'] as $key => $p) {
1630
-                            $p['cpid'] = $key;
1631
-                            $retAdmin = $this->updateContestRankDetail($chacheAdmin['contest_info'],$p,$cid,$s['uid'],$retAdmin);
1630
+                            $p['cpid']=$key;
1631
+                            $retAdmin=$this->updateContestRankDetail($chacheAdmin['contest_info'], $p, $cid, $s['uid'], $retAdmin);
1632 1632
                         }
1633 1633
                     }
1634
-                    $retAdmin = $this->sortContestRankTable($chacheAdmin['contest_info'],$cid,$retAdmin);
1634
+                    $retAdmin=$this->sortContestRankTable($chacheAdmin['contest_info'], $cid, $retAdmin);
1635 1635
                     Cache::tags(['contest', 'rank'])->put("contestAdmin$cid", $retAdmin);
1636 1636
                 }
1637 1637
             }
1638
-        }catch(LockTimeoutException $e){
1638
+        } catch (LockTimeoutException $e) {
1639 1639
             Log::warning("Contest Rank Lock Timed Out");
1640
-        }finally{
1640
+        } finally {
1641 1641
             optional($lock)->release();
1642 1642
         }
1643 1643
     }
1644 1644
 
1645
-    public function sortContestRankTable($contest_info,$cid,$ret)
1645
+    public function sortContestRankTable($contest_info, $cid, $ret)
1646 1646
     {
1647
-        if ($contest_info["rule"]==1){
1648
-            usort($ret, function ($a, $b) {
1647
+        if ($contest_info["rule"]==1) {
1648
+            usort($ret, function($a, $b) {
1649 1649
                 if ($a["score"]==$b["score"]) {
1650 1650
                     if ($a["penalty"]==$b["penalty"]) {
1651 1651
                         return 0;
@@ -1660,8 +1660,8 @@  discard block
 block discarded – undo
1660 1660
                     return 1;
1661 1661
                 }
1662 1662
             });
1663
-        }else if ($contest_info["rule"]==2){
1664
-            usort($ret, function ($a, $b) {
1663
+        } else if ($contest_info["rule"]==2) {
1664
+            usort($ret, function($a, $b) {
1665 1665
                 if ($a["score"]==$b["score"]) {
1666 1666
                     if ($a["solved"]==$b["solved"]) {
1667 1667
                         return 0;
@@ -1680,21 +1680,21 @@  discard block
 block discarded – undo
1680 1680
         return $ret;
1681 1681
     }
1682 1682
 
1683
-    public function updateContestRankDetail($contest_info,$problem,$cid,$uid,$ret)
1683
+    public function updateContestRankDetail($contest_info, $problem, $cid, $uid, $ret)
1684 1684
     {
1685
-        $id = count($ret);
1686
-        foreach($ret as $key => $r){
1687
-            if($r['uid'] == $uid)
1688
-                $id = $key;
1685
+        $id=count($ret);
1686
+        foreach ($ret as $key => $r) {
1687
+            if ($r['uid']==$uid)
1688
+                $id=$key;
1689 1689
         }
1690 1690
         if ($contest_info["rule"]==1) {
1691 1691
             // ACM/ICPC Mode
1692
-            if($id == count($ret)){
1693
-                $prob_detail = [];
1694
-                $totPen = 0;
1695
-                $totScore = 0;
1696
-            }else{
1697
-                $prob_detail = $ret[$id]['problem_detail'];
1692
+            if ($id==count($ret)) {
1693
+                $prob_detail=[];
1694
+                $totPen=0;
1695
+                $totScore=0;
1696
+            } else {
1697
+                $prob_detail=$ret[$id]['problem_detail'];
1698 1698
                 $totPen=$ret[$id]['penalty'];
1699 1699
                 $totScore=$ret[$id]['score'];
1700 1700
             };
@@ -1712,7 +1712,7 @@  discard block
 block discarded – undo
1712 1712
                 "uid"=>$uid,
1713 1713
             ])->orderBy('submission_date', 'desc')->first();
1714 1714
 
1715
-            if ($ac_times<=1 && isset($last_record) && $last_record['verdict']!="Waiting" && $last_record['verdict']!="Submission Error" && $last_record['verdict']!="System Error"){
1715
+            if ($ac_times<=1 && isset($last_record) && $last_record['verdict']!="Waiting" && $last_record['verdict']!="Submission Error" && $last_record['verdict']!="System Error") {
1716 1716
                 $prob_stat=$this->contestProblemInfoACM($cid, $problem["pid"], $uid);
1717 1717
 
1718 1718
                 $prob_detail[$problem['cpid']]=[
@@ -1744,12 +1744,12 @@  discard block
 block discarded – undo
1744 1744
             }
1745 1745
         } elseif ($contest_info["rule"]==2) {
1746 1746
             // IOI Mode
1747
-            if($id == count($ret)){
1748
-                $prob_detail = [];
1749
-                $totSolved = 0;
1750
-                $totScore = 0;
1751
-            }else{
1752
-                $prob_detail = $ret[$id]['problem_detail'];
1747
+            if ($id==count($ret)) {
1748
+                $prob_detail=[];
1749
+                $totSolved=0;
1750
+                $totScore=0;
1751
+            } else {
1752
+                $prob_detail=$ret[$id]['problem_detail'];
1753 1753
                 $totSolved=$ret[$id]['solved'];
1754 1754
                 $totScore=$ret[$id]['score'];
1755 1755
             };
@@ -1782,47 +1782,47 @@  discard block
 block discarded – undo
1782 1782
         return $ret;
1783 1783
     }
1784 1784
 
1785
-    public function assignMember($cid,$uid){
1785
+    public function assignMember($cid, $uid) {
1786 1786
         return DB::table("contest")->where(["cid"=>$cid])->update([
1787 1787
             "assign_uid"=>$uid
1788 1788
         ]);
1789 1789
     }
1790 1790
 
1791
-    public function canUpdateContestTime($cid,$time = [])
1791
+    public function canUpdateContestTime($cid, $time=[])
1792 1792
     {
1793
-        $begin_time_new = $time['begin'] ?? null;
1794
-        $end_time_new = $time['end'] ?? null;
1793
+        $begin_time_new=$time['begin'] ?? null;
1794
+        $end_time_new=$time['end'] ?? null;
1795 1795
 
1796
-        $hold_time = DB::table('contest')
1797
-            ->where('cid',$cid)
1798
-            ->select('begin_time','end_time')
1796
+        $hold_time=DB::table('contest')
1797
+            ->where('cid', $cid)
1798
+            ->select('begin_time', 'end_time')
1799 1799
             ->first();
1800
-        $begin_stamps = strtotime($hold_time['begin_time']);
1801
-        $end_stamps = strtotime($hold_time['end_time']);
1800
+        $begin_stamps=strtotime($hold_time['begin_time']);
1801
+        $end_stamps=strtotime($hold_time['end_time']);
1802 1802
         /*
1803 1803
         -1 : have not begun
1804 1804
          0 : ing
1805 1805
          1 : end
1806 1806
         */
1807
-        $status = time() >= $end_stamps ? 1
1808
-                : (time() <= $begin_stamps ? -1 : 0);
1809
-        if($status === -1){
1810
-            if(time() > $begin_time_new){
1807
+        $status=time()>=$end_stamps ? 1
1808
+                : (time()<=$begin_stamps ? -1 : 0);
1809
+        if ($status===-1) {
1810
+            if (time()>$begin_time_new) {
1811 1811
                 return false;
1812 1812
             }
1813 1813
             return true;
1814
-        }else if($status === 0){
1815
-            if($begin_time_new !== null){
1814
+        } else if ($status===0) {
1815
+            if ($begin_time_new!==null) {
1816 1816
                 return false;
1817 1817
             }
1818
-            if($end_time_new !== null){
1819
-                if(strtotime($end_time_new) <= time()){
1818
+            if ($end_time_new!==null) {
1819
+                if (strtotime($end_time_new)<=time()) {
1820 1820
                     return false;
1821
-                }else{
1821
+                } else {
1822 1822
                     return true;
1823 1823
                 }
1824 1824
             }
1825
-        }else{
1825
+        } else {
1826 1826
             return false;
1827 1827
         }
1828 1828
 
@@ -1831,22 +1831,22 @@  discard block
 block discarded – undo
1831 1831
 
1832 1832
     public function replyClarification($ccid, $content)
1833 1833
     {
1834
-        return DB::table("contest_clarification")->where('ccid','=',$ccid)->update([
1834
+        return DB::table("contest_clarification")->where('ccid', '=', $ccid)->update([
1835 1835
             "reply"=>$content
1836 1836
         ]);
1837 1837
     }
1838 1838
 
1839 1839
     public function setClarificationPublic($ccid, $public)
1840 1840
     {
1841
-        if($public)
1841
+        if ($public)
1842 1842
         {
1843
-            return DB::table("contest_clarification")->where('ccid','=',$ccid)->update([
1843
+            return DB::table("contest_clarification")->where('ccid', '=', $ccid)->update([
1844 1844
                 "public"=>1
1845 1845
             ]);
1846 1846
         }
1847 1847
         else
1848 1848
         {
1849
-            return DB::table("contest_clarification")->where('ccid','=',$ccid)->update([
1849
+            return DB::table("contest_clarification")->where('ccid', '=', $ccid)->update([
1850 1850
                 "public"=>0
1851 1851
             ]);
1852 1852
         }
@@ -1859,90 +1859,90 @@  discard block
 block discarded – undo
1859 1859
 
1860 1860
     public function praticeAnalysis($cid)
1861 1861
     {
1862
-        $gid = DB::table('contest')
1863
-            ->where('cid',$cid)
1862
+        $gid=DB::table('contest')
1863
+            ->where('cid', $cid)
1864 1864
             ->first()['gid'];
1865
-        $contestRank = $this->contestRank($cid,Auth::user()->id);
1866
-        if(!empty($contestRank)){
1867
-            $all_problems = DB::table('problem')
1868
-            ->whereIn('pid',array_column($contestRank[0]['problem_detail'],'pid'))
1869
-            ->select('pid','title')
1865
+        $contestRank=$this->contestRank($cid, Auth::user()->id);
1866
+        if (!empty($contestRank)) {
1867
+            $all_problems=DB::table('problem')
1868
+            ->whereIn('pid', array_column($contestRank[0]['problem_detail'], 'pid'))
1869
+            ->select('pid', 'title')
1870 1870
             ->get()->all();
1871
-        }else{
1872
-            $all_problems = [];
1871
+        } else {
1872
+            $all_problems=[];
1873 1873
         }
1874
-        $tags = DB::table('group_problem_tag')
1874
+        $tags=DB::table('group_problem_tag')
1875 1875
             ->where('gid', $gid)
1876
-            ->whereIn('pid', array_column($all_problems,'pid'))
1876
+            ->whereIn('pid', array_column($all_problems, 'pid'))
1877 1877
             ->get()->all();
1878
-        $all_tags = array_unique(array_column($tags,'tag'));
1879
-        $memberData = [];
1880
-        foreach($contestRank as $member){
1881
-            $m = [
1878
+        $all_tags=array_unique(array_column($tags, 'tag'));
1879
+        $memberData=[];
1880
+        foreach ($contestRank as $member) {
1881
+            $m=[
1882 1882
                 'uid' => $member['uid'],
1883 1883
                 'name' => $member['name'],
1884 1884
                 'nick_name' => $member['nick_name'],
1885 1885
             ];
1886
-            $completion = [];
1887
-            foreach ($all_tags as $tag){
1888
-                $completion[$tag] = [];
1886
+            $completion=[];
1887
+            foreach ($all_tags as $tag) {
1888
+                $completion[$tag]=[];
1889 1889
                 foreach ($tags as $t) {
1890
-                    if($t['tag'] == $tag){
1890
+                    if ($t['tag']==$tag) {
1891 1891
                         foreach ($member['problem_detail'] as $pd) {
1892
-                            if($pd['pid'] == $t['pid']){
1893
-                                $completion[$tag][$t['pid']] = $pd['solved_time_parsed'] == "" ? 0 : 1;
1892
+                            if ($pd['pid']==$t['pid']) {
1893
+                                $completion[$tag][$t['pid']]=$pd['solved_time_parsed']=="" ? 0 : 1;
1894 1894
                             }
1895 1895
                         }
1896 1896
                     }
1897 1897
                 }
1898 1898
             }
1899
-            $m['completion'] = $completion;
1900
-            $memberData[] = $m;
1899
+            $m['completion']=$completion;
1900
+            $memberData[]=$m;
1901 1901
         }
1902 1902
         return $memberData;
1903 1903
     }
1904 1904
 
1905 1905
     public function storeContestRankInMySQL($cid, $data)
1906 1906
     {
1907
-        $contestRankJson = json_encode($data);
1908
-        return DB::table('contest')->where('cid','=',$cid)->update([
1907
+        $contestRankJson=json_encode($data);
1908
+        return DB::table('contest')->where('cid', '=', $cid)->update([
1909 1909
             'rank' => $contestRankJson
1910 1910
         ]);
1911 1911
     }
1912 1912
 
1913 1913
     public function getContestRankFromMySQL($cid)
1914 1914
     {
1915
-        $contestRankJson = DB::table('contest')->where('cid','=',$cid)->pluck('rank')->first();
1916
-        $data = json_decode($contestRankJson, true);
1915
+        $contestRankJson=DB::table('contest')->where('cid', '=', $cid)->pluck('rank')->first();
1916
+        $data=json_decode($contestRankJson, true);
1917 1917
         return $data;
1918 1918
     }
1919 1919
 
1920 1920
     public function isVerified($cid)
1921 1921
     {
1922
-        return DB::table('contest')->where('cid','=',$cid)->pluck('verified')->first();
1922
+        return DB::table('contest')->where('cid', '=', $cid)->pluck('verified')->first();
1923 1923
     }
1924 1924
 
1925 1925
     public function getScrollBoardData($cid)
1926 1926
     {
1927
-        $members = DB::table("submission")
1928
-            ->join('users','users.id','=','submission.uid')
1927
+        $members=DB::table("submission")
1928
+            ->join('users', 'users.id', '=', 'submission.uid')
1929 1929
             ->join('contest', 'contest.cid', '=', 'submission.cid')
1930 1930
             ->join('group_member', 'users.id', '=', 'group_member.uid')
1931
-            ->where('submission.cid', $cid)->select('users.id as uid','users.name as name','group_member.nick_name as nick_name')
1931
+            ->where('submission.cid', $cid)->select('users.id as uid', 'users.name as name', 'group_member.nick_name as nick_name')
1932 1932
             ->groupBy('uid')->get()->all();
1933
-        $submissions = DB::table("submission")
1933
+        $submissions=DB::table("submission")
1934 1934
             ->where('cid', $cid)
1935 1935
             ->select('sid', 'verdict', 'submission_date', 'pid', 'uid')
1936 1936
             ->orderBy('submission_date')
1937 1937
             ->get()->all();
1938
-        $problems = DB::table('contest_problem')
1938
+        $problems=DB::table('contest_problem')
1939 1939
             ->where('cid', $cid)
1940
-            ->select('ncode','pid')
1940
+            ->select('ncode', 'pid')
1941 1941
             ->orderBy('ncode')
1942 1942
             ->get()->all();
1943
-        $contest = DB::table('contest')
1944
-            ->where('cid',$cid)
1945
-            ->select('begin_time','end_time','froze_length')
1943
+        $contest=DB::table('contest')
1944
+            ->where('cid', $cid)
1945
+            ->select('begin_time', 'end_time', 'froze_length')
1946 1946
             ->first();
1947 1947
         return [
1948 1948
             'members' => $members,
@@ -1954,16 +1954,16 @@  discard block
 block discarded – undo
1954 1954
 
1955 1955
     public function judgeOver($cid)
1956 1956
     {
1957
-        $submissions =  DB::table('submission')
1957
+        $submissions=DB::table('submission')
1958 1958
             ->where(['cid' => $cid])
1959
-            ->whereIn('verdict',['Waiting','Pending'])
1959
+            ->whereIn('verdict', ['Waiting', 'Pending'])
1960 1960
             ->select('sid')
1961 1961
             ->get()->all();
1962
-        if(empty($submissions)){
1962
+        if (empty($submissions)) {
1963 1963
             return [
1964 1964
                 'result' => true
1965 1965
             ];
1966
-        }else{
1966
+        } else {
1967 1967
             return [
1968 1968
                 'result' => false,
1969 1969
                 'sid' => $submissions
Please login to merge, or discard this patch.
Braces   +26 added lines, -27 removed lines patch added patch discarded remove patch
@@ -227,7 +227,7 @@  discard block
 block discarded – undo
227 227
                     $paginator=$paginator->where(["practice"=>$filter['practice']]);
228 228
                 }
229 229
                 $paginator = $paginator ->paginate(10);
230
-            }elseif($filter['public']=='0'){
230
+            } elseif($filter['public']=='0'){
231 231
                 $paginator=DB::table('group_member')
232 232
                 ->groupBy('contest.cid')
233 233
                 ->select('contest.*')
@@ -257,7 +257,7 @@  discard block
 block discarded – undo
257 257
                 )
258 258
                 ->orderBy('contest.begin_time', 'desc')
259 259
                 ->paginate(10);
260
-            }else{
260
+            } else{
261 261
                 $paginator=DB::table('group_member')
262 262
                 ->groupBy('contest.cid')
263 263
                 ->select('contest.*')
@@ -809,13 +809,13 @@  discard block
 block discarded – undo
809 809
         if(time() < $end_time){
810 810
             if($clearance == 3){
811 811
                 $contestRankRaw=Cache::tags(['contest', 'rank'])->get("contestAdmin$cid");
812
-            }else{
812
+            } else{
813 813
                 $contestRankRaw=Cache::tags(['contest', 'rank'])->get($cid);
814 814
             }
815 815
             if(!isset($contestRankRaw)){
816 816
                 $contestRankRaw=$contest_eloquent->rankRefresh();
817 817
             }
818
-        }else{
818
+        } else{
819 819
             if($clearance == 3){
820 820
                 $contestRankRaw=Cache::tags(['contest', 'rank'])->get("contestAdmin$cid");
821 821
                 if (!isset($contestRankRaw)) {
@@ -825,7 +825,7 @@  discard block
 block discarded – undo
825 825
                         $this->storeContestRankInMySQL($cid, $contestRankRaw);
826 826
                     }
827 827
                 }
828
-            }else{
828
+            } else{
829 829
                 $contestRankRaw=$this->getContestRankFromMySQL($cid);
830 830
                 if(!isset($contestRankRaw)){
831 831
                     $contestRankRaw=Cache::tags(['contest', 'rank'])->get($cid);
@@ -910,7 +910,7 @@  discard block
 block discarded – undo
910 910
             return DB::table("contest_clarification")->where([
911 911
                 "cid"=>$cid
912 912
             ])->orderBy('create_time', 'desc')->get()->all();
913
-        }else{
913
+        } else{
914 914
             return DB::table("contest_clarification")->where([
915 915
                 "cid"=>$cid
916 916
             ])->where(function ($query) {
@@ -1075,7 +1075,7 @@  discard block
 block discarded – undo
1075 1075
         $filter['pid'] = array_search($filter['ncode'], array_column($problemSet_temp, 'ncode'));
1076 1076
         if($filter['pid']==false){
1077 1077
             $filter['pid'] = null;
1078
-        }else{
1078
+        } else{
1079 1079
             $filter['pid'] = $problemSet_temp[$filter['pid']]['pid'];
1080 1080
         }
1081 1081
 
@@ -1183,7 +1183,7 @@  discard block
 block discarded – undo
1183 1183
                     "records"=>[]
1184 1184
                 ];
1185 1185
             }
1186
-        }else{
1186
+        } else{
1187 1187
             if ($basicInfo["status_visibility"]==2) {
1188 1188
                 // View all
1189 1189
                 $paginator=DB::table("submission")->where([
@@ -1433,7 +1433,7 @@  discard block
 block discarded – undo
1433 1433
             if($ratingCalculator->calculate()){
1434 1434
                 $ratingCalculator->storage();
1435 1435
                 return true;
1436
-            }else{
1436
+            } else{
1437 1437
                 return false;
1438 1438
             }
1439 1439
         } else {
@@ -1482,7 +1482,7 @@  discard block
 block discarded – undo
1482 1482
             $contestRankRaw = $this->contestRankCache($cid);
1483 1483
             Cache::tags(['contest', 'rank'])->put($cid, $contestRankRaw);
1484 1484
             Cache::tags(['contest', 'rank'])->put("contestAdmin$cid", $contestRankRaw);
1485
-        }else{
1485
+        } else{
1486 1486
             DB::table($this->tableName)
1487 1487
                 ->where('cid',$cid)
1488 1488
                 ->update($data);
@@ -1584,8 +1584,7 @@  discard block
 block discarded – undo
1584 1584
                     if(time() > $chache['end_time']){
1585 1585
                         $this->storeContestRankInMySQL($cid, $ret);
1586 1586
                     }
1587
-                }
1588
-                else{
1587
+                } else{
1589 1588
                     $ret=[];
1590 1589
                     $chache=[];
1591 1590
                     $chache['contest_info']=DB::table("contest")->where("cid", $cid)->first();
@@ -1600,7 +1599,7 @@  discard block
 block discarded – undo
1600 1599
                             "cid"=>$cid,
1601 1600
                             "audit"=>1
1602 1601
                         ])->select('uid')->get()->all();
1603
-                    }else{
1602
+                    } else{
1604 1603
                         $submissionUsers=DB::table("submission")->where([
1605 1604
                             "cid"=>$cid
1606 1605
                         ])->where(
@@ -1635,9 +1634,9 @@  discard block
 block discarded – undo
1635 1634
                     Cache::tags(['contest', 'rank'])->put("contestAdmin$cid", $retAdmin);
1636 1635
                 }
1637 1636
             }
1638
-        }catch(LockTimeoutException $e){
1637
+        } catch(LockTimeoutException $e){
1639 1638
             Log::warning("Contest Rank Lock Timed Out");
1640
-        }finally{
1639
+        } finally{
1641 1640
             optional($lock)->release();
1642 1641
         }
1643 1642
     }
@@ -1660,7 +1659,7 @@  discard block
 block discarded – undo
1660 1659
                     return 1;
1661 1660
                 }
1662 1661
             });
1663
-        }else if ($contest_info["rule"]==2){
1662
+        } else if ($contest_info["rule"]==2){
1664 1663
             usort($ret, function ($a, $b) {
1665 1664
                 if ($a["score"]==$b["score"]) {
1666 1665
                     if ($a["solved"]==$b["solved"]) {
@@ -1684,8 +1683,9 @@  discard block
 block discarded – undo
1684 1683
     {
1685 1684
         $id = count($ret);
1686 1685
         foreach($ret as $key => $r){
1687
-            if($r['uid'] == $uid)
1688
-                $id = $key;
1686
+            if($r['uid'] == $uid) {
1687
+                            $id = $key;
1688
+            }
1689 1689
         }
1690 1690
         if ($contest_info["rule"]==1) {
1691 1691
             // ACM/ICPC Mode
@@ -1693,7 +1693,7 @@  discard block
 block discarded – undo
1693 1693
                 $prob_detail = [];
1694 1694
                 $totPen = 0;
1695 1695
                 $totScore = 0;
1696
-            }else{
1696
+            } else{
1697 1697
                 $prob_detail = $ret[$id]['problem_detail'];
1698 1698
                 $totPen=$ret[$id]['penalty'];
1699 1699
                 $totScore=$ret[$id]['score'];
@@ -1748,7 +1748,7 @@  discard block
 block discarded – undo
1748 1748
                 $prob_detail = [];
1749 1749
                 $totSolved = 0;
1750 1750
                 $totScore = 0;
1751
-            }else{
1751
+            } else{
1752 1752
                 $prob_detail = $ret[$id]['problem_detail'];
1753 1753
                 $totSolved=$ret[$id]['solved'];
1754 1754
                 $totScore=$ret[$id]['score'];
@@ -1811,18 +1811,18 @@  discard block
 block discarded – undo
1811 1811
                 return false;
1812 1812
             }
1813 1813
             return true;
1814
-        }else if($status === 0){
1814
+        } else if($status === 0){
1815 1815
             if($begin_time_new !== null){
1816 1816
                 return false;
1817 1817
             }
1818 1818
             if($end_time_new !== null){
1819 1819
                 if(strtotime($end_time_new) <= time()){
1820 1820
                     return false;
1821
-                }else{
1821
+                } else{
1822 1822
                     return true;
1823 1823
                 }
1824 1824
             }
1825
-        }else{
1825
+        } else{
1826 1826
             return false;
1827 1827
         }
1828 1828
 
@@ -1843,8 +1843,7 @@  discard block
 block discarded – undo
1843 1843
             return DB::table("contest_clarification")->where('ccid','=',$ccid)->update([
1844 1844
                 "public"=>1
1845 1845
             ]);
1846
-        }
1847
-        else
1846
+        } else
1848 1847
         {
1849 1848
             return DB::table("contest_clarification")->where('ccid','=',$ccid)->update([
1850 1849
                 "public"=>0
@@ -1868,7 +1867,7 @@  discard block
 block discarded – undo
1868 1867
             ->whereIn('pid',array_column($contestRank[0]['problem_detail'],'pid'))
1869 1868
             ->select('pid','title')
1870 1869
             ->get()->all();
1871
-        }else{
1870
+        } else{
1872 1871
             $all_problems = [];
1873 1872
         }
1874 1873
         $tags = DB::table('group_problem_tag')
@@ -1963,7 +1962,7 @@  discard block
 block discarded – undo
1963 1962
             return [
1964 1963
                 'result' => true
1965 1964
             ];
1966
-        }else{
1965
+        } else{
1967 1966
             return [
1968 1967
                 'result' => false,
1969 1968
                 'sid' => $submissions
Please login to merge, or discard this patch.
app/Exports/AccountExport.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -11,7 +11,7 @@
 block discarded – undo
11 11
 
12 12
     public function __construct(array $data)
13 13
     {
14
-        $this->data = $data;
14
+        $this->data=$data;
15 15
     }
16 16
 
17 17
     public function array(): array
Please login to merge, or discard this patch.
app/Exports/GroupAnalysisExport.php 2 patches
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -28,8 +28,8 @@  discard block
 block discarded – undo
28 28
     }
29 29
 
30 30
     /**
31
-    * @return array
32
-    */
31
+     * @return array
32
+     */
33 33
     public function registerEvents(): array
34 34
     {
35 35
         return [
@@ -46,8 +46,8 @@  discard block
 block discarded – undo
46 46
     }
47 47
 
48 48
     /**
49
-    * @return \Illuminate\Support\Collection
50
-    */
49
+     * @return \Illuminate\Support\Collection
50
+     */
51 51
     public function collection()
52 52
     {
53 53
         $maxium = $this->config['maxium'] ?? false;
Please login to merge, or discard this patch.
Spacing   +52 added lines, -52 removed lines patch added patch discarded remove patch
@@ -16,16 +16,16 @@  discard block
 block discarded – undo
16 16
     private $member_data;
17 17
     private $config;
18 18
 
19
-    public function __construct($data, $config = [])
19
+    public function __construct($data, $config=[])
20 20
     {
21
-        if ($config['mode'] == 'contest') {
22
-            $this->contest_data = $data['contest_data'];
23
-            $this->member_data = $data['member_data'];
21
+        if ($config['mode']=='contest') {
22
+            $this->contest_data=$data['contest_data'];
23
+            $this->member_data=$data['member_data'];
24 24
         } else {
25
-            $this->member_data = $data['member_data'];
26
-            $this->tag_problems = $data['tag_problems'];
25
+            $this->member_data=$data['member_data'];
26
+            $this->tag_problems=$data['tag_problems'];
27 27
         }
28
-        $this->config = $config;
28
+        $this->config=$config;
29 29
     }
30 30
 
31 31
     /**
@@ -34,9 +34,9 @@  discard block
 block discarded – undo
34 34
     public function registerEvents(): array
35 35
     {
36 36
         return [
37
-            AfterSheet::class => function (AfterSheet $event) {
38
-                if ($this->config['mode'] === 'contest') {
39
-                    $mergeCell = ['A1:A2','B1:E1'];
37
+            AfterSheet::class => function(AfterSheet $event) {
38
+                if ($this->config['mode']==='contest') {
39
+                    $mergeCell=['A1:A2', 'B1:E1'];
40 40
                     foreach ($this->contest_data as $c) {
41 41
                         array_push($mergeCell, $this->mergeCellColumnNext());
42 42
                     }
@@ -51,46 +51,46 @@  discard block
 block discarded – undo
51 51
     */
52 52
     public function collection()
53 53
     {
54
-        $maxium = $this->config['maxium'] ?? false;
55
-        $percent = $this->config['percent'] ?? false;
54
+        $maxium=$this->config['maxium'] ?? false;
55
+        $percent=$this->config['percent'] ?? false;
56 56
 
57
-        if ($this->config['mode'] == 'contest') {
58
-            $row_1 = ['Member','Total','','',''];
59
-            $row_2 = ['','Elo','Rank','Solved','Penalty'];
57
+        if ($this->config['mode']=='contest') {
58
+            $row_1=['Member', 'Total', '', '', ''];
59
+            $row_2=['', 'Elo', 'Rank', 'Solved', 'Penalty'];
60 60
             foreach ($this->contest_data as $contest) {
61
-                array_push($row_1, $contest['name'], '','');
62
-                array_push($row_2, 'Rank','Solved', 'Penalty');
61
+                array_push($row_1, $contest['name'], '', '');
62
+                array_push($row_2, 'Rank', 'Solved', 'Penalty');
63 63
             }
64
-            $data = [$row_1,$row_2];
64
+            $data=[$row_1, $row_2];
65 65
             foreach ($this->member_data as $member) {
66
-                $display_name = $member['name'];
66
+                $display_name=$member['name'];
67 67
                 if (!empty($member['nick_name'])) {
68
-                    $display_name .= ' ('.$member['nick_name'].')';
68
+                    $display_name.=' ('.$member['nick_name'].')';
69 69
                 }
70
-                $row = [
70
+                $row=[
71 71
                     $display_name,
72 72
                     $member['elo'],
73 73
                     !empty($member['rank_ave']) ? round($member['rank_ave'], 1) : '-',
74
-                    $percent === 'true'  ? ($member['problem_all'] != 0 ? round($member['solved_all'] / $member['problem_all'] * 100, 1) : '-'). ' %'
75
-                            : ($maxium === 'true'  ? $member['solved_all'] . ' / ' . $member['problem_all'] : $member['solved_all']),
74
+                    $percent==='true' ? ($member['problem_all']!=0 ? round($member['solved_all'] / $member['problem_all'] * 100, 1) : '-').' %'
75
+                            : ($maxium==='true' ? $member['solved_all'].' / '.$member['problem_all'] : $member['solved_all']),
76 76
                     round($member['penalty']),
77 77
                 ];
78 78
                 foreach ($this->contest_data as $contest) {
79 79
                     if (in_array($contest['cid'], array_keys($member['contest_detial']))) {
80
-                        $contest_detial = $member['contest_detial'][$contest['cid']];
80
+                        $contest_detial=$member['contest_detial'][$contest['cid']];
81 81
                         array_push(
82 82
                             $row,
83 83
                             $contest_detial['rank'],
84
-                            $percent === 'true' ? (round($contest_detial['solved'] / $contest_detial['problems'] * 100, 1) . ' %')
85
-                                    : ($maxium === 'true' ? $contest_detial['solved'].' / '.$contest_detial['problems'] : $contest_detial['solved']),
84
+                            $percent==='true' ? (round($contest_detial['solved'] / $contest_detial['problems'] * 100, 1).' %')
85
+                                    : ($maxium==='true' ? $contest_detial['solved'].' / '.$contest_detial['problems'] : $contest_detial['solved']),
86 86
                             round($contest_detial['penalty'])
87 87
                         );
88 88
                     } else {
89 89
                         array_push(
90 90
                             $row,
91 91
                             '-',
92
-                            $percent === 'true' ? '- %'
93
-                                    : ($maxium === 'true' ? '- / -' : ' - '),
92
+                            $percent==='true' ? '- %'
93
+                                    : ($maxium==='true' ? '- / -' : ' - '),
94 94
                             0
95 95
                         );
96 96
                     }
@@ -98,27 +98,27 @@  discard block
 block discarded – undo
98 98
                 array_push($data, $row);
99 99
             }
100 100
         } else {
101
-            $row_1 = ['Member'];
102
-            $row_2 = [''];
101
+            $row_1=['Member'];
102
+            $row_2=[''];
103 103
             foreach ($this->tag_problems as $tag => $tag_problem_set) {
104 104
                 array_push($row_1, $tag);
105 105
                 array_push($row_2, 'Solved');
106 106
             }
107
-            $data = [$row_1,$row_2];
107
+            $data=[$row_1, $row_2];
108 108
             foreach ($this->member_data as $member) {
109
-                $display_name = $member['name'];
109
+                $display_name=$member['name'];
110 110
                 if (!empty($member['nick_name'])) {
111
-                    $display_name .= ' ('.$member['nick_name'].')';
111
+                    $display_name.=' ('.$member['nick_name'].')';
112 112
                 }
113
-                $row = [
113
+                $row=[
114 114
                     $display_name,
115 115
                 ];
116 116
                 foreach ($member['completion'] as $tag => $tag_completion) {
117
-                    $count = count($tag_completion);
118
-                    $solved = eval('return '.join('+', array_values($tag_completion)).';');
117
+                    $count=count($tag_completion);
118
+                    $solved=eval('return '.join('+', array_values($tag_completion)).';');
119 119
                     array_push(
120 120
                         $row,
121
-                        $percent === 'true' ? (round($solved / $count * 100, 1) . ' %') : ($maxium  === 'true' ? $solved .' / '.$count : $solved)
121
+                        $percent==='true' ? (round($solved / $count * 100, 1).' %') : ($maxium==='true' ? $solved.' / '.$count : $solved)
122 122
                     );
123 123
                 }
124 124
                 array_push($data, $row);
@@ -129,33 +129,33 @@  discard block
 block discarded – undo
129 129
 
130 130
     private function mergeCellColumnNext()
131 131
     {
132
-        static $columns = [
133
-            [2],[4]
132
+        static $columns=[
133
+            [2], [4]
134 134
         ];
135
-        $columns_str = ['',''];
136
-        $chars = str_split('ABCDEFGHIJKLMNOPQRSTUVWXYZ');
135
+        $columns_str=['', ''];
136
+        $chars=str_split('ABCDEFGHIJKLMNOPQRSTUVWXYZ');
137 137
         foreach ($columns as $key => &$column) {
138
-            $column[0] += 3;
139
-            if ($column[0] > 25) {
138
+            $column[0]+=3;
139
+            if ($column[0]>25) {
140 140
                 if (isset($column[1])) {
141
-                    $column[1] += 1;
142
-                    if ($column[1] > 25) {
141
+                    $column[1]+=1;
142
+                    if ($column[1]>25) {
143 143
                         if (isset($column[2])) {
144
-                            $column[2] += 1;
144
+                            $column[2]+=1;
145 145
                         } else {
146
-                            $column[2] = 0;
146
+                            $column[2]=0;
147 147
                         }
148 148
                     }
149 149
                 } else {
150
-                    $column[1] = 0;
150
+                    $column[1]=0;
151 151
                 }
152 152
             }
153
-            $columns_str[$key] = '';
154
-            $reverse_column = array_reverse($column);
153
+            $columns_str[$key]='';
154
+            $reverse_column=array_reverse($column);
155 155
             foreach ($reverse_column as $ord) {
156
-                $columns_str[$key] .= $chars[$ord];
156
+                $columns_str[$key].=$chars[$ord];
157 157
             }
158
-            $columns_str[$key] .= '1';
158
+            $columns_str[$key].='1';
159 159
         }
160 160
         return $columns_str[0].':'.$columns_str[1];
161 161
     }
Please login to merge, or discard this patch.
app/Http/Controllers/OAuth/GithubController.php 2 patches
Braces   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -42,7 +42,7 @@  discard block
 block discarded – undo
42 42
     {
43 43
         try{
44 44
             $github_user = Socialite::driver('github')->user();
45
-        }catch(\Laravel\Socialite\Two\InvalidStateException $e){
45
+        } catch(\Laravel\Socialite\Two\InvalidStateException $e){
46 46
             return redirect('/');
47 47
         }
48 48
 
@@ -86,7 +86,7 @@  discard block
 block discarded – undo
86 86
                     ],
87 87
                 ]
88 88
             ]);
89
-        }else{
89
+        } else{
90 90
             $ret = $accountModel->findExtra('github_id',$github_user->id);
91 91
             if(!empty($ret)){
92 92
                 Auth::loginUsingId($ret['uid']);
@@ -96,7 +96,7 @@  discard block
 block discarded – undo
96 96
                 $accountModel->setExtra($user_id,'github_homepage',($github_user->user)['html_url']);
97 97
                 $accountModel->setExtra($user_id,'github_token',$github_user->token,101);
98 98
                 return redirect('/');
99
-            }else{
99
+            } else{
100 100
                 return view('oauth.index',[
101 101
                     'page_title'=>"OAuth",
102 102
                     'site_title'=>config("app.name"),
@@ -143,7 +143,7 @@  discard block
 block discarded – undo
143 143
                     ],
144 144
                 ]
145 145
             ]);
146
-        }else{
146
+        } else{
147 147
             return view('oauth.index',[
148 148
                 'page_title'=>"OAuth",
149 149
                 'site_title'=>config("app.name"),
@@ -183,7 +183,7 @@  discard block
 block discarded – undo
183 183
                     ],
184 184
                 ]
185 185
             ]);
186
-        }else{
186
+        } else{
187 187
             return view('oauth.index',[
188 188
                 'page_title'=>"OAuth",
189 189
                 'site_title'=>config("app.name"),
Please login to merge, or discard this patch.
Spacing   +52 added lines, -52 removed lines patch added patch discarded remove patch
@@ -12,20 +12,20 @@  discard block
 block discarded – undo
12 12
 {
13 13
     public function redirectTo()
14 14
     {
15
-        $accountModel = new AccountModel();
16
-        if(Auth::check()){
15
+        $accountModel=new AccountModel();
16
+        if (Auth::check()) {
17 17
             $info=$accountModel->detail(Auth::user()->id);
18
-            if(Auth::check() && $info['contest_account']){
18
+            if (Auth::check() && $info['contest_account']) {
19 19
                 return redirect('/account/settings');
20 20
             }
21 21
         }
22
-        if(Auth::check() && $accountModel->getExtra(Auth::user()->id ,'github_id')){
23
-            return view('oauth.index',[
22
+        if (Auth::check() && $accountModel->getExtra(Auth::user()->id, 'github_id')) {
23
+            return view('oauth.index', [
24 24
                 'page_title'=>"OAuth",
25 25
                 'site_title'=>config("app.name"),
26 26
                 'navigation'=>"OAuth",
27 27
                 'platform' => 'Github',
28
-                'display_html' => 'You\'re already tied to the github account : <span class="text-info">'.$accountModel->getExtra(Auth::user()->id ,'github_email').'</span><br />
28
+                'display_html' => 'You\'re already tied to the github account : <span class="text-info">'.$accountModel->getExtra(Auth::user()->id, 'github_email').'</span><br />
29 29
                 You can choose to unbind or go back to the homepage',
30 30
                 'buttons' => [
31 31
                     [
@@ -45,19 +45,19 @@  discard block
 block discarded – undo
45 45
 
46 46
     public function handleCallback()
47 47
     {
48
-        try{
49
-            $github_user = Socialite::driver('github')->user();
50
-        }catch(\Laravel\Socialite\Two\InvalidStateException $e){
48
+        try {
49
+            $github_user=Socialite::driver('github')->user();
50
+        } catch (\Laravel\Socialite\Two\InvalidStateException $e) {
51 51
             return redirect('/');
52 52
         }
53 53
 
54
-        $accountModel = new AccountModel();
55
-        if(Auth::check()){
56
-            $user_id = Auth::user()->id;
57
-            $ret = $accountModel->findExtra('github_id',$github_user->id);
58
-            if(!empty($ret) && $ret['uid'] != $user_id){
59
-                $user = UserModel::find($ret['uid']);
60
-                return view('oauth.index',[
54
+        $accountModel=new AccountModel();
55
+        if (Auth::check()) {
56
+            $user_id=Auth::user()->id;
57
+            $ret=$accountModel->findExtra('github_id', $github_user->id);
58
+            if (!empty($ret) && $ret['uid']!=$user_id) {
59
+                $user=UserModel::find($ret['uid']);
60
+                return view('oauth.index', [
61 61
                     'page_title'=>"OAuth",
62 62
                     'site_title'=>config("app.name"),
63 63
                     'navigation'=>"OAuth",
@@ -72,17 +72,17 @@  discard block
 block discarded – undo
72 72
                     ]
73 73
                 ]);
74 74
             }
75
-            $accountModel->setExtra($user_id,'github_id',$github_user->id);
76
-            $accountModel->setExtra($user_id,'github_email',$github_user->email);
77
-            $accountModel->setExtra($user_id,'github_nickname',$github_user->nickname);
78
-            $accountModel->setExtra($user_id,'github_homepage',($github_user->user)['html_url']);
79
-            $accountModel->setExtra($user_id,'github_token',$github_user->token,101);
80
-            return view('oauth.index',[
75
+            $accountModel->setExtra($user_id, 'github_id', $github_user->id);
76
+            $accountModel->setExtra($user_id, 'github_email', $github_user->email);
77
+            $accountModel->setExtra($user_id, 'github_nickname', $github_user->nickname);
78
+            $accountModel->setExtra($user_id, 'github_homepage', ($github_user->user)['html_url']);
79
+            $accountModel->setExtra($user_id, 'github_token', $github_user->token, 101);
80
+            return view('oauth.index', [
81 81
                 'page_title'=>"OAuth",
82 82
                 'site_title'=>config("app.name"),
83 83
                 'navigation'=>"OAuth",
84 84
                 'platform' => 'Github',
85
-                'display_html' => 'You have successfully tied up the github account : <span class="text-info">'.$accountModel->getExtra(Auth::user()->id ,'github_email').'</span><br />
85
+                'display_html' => 'You have successfully tied up the github account : <span class="text-info">'.$accountModel->getExtra(Auth::user()->id, 'github_email').'</span><br />
86 86
                 You can log in to '.config("app.name").' later using this account',
87 87
                 'buttons' => [
88 88
                     [
@@ -91,18 +91,18 @@  discard block
 block discarded – undo
91 91
                     ],
92 92
                 ]
93 93
             ]);
94
-        }else{
95
-            $ret = $accountModel->findExtra('github_id',$github_user->id);
96
-            if(!empty($ret)){
94
+        } else {
95
+            $ret=$accountModel->findExtra('github_id', $github_user->id);
96
+            if (!empty($ret)) {
97 97
                 Auth::loginUsingId($ret['uid']);
98
-                $user_id = Auth::user()->id;
99
-                $accountModel->setExtra($user_id,'github_email',$github_user->email);
100
-                $accountModel->setExtra($user_id,'github_nickname',$github_user->nickname);
101
-                $accountModel->setExtra($user_id,'github_homepage',($github_user->user)['html_url']);
102
-                $accountModel->setExtra($user_id,'github_token',$github_user->token,101);
98
+                $user_id=Auth::user()->id;
99
+                $accountModel->setExtra($user_id, 'github_email', $github_user->email);
100
+                $accountModel->setExtra($user_id, 'github_nickname', $github_user->nickname);
101
+                $accountModel->setExtra($user_id, 'github_homepage', ($github_user->user)['html_url']);
102
+                $accountModel->setExtra($user_id, 'github_token', $github_user->token, 101);
103 103
                 return redirect('/');
104
-            }else{
105
-                return view('oauth.index',[
104
+            } else {
105
+                return view('oauth.index', [
106 106
                     'page_title'=>"OAuth",
107 107
                     'site_title'=>config("app.name"),
108 108
                     'navigation'=>"OAuth",
@@ -125,19 +125,19 @@  discard block
 block discarded – undo
125 125
 
126 126
     public function unbind()
127 127
     {
128
-        if(!Auth::check()){
128
+        if (!Auth::check()) {
129 129
             return redirect('/');
130 130
         }
131
-        $accountModel = new AccountModel();
132
-        if($accountModel->getExtra(Auth::user()->id ,'github_id')){
133
-            return view('oauth.index',[
131
+        $accountModel=new AccountModel();
132
+        if ($accountModel->getExtra(Auth::user()->id, 'github_id')) {
133
+            return view('oauth.index', [
134 134
                 'page_title'=>"OAuth",
135 135
                 'site_title'=>config("app.name"),
136 136
                 'navigation'=>"OAuth",
137 137
                 'platform' => 'Github',
138 138
                 'display_html' => 'You are trying to unbind the following two : <br />
139 139
                 Your '.config("app.name").' account : <span class="text-info">'.Auth::user()->email.'</span><br />
140
-                This Github account : <span class="text-info">'.$accountModel->getExtra(Auth::user()->id ,'github_email').'</span><br />
140
+                This Github account : <span class="text-info">'.$accountModel->getExtra(Auth::user()->id, 'github_email').'</span><br />
141 141
                 Make your decision carefully, although you can later establish the binding again',
142 142
                 'buttons' => [
143 143
                     [
@@ -151,8 +151,8 @@  discard block
 block discarded – undo
151 151
                     ],
152 152
                 ]
153 153
             ]);
154
-        }else{
155
-            return view('oauth.index',[
154
+        } else {
155
+            return view('oauth.index', [
156 156
                 'page_title'=>"OAuth",
157 157
                 'site_title'=>config("app.name"),
158 158
                 'navigation'=>"OAuth",
@@ -170,18 +170,18 @@  discard block
 block discarded – undo
170 170
 
171 171
     public function confirmUnbind()
172 172
     {
173
-        if(!Auth::check()){
173
+        if (!Auth::check()) {
174 174
             return redirect('/');
175 175
         }
176
-        $accountModel = new AccountModel();
177
-        $user_id = Auth::user()->id;
178
-        if($accountModel->getExtra($user_id ,'github_id')){
179
-            $accountModel->setExtra($user_id,'github_id',null);
180
-            $accountModel->setExtra($user_id,'github_email',null);
181
-            $accountModel->setExtra($user_id,'github_nickname',null);
182
-            $accountModel->setExtra($user_id,'github_homepage',null);
183
-            $accountModel->setExtra($user_id,'github_token',null);
184
-            return view('oauth.index',[
176
+        $accountModel=new AccountModel();
177
+        $user_id=Auth::user()->id;
178
+        if ($accountModel->getExtra($user_id, 'github_id')) {
179
+            $accountModel->setExtra($user_id, 'github_id', null);
180
+            $accountModel->setExtra($user_id, 'github_email', null);
181
+            $accountModel->setExtra($user_id, 'github_nickname', null);
182
+            $accountModel->setExtra($user_id, 'github_homepage', null);
183
+            $accountModel->setExtra($user_id, 'github_token', null);
184
+            return view('oauth.index', [
185 185
                 'page_title'=>"OAuth",
186 186
                 'site_title'=>config("app.name"),
187 187
                 'navigation'=>"OAuth",
@@ -194,8 +194,8 @@  discard block
 block discarded – undo
194 194
                     ],
195 195
                 ]
196 196
             ]);
197
-        }else{
198
-            return view('oauth.index',[
197
+        } else {
198
+            return view('oauth.index', [
199 199
                 'page_title'=>"OAuth",
200 200
                 'site_title'=>config("app.name"),
201 201
                 'navigation'=>"OAuth",
Please login to merge, or discard this patch.
app/Http/Controllers/UserController.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -28,8 +28,8 @@
 block discarded – undo
28 28
         $accountModel=new AccountModel();
29 29
         $info=$accountModel->detail($uid);
30 30
         $feed=$accountModel->feed($uid);
31
-        $extraInfo = $accountModel->getExtra($uid, ['gender', 'contanct', 'school', 'country', 'location'],0);
32
-        $socialiteInfo = $accountModel->getSocialiteInfo($uid,0);
31
+        $extraInfo=$accountModel->getExtra($uid, ['gender', 'contanct', 'school', 'country', 'location'], 0);
32
+        $socialiteInfo=$accountModel->getSocialiteInfo($uid, 0);
33 33
         return view("account.dashboard", [
34 34
             'page_title'=>$info["name"],
35 35
             'site_title'=>config("app.name"),
Please login to merge, or discard this patch.
app/Http/Controllers/Auth/ForgotPasswordController.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -37,7 +37,7 @@
 block discarded – undo
37 37
      */
38 38
     public function showLinkRequestForm()
39 39
     {
40
-        return view('auth.passwords.email',[
40
+        return view('auth.passwords.email', [
41 41
             'page_title'=>"Reset Password",
42 42
             'site_title'=>config("app.name"),
43 43
             'navigation' => "Account"
Please login to merge, or discard this patch.