@@ -131,8 +131,8 @@ |
||
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"], |
@@ -132,7 +132,9 @@ |
||
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"], |
@@ -78,7 +78,7 @@ |
||
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 | } |
@@ -14,36 +14,36 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 | } |
@@ -100,11 +100,11 @@ |
||
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); |
@@ -265,7 +265,7 @@ |
||
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( |
@@ -224,7 +224,7 @@ discard block |
||
224 | 224 | $paginator=$paginator->where(["practice"=>$filter['practice']]); |
225 | 225 | } |
226 | 226 | $paginator = $paginator ->paginate(10); |
227 | - }elseif($filter['public']=='0'){ |
|
227 | + } elseif($filter['public']=='0'){ |
|
228 | 228 | $paginator=DB::table('group_member') |
229 | 229 | ->groupBy('contest.cid') |
230 | 230 | ->select('contest.*') |
@@ -254,7 +254,7 @@ discard block |
||
254 | 254 | ) |
255 | 255 | ->orderBy('contest.begin_time', 'desc') |
256 | 256 | ->paginate(10); |
257 | - }else{ |
|
257 | + } else{ |
|
258 | 258 | $paginator=DB::table('group_member') |
259 | 259 | ->groupBy('contest.cid') |
260 | 260 | ->select('contest.*') |
@@ -797,13 +797,13 @@ discard block |
||
797 | 797 | if(time() < $end_time){ |
798 | 798 | if($clearance == 3){ |
799 | 799 | $contestRankRaw=Cache::tags(['contest', 'rank'])->get("contestAdmin$cid"); |
800 | - }else{ |
|
800 | + } else{ |
|
801 | 801 | $contestRankRaw=Cache::tags(['contest', 'rank'])->get($cid); |
802 | 802 | } |
803 | 803 | if(!isset($contestRankRaw)){ |
804 | 804 | $contestRankRaw=$this->contestRankCache($cid); |
805 | 805 | } |
806 | - }else{ |
|
806 | + } else{ |
|
807 | 807 | if($clearance == 3){ |
808 | 808 | $contestRankRaw=Cache::tags(['contest', 'rank'])->get("contestAdmin$cid"); |
809 | 809 | if (!isset($contestRankRaw)) { |
@@ -813,7 +813,7 @@ discard block |
||
813 | 813 | $this->storeContestRankInMySQL($cid, $contestRankRaw); |
814 | 814 | } |
815 | 815 | } |
816 | - }else{ |
|
816 | + } else{ |
|
817 | 817 | $contestRankRaw=$this->getContestRankFromMySQL($cid); |
818 | 818 | if(!isset($contestRankRaw)){ |
819 | 819 | $contestRankRaw=Cache::tags(['contest', 'rank'])->get($cid); |
@@ -898,7 +898,7 @@ discard block |
||
898 | 898 | return DB::table("contest_clarification")->where([ |
899 | 899 | "cid"=>$cid |
900 | 900 | ])->orderBy('create_time', 'desc')->get()->all(); |
901 | - }else{ |
|
901 | + } else{ |
|
902 | 902 | return DB::table("contest_clarification")->where([ |
903 | 903 | "cid"=>$cid |
904 | 904 | ])->where(function ($query) { |
@@ -1062,7 +1062,7 @@ discard block |
||
1062 | 1062 | $filter['pid'] = array_search($filter['ncode'], array_column($problemSet_temp, 'ncode')); |
1063 | 1063 | if($filter['pid']==false){ |
1064 | 1064 | $filter['pid'] = null; |
1065 | - }else{ |
|
1065 | + } else{ |
|
1066 | 1066 | $filter['pid'] = $problemSet_temp[$filter['pid']]['pid']; |
1067 | 1067 | } |
1068 | 1068 | |
@@ -1170,7 +1170,7 @@ discard block |
||
1170 | 1170 | "records"=>[] |
1171 | 1171 | ]; |
1172 | 1172 | } |
1173 | - }else{ |
|
1173 | + } else{ |
|
1174 | 1174 | if ($basicInfo["status_visibility"]==2) { |
1175 | 1175 | // View all |
1176 | 1176 | $paginator=DB::table("submission")->where([ |
@@ -1420,7 +1420,7 @@ discard block |
||
1420 | 1420 | if($ratingCalculator->calculate()){ |
1421 | 1421 | $ratingCalculator->storage(); |
1422 | 1422 | return true; |
1423 | - }else{ |
|
1423 | + } else{ |
|
1424 | 1424 | return false; |
1425 | 1425 | } |
1426 | 1426 | } else { |
@@ -1469,7 +1469,7 @@ discard block |
||
1469 | 1469 | $contestRankRaw = $this->contestRankCache($cid); |
1470 | 1470 | Cache::tags(['contest', 'rank'])->put($cid, $contestRankRaw); |
1471 | 1471 | Cache::tags(['contest', 'rank'])->put("contestAdmin$cid", $contestRankRaw); |
1472 | - }else{ |
|
1472 | + } else{ |
|
1473 | 1473 | DB::table($this->tableName) |
1474 | 1474 | ->where('cid',$cid) |
1475 | 1475 | ->update($data); |
@@ -1569,8 +1569,7 @@ discard block |
||
1569 | 1569 | if(time() > $chache['end_time']){ |
1570 | 1570 | $this->storeContestRankInMySQL($cid, $ret); |
1571 | 1571 | } |
1572 | - } |
|
1573 | - else{ |
|
1572 | + } else{ |
|
1574 | 1573 | $ret=[]; |
1575 | 1574 | $chache=[]; |
1576 | 1575 | $chache['contest_info']=DB::table("contest")->where("cid", $cid)->first(); |
@@ -1585,7 +1584,7 @@ discard block |
||
1585 | 1584 | "cid"=>$cid, |
1586 | 1585 | "audit"=>1 |
1587 | 1586 | ])->select('uid')->get()->all(); |
1588 | - }else{ |
|
1587 | + } else{ |
|
1589 | 1588 | $submissionUsers=DB::table("submission")->where([ |
1590 | 1589 | "cid"=>$cid |
1591 | 1590 | ])->where( |
@@ -1620,9 +1619,9 @@ discard block |
||
1620 | 1619 | Cache::tags(['contest', 'rank'])->put("contestAdmin$cid", $retAdmin); |
1621 | 1620 | } |
1622 | 1621 | } |
1623 | - }catch(LockTimeoutException $e){ |
|
1622 | + } catch(LockTimeoutException $e){ |
|
1624 | 1623 | Log::warning("Contest Rank Lock Timed Out"); |
1625 | - }finally{ |
|
1624 | + } finally{ |
|
1626 | 1625 | optional($lock)->release(); |
1627 | 1626 | } |
1628 | 1627 | } |
@@ -1645,7 +1644,7 @@ discard block |
||
1645 | 1644 | return 1; |
1646 | 1645 | } |
1647 | 1646 | }); |
1648 | - }else if ($contest_info["rule"]==2){ |
|
1647 | + } else if ($contest_info["rule"]==2){ |
|
1649 | 1648 | usort($ret, function ($a, $b) { |
1650 | 1649 | if ($a["score"]==$b["score"]) { |
1651 | 1650 | if ($a["solved"]==$b["solved"]) { |
@@ -1669,8 +1668,9 @@ discard block |
||
1669 | 1668 | { |
1670 | 1669 | $id = count($ret); |
1671 | 1670 | foreach($ret as $key => $r){ |
1672 | - if($r['uid'] == $uid) |
|
1673 | - $id = $key; |
|
1671 | + if($r['uid'] == $uid) { |
|
1672 | + $id = $key; |
|
1673 | + } |
|
1674 | 1674 | } |
1675 | 1675 | if ($contest_info["rule"]==1) { |
1676 | 1676 | // ACM/ICPC Mode |
@@ -1678,7 +1678,7 @@ discard block |
||
1678 | 1678 | $prob_detail = []; |
1679 | 1679 | $totPen = 0; |
1680 | 1680 | $totScore = 0; |
1681 | - }else{ |
|
1681 | + } else{ |
|
1682 | 1682 | $prob_detail = $ret[$id]['problem_detail']; |
1683 | 1683 | $totPen=$ret[$id]['penalty']; |
1684 | 1684 | $totScore=$ret[$id]['score']; |
@@ -1733,7 +1733,7 @@ discard block |
||
1733 | 1733 | $prob_detail = []; |
1734 | 1734 | $totSolved = 0; |
1735 | 1735 | $totScore = 0; |
1736 | - }else{ |
|
1736 | + } else{ |
|
1737 | 1737 | $prob_detail = $ret[$id]['problem_detail']; |
1738 | 1738 | $totSolved=$ret[$id]['solved']; |
1739 | 1739 | $totScore=$ret[$id]['score']; |
@@ -1796,18 +1796,18 @@ discard block |
||
1796 | 1796 | return false; |
1797 | 1797 | } |
1798 | 1798 | return true; |
1799 | - }else if($status === 0){ |
|
1799 | + } else if($status === 0){ |
|
1800 | 1800 | if($begin_time_new !== null){ |
1801 | 1801 | return false; |
1802 | 1802 | } |
1803 | 1803 | if($end_time_new !== null){ |
1804 | 1804 | if(strtotime($end_time_new) <= time()){ |
1805 | 1805 | return false; |
1806 | - }else{ |
|
1806 | + } else{ |
|
1807 | 1807 | return true; |
1808 | 1808 | } |
1809 | 1809 | } |
1810 | - }else{ |
|
1810 | + } else{ |
|
1811 | 1811 | return false; |
1812 | 1812 | } |
1813 | 1813 | |
@@ -1828,8 +1828,7 @@ discard block |
||
1828 | 1828 | return DB::table("contest_clarification")->where('ccid','=',$ccid)->update([ |
1829 | 1829 | "public"=>1 |
1830 | 1830 | ]); |
1831 | - } |
|
1832 | - else |
|
1831 | + } else |
|
1833 | 1832 | { |
1834 | 1833 | return DB::table("contest_clarification")->where('ccid','=',$ccid)->update([ |
1835 | 1834 | "public"=>0 |
@@ -1852,7 +1851,7 @@ discard block |
||
1852 | 1851 | ->whereIn('pid',array_column($contestRank[0]['problem_detail'],'pid')) |
1853 | 1852 | ->select('pid','title') |
1854 | 1853 | ->get()->all(); |
1855 | - }else{ |
|
1854 | + } else{ |
|
1856 | 1855 | $all_problems = []; |
1857 | 1856 | } |
1858 | 1857 | $tags = DB::table('group_problem_tag') |
@@ -111,8 +111,8 @@ discard block |
||
111 | 111 | |
112 | 112 | public function gcode($cid) |
113 | 113 | { |
114 | - $gid = $this->gid($cid); |
|
115 | - return DB::table('group')->where('gid','=',$gid)->first()["gcode"]; |
|
114 | + $gid=$this->gid($cid); |
|
115 | + return DB::table('group')->where('gid', '=', $gid)->first()["gcode"]; |
|
116 | 116 | } |
117 | 117 | |
118 | 118 | public function runningContest() |
@@ -137,19 +137,19 @@ discard block |
||
137 | 137 | |
138 | 138 | public function listForSetting($gid) |
139 | 139 | { |
140 | - $uid = Auth::user()->id; |
|
141 | - $group_contests = DB::table('contest') |
|
142 | - ->where('gid',$gid) |
|
143 | - ->orderBy('begin_time','desc') |
|
140 | + $uid=Auth::user()->id; |
|
141 | + $group_contests=DB::table('contest') |
|
142 | + ->where('gid', $gid) |
|
143 | + ->orderBy('begin_time', 'desc') |
|
144 | 144 | ->get()->all(); |
145 | - $groupModel = new GroupModel(); |
|
146 | - $group_clearance = $groupModel->judgeClearance($gid,$uid); |
|
145 | + $groupModel=new GroupModel(); |
|
146 | + $group_clearance=$groupModel->judgeClearance($gid, $uid); |
|
147 | 147 | foreach ($group_contests as &$contest) { |
148 | - $contest['is_admin'] = ($contest['assign_uid'] == $uid || $group_clearance == 3); |
|
149 | - $contest['begin_stamps'] = strtotime($contest['begin_time']); |
|
150 | - $contest['end_stamps'] = strtotime($contest['end_time']); |
|
151 | - $contest['status'] = time() >= $contest['end_stamps'] ? 1 |
|
152 | - : (time() <= $contest['begin_stamps'] ? -1 : 0); |
|
148 | + $contest['is_admin']=($contest['assign_uid']==$uid || $group_clearance==3); |
|
149 | + $contest['begin_stamps']=strtotime($contest['begin_time']); |
|
150 | + $contest['end_stamps']=strtotime($contest['end_time']); |
|
151 | + $contest['status']=time()>=$contest['end_stamps'] ? 1 |
|
152 | + : (time()<=$contest['begin_stamps'] ? -1 : 0); |
|
153 | 153 | $contest["rule_parsed"]=$this->rule[$contest["rule"]]; |
154 | 154 | $contest["date_parsed"]=[ |
155 | 155 | "date"=>date_format(date_create($contest["begin_time"]), 'j'), |
@@ -157,11 +157,11 @@ discard block |
||
157 | 157 | ]; |
158 | 158 | $contest["length"]=$this->calcLength($contest["begin_time"], $contest["end_time"]); |
159 | 159 | } |
160 | - usort($group_contests,function($a,$b){ |
|
161 | - if($a['is_admin'] == $b['is_admin']){ |
|
162 | - return $b['begin_stamps'] - $a['begin_stamps']; |
|
160 | + usort($group_contests, function($a, $b) { |
|
161 | + if ($a['is_admin']==$b['is_admin']) { |
|
162 | + return $b['begin_stamps']-$a['begin_stamps']; |
|
163 | 163 | } |
164 | - return $b['is_admin'] - $a['is_admin']; |
|
164 | + return $b['is_admin']-$a['is_admin']; |
|
165 | 165 | }); |
166 | 166 | return $group_contests; |
167 | 167 | } |
@@ -172,9 +172,9 @@ discard block |
||
172 | 172 | // "gid"=>$gid |
173 | 173 | // ])->orderBy('begin_time', 'desc')->get()->all(); |
174 | 174 | $preQuery=DB::table($this->tableName); |
175 | - $paginator=$preQuery->where('gid','=',$gid)->orderBy('begin_time', 'desc')->paginate(10); |
|
175 | + $paginator=$preQuery->where('gid', '=', $gid)->orderBy('begin_time', 'desc')->paginate(10); |
|
176 | 176 | $contest_list=$paginator->all(); |
177 | - if(empty($contest_list)){ |
|
177 | + if (empty($contest_list)) { |
|
178 | 178 | return null; |
179 | 179 | } |
180 | 180 | |
@@ -199,7 +199,7 @@ discard block |
||
199 | 199 | ])->first()["rule"]; |
200 | 200 | } |
201 | 201 | |
202 | - public function list($filter,$uid) |
|
202 | + public function list($filter, $uid) |
|
203 | 203 | { |
204 | 204 | if ($uid) { |
205 | 205 | //$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); |
@@ -223,15 +223,15 @@ discard block |
||
223 | 223 | if ($filter['practice']) { |
224 | 224 | $paginator=$paginator->where(["practice"=>$filter['practice']]); |
225 | 225 | } |
226 | - $paginator = $paginator ->paginate(10); |
|
227 | - }elseif($filter['public']=='0'){ |
|
226 | + $paginator=$paginator ->paginate(10); |
|
227 | + }elseif ($filter['public']=='0') { |
|
228 | 228 | $paginator=DB::table('group_member') |
229 | 229 | ->groupBy('contest.cid') |
230 | 230 | ->select('contest.*') |
231 | 231 | ->join('contest', 'group_member.gid', '=', 'contest.gid') |
232 | 232 | ->leftJoin('contest_participant', 'contest.cid', '=', 'contest_participant.cid') |
233 | 233 | ->where( |
234 | - function ($query) use ($filter,$uid) { |
|
234 | + function($query) use ($filter, $uid) { |
|
235 | 235 | if ($filter['rule']) { |
236 | 236 | $query=$query->where(["rule"=>$filter['rule']]); |
237 | 237 | } |
@@ -254,14 +254,14 @@ discard block |
||
254 | 254 | ) |
255 | 255 | ->orderBy('contest.begin_time', 'desc') |
256 | 256 | ->paginate(10); |
257 | - }else{ |
|
257 | + } else { |
|
258 | 258 | $paginator=DB::table('group_member') |
259 | 259 | ->groupBy('contest.cid') |
260 | 260 | ->select('contest.*') |
261 | 261 | ->join('contest', 'group_member.gid', '=', 'contest.gid') |
262 | 262 | ->leftJoin('contest_participant', 'contest.cid', '=', 'contest_participant.cid') |
263 | 263 | ->where( |
264 | - function ($query) use ($filter) { |
|
264 | + function($query) use ($filter) { |
|
265 | 265 | if ($filter['rule']) { |
266 | 266 | $query=$query->where(["rule"=>$filter['rule']]); |
267 | 267 | } |
@@ -282,7 +282,7 @@ discard block |
||
282 | 282 | } |
283 | 283 | ) |
284 | 284 | ->orWhere( |
285 | - function ($query) use ($filter,$uid) { |
|
285 | + function($query) use ($filter, $uid) { |
|
286 | 286 | if ($filter['rule']) { |
287 | 287 | $query=$query->where(["rule"=>$filter['rule']]); |
288 | 288 | } |
@@ -328,7 +328,7 @@ discard block |
||
328 | 328 | if ($filter['practice']) { |
329 | 329 | $paginator=$paginator->where(["practice"=>$filter['practice']]); |
330 | 330 | } |
331 | - $paginator = $paginator ->paginate(10); |
|
331 | + $paginator=$paginator ->paginate(10); |
|
332 | 332 | } |
333 | 333 | $contest_list=$paginator->all(); |
334 | 334 | foreach ($contest_list as &$c) { |
@@ -366,14 +366,14 @@ discard block |
||
366 | 366 | } |
367 | 367 | } |
368 | 368 | |
369 | - public function registContest($cid,$uid) |
|
369 | + public function registContest($cid, $uid) |
|
370 | 370 | { |
371 | 371 | $registered=DB::table("contest_participant")->where([ |
372 | 372 | "cid"=>$cid, |
373 | 373 | "uid"=>$uid |
374 | 374 | ])->first(); |
375 | 375 | |
376 | - if(empty($registered)){ |
|
376 | + if (empty($registered)) { |
|
377 | 377 | DB::table("contest_participant")->insert([ |
378 | 378 | "cid"=>$cid, |
379 | 379 | "uid"=>$uid, |
@@ -406,9 +406,9 @@ discard block |
||
406 | 406 | public function problems($cid) |
407 | 407 | { |
408 | 408 | return DB::table('contest_problem') |
409 | - ->join('problem','contest_problem.pid','=','problem.pid') |
|
410 | - ->where('cid',$cid) |
|
411 | - ->select('problem.pid as pid','pcode','number') |
|
409 | + ->join('problem', 'contest_problem.pid', '=', 'problem.pid') |
|
410 | + ->where('cid', $cid) |
|
411 | + ->select('problem.pid as pid', 'pcode', 'number') |
|
412 | 412 | ->orderBy('number') |
413 | 413 | ->get()->all(); |
414 | 414 | } |
@@ -430,18 +430,18 @@ discard block |
||
430 | 430 | $end_time=strtotime(DB::table("contest")->where(["cid"=>$cid])->select("end_time")->first()["end_time"]); |
431 | 431 | |
432 | 432 | foreach ($problemSet as &$p) { |
433 | - if($p['practice']){ |
|
434 | - $tags = DB::table("group_problem_tag") |
|
435 | - ->where('gid',$p['gid']) |
|
436 | - ->where('pid',$p['pid']) |
|
433 | + if ($p['practice']) { |
|
434 | + $tags=DB::table("group_problem_tag") |
|
435 | + ->where('gid', $p['gid']) |
|
436 | + ->where('pid', $p['pid']) |
|
437 | 437 | ->get()->all(); |
438 | - $tags_arr = []; |
|
439 | - if(!empty($tags)){ |
|
438 | + $tags_arr=[]; |
|
439 | + if (!empty($tags)) { |
|
440 | 440 | foreach ($tags as $value) { |
441 | - array_push($tags_arr,$value['tag']); |
|
441 | + array_push($tags_arr, $value['tag']); |
|
442 | 442 | } |
443 | 443 | } |
444 | - $p['tags'] = $tags_arr; |
|
444 | + $p['tags']=$tags_arr; |
|
445 | 445 | } |
446 | 446 | if ($contest_rule==1) { |
447 | 447 | $prob_stat=DB::table("submission")->select( |
@@ -702,7 +702,7 @@ discard block |
||
702 | 702 | "problem_detail" => $prob_detail |
703 | 703 | ]; |
704 | 704 | } |
705 | - usort($ret, function ($a, $b) { |
|
705 | + usort($ret, function($a, $b) { |
|
706 | 706 | if ($a["score"]==$b["score"]) { |
707 | 707 | if ($a["penalty"]==$b["penalty"]) { |
708 | 708 | return 0; |
@@ -749,7 +749,7 @@ discard block |
||
749 | 749 | "problem_detail" => $prob_detail |
750 | 750 | ]; |
751 | 751 | } |
752 | - usort($ret, function ($a, $b) { |
|
752 | + usort($ret, function($a, $b) { |
|
753 | 753 | if ($a["score"]==$b["score"]) { |
754 | 754 | if ($a["solved"]==$b["solved"]) { |
755 | 755 | return 0; |
@@ -771,7 +771,7 @@ discard block |
||
771 | 771 | return $ret; |
772 | 772 | } |
773 | 773 | |
774 | - public function contestRank($cid, $uid = 0) |
|
774 | + public function contestRank($cid, $uid=0) |
|
775 | 775 | { |
776 | 776 | // [ToDo] If the current user's in the organizer group show nick name |
777 | 777 | // [ToDo] The participants determination |
@@ -789,35 +789,35 @@ discard block |
||
789 | 789 | "gid" => $contest_info["gid"] |
790 | 790 | ])->where("role", ">", 0)->first()); |
791 | 791 | |
792 | - $clearance = $this -> judgeClearance($cid, $uid); |
|
792 | + $clearance=$this -> judgeClearance($cid, $uid); |
|
793 | 793 | |
794 | 794 | /** New Version With MySQL */ |
795 | 795 | $end_time=strtotime(DB::table("contest")->where(["cid"=>$cid])->select("end_time")->first()["end_time"]); |
796 | 796 | |
797 | - if(time() < $end_time){ |
|
798 | - if($clearance == 3){ |
|
797 | + if (time()<$end_time) { |
|
798 | + if ($clearance==3) { |
|
799 | 799 | $contestRankRaw=Cache::tags(['contest', 'rank'])->get("contestAdmin$cid"); |
800 | - }else{ |
|
800 | + } else { |
|
801 | 801 | $contestRankRaw=Cache::tags(['contest', 'rank'])->get($cid); |
802 | 802 | } |
803 | - if(!isset($contestRankRaw)){ |
|
803 | + if (!isset($contestRankRaw)) { |
|
804 | 804 | $contestRankRaw=$this->contestRankCache($cid); |
805 | 805 | } |
806 | - }else{ |
|
807 | - if($clearance == 3){ |
|
806 | + } else { |
|
807 | + if ($clearance==3) { |
|
808 | 808 | $contestRankRaw=Cache::tags(['contest', 'rank'])->get("contestAdmin$cid"); |
809 | 809 | if (!isset($contestRankRaw)) { |
810 | 810 | $contestRankRaw=$this->getContestRankFromMySQL($cid); |
811 | - if(!isset($contestRankRaw)){ |
|
811 | + if (!isset($contestRankRaw)) { |
|
812 | 812 | $contestRankRaw=$this->contestRankCache($cid); |
813 | 813 | $this->storeContestRankInMySQL($cid, $contestRankRaw); |
814 | 814 | } |
815 | 815 | } |
816 | - }else{ |
|
816 | + } else { |
|
817 | 817 | $contestRankRaw=$this->getContestRankFromMySQL($cid); |
818 | - if(!isset($contestRankRaw)){ |
|
818 | + if (!isset($contestRankRaw)) { |
|
819 | 819 | $contestRankRaw=Cache::tags(['contest', 'rank'])->get($cid); |
820 | - if(!isset($contestRankRaw)){ |
|
820 | + if (!isset($contestRankRaw)) { |
|
821 | 821 | $contestRankRaw=$this->contestRankCache($cid); |
822 | 822 | } |
823 | 823 | $this->storeContestRankInMySQL($cid, $contestRankRaw); |
@@ -835,15 +835,15 @@ discard block |
||
835 | 835 | // $contestRankRaw=$this->contestRankCache($cid); |
836 | 836 | // } |
837 | 837 | // } |
838 | - if($contest_info["rule"]==1){ |
|
838 | + if ($contest_info["rule"]==1) { |
|
839 | 839 | foreach ($contestRankRaw as &$cr) { |
840 | - $solved = 0; |
|
841 | - foreach($cr['problem_detail'] as $pd){ |
|
842 | - if(!empty($pd['solved_time_parsed'])){ |
|
843 | - $solved ++; |
|
840 | + $solved=0; |
|
841 | + foreach ($cr['problem_detail'] as $pd) { |
|
842 | + if (!empty($pd['solved_time_parsed'])) { |
|
843 | + $solved++; |
|
844 | 844 | } |
845 | 845 | } |
846 | - $cr['solved'] = $solved; |
|
846 | + $cr['solved']=$solved; |
|
847 | 847 | } |
848 | 848 | } |
849 | 849 | |
@@ -892,16 +892,16 @@ discard block |
||
892 | 892 | |
893 | 893 | public function getClarificationList($cid) |
894 | 894 | { |
895 | - $uid = Auth::user()->id; |
|
896 | - $clearance = $this -> judgeClearance($cid, $uid); |
|
897 | - if($clearance == 3){ |
|
895 | + $uid=Auth::user()->id; |
|
896 | + $clearance=$this -> judgeClearance($cid, $uid); |
|
897 | + if ($clearance==3) { |
|
898 | 898 | return DB::table("contest_clarification")->where([ |
899 | 899 | "cid"=>$cid |
900 | 900 | ])->orderBy('create_time', 'desc')->get()->all(); |
901 | - }else{ |
|
901 | + } else { |
|
902 | 902 | return DB::table("contest_clarification")->where([ |
903 | 903 | "cid"=>$cid |
904 | - ])->where(function ($query) { |
|
904 | + ])->where(function($query) { |
|
905 | 905 | $query->where([ |
906 | 906 | "public"=>1 |
907 | 907 | ])->orWhere([ |
@@ -1046,7 +1046,7 @@ discard block |
||
1046 | 1046 | public function getContestRecord($filter, $cid) |
1047 | 1047 | { |
1048 | 1048 | $basicInfo=$this->basic($cid); |
1049 | - $userInfo=DB::table('group_member')->where('gid',$basicInfo["gid"])->where('uid',Auth::user()->id)->get()->first(); |
|
1049 | + $userInfo=DB::table('group_member')->where('gid', $basicInfo["gid"])->where('uid', Auth::user()->id)->get()->first(); |
|
1050 | 1050 | $problemSet_temp=DB::table("contest_problem")->join("problem", "contest_problem.pid", "=", "problem.pid")->where([ |
1051 | 1051 | "cid"=>$cid |
1052 | 1052 | ])->orderBy('ncode', 'asc')->select("ncode", "alias", "contest_problem.pid as pid", "title", "points", "tot_score")->get()->all(); |
@@ -1059,14 +1059,14 @@ discard block |
||
1059 | 1059 | $end_time=strtotime(DB::table("contest")->where(["cid"=>$cid])->select("end_time")->first()["end_time"]); |
1060 | 1060 | $contestEnd=time()>$end_time; |
1061 | 1061 | |
1062 | - $filter['pid'] = array_search($filter['ncode'], array_column($problemSet_temp, 'ncode')); |
|
1063 | - if($filter['pid']==false){ |
|
1064 | - $filter['pid'] = null; |
|
1065 | - }else{ |
|
1066 | - $filter['pid'] = $problemSet_temp[$filter['pid']]['pid']; |
|
1062 | + $filter['pid']=array_search($filter['ncode'], array_column($problemSet_temp, 'ncode')); |
|
1063 | + if ($filter['pid']==false) { |
|
1064 | + $filter['pid']=null; |
|
1065 | + } else { |
|
1066 | + $filter['pid']=$problemSet_temp[$filter['pid']]['pid']; |
|
1067 | 1067 | } |
1068 | 1068 | |
1069 | - if($userInfo==null || $userInfo["role"]!=3){ |
|
1069 | + if ($userInfo==null || $userInfo["role"]!=3) { |
|
1070 | 1070 | if ($basicInfo["status_visibility"]==2) { |
1071 | 1071 | // View all |
1072 | 1072 | $paginator=DB::table("submission")->where([ |
@@ -1080,7 +1080,7 @@ discard block |
||
1080 | 1080 | "users.id", |
1081 | 1081 | "=", |
1082 | 1082 | "submission.uid" |
1083 | - )->where(function ($query) use ($frozen_time) { |
|
1083 | + )->where(function($query) use ($frozen_time) { |
|
1084 | 1084 | $query->where( |
1085 | 1085 | "submission_date", |
1086 | 1086 | "<", |
@@ -1107,15 +1107,15 @@ discard block |
||
1107 | 1107 | 'desc' |
1108 | 1108 | ); |
1109 | 1109 | |
1110 | - if($filter["pid"]){ |
|
1110 | + if ($filter["pid"]) { |
|
1111 | 1111 | $paginator=$paginator->where(["pid"=>$filter["pid"]]); |
1112 | 1112 | } |
1113 | 1113 | |
1114 | - if($filter["result"]){ |
|
1114 | + if ($filter["result"]) { |
|
1115 | 1115 | $paginator=$paginator->where(["verdict"=>$filter["result"]]); |
1116 | 1116 | } |
1117 | 1117 | |
1118 | - if($filter["account"]){ |
|
1118 | + if ($filter["account"]) { |
|
1119 | 1119 | $paginator=$paginator->where(["name"=>$filter["account"]]); |
1120 | 1120 | } |
1121 | 1121 | |
@@ -1151,15 +1151,15 @@ discard block |
||
1151 | 1151 | 'desc' |
1152 | 1152 | ); |
1153 | 1153 | |
1154 | - if($filter["pid"]){ |
|
1154 | + if ($filter["pid"]) { |
|
1155 | 1155 | $paginator=$paginator->where(["pid"=>$filter["pid"]]); |
1156 | 1156 | } |
1157 | 1157 | |
1158 | - if($filter["result"]){ |
|
1158 | + if ($filter["result"]) { |
|
1159 | 1159 | $paginator=$paginator->where(["verdict"=>$filter["result"]]); |
1160 | 1160 | } |
1161 | 1161 | |
1162 | - if($filter["account"]){ |
|
1162 | + if ($filter["account"]) { |
|
1163 | 1163 | $paginator=$paginator->where(["name"=>$filter["account"]]); |
1164 | 1164 | } |
1165 | 1165 | |
@@ -1170,7 +1170,7 @@ discard block |
||
1170 | 1170 | "records"=>[] |
1171 | 1171 | ]; |
1172 | 1172 | } |
1173 | - }else{ |
|
1173 | + } else { |
|
1174 | 1174 | if ($basicInfo["status_visibility"]==2) { |
1175 | 1175 | // View all |
1176 | 1176 | $paginator=DB::table("submission")->where([ |
@@ -1202,15 +1202,15 @@ discard block |
||
1202 | 1202 | 'desc' |
1203 | 1203 | ); |
1204 | 1204 | |
1205 | - if($filter["pid"]){ |
|
1205 | + if ($filter["pid"]) { |
|
1206 | 1206 | $paginator=$paginator->where(["pid"=>$filter["pid"]]); |
1207 | 1207 | } |
1208 | 1208 | |
1209 | - if($filter["result"]){ |
|
1209 | + if ($filter["result"]) { |
|
1210 | 1210 | $paginator=$paginator->where(["verdict"=>$filter["result"]]); |
1211 | 1211 | } |
1212 | 1212 | |
1213 | - if($filter["account"]){ |
|
1213 | + if ($filter["account"]) { |
|
1214 | 1214 | $paginator=$paginator->where(["name"=>$filter["account"]]); |
1215 | 1215 | } |
1216 | 1216 | |
@@ -1246,15 +1246,15 @@ discard block |
||
1246 | 1246 | 'desc' |
1247 | 1247 | ); |
1248 | 1248 | |
1249 | - if($filter["pid"]){ |
|
1249 | + if ($filter["pid"]) { |
|
1250 | 1250 | $paginator=$paginator->where(["pid"=>$filter["pid"]]); |
1251 | 1251 | } |
1252 | 1252 | |
1253 | - if($filter["result"]){ |
|
1253 | + if ($filter["result"]) { |
|
1254 | 1254 | $paginator=$paginator->where(["verdict"=>$filter["result"]]); |
1255 | 1255 | } |
1256 | 1256 | |
1257 | - if($filter["account"]){ |
|
1257 | + if ($filter["account"]) { |
|
1258 | 1258 | $paginator=$paginator->where(["name"=>$filter["account"]]); |
1259 | 1259 | } |
1260 | 1260 | |
@@ -1310,21 +1310,21 @@ discard block |
||
1310 | 1310 | if ($uid==0) { |
1311 | 1311 | return 0; |
1312 | 1312 | } |
1313 | - $groupModel = new GroupModel(); |
|
1313 | + $groupModel=new GroupModel(); |
|
1314 | 1314 | $contest_info=DB::table("contest")->where("cid", $cid)->first(); |
1315 | - $userInfo=DB::table('group_member')->where('gid',$contest_info["gid"])->where('uid',$uid)->get()->first(); |
|
1315 | + $userInfo=DB::table('group_member')->where('gid', $contest_info["gid"])->where('uid', $uid)->get()->first(); |
|
1316 | 1316 | |
1317 | - if(empty($contest_info)){ |
|
1317 | + if (empty($contest_info)) { |
|
1318 | 1318 | // contest not exist |
1319 | 1319 | return 0; |
1320 | 1320 | } |
1321 | 1321 | |
1322 | - if($uid == $contest_info['assign_uid'] || $groupModel->judgeClearance($contest_info['gid'],$uid) == 3){ |
|
1322 | + if ($uid==$contest_info['assign_uid'] || $groupModel->judgeClearance($contest_info['gid'], $uid)==3) { |
|
1323 | 1323 | return 3; |
1324 | 1324 | } |
1325 | 1325 | |
1326 | - $contest_started = strtotime($contest_info['begin_time']) < time(); |
|
1327 | - $contest_ended = strtotime($contest_info['end_time']) < time(); |
|
1326 | + $contest_started=strtotime($contest_info['begin_time'])<time(); |
|
1327 | + $contest_ended=strtotime($contest_info['end_time'])<time(); |
|
1328 | 1328 | if (!$contest_started) { |
1329 | 1329 | // not started or do not exist |
1330 | 1330 | return 0; |
@@ -1415,12 +1415,12 @@ discard block |
||
1415 | 1415 | public function updateProfessionalRate($cid) |
1416 | 1416 | { |
1417 | 1417 | $basic=$this->basic($cid); |
1418 | - if($basic["rated"]&&!$basic["is_rated"]){ |
|
1418 | + if ($basic["rated"] && !$basic["is_rated"]) { |
|
1419 | 1419 | $ratingCalculator=new RatingCalculator($cid); |
1420 | - if($ratingCalculator->calculate()){ |
|
1420 | + if ($ratingCalculator->calculate()) { |
|
1421 | 1421 | $ratingCalculator->storage(); |
1422 | 1422 | return true; |
1423 | - }else{ |
|
1423 | + } else { |
|
1424 | 1424 | return false; |
1425 | 1425 | } |
1426 | 1426 | } else { |
@@ -1428,26 +1428,26 @@ discard block |
||
1428 | 1428 | } |
1429 | 1429 | } |
1430 | 1430 | |
1431 | - public function contestUpdate($cid,$data,$problems) |
|
1431 | + public function contestUpdate($cid, $data, $problems) |
|
1432 | 1432 | { |
1433 | - if($problems !== false){ |
|
1434 | - $old_problmes = array_column( |
|
1433 | + if ($problems!==false) { |
|
1434 | + $old_problmes=array_column( |
|
1435 | 1435 | DB::table('contest_problem') |
1436 | - ->where('cid',$cid) |
|
1436 | + ->where('cid', $cid) |
|
1437 | 1437 | ->get()->all(), |
1438 | 1438 | 'pid' |
1439 | 1439 | ); |
1440 | - DB::transaction(function () use ($cid, $data, $problems,$old_problmes) { |
|
1440 | + DB::transaction(function() use ($cid, $data, $problems, $old_problmes) { |
|
1441 | 1441 | DB::table($this->tableName) |
1442 | - ->where('cid',$cid) |
|
1442 | + ->where('cid', $cid) |
|
1443 | 1443 | ->update($data); |
1444 | 1444 | DB::table('contest_problem') |
1445 | - ->where('cid',$cid) |
|
1445 | + ->where('cid', $cid) |
|
1446 | 1446 | ->delete(); |
1447 | - $new_problems = []; |
|
1447 | + $new_problems=[]; |
|
1448 | 1448 | foreach ($problems as $p) { |
1449 | 1449 | $pid=DB::table("problem")->where(["pcode"=>$p["pcode"]])->select("pid")->first()["pid"]; |
1450 | - array_push($new_problems,$pid); |
|
1450 | + array_push($new_problems, $pid); |
|
1451 | 1451 | DB::table("contest_problem")->insert([ |
1452 | 1452 | "cid"=>$cid, |
1453 | 1453 | "number"=>$p["number"], |
@@ -1457,29 +1457,29 @@ discard block |
||
1457 | 1457 | "points"=>$p["points"] |
1458 | 1458 | ]); |
1459 | 1459 | } |
1460 | - foreach($old_problmes as $op) { |
|
1461 | - if(!in_array($op,$new_problems)){ |
|
1460 | + foreach ($old_problmes as $op) { |
|
1461 | + if (!in_array($op, $new_problems)) { |
|
1462 | 1462 | DB::table('submission') |
1463 | - ->where('cid',$cid) |
|
1464 | - ->where('pid',$op) |
|
1463 | + ->where('cid', $cid) |
|
1464 | + ->where('pid', $op) |
|
1465 | 1465 | ->delete(); |
1466 | 1466 | } |
1467 | 1467 | } |
1468 | 1468 | }, 5); |
1469 | - $contestRankRaw = $this->contestRankCache($cid); |
|
1469 | + $contestRankRaw=$this->contestRankCache($cid); |
|
1470 | 1470 | Cache::tags(['contest', 'rank'])->put($cid, $contestRankRaw); |
1471 | 1471 | Cache::tags(['contest', 'rank'])->put("contestAdmin$cid", $contestRankRaw); |
1472 | - }else{ |
|
1472 | + } else { |
|
1473 | 1473 | DB::table($this->tableName) |
1474 | - ->where('cid',$cid) |
|
1474 | + ->where('cid', $cid) |
|
1475 | 1475 | ->update($data); |
1476 | 1476 | } |
1477 | 1477 | } |
1478 | 1478 | |
1479 | - public function contestUpdateProblem($cid,$problems) |
|
1479 | + public function contestUpdateProblem($cid, $problems) |
|
1480 | 1480 | { |
1481 | 1481 | DB::table('contest_problem') |
1482 | - ->where('cid',$cid) |
|
1482 | + ->where('cid', $cid) |
|
1483 | 1483 | ->delete(); |
1484 | 1484 | foreach ($problems as $p) { |
1485 | 1485 | DB::table("contest_problem")->insertGetId([ |
@@ -1495,8 +1495,8 @@ discard block |
||
1495 | 1495 | |
1496 | 1496 | public function arrangeContest($gid, $config, $problems) |
1497 | 1497 | { |
1498 | - $cid = -1; |
|
1499 | - DB::transaction(function () use ($gid, $config, $problems,&$cid) { |
|
1498 | + $cid=-1; |
|
1499 | + DB::transaction(function() use ($gid, $config, $problems, &$cid) { |
|
1500 | 1500 | $cid=DB::table($this->tableName)->insertGetId([ |
1501 | 1501 | "gid"=>$gid, |
1502 | 1502 | "name"=>$config["name"], |
@@ -1510,7 +1510,7 @@ discard block |
||
1510 | 1510 | "rule"=>1, //todo |
1511 | 1511 | "begin_time"=>$config["begin_time"], |
1512 | 1512 | "end_time"=>$config["end_time"], |
1513 | - "vcid"=>isset($config["vcid"])?$config["vcid"]:null, |
|
1513 | + "vcid"=>isset($config["vcid"]) ? $config["vcid"] : null, |
|
1514 | 1514 | "public"=>$config["public"], |
1515 | 1515 | "registration"=>0, //todo |
1516 | 1516 | "registration_due"=>null, //todo |
@@ -1518,7 +1518,7 @@ discard block |
||
1518 | 1518 | "froze_length"=>0, //todo |
1519 | 1519 | "status_visibility"=>2, //todo |
1520 | 1520 | "create_time"=>date("Y-m-d H:i:s"), |
1521 | - "crawled" => isset($config['vcid'])?$config['crawled'] : null, |
|
1521 | + "crawled" => isset($config['vcid']) ? $config['crawled'] : null, |
|
1522 | 1522 | "audit_status"=>$config["public"] ? 0 : 1 |
1523 | 1523 | ]); |
1524 | 1524 | |
@@ -1537,13 +1537,13 @@ discard block |
||
1537 | 1537 | return $cid; |
1538 | 1538 | } |
1539 | 1539 | |
1540 | - public function updateContestRankTable($cid,$sub) |
|
1540 | + public function updateContestRankTable($cid, $sub) |
|
1541 | 1541 | { |
1542 | - $lock = Cache::lock("contestrank$cid",10); |
|
1543 | - try{ |
|
1544 | - if($lock->get()){ |
|
1545 | - if(Cache::tags(['contest','rank'])->get($cid) != null){ |
|
1546 | - $ret = Cache::tags(['contest','rank'])->get($cid); |
|
1542 | + $lock=Cache::lock("contestrank$cid", 10); |
|
1543 | + try { |
|
1544 | + if ($lock->get()) { |
|
1545 | + if (Cache::tags(['contest', 'rank'])->get($cid)!=null) { |
|
1546 | + $ret=Cache::tags(['contest', 'rank'])->get($cid); |
|
1547 | 1547 | $chache=[]; |
1548 | 1548 | $chache['contest_info']=DB::table("contest")->where("cid", $cid)->first(); |
1549 | 1549 | $chache['problemSet']=DB::table("contest_problem")->join("problem", "contest_problem.pid", "=", "problem.pid")->where([ |
@@ -1552,27 +1552,27 @@ discard block |
||
1552 | 1552 | $chache['frozen_time']=DB::table("contest")->where(["cid"=>$cid])->select(DB::raw("UNIX_TIMESTAMP(end_time)-froze_length as frozen_time"))->first()["frozen_time"]; |
1553 | 1553 | $chache['end_time']=strtotime(DB::table("contest")->where(["cid"=>$cid])->select("end_time")->first()["end_time"]); |
1554 | 1554 | |
1555 | - $id = 0; |
|
1555 | + $id=0; |
|
1556 | 1556 | |
1557 | - foreach($chache['problemSet'] as $key => $p){ |
|
1558 | - if ($p['pid'] == $sub['pid']){ |
|
1559 | - $chache['problemSet'][$key]['cpid'] = $key; |
|
1560 | - $id = $key; |
|
1557 | + foreach ($chache['problemSet'] as $key => $p) { |
|
1558 | + if ($p['pid']==$sub['pid']) { |
|
1559 | + $chache['problemSet'][$key]['cpid']=$key; |
|
1560 | + $id=$key; |
|
1561 | 1561 | } |
1562 | 1562 | } |
1563 | 1563 | |
1564 | - $ret = $this->updateContestRankDetail($chache['contest_info'],$chache['problemSet'][$id],$cid,$sub['uid'],$ret); |
|
1565 | - $ret = $this->sortContestRankTable($chache['contest_info'],$cid,$ret); |
|
1564 | + $ret=$this->updateContestRankDetail($chache['contest_info'], $chache['problemSet'][$id], $cid, $sub['uid'], $ret); |
|
1565 | + $ret=$this->sortContestRankTable($chache['contest_info'], $cid, $ret); |
|
1566 | 1566 | |
1567 | - if (time() < $chache['frozen_time']){ |
|
1567 | + if (time()<$chache['frozen_time']) { |
|
1568 | 1568 | Cache::tags(['contest', 'rank'])->put($cid, $ret); |
1569 | 1569 | } |
1570 | 1570 | Cache::tags(['contest', 'rank'])->put("contestAdmin$cid", $ret); |
1571 | - if(time() > $chache['end_time']){ |
|
1571 | + if (time()>$chache['end_time']) { |
|
1572 | 1572 | $this->storeContestRankInMySQL($cid, $ret); |
1573 | 1573 | } |
1574 | 1574 | } |
1575 | - else{ |
|
1575 | + else { |
|
1576 | 1576 | $ret=[]; |
1577 | 1577 | $chache=[]; |
1578 | 1578 | $chache['contest_info']=DB::table("contest")->where("cid", $cid)->first(); |
@@ -1587,7 +1587,7 @@ discard block |
||
1587 | 1587 | "cid"=>$cid, |
1588 | 1588 | "audit"=>1 |
1589 | 1589 | ])->select('uid')->get()->all(); |
1590 | - }else{ |
|
1590 | + } else { |
|
1591 | 1591 | $submissionUsers=DB::table("submission")->where([ |
1592 | 1592 | "cid"=>$cid |
1593 | 1593 | ])->where( |
@@ -1600,39 +1600,39 @@ discard block |
||
1600 | 1600 | ])->select('uid')->groupBy('uid')->get()->all(); |
1601 | 1601 | } |
1602 | 1602 | |
1603 | - $chacheAdmin = $chache; |
|
1603 | + $chacheAdmin=$chache; |
|
1604 | 1604 | |
1605 | 1605 | foreach ($submissionUsers as $s) { |
1606 | 1606 | foreach ($chache['problemSet'] as $key => $p) { |
1607 | - $p['cpid'] = $key; |
|
1608 | - $ret = $this->updateContestRankDetail($chache['contest_info'],$p,$cid,$s['uid'],$ret); |
|
1607 | + $p['cpid']=$key; |
|
1608 | + $ret=$this->updateContestRankDetail($chache['contest_info'], $p, $cid, $s['uid'], $ret); |
|
1609 | 1609 | } |
1610 | 1610 | } |
1611 | - $ret = $this->sortContestRankTable($chache['contest_info'],$cid,$ret); |
|
1611 | + $ret=$this->sortContestRankTable($chache['contest_info'], $cid, $ret); |
|
1612 | 1612 | Cache::tags(['contest', 'rank'])->put($cid, $ret); |
1613 | 1613 | |
1614 | 1614 | $retAdmin=[]; |
1615 | 1615 | foreach ($submissionUsersAdmin as $s) { |
1616 | 1616 | foreach ($chacheAdmin['problemSet'] as $key => $p) { |
1617 | - $p['cpid'] = $key; |
|
1618 | - $retAdmin = $this->updateContestRankDetail($chacheAdmin['contest_info'],$p,$cid,$s['uid'],$retAdmin); |
|
1617 | + $p['cpid']=$key; |
|
1618 | + $retAdmin=$this->updateContestRankDetail($chacheAdmin['contest_info'], $p, $cid, $s['uid'], $retAdmin); |
|
1619 | 1619 | } |
1620 | 1620 | } |
1621 | - $retAdmin = $this->sortContestRankTable($chacheAdmin['contest_info'],$cid,$retAdmin); |
|
1621 | + $retAdmin=$this->sortContestRankTable($chacheAdmin['contest_info'], $cid, $retAdmin); |
|
1622 | 1622 | Cache::tags(['contest', 'rank'])->put("contestAdmin$cid", $retAdmin); |
1623 | 1623 | } |
1624 | 1624 | } |
1625 | - }catch(LockTimeoutException $e){ |
|
1625 | + } catch (LockTimeoutException $e) { |
|
1626 | 1626 | Log::warning("Contest Rank Lock Timed Out"); |
1627 | - }finally{ |
|
1627 | + } finally { |
|
1628 | 1628 | optional($lock)->release(); |
1629 | 1629 | } |
1630 | 1630 | } |
1631 | 1631 | |
1632 | - public function sortContestRankTable($contest_info,$cid,$ret) |
|
1632 | + public function sortContestRankTable($contest_info, $cid, $ret) |
|
1633 | 1633 | { |
1634 | - if ($contest_info["rule"]==1){ |
|
1635 | - usort($ret, function ($a, $b) { |
|
1634 | + if ($contest_info["rule"]==1) { |
|
1635 | + usort($ret, function($a, $b) { |
|
1636 | 1636 | if ($a["score"]==$b["score"]) { |
1637 | 1637 | if ($a["penalty"]==$b["penalty"]) { |
1638 | 1638 | return 0; |
@@ -1647,8 +1647,8 @@ discard block |
||
1647 | 1647 | return 1; |
1648 | 1648 | } |
1649 | 1649 | }); |
1650 | - }else if ($contest_info["rule"]==2){ |
|
1651 | - usort($ret, function ($a, $b) { |
|
1650 | + } else if ($contest_info["rule"]==2) { |
|
1651 | + usort($ret, function($a, $b) { |
|
1652 | 1652 | if ($a["score"]==$b["score"]) { |
1653 | 1653 | if ($a["solved"]==$b["solved"]) { |
1654 | 1654 | return 0; |
@@ -1667,21 +1667,21 @@ discard block |
||
1667 | 1667 | return $ret; |
1668 | 1668 | } |
1669 | 1669 | |
1670 | - public function updateContestRankDetail($contest_info,$problem,$cid,$uid,$ret) |
|
1670 | + public function updateContestRankDetail($contest_info, $problem, $cid, $uid, $ret) |
|
1671 | 1671 | { |
1672 | - $id = count($ret); |
|
1673 | - foreach($ret as $key => $r){ |
|
1674 | - if($r['uid'] == $uid) |
|
1675 | - $id = $key; |
|
1672 | + $id=count($ret); |
|
1673 | + foreach ($ret as $key => $r) { |
|
1674 | + if ($r['uid']==$uid) |
|
1675 | + $id=$key; |
|
1676 | 1676 | } |
1677 | 1677 | if ($contest_info["rule"]==1) { |
1678 | 1678 | // ACM/ICPC Mode |
1679 | - if($id == count($ret)){ |
|
1680 | - $prob_detail = []; |
|
1681 | - $totPen = 0; |
|
1682 | - $totScore = 0; |
|
1683 | - }else{ |
|
1684 | - $prob_detail = $ret[$id]['problem_detail']; |
|
1679 | + if ($id==count($ret)) { |
|
1680 | + $prob_detail=[]; |
|
1681 | + $totPen=0; |
|
1682 | + $totScore=0; |
|
1683 | + } else { |
|
1684 | + $prob_detail=$ret[$id]['problem_detail']; |
|
1685 | 1685 | $totPen=$ret[$id]['penalty']; |
1686 | 1686 | $totScore=$ret[$id]['score']; |
1687 | 1687 | }; |
@@ -1699,7 +1699,7 @@ discard block |
||
1699 | 1699 | "uid"=>$uid, |
1700 | 1700 | ])->orderBy('submission_date', 'desc')->first(); |
1701 | 1701 | |
1702 | - if ($ac_times<=1 && isset($last_record) && $last_record['verdict']!="Waiting" && $last_record['verdict']!="Submission Error" && $last_record['verdict']!="System Error"){ |
|
1702 | + if ($ac_times<=1 && isset($last_record) && $last_record['verdict']!="Waiting" && $last_record['verdict']!="Submission Error" && $last_record['verdict']!="System Error") { |
|
1703 | 1703 | $prob_stat=$this->contestProblemInfoACM($cid, $problem["pid"], $uid); |
1704 | 1704 | |
1705 | 1705 | $prob_detail[$problem['cpid']]=[ |
@@ -1731,12 +1731,12 @@ discard block |
||
1731 | 1731 | } |
1732 | 1732 | } elseif ($contest_info["rule"]==2) { |
1733 | 1733 | // OI Mode |
1734 | - if($id == count($ret)){ |
|
1735 | - $prob_detail = []; |
|
1736 | - $totSolved = 0; |
|
1737 | - $totScore = 0; |
|
1738 | - }else{ |
|
1739 | - $prob_detail = $ret[$id]['problem_detail']; |
|
1734 | + if ($id==count($ret)) { |
|
1735 | + $prob_detail=[]; |
|
1736 | + $totSolved=0; |
|
1737 | + $totScore=0; |
|
1738 | + } else { |
|
1739 | + $prob_detail=$ret[$id]['problem_detail']; |
|
1740 | 1740 | $totSolved=$ret[$id]['solved']; |
1741 | 1741 | $totScore=$ret[$id]['score']; |
1742 | 1742 | }; |
@@ -1769,47 +1769,47 @@ discard block |
||
1769 | 1769 | return $ret; |
1770 | 1770 | } |
1771 | 1771 | |
1772 | - public function assignMember($cid,$uid){ |
|
1772 | + public function assignMember($cid, $uid) { |
|
1773 | 1773 | return DB::table("contest")->where(["cid"=>$cid])->update([ |
1774 | 1774 | "assign_uid"=>$uid |
1775 | 1775 | ]); |
1776 | 1776 | } |
1777 | 1777 | |
1778 | - public function canUpdateContestTime($cid,$time = []) |
|
1778 | + public function canUpdateContestTime($cid, $time=[]) |
|
1779 | 1779 | { |
1780 | - $begin_time_new = $time['begin'] ?? null; |
|
1781 | - $end_time_new = $time['end'] ?? null; |
|
1780 | + $begin_time_new=$time['begin'] ?? null; |
|
1781 | + $end_time_new=$time['end'] ?? null; |
|
1782 | 1782 | |
1783 | - $hold_time = DB::table('contest') |
|
1784 | - ->where('cid',$cid) |
|
1785 | - ->select('begin_time','end_time') |
|
1783 | + $hold_time=DB::table('contest') |
|
1784 | + ->where('cid', $cid) |
|
1785 | + ->select('begin_time', 'end_time') |
|
1786 | 1786 | ->first(); |
1787 | - $begin_stamps = strtotime($hold_time['begin_time']); |
|
1788 | - $end_stamps = strtotime($hold_time['end_time']); |
|
1787 | + $begin_stamps=strtotime($hold_time['begin_time']); |
|
1788 | + $end_stamps=strtotime($hold_time['end_time']); |
|
1789 | 1789 | /* |
1790 | 1790 | -1 : have not begun |
1791 | 1791 | 0 : ing |
1792 | 1792 | 1 : end |
1793 | 1793 | */ |
1794 | - $status = time() >= $end_stamps ? 1 |
|
1795 | - : (time() <= $begin_stamps ? -1 : 0); |
|
1796 | - if($status === -1){ |
|
1797 | - if(time() > $begin_time_new){ |
|
1794 | + $status=time()>=$end_stamps ? 1 |
|
1795 | + : (time()<=$begin_stamps ? -1 : 0); |
|
1796 | + if ($status===-1) { |
|
1797 | + if (time()>$begin_time_new) { |
|
1798 | 1798 | return false; |
1799 | 1799 | } |
1800 | 1800 | return true; |
1801 | - }else if($status === 0){ |
|
1802 | - if($begin_time_new !== null){ |
|
1801 | + } else if ($status===0) { |
|
1802 | + if ($begin_time_new!==null) { |
|
1803 | 1803 | return false; |
1804 | 1804 | } |
1805 | - if($end_time_new !== null){ |
|
1806 | - if(strtotime($end_time_new) <= time()){ |
|
1805 | + if ($end_time_new!==null) { |
|
1806 | + if (strtotime($end_time_new)<=time()) { |
|
1807 | 1807 | return false; |
1808 | - }else{ |
|
1808 | + } else { |
|
1809 | 1809 | return true; |
1810 | 1810 | } |
1811 | 1811 | } |
1812 | - }else{ |
|
1812 | + } else { |
|
1813 | 1813 | return false; |
1814 | 1814 | } |
1815 | 1815 | |
@@ -1818,22 +1818,22 @@ discard block |
||
1818 | 1818 | |
1819 | 1819 | public function replyClarification($ccid, $content) |
1820 | 1820 | { |
1821 | - return DB::table("contest_clarification")->where('ccid','=',$ccid)->update([ |
|
1821 | + return DB::table("contest_clarification")->where('ccid', '=', $ccid)->update([ |
|
1822 | 1822 | "reply"=>$content |
1823 | 1823 | ]); |
1824 | 1824 | } |
1825 | 1825 | |
1826 | 1826 | public function setClarificationPublic($ccid, $public) |
1827 | 1827 | { |
1828 | - if($public) |
|
1828 | + if ($public) |
|
1829 | 1829 | { |
1830 | - return DB::table("contest_clarification")->where('ccid','=',$ccid)->update([ |
|
1830 | + return DB::table("contest_clarification")->where('ccid', '=', $ccid)->update([ |
|
1831 | 1831 | "public"=>1 |
1832 | 1832 | ]); |
1833 | 1833 | } |
1834 | 1834 | else |
1835 | 1835 | { |
1836 | - return DB::table("contest_clarification")->where('ccid','=',$ccid)->update([ |
|
1836 | + return DB::table("contest_clarification")->where('ccid', '=', $ccid)->update([ |
|
1837 | 1837 | "public"=>0 |
1838 | 1838 | ]); |
1839 | 1839 | } |
@@ -1844,67 +1844,67 @@ discard block |
||
1844 | 1844 | return Cache::tags(['contest', 'account'])->get($cid); |
1845 | 1845 | } |
1846 | 1846 | |
1847 | - public function praticeAnalysis($cid){ |
|
1848 | - $gid = DB::table('contest') |
|
1849 | - ->where('cid',$cid) |
|
1847 | + public function praticeAnalysis($cid) { |
|
1848 | + $gid=DB::table('contest') |
|
1849 | + ->where('cid', $cid) |
|
1850 | 1850 | ->first()['gid']; |
1851 | - $contestRank = $this->contestRank($cid,Auth::user()->id); |
|
1852 | - if(!empty($contestRank)){ |
|
1853 | - $all_problems = DB::table('problem') |
|
1854 | - ->whereIn('pid',array_column($contestRank[0]['problem_detail'],'pid')) |
|
1855 | - ->select('pid','title') |
|
1851 | + $contestRank=$this->contestRank($cid, Auth::user()->id); |
|
1852 | + if (!empty($contestRank)) { |
|
1853 | + $all_problems=DB::table('problem') |
|
1854 | + ->whereIn('pid', array_column($contestRank[0]['problem_detail'], 'pid')) |
|
1855 | + ->select('pid', 'title') |
|
1856 | 1856 | ->get()->all(); |
1857 | - }else{ |
|
1858 | - $all_problems = []; |
|
1857 | + } else { |
|
1858 | + $all_problems=[]; |
|
1859 | 1859 | } |
1860 | - $tags = DB::table('group_problem_tag') |
|
1860 | + $tags=DB::table('group_problem_tag') |
|
1861 | 1861 | ->where('gid', $gid) |
1862 | - ->whereIn('pid', array_column($all_problems,'pid')) |
|
1862 | + ->whereIn('pid', array_column($all_problems, 'pid')) |
|
1863 | 1863 | ->get()->all(); |
1864 | - $all_tags = array_unique(array_column($tags,'tag')); |
|
1865 | - $memberData = []; |
|
1866 | - foreach($contestRank as $member){ |
|
1867 | - $m = [ |
|
1864 | + $all_tags=array_unique(array_column($tags, 'tag')); |
|
1865 | + $memberData=[]; |
|
1866 | + foreach ($contestRank as $member) { |
|
1867 | + $m=[ |
|
1868 | 1868 | 'uid' => $member['uid'], |
1869 | 1869 | 'name' => $member['name'], |
1870 | 1870 | 'nick_name' => $member['nick_name'], |
1871 | 1871 | ]; |
1872 | - $completion = []; |
|
1873 | - foreach ($all_tags as $tag){ |
|
1874 | - $completion[$tag] = []; |
|
1872 | + $completion=[]; |
|
1873 | + foreach ($all_tags as $tag) { |
|
1874 | + $completion[$tag]=[]; |
|
1875 | 1875 | foreach ($tags as $t) { |
1876 | - if($t['tag'] == $tag){ |
|
1876 | + if ($t['tag']==$tag) { |
|
1877 | 1877 | foreach ($member['problem_detail'] as $pd) { |
1878 | - if($pd['pid'] == $t['pid']){ |
|
1879 | - $completion[$tag][$t['pid']] = $pd['solved_time_parsed'] == "" ? 0 : 1; |
|
1878 | + if ($pd['pid']==$t['pid']) { |
|
1879 | + $completion[$tag][$t['pid']]=$pd['solved_time_parsed']=="" ? 0 : 1; |
|
1880 | 1880 | } |
1881 | 1881 | } |
1882 | 1882 | } |
1883 | 1883 | } |
1884 | 1884 | } |
1885 | - $m['completion'] = $completion; |
|
1886 | - $memberData[] = $m; |
|
1885 | + $m['completion']=$completion; |
|
1886 | + $memberData[]=$m; |
|
1887 | 1887 | } |
1888 | 1888 | return $memberData; |
1889 | 1889 | } |
1890 | 1890 | |
1891 | 1891 | public function storeContestRankInMySQL($cid, $data) |
1892 | 1892 | { |
1893 | - $contestRankJson = json_encode($data); |
|
1894 | - return DB::table('contest')->where('cid','=',$cid)->update([ |
|
1893 | + $contestRankJson=json_encode($data); |
|
1894 | + return DB::table('contest')->where('cid', '=', $cid)->update([ |
|
1895 | 1895 | 'rank' => $contestRankJson |
1896 | 1896 | ]); |
1897 | 1897 | } |
1898 | 1898 | |
1899 | 1899 | public function getContestRankFromMySQL($cid) |
1900 | 1900 | { |
1901 | - $contestRankJson = DB::table('contest')->where('cid','=',$cid)->pluck('rank')->first(); |
|
1902 | - $data = json_decode($contestRankJson, true); |
|
1901 | + $contestRankJson=DB::table('contest')->where('cid', '=', $cid)->pluck('rank')->first(); |
|
1902 | + $data=json_decode($contestRankJson, true); |
|
1903 | 1903 | return $data; |
1904 | 1904 | } |
1905 | 1905 | |
1906 | 1906 | public function isVerified($cid) |
1907 | 1907 | { |
1908 | - return DB::table('contest')->where('cid','=',$cid)->pluck('verified')->first(); |
|
1908 | + return DB::table('contest')->where('cid', '=', $cid)->pluck('verified')->first(); |
|
1909 | 1909 | } |
1910 | 1910 | } |
@@ -11,7 +11,7 @@ |
||
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 |
@@ -28,8 +28,8 @@ discard block |
||
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 |
||
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; |
@@ -16,16 +16,16 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 | } |
@@ -13,14 +13,14 @@ discard block |
||
13 | 13 | { |
14 | 14 | public function redirectTo() |
15 | 15 | { |
16 | - $accountModel = new AccountModel(); |
|
17 | - if(Auth::check() && $accountModel->getExtra(Auth::user()->id ,'github_id')){ |
|
18 | - return view('oauth.index',[ |
|
16 | + $accountModel=new AccountModel(); |
|
17 | + if (Auth::check() && $accountModel->getExtra(Auth::user()->id, 'github_id')) { |
|
18 | + return view('oauth.index', [ |
|
19 | 19 | 'page_title'=>"OAuth", |
20 | 20 | 'site_title'=>config("app.name"), |
21 | 21 | 'navigation'=>"OAuth", |
22 | 22 | 'platform' => 'Github', |
23 | - 'display_html' => 'You\'re already tied to the github account : <span class="text-info">'.$accountModel->getExtra(Auth::user()->id ,'github_email').'</span><br /> |
|
23 | + 'display_html' => 'You\'re already tied to the github account : <span class="text-info">'.$accountModel->getExtra(Auth::user()->id, 'github_email').'</span><br /> |
|
24 | 24 | You can choose to unbind or go back to the homepage', |
25 | 25 | 'buttons' => [ |
26 | 26 | [ |
@@ -40,19 +40,19 @@ discard block |
||
40 | 40 | |
41 | 41 | public function handleCallback() |
42 | 42 | { |
43 | - try{ |
|
44 | - $github_user = Socialite::driver('github')->user(); |
|
45 | - }catch(\Laravel\Socialite\Two\InvalidStateException $e){ |
|
43 | + try { |
|
44 | + $github_user=Socialite::driver('github')->user(); |
|
45 | + } catch (\Laravel\Socialite\Two\InvalidStateException $e) { |
|
46 | 46 | return redirect('/'); |
47 | 47 | } |
48 | 48 | |
49 | - $accountModel = new AccountModel(); |
|
50 | - if(Auth::check()){ |
|
51 | - $user_id = Auth::user()->id; |
|
52 | - $ret = $accountModel->findExtra('github_id',$github_user->id); |
|
53 | - if(!empty($ret) && $ret['uid'] != $user_id){ |
|
54 | - $user = UserModel::find($ret['uid']); |
|
55 | - return view('oauth.index',[ |
|
49 | + $accountModel=new AccountModel(); |
|
50 | + if (Auth::check()) { |
|
51 | + $user_id=Auth::user()->id; |
|
52 | + $ret=$accountModel->findExtra('github_id', $github_user->id); |
|
53 | + if (!empty($ret) && $ret['uid']!=$user_id) { |
|
54 | + $user=UserModel::find($ret['uid']); |
|
55 | + return view('oauth.index', [ |
|
56 | 56 | 'page_title'=>"OAuth", |
57 | 57 | 'site_title'=>config("app.name"), |
58 | 58 | 'navigation'=>"OAuth", |
@@ -67,17 +67,17 @@ discard block |
||
67 | 67 | ] |
68 | 68 | ]); |
69 | 69 | } |
70 | - $accountModel->setExtra($user_id,'github_id',$github_user->id); |
|
71 | - $accountModel->setExtra($user_id,'github_email',$github_user->email); |
|
72 | - $accountModel->setExtra($user_id,'github_nickname',$github_user->nickname); |
|
73 | - $accountModel->setExtra($user_id,'github_homepage',($github_user->user)['html_url']); |
|
74 | - $accountModel->setExtra($user_id,'github_token',$github_user->token,101); |
|
75 | - return view('oauth.index',[ |
|
70 | + $accountModel->setExtra($user_id, 'github_id', $github_user->id); |
|
71 | + $accountModel->setExtra($user_id, 'github_email', $github_user->email); |
|
72 | + $accountModel->setExtra($user_id, 'github_nickname', $github_user->nickname); |
|
73 | + $accountModel->setExtra($user_id, 'github_homepage', ($github_user->user)['html_url']); |
|
74 | + $accountModel->setExtra($user_id, 'github_token', $github_user->token, 101); |
|
75 | + return view('oauth.index', [ |
|
76 | 76 | 'page_title'=>"OAuth", |
77 | 77 | 'site_title'=>config("app.name"), |
78 | 78 | 'navigation'=>"OAuth", |
79 | 79 | 'platform' => 'Github', |
80 | - 'display_html' => 'You have successfully tied up the github account : <span class="text-info">'.$accountModel->getExtra(Auth::user()->id ,'github_email').'</span><br /> |
|
80 | + 'display_html' => 'You have successfully tied up the github account : <span class="text-info">'.$accountModel->getExtra(Auth::user()->id, 'github_email').'</span><br /> |
|
81 | 81 | You can log in to '.config("app.name").' later using this account', |
82 | 82 | 'buttons' => [ |
83 | 83 | [ |
@@ -86,18 +86,18 @@ discard block |
||
86 | 86 | ], |
87 | 87 | ] |
88 | 88 | ]); |
89 | - }else{ |
|
90 | - $ret = $accountModel->findExtra('github_id',$github_user->id); |
|
91 | - if(!empty($ret)){ |
|
89 | + } else { |
|
90 | + $ret=$accountModel->findExtra('github_id', $github_user->id); |
|
91 | + if (!empty($ret)) { |
|
92 | 92 | Auth::loginUsingId($ret['uid']); |
93 | - $user_id = Auth::user()->id; |
|
94 | - $accountModel->setExtra($user_id,'github_email',$github_user->email); |
|
95 | - $accountModel->setExtra($user_id,'github_nickname',$github_user->nickname); |
|
96 | - $accountModel->setExtra($user_id,'github_homepage',($github_user->user)['html_url']); |
|
97 | - $accountModel->setExtra($user_id,'github_token',$github_user->token,101); |
|
93 | + $user_id=Auth::user()->id; |
|
94 | + $accountModel->setExtra($user_id, 'github_email', $github_user->email); |
|
95 | + $accountModel->setExtra($user_id, 'github_nickname', $github_user->nickname); |
|
96 | + $accountModel->setExtra($user_id, 'github_homepage', ($github_user->user)['html_url']); |
|
97 | + $accountModel->setExtra($user_id, 'github_token', $github_user->token, 101); |
|
98 | 98 | return redirect('/'); |
99 | - }else{ |
|
100 | - return view('oauth.index',[ |
|
99 | + } else { |
|
100 | + return view('oauth.index', [ |
|
101 | 101 | 'page_title'=>"OAuth", |
102 | 102 | 'site_title'=>config("app.name"), |
103 | 103 | 'navigation'=>"OAuth", |
@@ -120,16 +120,16 @@ discard block |
||
120 | 120 | |
121 | 121 | public function unbind() |
122 | 122 | { |
123 | - $accountModel = new AccountModel(); |
|
124 | - if($accountModel->getExtra(Auth::user()->id ,'github_id')){ |
|
125 | - return view('oauth.index',[ |
|
123 | + $accountModel=new AccountModel(); |
|
124 | + if ($accountModel->getExtra(Auth::user()->id, 'github_id')) { |
|
125 | + return view('oauth.index', [ |
|
126 | 126 | 'page_title'=>"OAuth", |
127 | 127 | 'site_title'=>config("app.name"), |
128 | 128 | 'navigation'=>"OAuth", |
129 | 129 | 'platform' => 'Github', |
130 | 130 | 'display_html' => 'You are trying to unbind the following two : <br /> |
131 | 131 | Your '.config("app.name").' account : <span class="text-info">'.Auth::user()->email.'</span><br /> |
132 | - This Github account : <span class="text-info">'.$accountModel->getExtra(Auth::user()->id ,'github_email').'</span><br /> |
|
132 | + This Github account : <span class="text-info">'.$accountModel->getExtra(Auth::user()->id, 'github_email').'</span><br /> |
|
133 | 133 | Make your decision carefully, although you can later establish the binding again', |
134 | 134 | 'buttons' => [ |
135 | 135 | [ |
@@ -143,8 +143,8 @@ discard block |
||
143 | 143 | ], |
144 | 144 | ] |
145 | 145 | ]); |
146 | - }else{ |
|
147 | - return view('oauth.index',[ |
|
146 | + } else { |
|
147 | + return view('oauth.index', [ |
|
148 | 148 | 'page_title'=>"OAuth", |
149 | 149 | 'site_title'=>config("app.name"), |
150 | 150 | 'navigation'=>"OAuth", |
@@ -162,15 +162,15 @@ discard block |
||
162 | 162 | |
163 | 163 | public function confirmUnbind() |
164 | 164 | { |
165 | - $accountModel = new AccountModel(); |
|
166 | - $user_id = Auth::user()->id; |
|
167 | - if($accountModel->getExtra($user_id ,'github_id')){ |
|
168 | - $accountModel->setExtra($user_id,'github_id',null); |
|
169 | - $accountModel->setExtra($user_id,'github_email',null); |
|
170 | - $accountModel->setExtra($user_id,'github_nickname',null); |
|
171 | - $accountModel->setExtra($user_id,'github_homepage',null); |
|
172 | - $accountModel->setExtra($user_id,'github_token',null); |
|
173 | - return view('oauth.index',[ |
|
165 | + $accountModel=new AccountModel(); |
|
166 | + $user_id=Auth::user()->id; |
|
167 | + if ($accountModel->getExtra($user_id, 'github_id')) { |
|
168 | + $accountModel->setExtra($user_id, 'github_id', null); |
|
169 | + $accountModel->setExtra($user_id, 'github_email', null); |
|
170 | + $accountModel->setExtra($user_id, 'github_nickname', null); |
|
171 | + $accountModel->setExtra($user_id, 'github_homepage', null); |
|
172 | + $accountModel->setExtra($user_id, 'github_token', null); |
|
173 | + return view('oauth.index', [ |
|
174 | 174 | 'page_title'=>"OAuth", |
175 | 175 | 'site_title'=>config("app.name"), |
176 | 176 | 'navigation'=>"OAuth", |
@@ -183,8 +183,8 @@ discard block |
||
183 | 183 | ], |
184 | 184 | ] |
185 | 185 | ]); |
186 | - }else{ |
|
187 | - return view('oauth.index',[ |
|
186 | + } else { |
|
187 | + return view('oauth.index', [ |
|
188 | 188 | 'page_title'=>"OAuth", |
189 | 189 | 'site_title'=>config("app.name"), |
190 | 190 | 'navigation'=>"OAuth", |
@@ -42,7 +42,7 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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"), |
@@ -28,8 +28,8 @@ |
||
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"), |
@@ -37,7 +37,7 @@ |
||
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" |