@@ -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( |
@@ -228,7 +228,7 @@ discard block |
||
| 228 | 228 | $paginator=$paginator->where(["practice"=>$filter['practice']]); |
| 229 | 229 | } |
| 230 | 230 | $paginator = $paginator ->paginate(10); |
| 231 | - }elseif($filter['public']=='0'){ |
|
| 231 | + } elseif($filter['public']=='0'){ |
|
| 232 | 232 | $paginator=DB::table('group_member') |
| 233 | 233 | ->groupBy('contest.cid') |
| 234 | 234 | ->select('contest.*') |
@@ -258,7 +258,7 @@ discard block |
||
| 258 | 258 | ) |
| 259 | 259 | ->orderBy('contest.begin_time', 'desc') |
| 260 | 260 | ->paginate(10); |
| 261 | - }else{ |
|
| 261 | + } else{ |
|
| 262 | 262 | $paginator=DB::table('group_member') |
| 263 | 263 | ->groupBy('contest.cid') |
| 264 | 264 | ->select('contest.*') |
@@ -810,13 +810,13 @@ discard block |
||
| 810 | 810 | if(time() < $end_time){ |
| 811 | 811 | if($clearance == 3){ |
| 812 | 812 | $contestRankRaw=Cache::tags(['contest', 'rank'])->get("contestAdmin$cid"); |
| 813 | - }else{ |
|
| 813 | + } else{ |
|
| 814 | 814 | $contestRankRaw=Cache::tags(['contest', 'rank'])->get($cid); |
| 815 | 815 | } |
| 816 | 816 | if(!isset($contestRankRaw)){ |
| 817 | 817 | $contestRankRaw=$contest_eloquent->rankRefresh(); |
| 818 | 818 | } |
| 819 | - }else{ |
|
| 819 | + } else{ |
|
| 820 | 820 | if($clearance == 3){ |
| 821 | 821 | $contestRankRaw=Cache::tags(['contest', 'rank'])->get("contestAdmin$cid"); |
| 822 | 822 | if (!isset($contestRankRaw)) { |
@@ -826,7 +826,7 @@ discard block |
||
| 826 | 826 | $this->storeContestRankInMySQL($cid, $contestRankRaw); |
| 827 | 827 | } |
| 828 | 828 | } |
| 829 | - }else{ |
|
| 829 | + } else{ |
|
| 830 | 830 | $contestRankRaw=$this->getContestRankFromMySQL($cid); |
| 831 | 831 | if(!isset($contestRankRaw)){ |
| 832 | 832 | $contestRankRaw=Cache::tags(['contest', 'rank'])->get($cid); |
@@ -911,7 +911,7 @@ discard block |
||
| 911 | 911 | return DB::table("contest_clarification")->where([ |
| 912 | 912 | "cid"=>$cid |
| 913 | 913 | ])->orderBy('created_at', 'desc')->get()->all(); |
| 914 | - }else{ |
|
| 914 | + } else{ |
|
| 915 | 915 | return DB::table("contest_clarification")->where([ |
| 916 | 916 | "cid"=>$cid |
| 917 | 917 | ])->where(function ($query) { |
@@ -1076,7 +1076,7 @@ discard block |
||
| 1076 | 1076 | $filter['pid'] = array_search($filter['ncode'], array_column($problemSet_temp, 'ncode')); |
| 1077 | 1077 | if($filter['pid']==false){ |
| 1078 | 1078 | $filter['pid'] = null; |
| 1079 | - }else{ |
|
| 1079 | + } else{ |
|
| 1080 | 1080 | $filter['pid'] = $problemSet_temp[$filter['pid']]['pid']; |
| 1081 | 1081 | } |
| 1082 | 1082 | |
@@ -1184,7 +1184,7 @@ discard block |
||
| 1184 | 1184 | "records"=>[] |
| 1185 | 1185 | ]; |
| 1186 | 1186 | } |
| 1187 | - }else{ |
|
| 1187 | + } else{ |
|
| 1188 | 1188 | if ($basicInfo["status_visibility"]==2) { |
| 1189 | 1189 | // View all |
| 1190 | 1190 | $paginator=DB::table("submission")->where([ |
@@ -1434,7 +1434,7 @@ discard block |
||
| 1434 | 1434 | if($ratingCalculator->calculate()){ |
| 1435 | 1435 | $ratingCalculator->storage(); |
| 1436 | 1436 | return true; |
| 1437 | - }else{ |
|
| 1437 | + } else{ |
|
| 1438 | 1438 | return false; |
| 1439 | 1439 | } |
| 1440 | 1440 | } else { |
@@ -1483,7 +1483,7 @@ discard block |
||
| 1483 | 1483 | $contestRankRaw = $this->contestRankCache($cid); |
| 1484 | 1484 | Cache::tags(['contest', 'rank'])->put($cid, $contestRankRaw); |
| 1485 | 1485 | Cache::tags(['contest', 'rank'])->put("contestAdmin$cid", $contestRankRaw); |
| 1486 | - }else{ |
|
| 1486 | + } else{ |
|
| 1487 | 1487 | DB::table($this->tableName) |
| 1488 | 1488 | ->where('cid',$cid) |
| 1489 | 1489 | ->update($data); |
@@ -1585,8 +1585,7 @@ discard block |
||
| 1585 | 1585 | if(time() > $chache['end_time']){ |
| 1586 | 1586 | $this->storeContestRankInMySQL($cid, $ret); |
| 1587 | 1587 | } |
| 1588 | - } |
|
| 1589 | - else{ |
|
| 1588 | + } else{ |
|
| 1590 | 1589 | $ret=[]; |
| 1591 | 1590 | $chache=[]; |
| 1592 | 1591 | $chache['contest_info']=DB::table("contest")->where("cid", $cid)->first(); |
@@ -1601,7 +1600,7 @@ discard block |
||
| 1601 | 1600 | "cid"=>$cid, |
| 1602 | 1601 | "audit"=>1 |
| 1603 | 1602 | ])->select('uid')->get()->all(); |
| 1604 | - }else{ |
|
| 1603 | + } else{ |
|
| 1605 | 1604 | $submissionUsers=DB::table("submission")->where([ |
| 1606 | 1605 | "cid"=>$cid |
| 1607 | 1606 | ])->where( |
@@ -1636,9 +1635,9 @@ discard block |
||
| 1636 | 1635 | Cache::tags(['contest', 'rank'])->put("contestAdmin$cid", $retAdmin); |
| 1637 | 1636 | } |
| 1638 | 1637 | } |
| 1639 | - }catch(LockTimeoutException $e){ |
|
| 1638 | + } catch(LockTimeoutException $e){ |
|
| 1640 | 1639 | Log::warning("Contest Rank Lock Timed Out"); |
| 1641 | - }finally{ |
|
| 1640 | + } finally{ |
|
| 1642 | 1641 | optional($lock)->release(); |
| 1643 | 1642 | } |
| 1644 | 1643 | } |
@@ -1661,7 +1660,7 @@ discard block |
||
| 1661 | 1660 | return 1; |
| 1662 | 1661 | } |
| 1663 | 1662 | }); |
| 1664 | - }else if ($contest_info["rule"]==2){ |
|
| 1663 | + } else if ($contest_info["rule"]==2){ |
|
| 1665 | 1664 | usort($ret, function ($a, $b) { |
| 1666 | 1665 | if ($a["score"]==$b["score"]) { |
| 1667 | 1666 | if ($a["solved"]==$b["solved"]) { |
@@ -1685,8 +1684,9 @@ discard block |
||
| 1685 | 1684 | { |
| 1686 | 1685 | $id = count($ret); |
| 1687 | 1686 | foreach($ret as $key => $r){ |
| 1688 | - if($r['uid'] == $uid) |
|
| 1689 | - $id = $key; |
|
| 1687 | + if($r['uid'] == $uid) { |
|
| 1688 | + $id = $key; |
|
| 1689 | + } |
|
| 1690 | 1690 | } |
| 1691 | 1691 | if ($contest_info["rule"]==1) { |
| 1692 | 1692 | // ACM/ICPC Mode |
@@ -1694,7 +1694,7 @@ discard block |
||
| 1694 | 1694 | $prob_detail = []; |
| 1695 | 1695 | $totPen = 0; |
| 1696 | 1696 | $totScore = 0; |
| 1697 | - }else{ |
|
| 1697 | + } else{ |
|
| 1698 | 1698 | $prob_detail = $ret[$id]['problem_detail']; |
| 1699 | 1699 | $totPen=$ret[$id]['penalty']; |
| 1700 | 1700 | $totScore=$ret[$id]['score']; |
@@ -1749,7 +1749,7 @@ discard block |
||
| 1749 | 1749 | $prob_detail = []; |
| 1750 | 1750 | $totSolved = 0; |
| 1751 | 1751 | $totScore = 0; |
| 1752 | - }else{ |
|
| 1752 | + } else{ |
|
| 1753 | 1753 | $prob_detail = $ret[$id]['problem_detail']; |
| 1754 | 1754 | $totSolved=$ret[$id]['solved']; |
| 1755 | 1755 | $totScore=$ret[$id]['score']; |
@@ -1812,18 +1812,18 @@ discard block |
||
| 1812 | 1812 | return false; |
| 1813 | 1813 | } |
| 1814 | 1814 | return true; |
| 1815 | - }else if($status === 0){ |
|
| 1815 | + } else if($status === 0){ |
|
| 1816 | 1816 | if($begin_time_new !== null){ |
| 1817 | 1817 | return false; |
| 1818 | 1818 | } |
| 1819 | 1819 | if($end_time_new !== null){ |
| 1820 | 1820 | if(strtotime($end_time_new) <= time()){ |
| 1821 | 1821 | return false; |
| 1822 | - }else{ |
|
| 1822 | + } else{ |
|
| 1823 | 1823 | return true; |
| 1824 | 1824 | } |
| 1825 | 1825 | } |
| 1826 | - }else{ |
|
| 1826 | + } else{ |
|
| 1827 | 1827 | return false; |
| 1828 | 1828 | } |
| 1829 | 1829 | |
@@ -1844,8 +1844,7 @@ discard block |
||
| 1844 | 1844 | return DB::table("contest_clarification")->where('ccid','=',$ccid)->update([ |
| 1845 | 1845 | "public"=>1 |
| 1846 | 1846 | ]); |
| 1847 | - } |
|
| 1848 | - else |
|
| 1847 | + } else |
|
| 1849 | 1848 | { |
| 1850 | 1849 | return DB::table("contest_clarification")->where('ccid','=',$ccid)->update([ |
| 1851 | 1850 | "public"=>0 |
@@ -1869,7 +1868,7 @@ discard block |
||
| 1869 | 1868 | ->whereIn('pid',array_column($contestRank[0]['problem_detail'],'pid')) |
| 1870 | 1869 | ->select('pid','title') |
| 1871 | 1870 | ->get()->all(); |
| 1872 | - }else{ |
|
| 1871 | + } else{ |
|
| 1873 | 1872 | $all_problems = []; |
| 1874 | 1873 | } |
| 1875 | 1874 | $tags = DB::table('group_problem_tag') |
@@ -2022,12 +2021,10 @@ discard block |
||
| 2022 | 2021 | $zipFile |
| 2023 | 2022 | ->saveAsFile(base_path('storage/app/private/'.$path.$cid.".zip")); // save the archive to a file |
| 2024 | 2023 | //->extractTo(base_path('storage/app/private/'.$path)); // extract files to the specified directory |
| 2025 | - } |
|
| 2026 | - catch(\PhpZip\Exception\ZipException $e){ |
|
| 2024 | + } catch(\PhpZip\Exception\ZipException $e){ |
|
| 2027 | 2025 | // handle exception |
| 2028 | 2026 | Log::debug($e); |
| 2029 | - } |
|
| 2030 | - finally{ |
|
| 2027 | + } finally{ |
|
| 2031 | 2028 | $zipFile->close(); |
| 2032 | 2029 | } |
| 2033 | 2030 | } |
@@ -2053,7 +2050,7 @@ discard block |
||
| 2053 | 2050 | return [ |
| 2054 | 2051 | 'result' => true |
| 2055 | 2052 | ]; |
| 2056 | - }else{ |
|
| 2053 | + } else{ |
|
| 2057 | 2054 | return [ |
| 2058 | 2055 | 'result' => false, |
| 2059 | 2056 | 'sid' => $submissions |
@@ -115,8 +115,8 @@ discard block |
||
| 115 | 115 | |
| 116 | 116 | public function gcode($cid) |
| 117 | 117 | { |
| 118 | - $gid = $this->gid($cid); |
|
| 119 | - return DB::table('group')->where('gid','=',$gid)->first()["gcode"]; |
|
| 118 | + $gid=$this->gid($cid); |
|
| 119 | + return DB::table('group')->where('gid', '=', $gid)->first()["gcode"]; |
|
| 120 | 120 | } |
| 121 | 121 | |
| 122 | 122 | public function runningContest() |
@@ -141,19 +141,19 @@ discard block |
||
| 141 | 141 | |
| 142 | 142 | public function listForSetting($gid) |
| 143 | 143 | { |
| 144 | - $uid = Auth::user()->id; |
|
| 145 | - $group_contests = DB::table('contest') |
|
| 146 | - ->where('gid',$gid) |
|
| 147 | - ->orderBy('begin_time','desc') |
|
| 144 | + $uid=Auth::user()->id; |
|
| 145 | + $group_contests=DB::table('contest') |
|
| 146 | + ->where('gid', $gid) |
|
| 147 | + ->orderBy('begin_time', 'desc') |
|
| 148 | 148 | ->get()->all(); |
| 149 | - $groupModel = new GroupModel(); |
|
| 150 | - $group_clearance = $groupModel->judgeClearance($gid,$uid); |
|
| 149 | + $groupModel=new GroupModel(); |
|
| 150 | + $group_clearance=$groupModel->judgeClearance($gid, $uid); |
|
| 151 | 151 | foreach ($group_contests as &$contest) { |
| 152 | - $contest['is_admin'] = ($contest['assign_uid'] == $uid || $group_clearance == 3); |
|
| 153 | - $contest['begin_stamps'] = strtotime($contest['begin_time']); |
|
| 154 | - $contest['end_stamps'] = strtotime($contest['end_time']); |
|
| 155 | - $contest['status'] = time() >= $contest['end_stamps'] ? 1 |
|
| 156 | - : (time() <= $contest['begin_stamps'] ? -1 : 0); |
|
| 152 | + $contest['is_admin']=($contest['assign_uid']==$uid || $group_clearance==3); |
|
| 153 | + $contest['begin_stamps']=strtotime($contest['begin_time']); |
|
| 154 | + $contest['end_stamps']=strtotime($contest['end_time']); |
|
| 155 | + $contest['status']=time()>=$contest['end_stamps'] ? 1 |
|
| 156 | + : (time()<=$contest['begin_stamps'] ? -1 : 0); |
|
| 157 | 157 | $contest["rule_parsed"]=$this->rule[$contest["rule"]]; |
| 158 | 158 | $contest["date_parsed"]=[ |
| 159 | 159 | "date"=>date_format(date_create($contest["begin_time"]), 'j'), |
@@ -161,11 +161,11 @@ discard block |
||
| 161 | 161 | ]; |
| 162 | 162 | $contest["length"]=$this->calcLength($contest["begin_time"], $contest["end_time"]); |
| 163 | 163 | } |
| 164 | - usort($group_contests,function($a,$b){ |
|
| 165 | - if($a['is_admin'] == $b['is_admin']){ |
|
| 166 | - return $b['begin_stamps'] - $a['begin_stamps']; |
|
| 164 | + usort($group_contests, function($a, $b) { |
|
| 165 | + if ($a['is_admin']==$b['is_admin']) { |
|
| 166 | + return $b['begin_stamps']-$a['begin_stamps']; |
|
| 167 | 167 | } |
| 168 | - return $b['is_admin'] - $a['is_admin']; |
|
| 168 | + return $b['is_admin']-$a['is_admin']; |
|
| 169 | 169 | }); |
| 170 | 170 | return $group_contests; |
| 171 | 171 | } |
@@ -176,9 +176,9 @@ discard block |
||
| 176 | 176 | // "gid"=>$gid |
| 177 | 177 | // ])->orderBy('begin_time', 'desc')->get()->all(); |
| 178 | 178 | $preQuery=DB::table($this->tableName); |
| 179 | - $paginator=$preQuery->where('gid','=',$gid)->orderBy('begin_time', 'desc')->paginate(10); |
|
| 179 | + $paginator=$preQuery->where('gid', '=', $gid)->orderBy('begin_time', 'desc')->paginate(10); |
|
| 180 | 180 | $contest_list=$paginator->all(); |
| 181 | - if(empty($contest_list)){ |
|
| 181 | + if (empty($contest_list)) { |
|
| 182 | 182 | return null; |
| 183 | 183 | } |
| 184 | 184 | |
@@ -203,7 +203,7 @@ discard block |
||
| 203 | 203 | ])->first()["rule"]; |
| 204 | 204 | } |
| 205 | 205 | |
| 206 | - public function list($filter,$uid) |
|
| 206 | + public function list($filter, $uid) |
|
| 207 | 207 | { |
| 208 | 208 | if ($uid) { |
| 209 | 209 | //$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); |
@@ -227,15 +227,15 @@ discard block |
||
| 227 | 227 | if ($filter['practice']) { |
| 228 | 228 | $paginator=$paginator->where(["practice"=>$filter['practice']]); |
| 229 | 229 | } |
| 230 | - $paginator = $paginator ->paginate(10); |
|
| 231 | - }elseif($filter['public']=='0'){ |
|
| 230 | + $paginator=$paginator ->paginate(10); |
|
| 231 | + }elseif ($filter['public']=='0') { |
|
| 232 | 232 | $paginator=DB::table('group_member') |
| 233 | 233 | ->groupBy('contest.cid') |
| 234 | 234 | ->select('contest.*') |
| 235 | 235 | ->join('contest', 'group_member.gid', '=', 'contest.gid') |
| 236 | 236 | ->leftJoin('contest_participant', 'contest.cid', '=', 'contest_participant.cid') |
| 237 | 237 | ->where( |
| 238 | - function ($query) use ($filter,$uid) { |
|
| 238 | + function($query) use ($filter, $uid) { |
|
| 239 | 239 | if ($filter['rule']) { |
| 240 | 240 | $query=$query->where(["rule"=>$filter['rule']]); |
| 241 | 241 | } |
@@ -258,14 +258,14 @@ discard block |
||
| 258 | 258 | ) |
| 259 | 259 | ->orderBy('contest.begin_time', 'desc') |
| 260 | 260 | ->paginate(10); |
| 261 | - }else{ |
|
| 261 | + } else { |
|
| 262 | 262 | $paginator=DB::table('group_member') |
| 263 | 263 | ->groupBy('contest.cid') |
| 264 | 264 | ->select('contest.*') |
| 265 | 265 | ->join('contest', 'group_member.gid', '=', 'contest.gid') |
| 266 | 266 | ->leftJoin('contest_participant', 'contest.cid', '=', 'contest_participant.cid') |
| 267 | 267 | ->where( |
| 268 | - function ($query) use ($filter) { |
|
| 268 | + function($query) use ($filter) { |
|
| 269 | 269 | if ($filter['rule']) { |
| 270 | 270 | $query=$query->where(["rule"=>$filter['rule']]); |
| 271 | 271 | } |
@@ -286,7 +286,7 @@ discard block |
||
| 286 | 286 | } |
| 287 | 287 | ) |
| 288 | 288 | ->orWhere( |
| 289 | - function ($query) use ($filter,$uid) { |
|
| 289 | + function($query) use ($filter, $uid) { |
|
| 290 | 290 | if ($filter['rule']) { |
| 291 | 291 | $query=$query->where(["rule"=>$filter['rule']]); |
| 292 | 292 | } |
@@ -332,7 +332,7 @@ discard block |
||
| 332 | 332 | if ($filter['practice']) { |
| 333 | 333 | $paginator=$paginator->where(["practice"=>$filter['practice']]); |
| 334 | 334 | } |
| 335 | - $paginator = $paginator ->paginate(10); |
|
| 335 | + $paginator=$paginator ->paginate(10); |
|
| 336 | 336 | } |
| 337 | 337 | $contest_list=$paginator->all(); |
| 338 | 338 | foreach ($contest_list as &$c) { |
@@ -370,14 +370,14 @@ discard block |
||
| 370 | 370 | } |
| 371 | 371 | } |
| 372 | 372 | |
| 373 | - public function registContest($cid,$uid) |
|
| 373 | + public function registContest($cid, $uid) |
|
| 374 | 374 | { |
| 375 | 375 | $registered=DB::table("contest_participant")->where([ |
| 376 | 376 | "cid"=>$cid, |
| 377 | 377 | "uid"=>$uid |
| 378 | 378 | ])->first(); |
| 379 | 379 | |
| 380 | - if(empty($registered)){ |
|
| 380 | + if (empty($registered)) { |
|
| 381 | 381 | DB::table("contest_participant")->insert([ |
| 382 | 382 | "cid"=>$cid, |
| 383 | 383 | "uid"=>$uid, |
@@ -385,7 +385,7 @@ discard block |
||
| 385 | 385 | ]); |
| 386 | 386 | $name=User::find($uid)->name; |
| 387 | 387 | $contest=$this->basic($cid); |
| 388 | - $url=route('contest.detail',['cid' => $cid]); |
|
| 388 | + $url=route('contest.detail', ['cid' => $cid]); |
|
| 389 | 389 | sendMessage([ |
| 390 | 390 | 'receiver' => $uid, |
| 391 | 391 | 'sender' => 1, // potential bugs |
@@ -419,9 +419,9 @@ discard block |
||
| 419 | 419 | public function problems($cid) |
| 420 | 420 | { |
| 421 | 421 | return DB::table('contest_problem') |
| 422 | - ->join('problem','contest_problem.pid','=','problem.pid') |
|
| 423 | - ->where('cid',$cid) |
|
| 424 | - ->select('problem.pid as pid','pcode','number') |
|
| 422 | + ->join('problem', 'contest_problem.pid', '=', 'problem.pid') |
|
| 423 | + ->where('cid', $cid) |
|
| 424 | + ->select('problem.pid as pid', 'pcode', 'number') |
|
| 425 | 425 | ->orderBy('number') |
| 426 | 426 | ->get()->all(); |
| 427 | 427 | } |
@@ -443,18 +443,18 @@ discard block |
||
| 443 | 443 | $end_time=strtotime(DB::table("contest")->where(["cid"=>$cid])->select("end_time")->first()["end_time"]); |
| 444 | 444 | |
| 445 | 445 | foreach ($problemSet as &$p) { |
| 446 | - if($p['practice']){ |
|
| 447 | - $tags = DB::table("group_problem_tag") |
|
| 448 | - ->where('gid',$p['gid']) |
|
| 449 | - ->where('pid',$p['pid']) |
|
| 446 | + if ($p['practice']) { |
|
| 447 | + $tags=DB::table("group_problem_tag") |
|
| 448 | + ->where('gid', $p['gid']) |
|
| 449 | + ->where('pid', $p['pid']) |
|
| 450 | 450 | ->get()->all(); |
| 451 | - $tags_arr = []; |
|
| 452 | - if(!empty($tags)){ |
|
| 451 | + $tags_arr=[]; |
|
| 452 | + if (!empty($tags)) { |
|
| 453 | 453 | foreach ($tags as $value) { |
| 454 | - array_push($tags_arr,$value['tag']); |
|
| 454 | + array_push($tags_arr, $value['tag']); |
|
| 455 | 455 | } |
| 456 | 456 | } |
| 457 | - $p['tags'] = $tags_arr; |
|
| 457 | + $p['tags']=$tags_arr; |
|
| 458 | 458 | } |
| 459 | 459 | if ($contest_rule==1) { |
| 460 | 460 | $prob_stat=DB::table("submission")->select( |
@@ -715,7 +715,7 @@ discard block |
||
| 715 | 715 | "problem_detail" => $prob_detail |
| 716 | 716 | ]; |
| 717 | 717 | } |
| 718 | - usort($ret, function ($a, $b) { |
|
| 718 | + usort($ret, function($a, $b) { |
|
| 719 | 719 | if ($a["score"]==$b["score"]) { |
| 720 | 720 | if ($a["penalty"]==$b["penalty"]) { |
| 721 | 721 | return 0; |
@@ -762,7 +762,7 @@ discard block |
||
| 762 | 762 | "problem_detail" => $prob_detail |
| 763 | 763 | ]; |
| 764 | 764 | } |
| 765 | - usort($ret, function ($a, $b) { |
|
| 765 | + usort($ret, function($a, $b) { |
|
| 766 | 766 | if ($a["score"]==$b["score"]) { |
| 767 | 767 | if ($a["solved"]==$b["solved"]) { |
| 768 | 768 | return 0; |
@@ -784,7 +784,7 @@ discard block |
||
| 784 | 784 | return $ret; |
| 785 | 785 | } |
| 786 | 786 | |
| 787 | - public function contestRank($cid, $uid = 0) |
|
| 787 | + public function contestRank($cid, $uid=0) |
|
| 788 | 788 | { |
| 789 | 789 | // [ToDo] If the current user's in the organizer group show nick name |
| 790 | 790 | // [ToDo] The participants determination |
@@ -801,36 +801,36 @@ discard block |
||
| 801 | 801 | "gid" => $contest_info["gid"] |
| 802 | 802 | ])->where("role", ">", 0)->first()); |
| 803 | 803 | |
| 804 | - $clearance = $this -> judgeClearance($cid, $uid); |
|
| 804 | + $clearance=$this -> judgeClearance($cid, $uid); |
|
| 805 | 805 | |
| 806 | 806 | /** New Version With MySQL */ |
| 807 | 807 | $end_time=strtotime(DB::table("contest")->where(["cid"=>$cid])->select("end_time")->first()["end_time"]); |
| 808 | - $contest_eloquent = EloquentContestModel::find($cid); |
|
| 808 | + $contest_eloquent=EloquentContestModel::find($cid); |
|
| 809 | 809 | |
| 810 | - if(time() < $end_time){ |
|
| 811 | - if($clearance == 3){ |
|
| 810 | + if (time()<$end_time) { |
|
| 811 | + if ($clearance==3) { |
|
| 812 | 812 | $contestRankRaw=Cache::tags(['contest', 'rank'])->get("contestAdmin$cid"); |
| 813 | - }else{ |
|
| 813 | + } else { |
|
| 814 | 814 | $contestRankRaw=Cache::tags(['contest', 'rank'])->get($cid); |
| 815 | 815 | } |
| 816 | - if(!isset($contestRankRaw)){ |
|
| 816 | + if (!isset($contestRankRaw)) { |
|
| 817 | 817 | $contestRankRaw=$contest_eloquent->rankRefresh(); |
| 818 | 818 | } |
| 819 | - }else{ |
|
| 820 | - if($clearance == 3){ |
|
| 819 | + } else { |
|
| 820 | + if ($clearance==3) { |
|
| 821 | 821 | $contestRankRaw=Cache::tags(['contest', 'rank'])->get("contestAdmin$cid"); |
| 822 | 822 | if (!isset($contestRankRaw)) { |
| 823 | 823 | $contestRankRaw=$this->getContestRankFromMySQL($cid); |
| 824 | - if(!isset($contestRankRaw)){ |
|
| 824 | + if (!isset($contestRankRaw)) { |
|
| 825 | 825 | $contestRankRaw=$contest_eloquent->rankRefresh(); |
| 826 | 826 | $this->storeContestRankInMySQL($cid, $contestRankRaw); |
| 827 | 827 | } |
| 828 | 828 | } |
| 829 | - }else{ |
|
| 829 | + } else { |
|
| 830 | 830 | $contestRankRaw=$this->getContestRankFromMySQL($cid); |
| 831 | - if(!isset($contestRankRaw)){ |
|
| 831 | + if (!isset($contestRankRaw)) { |
|
| 832 | 832 | $contestRankRaw=Cache::tags(['contest', 'rank'])->get($cid); |
| 833 | - if(!isset($contestRankRaw)){ |
|
| 833 | + if (!isset($contestRankRaw)) { |
|
| 834 | 834 | $contestRankRaw=$contest_eloquent->rankRefresh(); |
| 835 | 835 | } |
| 836 | 836 | $this->storeContestRankInMySQL($cid, $contestRankRaw); |
@@ -848,15 +848,15 @@ discard block |
||
| 848 | 848 | // $contestRankRaw=$this->contestRankCache($cid); |
| 849 | 849 | // } |
| 850 | 850 | // } |
| 851 | - if($contest_info["rule"]==1){ |
|
| 851 | + if ($contest_info["rule"]==1) { |
|
| 852 | 852 | foreach ($contestRankRaw as &$cr) { |
| 853 | - $solved = 0; |
|
| 854 | - foreach($cr['problem_detail'] as $pd){ |
|
| 855 | - if(!empty($pd['solved_time_parsed'])){ |
|
| 856 | - $solved ++; |
|
| 853 | + $solved=0; |
|
| 854 | + foreach ($cr['problem_detail'] as $pd) { |
|
| 855 | + if (!empty($pd['solved_time_parsed'])) { |
|
| 856 | + $solved++; |
|
| 857 | 857 | } |
| 858 | 858 | } |
| 859 | - $cr['solved'] = $solved; |
|
| 859 | + $cr['solved']=$solved; |
|
| 860 | 860 | } |
| 861 | 861 | } |
| 862 | 862 | |
@@ -905,16 +905,16 @@ discard block |
||
| 905 | 905 | |
| 906 | 906 | public function getClarificationList($cid) |
| 907 | 907 | { |
| 908 | - $uid = Auth::user()->id; |
|
| 909 | - $clearance = $this -> judgeClearance($cid, $uid); |
|
| 910 | - if($clearance == 3){ |
|
| 908 | + $uid=Auth::user()->id; |
|
| 909 | + $clearance=$this -> judgeClearance($cid, $uid); |
|
| 910 | + if ($clearance==3) { |
|
| 911 | 911 | return DB::table("contest_clarification")->where([ |
| 912 | 912 | "cid"=>$cid |
| 913 | 913 | ])->orderBy('created_at', 'desc')->get()->all(); |
| 914 | - }else{ |
|
| 914 | + } else { |
|
| 915 | 915 | return DB::table("contest_clarification")->where([ |
| 916 | 916 | "cid"=>$cid |
| 917 | - ])->where(function ($query) { |
|
| 917 | + ])->where(function($query) { |
|
| 918 | 918 | $query->where([ |
| 919 | 919 | "public"=>1 |
| 920 | 920 | ])->orWhere([ |
@@ -1027,7 +1027,7 @@ discard block |
||
| 1027 | 1027 | public function getContestRecord($filter, $cid) |
| 1028 | 1028 | { |
| 1029 | 1029 | $basicInfo=$this->basic($cid); |
| 1030 | - $userInfo=DB::table('group_member')->where('gid',$basicInfo["gid"])->where('uid',Auth::user()->id)->get()->first(); |
|
| 1030 | + $userInfo=DB::table('group_member')->where('gid', $basicInfo["gid"])->where('uid', Auth::user()->id)->get()->first(); |
|
| 1031 | 1031 | $problemSet_temp=DB::table("contest_problem")->join("problem", "contest_problem.pid", "=", "problem.pid")->where([ |
| 1032 | 1032 | "cid"=>$cid |
| 1033 | 1033 | ])->orderBy('ncode', 'asc')->select("ncode", "alias", "contest_problem.pid as pid", "title", "points", "tot_score")->get()->all(); |
@@ -1040,14 +1040,14 @@ discard block |
||
| 1040 | 1040 | $end_time=strtotime(DB::table("contest")->where(["cid"=>$cid])->select("end_time")->first()["end_time"]); |
| 1041 | 1041 | $contestEnd=time()>$end_time; |
| 1042 | 1042 | |
| 1043 | - $filter['pid'] = array_search($filter['ncode'], array_column($problemSet_temp, 'ncode')); |
|
| 1044 | - if($filter['pid']==false){ |
|
| 1045 | - $filter['pid'] = null; |
|
| 1046 | - }else{ |
|
| 1047 | - $filter['pid'] = $problemSet_temp[$filter['pid']]['pid']; |
|
| 1043 | + $filter['pid']=array_search($filter['ncode'], array_column($problemSet_temp, 'ncode')); |
|
| 1044 | + if ($filter['pid']==false) { |
|
| 1045 | + $filter['pid']=null; |
|
| 1046 | + } else { |
|
| 1047 | + $filter['pid']=$problemSet_temp[$filter['pid']]['pid']; |
|
| 1048 | 1048 | } |
| 1049 | 1049 | |
| 1050 | - if($userInfo==null || $userInfo["role"]!=3){ |
|
| 1050 | + if ($userInfo==null || $userInfo["role"]!=3) { |
|
| 1051 | 1051 | if ($basicInfo["status_visibility"]==2) { |
| 1052 | 1052 | // View all |
| 1053 | 1053 | $paginator=DB::table("submission")->where([ |
@@ -1061,7 +1061,7 @@ discard block |
||
| 1061 | 1061 | "users.id", |
| 1062 | 1062 | "=", |
| 1063 | 1063 | "submission.uid" |
| 1064 | - )->where(function ($query) use ($frozen_time) { |
|
| 1064 | + )->where(function($query) use ($frozen_time) { |
|
| 1065 | 1065 | $query->where( |
| 1066 | 1066 | "submission_date", |
| 1067 | 1067 | "<", |
@@ -1088,15 +1088,15 @@ discard block |
||
| 1088 | 1088 | 'desc' |
| 1089 | 1089 | ); |
| 1090 | 1090 | |
| 1091 | - if($filter["pid"]){ |
|
| 1091 | + if ($filter["pid"]) { |
|
| 1092 | 1092 | $paginator=$paginator->where(["pid"=>$filter["pid"]]); |
| 1093 | 1093 | } |
| 1094 | 1094 | |
| 1095 | - if($filter["result"]){ |
|
| 1095 | + if ($filter["result"]) { |
|
| 1096 | 1096 | $paginator=$paginator->where(["verdict"=>$filter["result"]]); |
| 1097 | 1097 | } |
| 1098 | 1098 | |
| 1099 | - if($filter["account"]){ |
|
| 1099 | + if ($filter["account"]) { |
|
| 1100 | 1100 | $paginator=$paginator->where(["name"=>$filter["account"]]); |
| 1101 | 1101 | } |
| 1102 | 1102 | |
@@ -1132,15 +1132,15 @@ discard block |
||
| 1132 | 1132 | 'desc' |
| 1133 | 1133 | ); |
| 1134 | 1134 | |
| 1135 | - if($filter["pid"]){ |
|
| 1135 | + if ($filter["pid"]) { |
|
| 1136 | 1136 | $paginator=$paginator->where(["pid"=>$filter["pid"]]); |
| 1137 | 1137 | } |
| 1138 | 1138 | |
| 1139 | - if($filter["result"]){ |
|
| 1139 | + if ($filter["result"]) { |
|
| 1140 | 1140 | $paginator=$paginator->where(["verdict"=>$filter["result"]]); |
| 1141 | 1141 | } |
| 1142 | 1142 | |
| 1143 | - if($filter["account"]){ |
|
| 1143 | + if ($filter["account"]) { |
|
| 1144 | 1144 | $paginator=$paginator->where(["name"=>$filter["account"]]); |
| 1145 | 1145 | } |
| 1146 | 1146 | |
@@ -1151,7 +1151,7 @@ discard block |
||
| 1151 | 1151 | "records"=>[] |
| 1152 | 1152 | ]; |
| 1153 | 1153 | } |
| 1154 | - }else{ |
|
| 1154 | + } else { |
|
| 1155 | 1155 | if ($basicInfo["status_visibility"]==2) { |
| 1156 | 1156 | // View all |
| 1157 | 1157 | $paginator=DB::table("submission")->where([ |
@@ -1183,15 +1183,15 @@ discard block |
||
| 1183 | 1183 | 'desc' |
| 1184 | 1184 | ); |
| 1185 | 1185 | |
| 1186 | - if($filter["pid"]){ |
|
| 1186 | + if ($filter["pid"]) { |
|
| 1187 | 1187 | $paginator=$paginator->where(["pid"=>$filter["pid"]]); |
| 1188 | 1188 | } |
| 1189 | 1189 | |
| 1190 | - if($filter["result"]){ |
|
| 1190 | + if ($filter["result"]) { |
|
| 1191 | 1191 | $paginator=$paginator->where(["verdict"=>$filter["result"]]); |
| 1192 | 1192 | } |
| 1193 | 1193 | |
| 1194 | - if($filter["account"]){ |
|
| 1194 | + if ($filter["account"]) { |
|
| 1195 | 1195 | $paginator=$paginator->where(["name"=>$filter["account"]]); |
| 1196 | 1196 | } |
| 1197 | 1197 | |
@@ -1227,15 +1227,15 @@ discard block |
||
| 1227 | 1227 | 'desc' |
| 1228 | 1228 | ); |
| 1229 | 1229 | |
| 1230 | - if($filter["pid"]){ |
|
| 1230 | + if ($filter["pid"]) { |
|
| 1231 | 1231 | $paginator=$paginator->where(["pid"=>$filter["pid"]]); |
| 1232 | 1232 | } |
| 1233 | 1233 | |
| 1234 | - if($filter["result"]){ |
|
| 1234 | + if ($filter["result"]) { |
|
| 1235 | 1235 | $paginator=$paginator->where(["verdict"=>$filter["result"]]); |
| 1236 | 1236 | } |
| 1237 | 1237 | |
| 1238 | - if($filter["account"]){ |
|
| 1238 | + if ($filter["account"]) { |
|
| 1239 | 1239 | $paginator=$paginator->where(["name"=>$filter["account"]]); |
| 1240 | 1240 | } |
| 1241 | 1241 | |
@@ -1288,24 +1288,24 @@ discard block |
||
| 1288 | 1288 | * 2 stands for participant* |
| 1289 | 1289 | * 3 stands for admin * |
| 1290 | 1290 | ***************************/ |
| 1291 | - if ($uid==0 || filter_var($cid, FILTER_VALIDATE_INT) === false) { |
|
| 1291 | + if ($uid==0 || filter_var($cid, FILTER_VALIDATE_INT)===false) { |
|
| 1292 | 1292 | return 0; |
| 1293 | 1293 | } |
| 1294 | - $groupModel = new GroupModel(); |
|
| 1294 | + $groupModel=new GroupModel(); |
|
| 1295 | 1295 | $contest_info=DB::table("contest")->where("cid", $cid)->first(); |
| 1296 | - $userInfo=DB::table('group_member')->where('gid',$contest_info["gid"])->where('uid',$uid)->get()->first(); |
|
| 1296 | + $userInfo=DB::table('group_member')->where('gid', $contest_info["gid"])->where('uid', $uid)->get()->first(); |
|
| 1297 | 1297 | |
| 1298 | - if(empty($contest_info)){ |
|
| 1298 | + if (empty($contest_info)) { |
|
| 1299 | 1299 | // contest not exist |
| 1300 | 1300 | return 0; |
| 1301 | 1301 | } |
| 1302 | 1302 | |
| 1303 | - if($uid == $contest_info['assign_uid'] || $groupModel->judgeClearance($contest_info['gid'],$uid) == 3){ |
|
| 1303 | + if ($uid==$contest_info['assign_uid'] || $groupModel->judgeClearance($contest_info['gid'], $uid)==3) { |
|
| 1304 | 1304 | return 3; |
| 1305 | 1305 | } |
| 1306 | 1306 | |
| 1307 | - $contest_started = strtotime($contest_info['begin_time']) < time(); |
|
| 1308 | - $contest_ended = strtotime($contest_info['end_time']) < time(); |
|
| 1307 | + $contest_started=strtotime($contest_info['begin_time'])<time(); |
|
| 1308 | + $contest_ended=strtotime($contest_info['end_time'])<time(); |
|
| 1309 | 1309 | if (!$contest_started) { |
| 1310 | 1310 | // not started or do not exist |
| 1311 | 1311 | return 0; |
@@ -1366,7 +1366,7 @@ discard block |
||
| 1366 | 1366 | |
| 1367 | 1367 | public function judgeOutsideClearance($cid, $uid=0) |
| 1368 | 1368 | { |
| 1369 | - if (filter_var($cid, FILTER_VALIDATE_INT) === false) { |
|
| 1369 | + if (filter_var($cid, FILTER_VALIDATE_INT)===false) { |
|
| 1370 | 1370 | return 0; |
| 1371 | 1371 | } |
| 1372 | 1372 | $contest_info=DB::table("contest")->where("cid", $cid)->first(); |
@@ -1399,12 +1399,12 @@ discard block |
||
| 1399 | 1399 | public function updateProfessionalRate($cid) |
| 1400 | 1400 | { |
| 1401 | 1401 | $basic=$this->basic($cid); |
| 1402 | - if($basic["rated"]&&!$basic["is_rated"]){ |
|
| 1402 | + if ($basic["rated"] && !$basic["is_rated"]) { |
|
| 1403 | 1403 | $ratingCalculator=new RatingCalculator($cid); |
| 1404 | - if($ratingCalculator->calculate()){ |
|
| 1404 | + if ($ratingCalculator->calculate()) { |
|
| 1405 | 1405 | $ratingCalculator->storage(); |
| 1406 | 1406 | return true; |
| 1407 | - }else{ |
|
| 1407 | + } else { |
|
| 1408 | 1408 | return false; |
| 1409 | 1409 | } |
| 1410 | 1410 | } else { |
@@ -1412,26 +1412,26 @@ discard block |
||
| 1412 | 1412 | } |
| 1413 | 1413 | } |
| 1414 | 1414 | |
| 1415 | - public function contestUpdate($cid,$data,$problems) |
|
| 1415 | + public function contestUpdate($cid, $data, $problems) |
|
| 1416 | 1416 | { |
| 1417 | - if($problems !== false){ |
|
| 1418 | - $old_problmes = array_column( |
|
| 1417 | + if ($problems!==false) { |
|
| 1418 | + $old_problmes=array_column( |
|
| 1419 | 1419 | DB::table('contest_problem') |
| 1420 | - ->where('cid',$cid) |
|
| 1420 | + ->where('cid', $cid) |
|
| 1421 | 1421 | ->get()->all(), |
| 1422 | 1422 | 'pid' |
| 1423 | 1423 | ); |
| 1424 | - DB::transaction(function () use ($cid, $data, $problems,$old_problmes) { |
|
| 1424 | + DB::transaction(function() use ($cid, $data, $problems, $old_problmes) { |
|
| 1425 | 1425 | DB::table($this->tableName) |
| 1426 | - ->where('cid',$cid) |
|
| 1426 | + ->where('cid', $cid) |
|
| 1427 | 1427 | ->update($data); |
| 1428 | 1428 | DB::table('contest_problem') |
| 1429 | - ->where('cid',$cid) |
|
| 1429 | + ->where('cid', $cid) |
|
| 1430 | 1430 | ->delete(); |
| 1431 | - $new_problems = []; |
|
| 1431 | + $new_problems=[]; |
|
| 1432 | 1432 | foreach ($problems as $p) { |
| 1433 | 1433 | $pid=DB::table("problem")->where(["pcode"=>$p["pcode"]])->select("pid")->first()["pid"]; |
| 1434 | - array_push($new_problems,$pid); |
|
| 1434 | + array_push($new_problems, $pid); |
|
| 1435 | 1435 | DB::table("contest_problem")->insert([ |
| 1436 | 1436 | "cid"=>$cid, |
| 1437 | 1437 | "number"=>$p["number"], |
@@ -1441,29 +1441,29 @@ discard block |
||
| 1441 | 1441 | "points"=>$p["points"] |
| 1442 | 1442 | ]); |
| 1443 | 1443 | } |
| 1444 | - foreach($old_problmes as $op) { |
|
| 1445 | - if(!in_array($op,$new_problems)){ |
|
| 1444 | + foreach ($old_problmes as $op) { |
|
| 1445 | + if (!in_array($op, $new_problems)) { |
|
| 1446 | 1446 | DB::table('submission') |
| 1447 | - ->where('cid',$cid) |
|
| 1448 | - ->where('pid',$op) |
|
| 1447 | + ->where('cid', $cid) |
|
| 1448 | + ->where('pid', $op) |
|
| 1449 | 1449 | ->delete(); |
| 1450 | 1450 | } |
| 1451 | 1451 | } |
| 1452 | 1452 | }, 5); |
| 1453 | - $contestRankRaw = $this->contestRankCache($cid); |
|
| 1453 | + $contestRankRaw=$this->contestRankCache($cid); |
|
| 1454 | 1454 | Cache::tags(['contest', 'rank'])->put($cid, $contestRankRaw); |
| 1455 | 1455 | Cache::tags(['contest', 'rank'])->put("contestAdmin$cid", $contestRankRaw); |
| 1456 | - }else{ |
|
| 1456 | + } else { |
|
| 1457 | 1457 | DB::table($this->tableName) |
| 1458 | - ->where('cid',$cid) |
|
| 1458 | + ->where('cid', $cid) |
|
| 1459 | 1459 | ->update($data); |
| 1460 | 1460 | } |
| 1461 | 1461 | } |
| 1462 | 1462 | |
| 1463 | - public function contestUpdateProblem($cid,$problems) |
|
| 1463 | + public function contestUpdateProblem($cid, $problems) |
|
| 1464 | 1464 | { |
| 1465 | 1465 | DB::table('contest_problem') |
| 1466 | - ->where('cid',$cid) |
|
| 1466 | + ->where('cid', $cid) |
|
| 1467 | 1467 | ->delete(); |
| 1468 | 1468 | foreach ($problems as $p) { |
| 1469 | 1469 | DB::table("contest_problem")->insertGetId([ |
@@ -1479,8 +1479,8 @@ discard block |
||
| 1479 | 1479 | |
| 1480 | 1480 | public function arrangeContest($gid, $config, $problems) |
| 1481 | 1481 | { |
| 1482 | - $cid = -1; |
|
| 1483 | - DB::transaction(function () use ($gid, $config, $problems,&$cid) { |
|
| 1482 | + $cid=-1; |
|
| 1483 | + DB::transaction(function() use ($gid, $config, $problems, &$cid) { |
|
| 1484 | 1484 | $cid=DB::table($this->tableName)->insertGetId([ |
| 1485 | 1485 | "gid"=>$gid, |
| 1486 | 1486 | "name"=>$config["name"], |
@@ -1494,7 +1494,7 @@ discard block |
||
| 1494 | 1494 | "rule"=>1, //todo |
| 1495 | 1495 | "begin_time"=>$config["begin_time"], |
| 1496 | 1496 | "end_time"=>$config["end_time"], |
| 1497 | - "vcid"=>isset($config["vcid"])?$config["vcid"]:null, |
|
| 1497 | + "vcid"=>isset($config["vcid"]) ? $config["vcid"] : null, |
|
| 1498 | 1498 | "public"=>$config["public"], |
| 1499 | 1499 | "registration"=>0, //todo |
| 1500 | 1500 | "registration_due"=>null, //todo |
@@ -1502,7 +1502,7 @@ discard block |
||
| 1502 | 1502 | "froze_length"=>0, //todo |
| 1503 | 1503 | "status_visibility"=>$config["status_visibility"], |
| 1504 | 1504 | "created_at"=>date("Y-m-d H:i:s"), |
| 1505 | - "crawled" => isset($config['vcid'])?$config['crawled'] : null, |
|
| 1505 | + "crawled" => isset($config['vcid']) ? $config['crawled'] : null, |
|
| 1506 | 1506 | "audit_status"=>$config["public"] ? 0 : 1 |
| 1507 | 1507 | ]); |
| 1508 | 1508 | |
@@ -1521,13 +1521,13 @@ discard block |
||
| 1521 | 1521 | return $cid; |
| 1522 | 1522 | } |
| 1523 | 1523 | |
| 1524 | - public function updateContestRankTable($cid,$sub) |
|
| 1524 | + public function updateContestRankTable($cid, $sub) |
|
| 1525 | 1525 | { |
| 1526 | - $lock = Cache::lock("contestrank$cid",10); |
|
| 1527 | - try{ |
|
| 1528 | - if($lock->get()){ |
|
| 1529 | - if(Cache::tags(['contest','rank'])->get($cid) != null){ |
|
| 1530 | - $ret = Cache::tags(['contest','rank'])->get($cid); |
|
| 1526 | + $lock=Cache::lock("contestrank$cid", 10); |
|
| 1527 | + try { |
|
| 1528 | + if ($lock->get()) { |
|
| 1529 | + if (Cache::tags(['contest', 'rank'])->get($cid)!=null) { |
|
| 1530 | + $ret=Cache::tags(['contest', 'rank'])->get($cid); |
|
| 1531 | 1531 | $chache=[]; |
| 1532 | 1532 | $chache['contest_info']=DB::table("contest")->where("cid", $cid)->first(); |
| 1533 | 1533 | $chache['problemSet']=DB::table("contest_problem")->join("problem", "contest_problem.pid", "=", "problem.pid")->where([ |
@@ -1536,27 +1536,27 @@ discard block |
||
| 1536 | 1536 | $chache['frozen_time']=DB::table("contest")->where(["cid"=>$cid])->select(DB::raw("UNIX_TIMESTAMP(end_time)-froze_length as frozen_time"))->first()["frozen_time"]; |
| 1537 | 1537 | $chache['end_time']=strtotime(DB::table("contest")->where(["cid"=>$cid])->select("end_time")->first()["end_time"]); |
| 1538 | 1538 | |
| 1539 | - $id = 0; |
|
| 1539 | + $id=0; |
|
| 1540 | 1540 | |
| 1541 | - foreach($chache['problemSet'] as $key => $p){ |
|
| 1542 | - if ($p['pid'] == $sub['pid']){ |
|
| 1543 | - $chache['problemSet'][$key]['cpid'] = $key; |
|
| 1544 | - $id = $key; |
|
| 1541 | + foreach ($chache['problemSet'] as $key => $p) { |
|
| 1542 | + if ($p['pid']==$sub['pid']) { |
|
| 1543 | + $chache['problemSet'][$key]['cpid']=$key; |
|
| 1544 | + $id=$key; |
|
| 1545 | 1545 | } |
| 1546 | 1546 | } |
| 1547 | 1547 | |
| 1548 | - $ret = $this->updateContestRankDetail($chache['contest_info'],$chache['problemSet'][$id],$cid,$sub['uid'],$ret); |
|
| 1549 | - $ret = $this->sortContestRankTable($chache['contest_info'],$cid,$ret); |
|
| 1548 | + $ret=$this->updateContestRankDetail($chache['contest_info'], $chache['problemSet'][$id], $cid, $sub['uid'], $ret); |
|
| 1549 | + $ret=$this->sortContestRankTable($chache['contest_info'], $cid, $ret); |
|
| 1550 | 1550 | |
| 1551 | - if (time() < $chache['frozen_time']){ |
|
| 1551 | + if (time()<$chache['frozen_time']) { |
|
| 1552 | 1552 | Cache::tags(['contest', 'rank'])->put($cid, $ret); |
| 1553 | 1553 | } |
| 1554 | 1554 | Cache::tags(['contest', 'rank'])->put("contestAdmin$cid", $ret); |
| 1555 | - if(time() > $chache['end_time']){ |
|
| 1555 | + if (time()>$chache['end_time']) { |
|
| 1556 | 1556 | $this->storeContestRankInMySQL($cid, $ret); |
| 1557 | 1557 | } |
| 1558 | 1558 | } |
| 1559 | - else{ |
|
| 1559 | + else { |
|
| 1560 | 1560 | $ret=[]; |
| 1561 | 1561 | $chache=[]; |
| 1562 | 1562 | $chache['contest_info']=DB::table("contest")->where("cid", $cid)->first(); |
@@ -1571,7 +1571,7 @@ discard block |
||
| 1571 | 1571 | "cid"=>$cid, |
| 1572 | 1572 | "audit"=>1 |
| 1573 | 1573 | ])->select('uid')->get()->all(); |
| 1574 | - }else{ |
|
| 1574 | + } else { |
|
| 1575 | 1575 | $submissionUsers=DB::table("submission")->where([ |
| 1576 | 1576 | "cid"=>$cid |
| 1577 | 1577 | ])->where( |
@@ -1584,39 +1584,39 @@ discard block |
||
| 1584 | 1584 | ])->select('uid')->groupBy('uid')->get()->all(); |
| 1585 | 1585 | } |
| 1586 | 1586 | |
| 1587 | - $chacheAdmin = $chache; |
|
| 1587 | + $chacheAdmin=$chache; |
|
| 1588 | 1588 | |
| 1589 | 1589 | foreach ($submissionUsers as $s) { |
| 1590 | 1590 | foreach ($chache['problemSet'] as $key => $p) { |
| 1591 | - $p['cpid'] = $key; |
|
| 1592 | - $ret = $this->updateContestRankDetail($chache['contest_info'],$p,$cid,$s['uid'],$ret); |
|
| 1591 | + $p['cpid']=$key; |
|
| 1592 | + $ret=$this->updateContestRankDetail($chache['contest_info'], $p, $cid, $s['uid'], $ret); |
|
| 1593 | 1593 | } |
| 1594 | 1594 | } |
| 1595 | - $ret = $this->sortContestRankTable($chache['contest_info'],$cid,$ret); |
|
| 1595 | + $ret=$this->sortContestRankTable($chache['contest_info'], $cid, $ret); |
|
| 1596 | 1596 | Cache::tags(['contest', 'rank'])->put($cid, $ret); |
| 1597 | 1597 | |
| 1598 | 1598 | $retAdmin=[]; |
| 1599 | 1599 | foreach ($submissionUsersAdmin as $s) { |
| 1600 | 1600 | foreach ($chacheAdmin['problemSet'] as $key => $p) { |
| 1601 | - $p['cpid'] = $key; |
|
| 1602 | - $retAdmin = $this->updateContestRankDetail($chacheAdmin['contest_info'],$p,$cid,$s['uid'],$retAdmin); |
|
| 1601 | + $p['cpid']=$key; |
|
| 1602 | + $retAdmin=$this->updateContestRankDetail($chacheAdmin['contest_info'], $p, $cid, $s['uid'], $retAdmin); |
|
| 1603 | 1603 | } |
| 1604 | 1604 | } |
| 1605 | - $retAdmin = $this->sortContestRankTable($chacheAdmin['contest_info'],$cid,$retAdmin); |
|
| 1605 | + $retAdmin=$this->sortContestRankTable($chacheAdmin['contest_info'], $cid, $retAdmin); |
|
| 1606 | 1606 | Cache::tags(['contest', 'rank'])->put("contestAdmin$cid", $retAdmin); |
| 1607 | 1607 | } |
| 1608 | 1608 | } |
| 1609 | - }catch(LockTimeoutException $e){ |
|
| 1609 | + } catch (LockTimeoutException $e) { |
|
| 1610 | 1610 | Log::warning("Contest Rank Lock Timed Out"); |
| 1611 | - }finally{ |
|
| 1611 | + } finally { |
|
| 1612 | 1612 | optional($lock)->release(); |
| 1613 | 1613 | } |
| 1614 | 1614 | } |
| 1615 | 1615 | |
| 1616 | - public function sortContestRankTable($contest_info,$cid,$ret) |
|
| 1616 | + public function sortContestRankTable($contest_info, $cid, $ret) |
|
| 1617 | 1617 | { |
| 1618 | - if ($contest_info["rule"]==1){ |
|
| 1619 | - usort($ret, function ($a, $b) { |
|
| 1618 | + if ($contest_info["rule"]==1) { |
|
| 1619 | + usort($ret, function($a, $b) { |
|
| 1620 | 1620 | if ($a["score"]==$b["score"]) { |
| 1621 | 1621 | if ($a["penalty"]==$b["penalty"]) { |
| 1622 | 1622 | return 0; |
@@ -1631,8 +1631,8 @@ discard block |
||
| 1631 | 1631 | return 1; |
| 1632 | 1632 | } |
| 1633 | 1633 | }); |
| 1634 | - }else if ($contest_info["rule"]==2){ |
|
| 1635 | - usort($ret, function ($a, $b) { |
|
| 1634 | + } else if ($contest_info["rule"]==2) { |
|
| 1635 | + usort($ret, function($a, $b) { |
|
| 1636 | 1636 | if ($a["score"]==$b["score"]) { |
| 1637 | 1637 | if ($a["solved"]==$b["solved"]) { |
| 1638 | 1638 | return 0; |
@@ -1651,21 +1651,21 @@ discard block |
||
| 1651 | 1651 | return $ret; |
| 1652 | 1652 | } |
| 1653 | 1653 | |
| 1654 | - public function updateContestRankDetail($contest_info,$problem,$cid,$uid,$ret) |
|
| 1654 | + public function updateContestRankDetail($contest_info, $problem, $cid, $uid, $ret) |
|
| 1655 | 1655 | { |
| 1656 | - $id = count($ret); |
|
| 1657 | - foreach($ret as $key => $r){ |
|
| 1658 | - if($r['uid'] == $uid) |
|
| 1659 | - $id = $key; |
|
| 1656 | + $id=count($ret); |
|
| 1657 | + foreach ($ret as $key => $r) { |
|
| 1658 | + if ($r['uid']==$uid) |
|
| 1659 | + $id=$key; |
|
| 1660 | 1660 | } |
| 1661 | 1661 | if ($contest_info["rule"]==1) { |
| 1662 | 1662 | // ACM/ICPC Mode |
| 1663 | - if($id == count($ret)){ |
|
| 1664 | - $prob_detail = []; |
|
| 1665 | - $totPen = 0; |
|
| 1666 | - $totScore = 0; |
|
| 1667 | - }else{ |
|
| 1668 | - $prob_detail = $ret[$id]['problem_detail']; |
|
| 1663 | + if ($id==count($ret)) { |
|
| 1664 | + $prob_detail=[]; |
|
| 1665 | + $totPen=0; |
|
| 1666 | + $totScore=0; |
|
| 1667 | + } else { |
|
| 1668 | + $prob_detail=$ret[$id]['problem_detail']; |
|
| 1669 | 1669 | $totPen=$ret[$id]['penalty']; |
| 1670 | 1670 | $totScore=$ret[$id]['score']; |
| 1671 | 1671 | }; |
@@ -1683,7 +1683,7 @@ discard block |
||
| 1683 | 1683 | "uid"=>$uid, |
| 1684 | 1684 | ])->orderBy('submission_date', 'desc')->first(); |
| 1685 | 1685 | |
| 1686 | - if ($ac_times<=1 && isset($last_record) && $last_record['verdict']!="Waiting" && $last_record['verdict']!="Submission Error" && $last_record['verdict']!="System Error"){ |
|
| 1686 | + if ($ac_times<=1 && isset($last_record) && $last_record['verdict']!="Waiting" && $last_record['verdict']!="Submission Error" && $last_record['verdict']!="System Error") { |
|
| 1687 | 1687 | $prob_stat=$this->contestProblemInfoACM($cid, $problem["pid"], $uid); |
| 1688 | 1688 | |
| 1689 | 1689 | $prob_detail[$problem['cpid']]=[ |
@@ -1715,12 +1715,12 @@ discard block |
||
| 1715 | 1715 | } |
| 1716 | 1716 | } elseif ($contest_info["rule"]==2) { |
| 1717 | 1717 | // IOI Mode |
| 1718 | - if($id == count($ret)){ |
|
| 1719 | - $prob_detail = []; |
|
| 1720 | - $totSolved = 0; |
|
| 1721 | - $totScore = 0; |
|
| 1722 | - }else{ |
|
| 1723 | - $prob_detail = $ret[$id]['problem_detail']; |
|
| 1718 | + if ($id==count($ret)) { |
|
| 1719 | + $prob_detail=[]; |
|
| 1720 | + $totSolved=0; |
|
| 1721 | + $totScore=0; |
|
| 1722 | + } else { |
|
| 1723 | + $prob_detail=$ret[$id]['problem_detail']; |
|
| 1724 | 1724 | $totSolved=$ret[$id]['solved']; |
| 1725 | 1725 | $totScore=$ret[$id]['score']; |
| 1726 | 1726 | }; |
@@ -1753,47 +1753,47 @@ discard block |
||
| 1753 | 1753 | return $ret; |
| 1754 | 1754 | } |
| 1755 | 1755 | |
| 1756 | - public function assignMember($cid,$uid){ |
|
| 1756 | + public function assignMember($cid, $uid) { |
|
| 1757 | 1757 | return DB::table("contest")->where(["cid"=>$cid])->update([ |
| 1758 | 1758 | "assign_uid"=>$uid |
| 1759 | 1759 | ]); |
| 1760 | 1760 | } |
| 1761 | 1761 | |
| 1762 | - public function canUpdateContestTime($cid,$time = []) |
|
| 1762 | + public function canUpdateContestTime($cid, $time=[]) |
|
| 1763 | 1763 | { |
| 1764 | - $begin_time_new = $time['begin'] ?? null; |
|
| 1765 | - $end_time_new = $time['end'] ?? null; |
|
| 1764 | + $begin_time_new=$time['begin'] ?? null; |
|
| 1765 | + $end_time_new=$time['end'] ?? null; |
|
| 1766 | 1766 | |
| 1767 | - $hold_time = DB::table('contest') |
|
| 1768 | - ->where('cid',$cid) |
|
| 1769 | - ->select('begin_time','end_time') |
|
| 1767 | + $hold_time=DB::table('contest') |
|
| 1768 | + ->where('cid', $cid) |
|
| 1769 | + ->select('begin_time', 'end_time') |
|
| 1770 | 1770 | ->first(); |
| 1771 | - $begin_stamps = strtotime($hold_time['begin_time']); |
|
| 1772 | - $end_stamps = strtotime($hold_time['end_time']); |
|
| 1771 | + $begin_stamps=strtotime($hold_time['begin_time']); |
|
| 1772 | + $end_stamps=strtotime($hold_time['end_time']); |
|
| 1773 | 1773 | /* |
| 1774 | 1774 | -1 : have not begun |
| 1775 | 1775 | 0 : ing |
| 1776 | 1776 | 1 : end |
| 1777 | 1777 | */ |
| 1778 | - $status = time() >= $end_stamps ? 1 |
|
| 1779 | - : (time() <= $begin_stamps ? -1 : 0); |
|
| 1780 | - if($status === -1){ |
|
| 1781 | - if(time() > $begin_time_new){ |
|
| 1778 | + $status=time()>=$end_stamps ? 1 |
|
| 1779 | + : (time()<=$begin_stamps ? -1 : 0); |
|
| 1780 | + if ($status===-1) { |
|
| 1781 | + if (time()>$begin_time_new) { |
|
| 1782 | 1782 | return false; |
| 1783 | 1783 | } |
| 1784 | 1784 | return true; |
| 1785 | - }else if($status === 0){ |
|
| 1786 | - if($begin_time_new !== null){ |
|
| 1785 | + } else if ($status===0) { |
|
| 1786 | + if ($begin_time_new!==null) { |
|
| 1787 | 1787 | return false; |
| 1788 | 1788 | } |
| 1789 | - if($end_time_new !== null){ |
|
| 1790 | - if(strtotime($end_time_new) <= time()){ |
|
| 1789 | + if ($end_time_new!==null) { |
|
| 1790 | + if (strtotime($end_time_new)<=time()) { |
|
| 1791 | 1791 | return false; |
| 1792 | - }else{ |
|
| 1792 | + } else { |
|
| 1793 | 1793 | return true; |
| 1794 | 1794 | } |
| 1795 | 1795 | } |
| 1796 | - }else{ |
|
| 1796 | + } else { |
|
| 1797 | 1797 | return false; |
| 1798 | 1798 | } |
| 1799 | 1799 | |
@@ -1802,22 +1802,22 @@ discard block |
||
| 1802 | 1802 | |
| 1803 | 1803 | public function replyClarification($ccid, $content) |
| 1804 | 1804 | { |
| 1805 | - return DB::table("contest_clarification")->where('ccid','=',$ccid)->update([ |
|
| 1805 | + return DB::table("contest_clarification")->where('ccid', '=', $ccid)->update([ |
|
| 1806 | 1806 | "reply"=>$content |
| 1807 | 1807 | ]); |
| 1808 | 1808 | } |
| 1809 | 1809 | |
| 1810 | 1810 | public function setClarificationPublic($ccid, $public) |
| 1811 | 1811 | { |
| 1812 | - if($public) |
|
| 1812 | + if ($public) |
|
| 1813 | 1813 | { |
| 1814 | - return DB::table("contest_clarification")->where('ccid','=',$ccid)->update([ |
|
| 1814 | + return DB::table("contest_clarification")->where('ccid', '=', $ccid)->update([ |
|
| 1815 | 1815 | "public"=>1 |
| 1816 | 1816 | ]); |
| 1817 | 1817 | } |
| 1818 | 1818 | else |
| 1819 | 1819 | { |
| 1820 | - return DB::table("contest_clarification")->where('ccid','=',$ccid)->update([ |
|
| 1820 | + return DB::table("contest_clarification")->where('ccid', '=', $ccid)->update([ |
|
| 1821 | 1821 | "public"=>0 |
| 1822 | 1822 | ]); |
| 1823 | 1823 | } |
@@ -1830,90 +1830,90 @@ discard block |
||
| 1830 | 1830 | |
| 1831 | 1831 | public function praticeAnalysis($cid) |
| 1832 | 1832 | { |
| 1833 | - $gid = DB::table('contest') |
|
| 1834 | - ->where('cid',$cid) |
|
| 1833 | + $gid=DB::table('contest') |
|
| 1834 | + ->where('cid', $cid) |
|
| 1835 | 1835 | ->first()['gid']; |
| 1836 | - $contestRank = $this->contestRank($cid,Auth::user()->id); |
|
| 1837 | - if(!empty($contestRank)){ |
|
| 1838 | - $all_problems = DB::table('problem') |
|
| 1839 | - ->whereIn('pid',array_column($contestRank[0]['problem_detail'],'pid')) |
|
| 1840 | - ->select('pid','title') |
|
| 1836 | + $contestRank=$this->contestRank($cid, Auth::user()->id); |
|
| 1837 | + if (!empty($contestRank)) { |
|
| 1838 | + $all_problems=DB::table('problem') |
|
| 1839 | + ->whereIn('pid', array_column($contestRank[0]['problem_detail'], 'pid')) |
|
| 1840 | + ->select('pid', 'title') |
|
| 1841 | 1841 | ->get()->all(); |
| 1842 | - }else{ |
|
| 1843 | - $all_problems = []; |
|
| 1842 | + } else { |
|
| 1843 | + $all_problems=[]; |
|
| 1844 | 1844 | } |
| 1845 | - $tags = DB::table('group_problem_tag') |
|
| 1845 | + $tags=DB::table('group_problem_tag') |
|
| 1846 | 1846 | ->where('gid', $gid) |
| 1847 | - ->whereIn('pid', array_column($all_problems,'pid')) |
|
| 1847 | + ->whereIn('pid', array_column($all_problems, 'pid')) |
|
| 1848 | 1848 | ->get()->all(); |
| 1849 | - $all_tags = array_unique(array_column($tags,'tag')); |
|
| 1850 | - $memberData = []; |
|
| 1851 | - foreach($contestRank as $member){ |
|
| 1852 | - $m = [ |
|
| 1849 | + $all_tags=array_unique(array_column($tags, 'tag')); |
|
| 1850 | + $memberData=[]; |
|
| 1851 | + foreach ($contestRank as $member) { |
|
| 1852 | + $m=[ |
|
| 1853 | 1853 | 'uid' => $member['uid'], |
| 1854 | 1854 | 'name' => $member['name'], |
| 1855 | 1855 | 'nick_name' => $member['nick_name'], |
| 1856 | 1856 | ]; |
| 1857 | - $completion = []; |
|
| 1858 | - foreach ($all_tags as $tag){ |
|
| 1859 | - $completion[$tag] = []; |
|
| 1857 | + $completion=[]; |
|
| 1858 | + foreach ($all_tags as $tag) { |
|
| 1859 | + $completion[$tag]=[]; |
|
| 1860 | 1860 | foreach ($tags as $t) { |
| 1861 | - if($t['tag'] == $tag){ |
|
| 1861 | + if ($t['tag']==$tag) { |
|
| 1862 | 1862 | foreach ($member['problem_detail'] as $pd) { |
| 1863 | - if($pd['pid'] == $t['pid']){ |
|
| 1864 | - $completion[$tag][$t['pid']] = $pd['solved_time_parsed'] == "" ? 0 : 1; |
|
| 1863 | + if ($pd['pid']==$t['pid']) { |
|
| 1864 | + $completion[$tag][$t['pid']]=$pd['solved_time_parsed']=="" ? 0 : 1; |
|
| 1865 | 1865 | } |
| 1866 | 1866 | } |
| 1867 | 1867 | } |
| 1868 | 1868 | } |
| 1869 | 1869 | } |
| 1870 | - $m['completion'] = $completion; |
|
| 1871 | - $memberData[] = $m; |
|
| 1870 | + $m['completion']=$completion; |
|
| 1871 | + $memberData[]=$m; |
|
| 1872 | 1872 | } |
| 1873 | 1873 | return $memberData; |
| 1874 | 1874 | } |
| 1875 | 1875 | |
| 1876 | 1876 | public function storeContestRankInMySQL($cid, $data) |
| 1877 | 1877 | { |
| 1878 | - $contestRankJson = json_encode($data); |
|
| 1879 | - return DB::table('contest')->where('cid','=',$cid)->update([ |
|
| 1878 | + $contestRankJson=json_encode($data); |
|
| 1879 | + return DB::table('contest')->where('cid', '=', $cid)->update([ |
|
| 1880 | 1880 | 'rank' => $contestRankJson |
| 1881 | 1881 | ]); |
| 1882 | 1882 | } |
| 1883 | 1883 | |
| 1884 | 1884 | public function getContestRankFromMySQL($cid) |
| 1885 | 1885 | { |
| 1886 | - $contestRankJson = DB::table('contest')->where('cid','=',$cid)->pluck('rank')->first(); |
|
| 1887 | - $data = json_decode($contestRankJson, true); |
|
| 1886 | + $contestRankJson=DB::table('contest')->where('cid', '=', $cid)->pluck('rank')->first(); |
|
| 1887 | + $data=json_decode($contestRankJson, true); |
|
| 1888 | 1888 | return $data; |
| 1889 | 1889 | } |
| 1890 | 1890 | |
| 1891 | 1891 | public function isVerified($cid) |
| 1892 | 1892 | { |
| 1893 | - return DB::table('contest')->where('cid','=',$cid)->pluck('verified')->first(); |
|
| 1893 | + return DB::table('contest')->where('cid', '=', $cid)->pluck('verified')->first(); |
|
| 1894 | 1894 | } |
| 1895 | 1895 | |
| 1896 | 1896 | public function getScrollBoardData($cid) |
| 1897 | 1897 | { |
| 1898 | - $members = DB::table("submission") |
|
| 1899 | - ->join('users','users.id','=','submission.uid') |
|
| 1898 | + $members=DB::table("submission") |
|
| 1899 | + ->join('users', 'users.id', '=', 'submission.uid') |
|
| 1900 | 1900 | ->join('contest', 'contest.cid', '=', 'submission.cid') |
| 1901 | 1901 | ->join('group_member', 'users.id', '=', 'group_member.uid') |
| 1902 | - ->where('submission.cid', $cid)->select('users.id as uid','users.name as name','group_member.nick_name as nick_name') |
|
| 1902 | + ->where('submission.cid', $cid)->select('users.id as uid', 'users.name as name', 'group_member.nick_name as nick_name') |
|
| 1903 | 1903 | ->groupBy('uid')->get()->all(); |
| 1904 | - $submissions = DB::table("submission") |
|
| 1904 | + $submissions=DB::table("submission") |
|
| 1905 | 1905 | ->where('cid', $cid) |
| 1906 | 1906 | ->select('sid', 'verdict', 'submission_date', 'pid', 'uid') |
| 1907 | 1907 | ->orderBy('submission_date') |
| 1908 | 1908 | ->get()->all(); |
| 1909 | - $problems = DB::table('contest_problem') |
|
| 1909 | + $problems=DB::table('contest_problem') |
|
| 1910 | 1910 | ->where('cid', $cid) |
| 1911 | - ->select('ncode','pid') |
|
| 1911 | + ->select('ncode', 'pid') |
|
| 1912 | 1912 | ->orderBy('ncode') |
| 1913 | 1913 | ->get()->all(); |
| 1914 | - $contest = DB::table('contest') |
|
| 1915 | - ->where('cid',$cid) |
|
| 1916 | - ->select('begin_time','end_time','froze_length') |
|
| 1914 | + $contest=DB::table('contest') |
|
| 1915 | + ->where('cid', $cid) |
|
| 1916 | + ->select('begin_time', 'end_time', 'froze_length') |
|
| 1917 | 1917 | ->first(); |
| 1918 | 1918 | return [ |
| 1919 | 1919 | 'members' => $members, |
@@ -1923,7 +1923,7 @@ discard block |
||
| 1923 | 1923 | ]; |
| 1924 | 1924 | } |
| 1925 | 1925 | |
| 1926 | - public function storageCode($path,$cid) |
|
| 1926 | + public function storageCode($path, $cid) |
|
| 1927 | 1927 | { |
| 1928 | 1928 | |
| 1929 | 1929 | Storage::disk("private")->makeDirectory($path); |
@@ -1934,7 +1934,7 @@ discard block |
||
| 1934 | 1934 | "cid"=>$cid |
| 1935 | 1935 | ])->get(); |
| 1936 | 1936 | $problem_info=array(); |
| 1937 | - foreach($contest_problems as $contest_problem) { |
|
| 1937 | + foreach ($contest_problems as $contest_problem) { |
|
| 1938 | 1938 | $problem_info[$contest_problem["pid"]]=DB::table("problem")->where([ |
| 1939 | 1939 | "pid"=>$contest_problem["pid"] |
| 1940 | 1940 | ])->first(); |
@@ -1945,7 +1945,7 @@ discard block |
||
| 1945 | 1945 | |
| 1946 | 1946 | $compilers=DB::table("compiler")->get(); |
| 1947 | 1947 | $language=array(); |
| 1948 | - foreach($compilers as $compiler) { |
|
| 1948 | + foreach ($compilers as $compiler) { |
|
| 1949 | 1949 | $language[$compiler["coid"]]=$compiler["lang"]; |
| 1950 | 1950 | } |
| 1951 | 1951 | |
@@ -1954,14 +1954,14 @@ discard block |
||
| 1954 | 1954 | $submissions=DB::table("submission")->where([ |
| 1955 | 1955 | "cid"=>$cid, |
| 1956 | 1956 | ])->get(); |
| 1957 | - foreach($submissions as $submission) { |
|
| 1957 | + foreach ($submissions as $submission) { |
|
| 1958 | 1958 | $user_name=DB::table("users")->where([ |
| 1959 | 1959 | "id"=>$submission["uid"] |
| 1960 | 1960 | ])->first(); |
| 1961 | 1961 | $SubmissionModel=new SubmissionModel(); |
| 1962 | 1962 | $suffix_name=isset($SubmissionModel->langConfig[$language[$submission["coid"]]]) ? $SubmissionModel->langConfig[$language[$submission["coid"]]]["extensions"][0] : $SubmissionModel->langConfig["plaintext"]["extensions"][0]; |
| 1963 | 1963 | //die($submission["sid"]); |
| 1964 | - $file_name=(string)($submission["sid"])."-".$user_name["name"]."-".$problem_info[$submission["pid"]]["ncode"]."-".$submission["verdict"].$suffix_name; |
|
| 1964 | + $file_name=(string) ($submission["sid"])."-".$user_name["name"]."-".$problem_info[$submission["pid"]]["ncode"]."-".$submission["verdict"].$suffix_name; |
|
| 1965 | 1965 | Storage::disk("private")->put($path."/".urlencode($problem_info[$submission["pid"]]["path"])."/".$file_name, $submission["solution"]); |
| 1966 | 1966 | } |
| 1967 | 1967 | } |
@@ -1971,33 +1971,33 @@ discard block |
||
| 1971 | 1971 | Storage::disk("private")->deleteDirectory($path); |
| 1972 | 1972 | } |
| 1973 | 1973 | |
| 1974 | - public function GenerateZip($path,$cid,$code_path,$outputFilename) |
|
| 1974 | + public function GenerateZip($path, $cid, $code_path, $outputFilename) |
|
| 1975 | 1975 | { |
| 1976 | 1976 | Storage::disk("private")->deleteDirectory($code_path); |
| 1977 | 1977 | |
| 1978 | - $this->storageCode($code_path,$cid); |
|
| 1978 | + $this->storageCode($code_path, $cid); |
|
| 1979 | 1979 | |
| 1980 | 1980 | Storage::disk("private")->makeDirectory($path); |
| 1981 | 1981 | |
| 1982 | 1982 | // create new archive |
| 1983 | - $zipFile = new \PhpZip\ZipFile(); |
|
| 1984 | - $directories = Storage::disk("private")->allDirectories($code_path); |
|
| 1985 | - try{ |
|
| 1986 | - foreach($directories as $directorie) |
|
| 1983 | + $zipFile=new \PhpZip\ZipFile(); |
|
| 1984 | + $directories=Storage::disk("private")->allDirectories($code_path); |
|
| 1985 | + try { |
|
| 1986 | + foreach ($directories as $directorie) |
|
| 1987 | 1987 | { |
| 1988 | 1988 | |
| 1989 | - preg_match("/contestCode\/\d+(.*)/",$directorie,$problem_name); |
|
| 1990 | - $zipFile->addDir(base_path('storage/app/private/'.$directorie),urldecode($problem_name[1]));// add files from the directory |
|
| 1989 | + preg_match("/contestCode\/\d+(.*)/", $directorie, $problem_name); |
|
| 1990 | + $zipFile->addDir(base_path('storage/app/private/'.$directorie), urldecode($problem_name[1])); // add files from the directory |
|
| 1991 | 1991 | } |
| 1992 | 1992 | $zipFile |
| 1993 | 1993 | ->saveAsFile(base_path('storage/app/private/'.$path.$cid.".zip")); // save the archive to a file |
| 1994 | 1994 | //->extractTo(base_path('storage/app/private/'.$path)); // extract files to the specified directory |
| 1995 | 1995 | } |
| 1996 | - catch(\PhpZip\Exception\ZipException $e){ |
|
| 1996 | + catch (\PhpZip\Exception\ZipException $e) { |
|
| 1997 | 1997 | // handle exception |
| 1998 | 1998 | Log::debug($e); |
| 1999 | 1999 | } |
| 2000 | - finally{ |
|
| 2000 | + finally { |
|
| 2001 | 2001 | $zipFile->close(); |
| 2002 | 2002 | } |
| 2003 | 2003 | } |
@@ -2009,21 +2009,21 @@ discard block |
||
| 2009 | 2009 | $contest=DB::table("contest")->where([ |
| 2010 | 2010 | "cid"=>$cid |
| 2011 | 2011 | ])->first(); |
| 2012 | - return $outputFilename=(string)($contest["cid"])."-".$contest["name"].".zip"; |
|
| 2012 | + return $outputFilename=(string) ($contest["cid"])."-".$contest["name"].".zip"; |
|
| 2013 | 2013 | } |
| 2014 | 2014 | |
| 2015 | 2015 | public function judgeOver($cid) |
| 2016 | 2016 | { |
| 2017 | - $submissions = DB::table('submission') |
|
| 2017 | + $submissions=DB::table('submission') |
|
| 2018 | 2018 | ->where(['cid' => $cid]) |
| 2019 | - ->whereIn('verdict',['Waiting','Pending']) |
|
| 2019 | + ->whereIn('verdict', ['Waiting', 'Pending']) |
|
| 2020 | 2020 | ->select('sid') |
| 2021 | 2021 | ->get()->all(); |
| 2022 | - if(empty($submissions)){ |
|
| 2022 | + if (empty($submissions)) { |
|
| 2023 | 2023 | return [ |
| 2024 | 2024 | 'result' => true |
| 2025 | 2025 | ]; |
| 2026 | - }else{ |
|
| 2026 | + } else { |
|
| 2027 | 2027 | return [ |
| 2028 | 2028 | 'result' => false, |
| 2029 | 2029 | 'sid' => $submissions |
@@ -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 | } |
@@ -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"), |
@@ -12,20 +12,20 @@ discard block |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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", |
@@ -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" |
@@ -28,8 +28,8 @@ discard block |
||
| 28 | 28 | $accountModel=new AccountModel(); |
| 29 | 29 | $info=$accountModel->detail(Auth::user()->id); |
| 30 | 30 | $feed=$accountModel->feed(Auth::user()->id); |
| 31 | - $extraInfo = $accountModel->getExtra(Auth::user()->id, ['gender', 'contanct', 'school', 'country', 'location'],100); |
|
| 32 | - $socialiteInfo = $accountModel->getSocialiteInfo(Auth::user()->id,100); |
|
| 31 | + $extraInfo=$accountModel->getExtra(Auth::user()->id, ['gender', 'contanct', 'school', 'country', 'location'], 100); |
|
| 32 | + $socialiteInfo=$accountModel->getSocialiteInfo(Auth::user()->id, 100); |
|
| 33 | 33 | return view("account.dashboard", [ |
| 34 | 34 | 'page_title'=>"DashBoard", |
| 35 | 35 | 'site_title'=>config("app.name"), |
@@ -52,11 +52,11 @@ discard block |
||
| 52 | 52 | { |
| 53 | 53 | $accountModel=new AccountModel(); |
| 54 | 54 | $info=$accountModel->detail(Auth::user()->id); |
| 55 | - if(!empty(session('last_email_send'))){ |
|
| 56 | - $email_cooldown = 300 - (time() - session('last_email_send')); |
|
| 55 | + if (!empty(session('last_email_send'))) { |
|
| 56 | + $email_cooldown=300-(time()-session('last_email_send')); |
|
| 57 | 57 | } |
| 58 | - $extraInfo = $accountModel->getExtra(Auth::user()->id, ['gender', 'contanct', 'school', 'country', 'location'],100); |
|
| 59 | - $socialiteInfo = $accountModel->getSocialiteInfo(Auth::user()->id,100); |
|
| 58 | + $extraInfo=$accountModel->getExtra(Auth::user()->id, ['gender', 'contanct', 'school', 'country', 'location'], 100); |
|
| 59 | + $socialiteInfo=$accountModel->getSocialiteInfo(Auth::user()->id, 100); |
|
| 60 | 60 | return view("account.dashboard", [ |
| 61 | 61 | 'page_title'=>"Settings", |
| 62 | 62 | 'site_title'=>config("app.name"), |
@@ -18,16 +18,16 @@ |
||
| 18 | 18 | public function handle($request, Closure $next) |
| 19 | 19 | { |
| 20 | 20 | if (Auth::check()) { |
| 21 | - if(isset($request->gcode)){ |
|
| 21 | + if (isset($request->gcode)) { |
|
| 22 | 22 | //group privilege |
| 23 | 23 | $groupModel=new GroupModel(); |
| 24 | - if($groupModel->judgeClearance($groupModel->gid($request->gcode), Auth::user()->id)>=2){ |
|
| 24 | + if ($groupModel->judgeClearance($groupModel->gid($request->gcode), Auth::user()->id)>=2) { |
|
| 25 | 25 | return $next($request); |
| 26 | 26 | } |
| 27 | - }elseif(isset($request->cid)) { |
|
| 27 | + }elseif (isset($request->cid)) { |
|
| 28 | 28 | //contest privilege |
| 29 | 29 | $contestModel=new ContestModel(); |
| 30 | - if($contestModel->judgeClearance($request->cid, Auth::user()->id)==3){ |
|
| 30 | + if ($contestModel->judgeClearance($request->cid, Auth::user()->id)==3) { |
|
| 31 | 31 | return $next($request); |
| 32 | 32 | } |
| 33 | 33 | } |
@@ -24,7 +24,7 @@ |
||
| 24 | 24 | if($groupModel->judgeClearance($groupModel->gid($request->gcode), Auth::user()->id)>=2){ |
| 25 | 25 | return $next($request); |
| 26 | 26 | } |
| 27 | - }elseif(isset($request->cid)) { |
|
| 27 | + } elseif(isset($request->cid)) { |
|
| 28 | 28 | //contest privilege |
| 29 | 29 | $contestModel=new ContestModel(); |
| 30 | 30 | if($contestModel->judgeClearance($request->cid, Auth::user()->id)==3){ |