@@ -111,8 +111,8 @@ discard block |
||
| 111 | 111 | |
| 112 | 112 | public function gcode($cid) |
| 113 | 113 | { |
| 114 | - $gid = $this->gid($cid); |
|
| 115 | - return DB::table('group')->where('gid','=',$gid)->first()["gcode"]; |
|
| 114 | + $gid=$this->gid($cid); |
|
| 115 | + return DB::table('group')->where('gid', '=', $gid)->first()["gcode"]; |
|
| 116 | 116 | } |
| 117 | 117 | |
| 118 | 118 | public function runningContest() |
@@ -131,19 +131,19 @@ discard block |
||
| 131 | 131 | |
| 132 | 132 | public function listForSetting($gid) |
| 133 | 133 | { |
| 134 | - $uid = Auth::user()->id; |
|
| 135 | - $group_contests = DB::table('contest') |
|
| 136 | - ->where('gid',$gid) |
|
| 137 | - ->orderBy('begin_time','desc') |
|
| 134 | + $uid=Auth::user()->id; |
|
| 135 | + $group_contests=DB::table('contest') |
|
| 136 | + ->where('gid', $gid) |
|
| 137 | + ->orderBy('begin_time', 'desc') |
|
| 138 | 138 | ->get()->all(); |
| 139 | - $groupModel = new GroupModel(); |
|
| 140 | - $group_clearance = $groupModel->judgeClearance($gid,$uid); |
|
| 139 | + $groupModel=new GroupModel(); |
|
| 140 | + $group_clearance=$groupModel->judgeClearance($gid, $uid); |
|
| 141 | 141 | foreach ($group_contests as &$contest) { |
| 142 | - $contest['is_admin'] = ($contest['assign_uid'] == $uid || $group_clearance == 3); |
|
| 143 | - $contest['begin_stamps'] = strtotime($contest['begin_time']); |
|
| 144 | - $contest['end_stamps'] = strtotime($contest['end_time']); |
|
| 145 | - $contest['status'] = time() >= $contest['end_stamps'] ? 1 |
|
| 146 | - : (time() <= $contest['begin_stamps'] ? -1 : 0); |
|
| 142 | + $contest['is_admin']=($contest['assign_uid']==$uid || $group_clearance==3); |
|
| 143 | + $contest['begin_stamps']=strtotime($contest['begin_time']); |
|
| 144 | + $contest['end_stamps']=strtotime($contest['end_time']); |
|
| 145 | + $contest['status']=time()>=$contest['end_stamps'] ? 1 |
|
| 146 | + : (time()<=$contest['begin_stamps'] ? -1 : 0); |
|
| 147 | 147 | $contest["rule_parsed"]=$this->rule[$contest["rule"]]; |
| 148 | 148 | $contest["date_parsed"]=[ |
| 149 | 149 | "date"=>date_format(date_create($contest["begin_time"]), 'j'), |
@@ -151,11 +151,11 @@ discard block |
||
| 151 | 151 | ]; |
| 152 | 152 | $contest["length"]=$this->calcLength($contest["begin_time"], $contest["end_time"]); |
| 153 | 153 | } |
| 154 | - usort($group_contests,function($a,$b){ |
|
| 155 | - if($a['is_admin'] == $b['is_admin']){ |
|
| 156 | - return $b['begin_stamps'] - $a['begin_stamps']; |
|
| 154 | + usort($group_contests, function($a, $b) { |
|
| 155 | + if ($a['is_admin']==$b['is_admin']) { |
|
| 156 | + return $b['begin_stamps']-$a['begin_stamps']; |
|
| 157 | 157 | } |
| 158 | - return $b['is_admin'] - $a['is_admin']; |
|
| 158 | + return $b['is_admin']-$a['is_admin']; |
|
| 159 | 159 | }); |
| 160 | 160 | return $group_contests; |
| 161 | 161 | } |
@@ -166,9 +166,9 @@ discard block |
||
| 166 | 166 | // "gid"=>$gid |
| 167 | 167 | // ])->orderBy('begin_time', 'desc')->get()->all(); |
| 168 | 168 | $preQuery=DB::table($this->tableName); |
| 169 | - $paginator=$preQuery->where('gid','=',$gid)->orderBy('begin_time', 'desc')->paginate(10); |
|
| 169 | + $paginator=$preQuery->where('gid', '=', $gid)->orderBy('begin_time', 'desc')->paginate(10); |
|
| 170 | 170 | $contest_list=$paginator->all(); |
| 171 | - if(empty($contest_list)){ |
|
| 171 | + if (empty($contest_list)) { |
|
| 172 | 172 | return null; |
| 173 | 173 | } |
| 174 | 174 | |
@@ -193,7 +193,7 @@ discard block |
||
| 193 | 193 | ])->first()["rule"]; |
| 194 | 194 | } |
| 195 | 195 | |
| 196 | - public function list($filter,$uid) |
|
| 196 | + public function list($filter, $uid) |
|
| 197 | 197 | { |
| 198 | 198 | if ($uid) { |
| 199 | 199 | //$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); |
@@ -217,15 +217,15 @@ discard block |
||
| 217 | 217 | if ($filter['practice']) { |
| 218 | 218 | $paginator=$paginator->where(["practice"=>$filter['practice']]); |
| 219 | 219 | } |
| 220 | - $paginator = $paginator ->paginate(10); |
|
| 221 | - }elseif($filter['public']=='0'){ |
|
| 220 | + $paginator=$paginator ->paginate(10); |
|
| 221 | + }elseif ($filter['public']=='0') { |
|
| 222 | 222 | $paginator=DB::table('group_member') |
| 223 | 223 | ->groupBy('contest.cid') |
| 224 | 224 | ->select('contest.*') |
| 225 | 225 | ->join('contest', 'group_member.gid', '=', 'contest.gid') |
| 226 | 226 | ->leftJoin('contest_participant', 'contest.cid', '=', 'contest_participant.cid') |
| 227 | 227 | ->where( |
| 228 | - function ($query) use ($filter,$uid) { |
|
| 228 | + function($query) use ($filter, $uid) { |
|
| 229 | 229 | if ($filter['rule']) { |
| 230 | 230 | $query=$query->where(["rule"=>$filter['rule']]); |
| 231 | 231 | } |
@@ -248,14 +248,14 @@ discard block |
||
| 248 | 248 | ) |
| 249 | 249 | ->orderBy('contest.begin_time', 'desc') |
| 250 | 250 | ->paginate(10); |
| 251 | - }else{ |
|
| 251 | + } else { |
|
| 252 | 252 | $paginator=DB::table('group_member') |
| 253 | 253 | ->groupBy('contest.cid') |
| 254 | 254 | ->select('contest.*') |
| 255 | 255 | ->join('contest', 'group_member.gid', '=', 'contest.gid') |
| 256 | 256 | ->leftJoin('contest_participant', 'contest.cid', '=', 'contest_participant.cid') |
| 257 | 257 | ->where( |
| 258 | - function ($query) use ($filter) { |
|
| 258 | + function($query) use ($filter) { |
|
| 259 | 259 | if ($filter['rule']) { |
| 260 | 260 | $query=$query->where(["rule"=>$filter['rule']]); |
| 261 | 261 | } |
@@ -276,7 +276,7 @@ discard block |
||
| 276 | 276 | } |
| 277 | 277 | ) |
| 278 | 278 | ->orWhere( |
| 279 | - function ($query) use ($filter,$uid) { |
|
| 279 | + function($query) use ($filter, $uid) { |
|
| 280 | 280 | if ($filter['rule']) { |
| 281 | 281 | $query=$query->where(["rule"=>$filter['rule']]); |
| 282 | 282 | } |
@@ -322,7 +322,7 @@ discard block |
||
| 322 | 322 | if ($filter['practice']) { |
| 323 | 323 | $paginator=$paginator->where(["practice"=>$filter['practice']]); |
| 324 | 324 | } |
| 325 | - $paginator = $paginator ->paginate(10); |
|
| 325 | + $paginator=$paginator ->paginate(10); |
|
| 326 | 326 | } |
| 327 | 327 | $contest_list=$paginator->all(); |
| 328 | 328 | foreach ($contest_list as &$c) { |
@@ -360,14 +360,14 @@ discard block |
||
| 360 | 360 | } |
| 361 | 361 | } |
| 362 | 362 | |
| 363 | - public function registContest($cid,$uid) |
|
| 363 | + public function registContest($cid, $uid) |
|
| 364 | 364 | { |
| 365 | 365 | $registered=DB::table("contest_participant")->where([ |
| 366 | 366 | "cid"=>$cid, |
| 367 | 367 | "uid"=>$uid |
| 368 | 368 | ])->first(); |
| 369 | 369 | |
| 370 | - if(empty($registered)){ |
|
| 370 | + if (empty($registered)) { |
|
| 371 | 371 | DB::table("contest_participant")->insert([ |
| 372 | 372 | "cid"=>$cid, |
| 373 | 373 | "uid"=>$uid, |
@@ -400,9 +400,9 @@ discard block |
||
| 400 | 400 | public function problems($cid) |
| 401 | 401 | { |
| 402 | 402 | return DB::table('contest_problem') |
| 403 | - ->join('problem','contest_problem.pid','=','problem.pid') |
|
| 404 | - ->where('cid',$cid) |
|
| 405 | - ->select('problem.pid as pid','pcode','number') |
|
| 403 | + ->join('problem', 'contest_problem.pid', '=', 'problem.pid') |
|
| 404 | + ->where('cid', $cid) |
|
| 405 | + ->select('problem.pid as pid', 'pcode', 'number') |
|
| 406 | 406 | ->orderBy('number') |
| 407 | 407 | ->get()->all(); |
| 408 | 408 | } |
@@ -424,18 +424,18 @@ discard block |
||
| 424 | 424 | $end_time=strtotime(DB::table("contest")->where(["cid"=>$cid])->select("end_time")->first()["end_time"]); |
| 425 | 425 | |
| 426 | 426 | foreach ($problemSet as &$p) { |
| 427 | - if($p['practice']){ |
|
| 428 | - $tags = DB::table("group_problem_tag") |
|
| 429 | - ->where('gid',$p['gid']) |
|
| 430 | - ->where('pid',$p['pid']) |
|
| 427 | + if ($p['practice']) { |
|
| 428 | + $tags=DB::table("group_problem_tag") |
|
| 429 | + ->where('gid', $p['gid']) |
|
| 430 | + ->where('pid', $p['pid']) |
|
| 431 | 431 | ->get()->all(); |
| 432 | - $tags_arr = []; |
|
| 433 | - if(!empty($tags)){ |
|
| 432 | + $tags_arr=[]; |
|
| 433 | + if (!empty($tags)) { |
|
| 434 | 434 | foreach ($tags as $value) { |
| 435 | - array_push($tags_arr,$value['tag']); |
|
| 435 | + array_push($tags_arr, $value['tag']); |
|
| 436 | 436 | } |
| 437 | 437 | } |
| 438 | - $p['tags'] = $tags_arr; |
|
| 438 | + $p['tags']=$tags_arr; |
|
| 439 | 439 | } |
| 440 | 440 | if ($contest_rule==1) { |
| 441 | 441 | $prob_stat=DB::table("submission")->select( |
@@ -696,7 +696,7 @@ discard block |
||
| 696 | 696 | "problem_detail" => $prob_detail |
| 697 | 697 | ]; |
| 698 | 698 | } |
| 699 | - usort($ret, function ($a, $b) { |
|
| 699 | + usort($ret, function($a, $b) { |
|
| 700 | 700 | if ($a["score"]==$b["score"]) { |
| 701 | 701 | if ($a["penalty"]==$b["penalty"]) { |
| 702 | 702 | return 0; |
@@ -743,7 +743,7 @@ discard block |
||
| 743 | 743 | "problem_detail" => $prob_detail |
| 744 | 744 | ]; |
| 745 | 745 | } |
| 746 | - usort($ret, function ($a, $b) { |
|
| 746 | + usort($ret, function($a, $b) { |
|
| 747 | 747 | if ($a["score"]==$b["score"]) { |
| 748 | 748 | if ($a["solved"]==$b["solved"]) { |
| 749 | 749 | return 0; |
@@ -765,7 +765,7 @@ discard block |
||
| 765 | 765 | return $ret; |
| 766 | 766 | } |
| 767 | 767 | |
| 768 | - public function contestRank($cid, $uid = 0) |
|
| 768 | + public function contestRank($cid, $uid=0) |
|
| 769 | 769 | { |
| 770 | 770 | // [ToDo] If the current user's in the organizer group show nick name |
| 771 | 771 | // [ToDo] The participants determination |
@@ -783,31 +783,31 @@ discard block |
||
| 783 | 783 | "gid" => $contest_info["gid"] |
| 784 | 784 | ])->where("role", ">", 0)->first()); |
| 785 | 785 | |
| 786 | - $clearance = $this -> judgeClearance($cid, $uid); |
|
| 786 | + $clearance=$this -> judgeClearance($cid, $uid); |
|
| 787 | 787 | |
| 788 | 788 | /** New Version With MySQL */ |
| 789 | 789 | $end_time=strtotime(DB::table("contest")->where(["cid"=>$cid])->select("end_time")->first()["end_time"]); |
| 790 | 790 | |
| 791 | - if(time() < $end_time){ |
|
| 792 | - if($clearance == 3){ |
|
| 791 | + if (time()<$end_time) { |
|
| 792 | + if ($clearance==3) { |
|
| 793 | 793 | $contestRankRaw=Cache::tags(['contest', 'rank'])->get("contestAdmin$cid"); |
| 794 | - }else{ |
|
| 794 | + } else { |
|
| 795 | 795 | $contestRankRaw=Cache::tags(['contest', 'rank'])->get($cid); |
| 796 | 796 | } |
| 797 | - if(!isset($contestRankRaw)){ |
|
| 797 | + if (!isset($contestRankRaw)) { |
|
| 798 | 798 | $contestRankRaw=$this->contestRankCache($cid); |
| 799 | 799 | } |
| 800 | - }else{ |
|
| 801 | - if($clearance == 3){ |
|
| 800 | + } else { |
|
| 801 | + if ($clearance==3) { |
|
| 802 | 802 | $contestRankRaw=Cache::tags(['contest', 'rank'])->get("contestAdmin$cid"); |
| 803 | 803 | if (!isset($contestRankRaw)) { |
| 804 | 804 | $contestRankRaw=$this->contestRankCache($cid); |
| 805 | 805 | } |
| 806 | - }else{ |
|
| 806 | + } else { |
|
| 807 | 807 | $contestRankRaw=$this->getContestRankFromMySQL($cid); |
| 808 | - if(!isset($contestRankRaw)){ |
|
| 808 | + if (!isset($contestRankRaw)) { |
|
| 809 | 809 | $contestRankRaw=Cache::tags(['contest', 'rank'])->get($cid); |
| 810 | - if(!isset($contestRankRaw)){ |
|
| 810 | + if (!isset($contestRankRaw)) { |
|
| 811 | 811 | $contestRankRaw=$this->contestRankCache($cid); |
| 812 | 812 | } |
| 813 | 813 | $this->storeContestRankInMySQL($cid, $contestRankRaw); |
@@ -825,15 +825,15 @@ discard block |
||
| 825 | 825 | // $contestRankRaw=$this->contestRankCache($cid); |
| 826 | 826 | // } |
| 827 | 827 | // } |
| 828 | - if($contest_info["rule"]==1){ |
|
| 828 | + if ($contest_info["rule"]==1) { |
|
| 829 | 829 | foreach ($contestRankRaw as &$cr) { |
| 830 | - $solved = 0; |
|
| 831 | - foreach($cr['problem_detail'] as $pd){ |
|
| 832 | - if(!empty($pd['solved_time_parsed'])){ |
|
| 833 | - $solved ++; |
|
| 830 | + $solved=0; |
|
| 831 | + foreach ($cr['problem_detail'] as $pd) { |
|
| 832 | + if (!empty($pd['solved_time_parsed'])) { |
|
| 833 | + $solved++; |
|
| 834 | 834 | } |
| 835 | 835 | } |
| 836 | - $cr['solved'] = $solved; |
|
| 836 | + $cr['solved']=$solved; |
|
| 837 | 837 | } |
| 838 | 838 | } |
| 839 | 839 | |
@@ -882,16 +882,16 @@ discard block |
||
| 882 | 882 | |
| 883 | 883 | public function getClarificationList($cid) |
| 884 | 884 | { |
| 885 | - $uid = Auth::user()->id; |
|
| 886 | - $clearance = $this -> judgeClearance($cid, $uid); |
|
| 887 | - if($clearance == 3){ |
|
| 885 | + $uid=Auth::user()->id; |
|
| 886 | + $clearance=$this -> judgeClearance($cid, $uid); |
|
| 887 | + if ($clearance==3) { |
|
| 888 | 888 | return DB::table("contest_clarification")->where([ |
| 889 | 889 | "cid"=>$cid |
| 890 | 890 | ])->orderBy('create_time', 'desc')->get()->all(); |
| 891 | - }else{ |
|
| 891 | + } else { |
|
| 892 | 892 | return DB::table("contest_clarification")->where([ |
| 893 | 893 | "cid"=>$cid |
| 894 | - ])->where(function ($query) { |
|
| 894 | + ])->where(function($query) { |
|
| 895 | 895 | $query->where([ |
| 896 | 896 | "public"=>1 |
| 897 | 897 | ])->orWhere([ |
@@ -1032,7 +1032,7 @@ discard block |
||
| 1032 | 1032 | public function getContestRecord($cid) |
| 1033 | 1033 | { |
| 1034 | 1034 | $basicInfo=$this->basic($cid); |
| 1035 | - $userInfo=DB::table('group_member')->where('gid',$basicInfo["gid"])->where('uid',Auth::user()->id)->get()->first(); |
|
| 1035 | + $userInfo=DB::table('group_member')->where('gid', $basicInfo["gid"])->where('uid', Auth::user()->id)->get()->first(); |
|
| 1036 | 1036 | $problemSet_temp=DB::table("contest_problem")->join("problem", "contest_problem.pid", "=", "problem.pid")->where([ |
| 1037 | 1037 | "cid"=>$cid |
| 1038 | 1038 | ])->orderBy('ncode', 'asc')->select("ncode", "alias", "contest_problem.pid as pid", "title", "points", "tot_score")->get()->all(); |
@@ -1045,7 +1045,7 @@ discard block |
||
| 1045 | 1045 | $end_time=strtotime(DB::table("contest")->where(["cid"=>$cid])->select("end_time")->first()["end_time"]); |
| 1046 | 1046 | $contestEnd=time()>$end_time; |
| 1047 | 1047 | |
| 1048 | - if($userInfo==null || $userInfo["role"]!=3){ |
|
| 1048 | + if ($userInfo==null || $userInfo["role"]!=3) { |
|
| 1049 | 1049 | if ($basicInfo["status_visibility"]==2) { |
| 1050 | 1050 | // View all |
| 1051 | 1051 | $paginator=DB::table("submission")->where([ |
@@ -1059,7 +1059,7 @@ discard block |
||
| 1059 | 1059 | "users.id", |
| 1060 | 1060 | "=", |
| 1061 | 1061 | "submission.uid" |
| 1062 | - )->where(function ($query) use ($frozen_time) { |
|
| 1062 | + )->where(function($query) use ($frozen_time) { |
|
| 1063 | 1063 | $query->where( |
| 1064 | 1064 | "submission_date", |
| 1065 | 1065 | "<", |
@@ -1121,7 +1121,7 @@ discard block |
||
| 1121 | 1121 | "records"=>[] |
| 1122 | 1122 | ]; |
| 1123 | 1123 | } |
| 1124 | - }else{ |
|
| 1124 | + } else { |
|
| 1125 | 1125 | if ($basicInfo["status_visibility"]==2) { |
| 1126 | 1126 | // View all |
| 1127 | 1127 | $paginator=DB::table("submission")->where([ |
@@ -1233,21 +1233,21 @@ discard block |
||
| 1233 | 1233 | if ($uid==0) { |
| 1234 | 1234 | return 0; |
| 1235 | 1235 | } |
| 1236 | - $groupModel = new GroupModel(); |
|
| 1236 | + $groupModel=new GroupModel(); |
|
| 1237 | 1237 | $contest_info=DB::table("contest")->where("cid", $cid)->first(); |
| 1238 | - $userInfo=DB::table('group_member')->where('gid',$contest_info["gid"])->where('uid',$uid)->get()->first(); |
|
| 1238 | + $userInfo=DB::table('group_member')->where('gid', $contest_info["gid"])->where('uid', $uid)->get()->first(); |
|
| 1239 | 1239 | |
| 1240 | - if(empty($contest_info)){ |
|
| 1240 | + if (empty($contest_info)) { |
|
| 1241 | 1241 | // contest not exist |
| 1242 | 1242 | return 0; |
| 1243 | 1243 | } |
| 1244 | 1244 | |
| 1245 | - if($uid == $contest_info['assign_uid'] || $groupModel->judgeClearance($contest_info['gid'],$uid) == 3){ |
|
| 1245 | + if ($uid==$contest_info['assign_uid'] || $groupModel->judgeClearance($contest_info['gid'], $uid)==3) { |
|
| 1246 | 1246 | return 3; |
| 1247 | 1247 | } |
| 1248 | 1248 | |
| 1249 | - $contest_started = strtotime($contest_info['begin_time']) < time(); |
|
| 1250 | - $contest_ended = strtotime($contest_info['end_time']) < time(); |
|
| 1249 | + $contest_started=strtotime($contest_info['begin_time'])<time(); |
|
| 1250 | + $contest_ended=strtotime($contest_info['end_time'])<time(); |
|
| 1251 | 1251 | if (!$contest_started) { |
| 1252 | 1252 | // not started or do not exist |
| 1253 | 1253 | return 0; |
@@ -1338,12 +1338,12 @@ discard block |
||
| 1338 | 1338 | public function updateProfessionalRate($cid) |
| 1339 | 1339 | { |
| 1340 | 1340 | $basic=$this->basic($cid); |
| 1341 | - if($basic["rated"]&&!$basic["is_rated"]){ |
|
| 1341 | + if ($basic["rated"] && !$basic["is_rated"]) { |
|
| 1342 | 1342 | $ratingCalculator=new RatingCalculator($cid); |
| 1343 | - if($ratingCalculator->calculate()){ |
|
| 1343 | + if ($ratingCalculator->calculate()) { |
|
| 1344 | 1344 | $ratingCalculator->storage(); |
| 1345 | 1345 | return true; |
| 1346 | - }else{ |
|
| 1346 | + } else { |
|
| 1347 | 1347 | return false; |
| 1348 | 1348 | } |
| 1349 | 1349 | } else { |
@@ -1351,26 +1351,26 @@ discard block |
||
| 1351 | 1351 | } |
| 1352 | 1352 | } |
| 1353 | 1353 | |
| 1354 | - public function contestUpdate($cid,$data,$problems) |
|
| 1354 | + public function contestUpdate($cid, $data, $problems) |
|
| 1355 | 1355 | { |
| 1356 | - if($problems !== false){ |
|
| 1357 | - $old_problmes = array_column( |
|
| 1356 | + if ($problems!==false) { |
|
| 1357 | + $old_problmes=array_column( |
|
| 1358 | 1358 | DB::table('contest_problem') |
| 1359 | - ->where('cid',$cid) |
|
| 1359 | + ->where('cid', $cid) |
|
| 1360 | 1360 | ->get()->all(), |
| 1361 | 1361 | 'pid' |
| 1362 | 1362 | ); |
| 1363 | - DB::transaction(function () use ($cid, $data, $problems,$old_problmes) { |
|
| 1363 | + DB::transaction(function() use ($cid, $data, $problems, $old_problmes) { |
|
| 1364 | 1364 | DB::table($this->tableName) |
| 1365 | - ->where('cid',$cid) |
|
| 1365 | + ->where('cid', $cid) |
|
| 1366 | 1366 | ->update($data); |
| 1367 | 1367 | DB::table('contest_problem') |
| 1368 | - ->where('cid',$cid) |
|
| 1368 | + ->where('cid', $cid) |
|
| 1369 | 1369 | ->delete(); |
| 1370 | - $new_problems = []; |
|
| 1370 | + $new_problems=[]; |
|
| 1371 | 1371 | foreach ($problems as $p) { |
| 1372 | 1372 | $pid=DB::table("problem")->where(["pcode"=>$p["pcode"]])->select("pid")->first()["pid"]; |
| 1373 | - array_push($new_problems,$pid); |
|
| 1373 | + array_push($new_problems, $pid); |
|
| 1374 | 1374 | DB::table("contest_problem")->insert([ |
| 1375 | 1375 | "cid"=>$cid, |
| 1376 | 1376 | "number"=>$p["number"], |
@@ -1380,28 +1380,28 @@ discard block |
||
| 1380 | 1380 | "points"=>$p["points"] |
| 1381 | 1381 | ]); |
| 1382 | 1382 | } |
| 1383 | - foreach($old_problmes as $op) { |
|
| 1384 | - if(!in_array($op,$new_problems)){ |
|
| 1383 | + foreach ($old_problmes as $op) { |
|
| 1384 | + if (!in_array($op, $new_problems)) { |
|
| 1385 | 1385 | DB::table('submission') |
| 1386 | - ->where('cid',$cid) |
|
| 1387 | - ->where('pid',$op) |
|
| 1386 | + ->where('cid', $cid) |
|
| 1387 | + ->where('pid', $op) |
|
| 1388 | 1388 | ->delete(); |
| 1389 | 1389 | } |
| 1390 | 1390 | } |
| 1391 | 1391 | }, 5); |
| 1392 | - $contestRankRaw = $this->contestRankCache($cid); |
|
| 1392 | + $contestRankRaw=$this->contestRankCache($cid); |
|
| 1393 | 1393 | Cache::tags(['contest', 'rank'])->put($cid, $contestRankRaw); |
| 1394 | 1394 | Cache::tags(['contest', 'rank'])->put("contestAdmin$cid", $contestRankRaw); |
| 1395 | - }else{ |
|
| 1395 | + } else { |
|
| 1396 | 1396 | DB::table($this->tableName) |
| 1397 | - ->where('cid',$cid) |
|
| 1397 | + ->where('cid', $cid) |
|
| 1398 | 1398 | ->update($data); |
| 1399 | 1399 | } |
| 1400 | 1400 | } |
| 1401 | 1401 | |
| 1402 | 1402 | public function arrangeContest($gid, $config, $problems) |
| 1403 | 1403 | { |
| 1404 | - DB::transaction(function () use ($gid, $config, $problems) { |
|
| 1404 | + DB::transaction(function() use ($gid, $config, $problems) { |
|
| 1405 | 1405 | $cid=DB::table($this->tableName)->insertGetId([ |
| 1406 | 1406 | "gid"=>$gid, |
| 1407 | 1407 | "name"=>$config["name"], |
@@ -1415,7 +1415,7 @@ discard block |
||
| 1415 | 1415 | "rule"=>1, //todo |
| 1416 | 1416 | "begin_time"=>$config["begin_time"], |
| 1417 | 1417 | "end_time"=>$config["end_time"], |
| 1418 | - "vcid"=>isset($config["vcid"])?$config["vcid"]:null, |
|
| 1418 | + "vcid"=>isset($config["vcid"]) ? $config["vcid"] : null, |
|
| 1419 | 1419 | "public"=>0, //todo |
| 1420 | 1420 | "registration"=>0, //todo |
| 1421 | 1421 | "registration_due"=>null, //todo |
@@ -1440,51 +1440,51 @@ discard block |
||
| 1440 | 1440 | }, 5); |
| 1441 | 1441 | } |
| 1442 | 1442 | |
| 1443 | - public function updateContestRankTable($cid,$sub) |
|
| 1443 | + public function updateContestRankTable($cid, $sub) |
|
| 1444 | 1444 | { |
| 1445 | - $lock = Cache::lock("contestrank$cid",10); |
|
| 1446 | - try{ |
|
| 1447 | - if($lock->get()){ |
|
| 1448 | - if(Cache::tags(['contest','rank'])->get($cid) != null){ |
|
| 1449 | - $chache = Cache::tags(['contest','data'])->get($cid); |
|
| 1450 | - $ret = Cache::tags(['contest','rank'])->get($cid); |
|
| 1445 | + $lock=Cache::lock("contestrank$cid", 10); |
|
| 1446 | + try { |
|
| 1447 | + if ($lock->get()) { |
|
| 1448 | + if (Cache::tags(['contest', 'rank'])->get($cid)!=null) { |
|
| 1449 | + $chache=Cache::tags(['contest', 'data'])->get($cid); |
|
| 1450 | + $ret=Cache::tags(['contest', 'rank'])->get($cid); |
|
| 1451 | 1451 | |
| 1452 | 1452 | /** |
| 1453 | 1453 | * Fix bugs caused by calling every 5 seconds(temporary) |
| 1454 | 1454 | */ |
| 1455 | - if($chache['contest_info']['rule']==1){ |
|
| 1455 | + if ($chache['contest_info']['rule']==1) { |
|
| 1456 | 1456 | //ACM-ICPC Mode |
| 1457 | - foreach($ret as $cr){ |
|
| 1458 | - if($cr["uid"]==$sub['uid']){ |
|
| 1459 | - foreach($cr["problem_detail"] as $crp){ |
|
| 1460 | - if($crp["pid"]==$sub['pid'] && $crp["solved_time_parsed"]){ |
|
| 1461 | - return ; |
|
| 1457 | + foreach ($ret as $cr) { |
|
| 1458 | + if ($cr["uid"]==$sub['uid']) { |
|
| 1459 | + foreach ($cr["problem_detail"] as $crp) { |
|
| 1460 | + if ($crp["pid"]==$sub['pid'] && $crp["solved_time_parsed"]) { |
|
| 1461 | + return; |
|
| 1462 | 1462 | } |
| 1463 | 1463 | } |
| 1464 | 1464 | } |
| 1465 | 1465 | } |
| 1466 | - } elseif ($chache['contest_info']['rule']==2){ |
|
| 1466 | + } elseif ($chache['contest_info']['rule']==2) { |
|
| 1467 | 1467 | //TODO: OI Mode |
| 1468 | 1468 | } |
| 1469 | 1469 | |
| 1470 | - $id = 0; |
|
| 1470 | + $id=0; |
|
| 1471 | 1471 | |
| 1472 | - foreach($chache['problemSet'] as $key => $p){ |
|
| 1473 | - if ($p['pid'] == $sub['pid']){ |
|
| 1474 | - $chache['problemSet'][$key]['cpid'] = $key; |
|
| 1475 | - $id = $key; |
|
| 1472 | + foreach ($chache['problemSet'] as $key => $p) { |
|
| 1473 | + if ($p['pid']==$sub['pid']) { |
|
| 1474 | + $chache['problemSet'][$key]['cpid']=$key; |
|
| 1475 | + $id=$key; |
|
| 1476 | 1476 | } |
| 1477 | 1477 | } |
| 1478 | 1478 | |
| 1479 | - $ret = $this->updateContestRankDetail($chache['contest_info'],$chache['problemSet'][$id],$cid,$sub['uid'],$ret); |
|
| 1480 | - $ret = $this->sortContestRankTable($chache['contest_info'],$cid,$ret); |
|
| 1479 | + $ret=$this->updateContestRankDetail($chache['contest_info'], $chache['problemSet'][$id], $cid, $sub['uid'], $ret); |
|
| 1480 | + $ret=$this->sortContestRankTable($chache['contest_info'], $cid, $ret); |
|
| 1481 | 1481 | |
| 1482 | - if (time() < $chache['frozen_time']){ |
|
| 1482 | + if (time()<$chache['frozen_time']) { |
|
| 1483 | 1483 | Cache::tags(['contest', 'rank'])->put($cid, $ret); |
| 1484 | 1484 | } |
| 1485 | 1485 | Cache::tags(['contest', 'rank'])->put("contestAdmin$cid", $ret); |
| 1486 | 1486 | } |
| 1487 | - else{ |
|
| 1487 | + else { |
|
| 1488 | 1488 | $ret=[]; |
| 1489 | 1489 | $chache=[]; |
| 1490 | 1490 | $chache['contest_info']=DB::table("contest")->where("cid", $cid)->first(); |
@@ -1501,7 +1501,7 @@ discard block |
||
| 1501 | 1501 | "cid"=>$cid, |
| 1502 | 1502 | "audit"=>1 |
| 1503 | 1503 | ])->select('uid')->get()->all(); |
| 1504 | - }else{ |
|
| 1504 | + } else { |
|
| 1505 | 1505 | $submissionUsers=DB::table("submission")->where([ |
| 1506 | 1506 | "cid"=>$cid |
| 1507 | 1507 | ])->where( |
@@ -1514,39 +1514,39 @@ discard block |
||
| 1514 | 1514 | ])->select('uid')->groupBy('uid')->get()->all(); |
| 1515 | 1515 | } |
| 1516 | 1516 | |
| 1517 | - $chacheAdmin = $chache; |
|
| 1517 | + $chacheAdmin=$chache; |
|
| 1518 | 1518 | |
| 1519 | 1519 | foreach ($submissionUsers as $s) { |
| 1520 | 1520 | foreach ($chache['problemSet'] as $key => $p) { |
| 1521 | - $p['cpid'] = $key; |
|
| 1522 | - $ret = $this->updateContestRankDetail($chache['contest_info'],$p,$cid,$s['uid'],$ret); |
|
| 1521 | + $p['cpid']=$key; |
|
| 1522 | + $ret=$this->updateContestRankDetail($chache['contest_info'], $p, $cid, $s['uid'], $ret); |
|
| 1523 | 1523 | } |
| 1524 | 1524 | } |
| 1525 | - $ret = $this->sortContestRankTable($chache['contest_info'],$cid,$ret); |
|
| 1525 | + $ret=$this->sortContestRankTable($chache['contest_info'], $cid, $ret); |
|
| 1526 | 1526 | Cache::tags(['contest', 'rank'])->put($cid, $ret); |
| 1527 | 1527 | |
| 1528 | 1528 | $retAdmin=[]; |
| 1529 | 1529 | foreach ($submissionUsersAdmin as $s) { |
| 1530 | 1530 | foreach ($chacheAdmin['problemSet'] as $key => $p) { |
| 1531 | - $p['cpid'] = $key; |
|
| 1532 | - $retAdmin = $this->updateContestRankDetail($chacheAdmin['contest_info'],$p,$cid,$s['uid'],$retAdmin); |
|
| 1531 | + $p['cpid']=$key; |
|
| 1532 | + $retAdmin=$this->updateContestRankDetail($chacheAdmin['contest_info'], $p, $cid, $s['uid'], $retAdmin); |
|
| 1533 | 1533 | } |
| 1534 | 1534 | } |
| 1535 | - $retAdmin = $this->sortContestRankTable($chacheAdmin['contest_info'],$cid,$retAdmin); |
|
| 1535 | + $retAdmin=$this->sortContestRankTable($chacheAdmin['contest_info'], $cid, $retAdmin); |
|
| 1536 | 1536 | Cache::tags(['contest', 'rank'])->put("contestAdmin$cid", $retAdmin); |
| 1537 | 1537 | } |
| 1538 | 1538 | } |
| 1539 | - }catch(LockTimeoutException $e){ |
|
| 1539 | + } catch (LockTimeoutException $e) { |
|
| 1540 | 1540 | Log::warning("Contest Rank Lock Timed Out"); |
| 1541 | - }finally{ |
|
| 1541 | + } finally { |
|
| 1542 | 1542 | optional($lock)->release(); |
| 1543 | 1543 | } |
| 1544 | 1544 | } |
| 1545 | 1545 | |
| 1546 | - public function sortContestRankTable($contest_info,$cid,$ret) |
|
| 1546 | + public function sortContestRankTable($contest_info, $cid, $ret) |
|
| 1547 | 1547 | { |
| 1548 | - if ($contest_info["rule"]==1){ |
|
| 1549 | - usort($ret, function ($a, $b) { |
|
| 1548 | + if ($contest_info["rule"]==1) { |
|
| 1549 | + usort($ret, function($a, $b) { |
|
| 1550 | 1550 | if ($a["score"]==$b["score"]) { |
| 1551 | 1551 | if ($a["penalty"]==$b["penalty"]) { |
| 1552 | 1552 | return 0; |
@@ -1561,8 +1561,8 @@ discard block |
||
| 1561 | 1561 | return 1; |
| 1562 | 1562 | } |
| 1563 | 1563 | }); |
| 1564 | - }else if ($contest_info["rule"]==2){ |
|
| 1565 | - usort($ret, function ($a, $b) { |
|
| 1564 | + } else if ($contest_info["rule"]==2) { |
|
| 1565 | + usort($ret, function($a, $b) { |
|
| 1566 | 1566 | if ($a["score"]==$b["score"]) { |
| 1567 | 1567 | if ($a["solved"]==$b["solved"]) { |
| 1568 | 1568 | return 0; |
@@ -1581,21 +1581,21 @@ discard block |
||
| 1581 | 1581 | return $ret; |
| 1582 | 1582 | } |
| 1583 | 1583 | |
| 1584 | - public function updateContestRankDetail($contest_info,$problem,$cid,$uid,$ret) |
|
| 1584 | + public function updateContestRankDetail($contest_info, $problem, $cid, $uid, $ret) |
|
| 1585 | 1585 | { |
| 1586 | - $id = count($ret); |
|
| 1587 | - foreach($ret as $key => $r){ |
|
| 1588 | - if($r['uid'] == $uid) |
|
| 1589 | - $id = $key; |
|
| 1586 | + $id=count($ret); |
|
| 1587 | + foreach ($ret as $key => $r) { |
|
| 1588 | + if ($r['uid']==$uid) |
|
| 1589 | + $id=$key; |
|
| 1590 | 1590 | } |
| 1591 | 1591 | if ($contest_info["rule"]==1) { |
| 1592 | 1592 | // ACM/ICPC Mode |
| 1593 | - if($id == count($ret)){ |
|
| 1594 | - $prob_detail = []; |
|
| 1595 | - $totPen = 0; |
|
| 1596 | - $totScore = 0; |
|
| 1597 | - }else{ |
|
| 1598 | - $prob_detail = $ret[$id]['problem_detail']; |
|
| 1593 | + if ($id==count($ret)) { |
|
| 1594 | + $prob_detail=[]; |
|
| 1595 | + $totPen=0; |
|
| 1596 | + $totScore=0; |
|
| 1597 | + } else { |
|
| 1598 | + $prob_detail=$ret[$id]['problem_detail']; |
|
| 1599 | 1599 | $totPen=$ret[$id]['penalty']; |
| 1600 | 1600 | $totScore=$ret[$id]['score']; |
| 1601 | 1601 | }; |
@@ -1630,12 +1630,12 @@ discard block |
||
| 1630 | 1630 | ]; |
| 1631 | 1631 | } elseif ($contest_info["rule"]==2) { |
| 1632 | 1632 | // OI Mode |
| 1633 | - if($id == count($ret)){ |
|
| 1634 | - $prob_detail = []; |
|
| 1635 | - $totSolved = 0; |
|
| 1636 | - $totScore = 0; |
|
| 1637 | - }else{ |
|
| 1638 | - $prob_detail = $ret[$id]['problem_detail']; |
|
| 1633 | + if ($id==count($ret)) { |
|
| 1634 | + $prob_detail=[]; |
|
| 1635 | + $totSolved=0; |
|
| 1636 | + $totScore=0; |
|
| 1637 | + } else { |
|
| 1638 | + $prob_detail=$ret[$id]['problem_detail']; |
|
| 1639 | 1639 | $totSolved=$ret[$id]['solved']; |
| 1640 | 1640 | $totScore=$ret[$id]['score']; |
| 1641 | 1641 | }; |
@@ -1668,7 +1668,7 @@ discard block |
||
| 1668 | 1668 | return $ret; |
| 1669 | 1669 | } |
| 1670 | 1670 | |
| 1671 | - public function assignMember($cid,$uid){ |
|
| 1671 | + public function assignMember($cid, $uid) { |
|
| 1672 | 1672 | return DB::table("contest")->where(["cid"=>$cid])->update([ |
| 1673 | 1673 | "assign_uid"=>$uid |
| 1674 | 1674 | ]); |
@@ -1676,22 +1676,22 @@ discard block |
||
| 1676 | 1676 | |
| 1677 | 1677 | public function replyClarification($ccid, $content) |
| 1678 | 1678 | { |
| 1679 | - return DB::table("contest_clarification")->where('ccid','=',$ccid)->update([ |
|
| 1679 | + return DB::table("contest_clarification")->where('ccid', '=', $ccid)->update([ |
|
| 1680 | 1680 | "reply"=>$content |
| 1681 | 1681 | ]); |
| 1682 | 1682 | } |
| 1683 | 1683 | |
| 1684 | 1684 | public function setClarificationPublic($ccid, $public) |
| 1685 | 1685 | { |
| 1686 | - if($public) |
|
| 1686 | + if ($public) |
|
| 1687 | 1687 | { |
| 1688 | - return DB::table("contest_clarification")->where('ccid','=',$ccid)->update([ |
|
| 1688 | + return DB::table("contest_clarification")->where('ccid', '=', $ccid)->update([ |
|
| 1689 | 1689 | "public"=>1 |
| 1690 | 1690 | ]); |
| 1691 | 1691 | } |
| 1692 | 1692 | else |
| 1693 | 1693 | { |
| 1694 | - return DB::table("contest_clarification")->where('ccid','=',$ccid)->update([ |
|
| 1694 | + return DB::table("contest_clarification")->where('ccid', '=', $ccid)->update([ |
|
| 1695 | 1695 | "public"=>0 |
| 1696 | 1696 | ]); |
| 1697 | 1697 | } |
@@ -1704,66 +1704,66 @@ discard block |
||
| 1704 | 1704 | |
| 1705 | 1705 | public function praticeAnalysis($cid) |
| 1706 | 1706 | { |
| 1707 | - $gid = DB::table('contest') |
|
| 1708 | - ->where('cid',$cid) |
|
| 1707 | + $gid=DB::table('contest') |
|
| 1708 | + ->where('cid', $cid) |
|
| 1709 | 1709 | ->first()['gid']; |
| 1710 | - $contestRank = $this->contestRank($cid,Auth::user()->id); |
|
| 1711 | - if(!empty($contestRank)){ |
|
| 1712 | - $all_problems = DB::table('problem') |
|
| 1713 | - ->whereIn('pid',array_column($contestRank[0]['problem_detail'],'pid')) |
|
| 1714 | - ->select('pid','title') |
|
| 1710 | + $contestRank=$this->contestRank($cid, Auth::user()->id); |
|
| 1711 | + if (!empty($contestRank)) { |
|
| 1712 | + $all_problems=DB::table('problem') |
|
| 1713 | + ->whereIn('pid', array_column($contestRank[0]['problem_detail'], 'pid')) |
|
| 1714 | + ->select('pid', 'title') |
|
| 1715 | 1715 | ->get()->all(); |
| 1716 | - }else{ |
|
| 1717 | - $all_problems = []; |
|
| 1716 | + } else { |
|
| 1717 | + $all_problems=[]; |
|
| 1718 | 1718 | } |
| 1719 | - $tags = DB::table('group_problem_tag') |
|
| 1719 | + $tags=DB::table('group_problem_tag') |
|
| 1720 | 1720 | ->where('gid', $gid) |
| 1721 | - ->whereIn('pid', array_column($all_problems,'pid')) |
|
| 1721 | + ->whereIn('pid', array_column($all_problems, 'pid')) |
|
| 1722 | 1722 | ->get()->all(); |
| 1723 | - $all_tags = array_unique(array_column($tags,'tag')); |
|
| 1724 | - $memberData = []; |
|
| 1725 | - foreach($contestRank as $member){ |
|
| 1726 | - $m = [ |
|
| 1723 | + $all_tags=array_unique(array_column($tags, 'tag')); |
|
| 1724 | + $memberData=[]; |
|
| 1725 | + foreach ($contestRank as $member) { |
|
| 1726 | + $m=[ |
|
| 1727 | 1727 | 'uid' => $member['uid'], |
| 1728 | 1728 | 'name' => $member['name'], |
| 1729 | 1729 | 'nick_name' => $member['nick_name'], |
| 1730 | 1730 | ]; |
| 1731 | - $completion = []; |
|
| 1732 | - foreach ($all_tags as $tag){ |
|
| 1733 | - $completion[$tag] = []; |
|
| 1731 | + $completion=[]; |
|
| 1732 | + foreach ($all_tags as $tag) { |
|
| 1733 | + $completion[$tag]=[]; |
|
| 1734 | 1734 | foreach ($tags as $t) { |
| 1735 | - if($t['tag'] == $tag){ |
|
| 1735 | + if ($t['tag']==$tag) { |
|
| 1736 | 1736 | foreach ($member['problem_detail'] as $pd) { |
| 1737 | - if($pd['pid'] == $t['pid']){ |
|
| 1738 | - $completion[$tag][$t['pid']] = $pd['solved_time_parsed'] == "" ? 0 : 1; |
|
| 1737 | + if ($pd['pid']==$t['pid']) { |
|
| 1738 | + $completion[$tag][$t['pid']]=$pd['solved_time_parsed']=="" ? 0 : 1; |
|
| 1739 | 1739 | } |
| 1740 | 1740 | } |
| 1741 | 1741 | } |
| 1742 | 1742 | } |
| 1743 | 1743 | } |
| 1744 | - $m['completion'] = $completion; |
|
| 1745 | - $memberData[] = $m; |
|
| 1744 | + $m['completion']=$completion; |
|
| 1745 | + $memberData[]=$m; |
|
| 1746 | 1746 | } |
| 1747 | 1747 | return $memberData; |
| 1748 | 1748 | } |
| 1749 | 1749 | |
| 1750 | 1750 | public function storeContestRankInMySQL($cid, $data) |
| 1751 | 1751 | { |
| 1752 | - $contestRankJson = json_encode($data); |
|
| 1753 | - return DB::table('contest')->where('cid','=',$cid)->update([ |
|
| 1752 | + $contestRankJson=json_encode($data); |
|
| 1753 | + return DB::table('contest')->where('cid', '=', $cid)->update([ |
|
| 1754 | 1754 | 'rank' => $contestRankJson |
| 1755 | 1755 | ]); |
| 1756 | 1756 | } |
| 1757 | 1757 | |
| 1758 | 1758 | public function getContestRankFromMySQL($cid) |
| 1759 | 1759 | { |
| 1760 | - $contestRankJson = DB::table('contest')->where('cid','=',$cid)->pluck('rank')->first(); |
|
| 1761 | - $data = json_decode($contestRankJson, true); |
|
| 1760 | + $contestRankJson=DB::table('contest')->where('cid', '=', $cid)->pluck('rank')->first(); |
|
| 1761 | + $data=json_decode($contestRankJson, true); |
|
| 1762 | 1762 | return $data; |
| 1763 | 1763 | } |
| 1764 | 1764 | |
| 1765 | 1765 | public function isVerified($cid) |
| 1766 | 1766 | { |
| 1767 | - return DB::table('contest')->where('cid','=',$cid)->pluck('verified')->first(); |
|
| 1767 | + return DB::table('contest')->where('cid', '=', $cid)->pluck('verified')->first(); |
|
| 1768 | 1768 | } |
| 1769 | 1769 | } |
@@ -21,22 +21,22 @@ discard block |
||
| 21 | 21 | 'cid' => 'required|integer', |
| 22 | 22 | 'uid' => 'required|integer' |
| 23 | 23 | ]); |
| 24 | - $cid = $request->input('cid'); |
|
| 25 | - $uid = $request->input('uid'); |
|
| 24 | + $cid=$request->input('cid'); |
|
| 25 | + $uid=$request->input('uid'); |
|
| 26 | 26 | |
| 27 | - $groupModel = new GroupModel(); |
|
| 28 | - $contestModel = new ContestModel(); |
|
| 27 | + $groupModel=new GroupModel(); |
|
| 28 | + $contestModel=new ContestModel(); |
|
| 29 | 29 | |
| 30 | - $contest_info = $contestModel->basic($cid); |
|
| 31 | - if($contestModel->judgeClearance($cid,Auth::user()->id) != 3){ |
|
| 30 | + $contest_info=$contestModel->basic($cid); |
|
| 31 | + if ($contestModel->judgeClearance($cid, Auth::user()->id)!=3) { |
|
| 32 | 32 | return ResponseModel::err(2001); |
| 33 | 33 | } |
| 34 | 34 | |
| 35 | - if($groupModel->judgeClearance($contest_info['gid'],$uid) < 2){ |
|
| 35 | + if ($groupModel->judgeClearance($contest_info['gid'], $uid)<2) { |
|
| 36 | 36 | return ResponseModel::err(7004); |
| 37 | 37 | } |
| 38 | 38 | |
| 39 | - $contestModel->assignMember($cid,$uid); |
|
| 39 | + $contestModel->assignMember($cid, $uid); |
|
| 40 | 40 | return ResponseModel::success(200); |
| 41 | 41 | } |
| 42 | 42 | |
@@ -45,30 +45,30 @@ discard block |
||
| 45 | 45 | $request->validate([ |
| 46 | 46 | 'cid' => 'required|integer', |
| 47 | 47 | ]); |
| 48 | - $cid = $request->input('cid'); |
|
| 48 | + $cid=$request->input('cid'); |
|
| 49 | 49 | |
| 50 | - $contestModel = new ContestModel(); |
|
| 51 | - $groupModel = new GroupModel(); |
|
| 50 | + $contestModel=new ContestModel(); |
|
| 51 | + $groupModel=new GroupModel(); |
|
| 52 | 52 | |
| 53 | - $contest_problems = $contestModel->problems($cid); |
|
| 54 | - $contest_detail = $contestModel->basic($cid); |
|
| 55 | - $contest_detail['problems'] = $contest_problems; |
|
| 56 | - $assign_uid = $contest_detail['assign_uid']; |
|
| 57 | - $clearance = $contestModel->judgeClearance($cid,Auth::user()->id); |
|
| 58 | - if($clearance != 3){ |
|
| 53 | + $contest_problems=$contestModel->problems($cid); |
|
| 54 | + $contest_detail=$contestModel->basic($cid); |
|
| 55 | + $contest_detail['problems']=$contest_problems; |
|
| 56 | + $assign_uid=$contest_detail['assign_uid']; |
|
| 57 | + $clearance=$contestModel->judgeClearance($cid, Auth::user()->id); |
|
| 58 | + if ($clearance!=3) { |
|
| 59 | 59 | return ResponseModel::err(2001); |
| 60 | 60 | } |
| 61 | - if($assign_uid != 0){ |
|
| 62 | - $assignee = $groupModel->userProfile($assign_uid,$contest_detail['gid']); |
|
| 63 | - }else{ |
|
| 64 | - $assignee = null; |
|
| 61 | + if ($assign_uid!=0) { |
|
| 62 | + $assignee=$groupModel->userProfile($assign_uid, $contest_detail['gid']); |
|
| 63 | + } else { |
|
| 64 | + $assignee=null; |
|
| 65 | 65 | } |
| 66 | - $ret = [ |
|
| 66 | + $ret=[ |
|
| 67 | 67 | 'contest_info' => $contest_detail, |
| 68 | 68 | 'assignee' => $assignee, |
| 69 | - 'is_admin' => $clearance == 3, |
|
| 69 | + 'is_admin' => $clearance==3, |
|
| 70 | 70 | ]; |
| 71 | - return ResponseModel::success(200,null,$ret); |
|
| 71 | + return ResponseModel::success(200, null, $ret); |
|
| 72 | 72 | } |
| 73 | 73 | |
| 74 | 74 | public function fetchClarification(Request $request) |
@@ -101,7 +101,7 @@ discard block |
||
| 101 | 101 | $all_data=$request->all(); |
| 102 | 102 | |
| 103 | 103 | $contestModel=new ContestModel(); |
| 104 | - return $contestModel->updateProfessionalRate($all_data["cid"])?ResponseModel::success(200):ResponseModel::err(1001); |
|
| 104 | + return $contestModel->updateProfessionalRate($all_data["cid"]) ?ResponseModel::success(200) : ResponseModel::err(1001); |
|
| 105 | 105 | } |
| 106 | 106 | |
| 107 | 107 | public function requestClarification(Request $request) |
@@ -158,16 +158,16 @@ discard block |
||
| 158 | 158 | $groupModel=new GroupModel(); |
| 159 | 159 | $basic=$contestModel->basic($all_data["cid"]); |
| 160 | 160 | |
| 161 | - if(!$basic["registration"]){ |
|
| 161 | + if (!$basic["registration"]) { |
|
| 162 | 162 | return ResponseModel::err(4003); |
| 163 | 163 | } |
| 164 | - if(strtotime($basic["registration_due"])<time()){ |
|
| 164 | + if (strtotime($basic["registration_due"])<time()) { |
|
| 165 | 165 | return ResponseModel::err(4004); |
| 166 | 166 | } |
| 167 | - if(!$basic["registant_type"]){ |
|
| 167 | + if (!$basic["registant_type"]) { |
|
| 168 | 168 | return ResponseModel::err(4005); |
| 169 | 169 | } |
| 170 | - if($basic["registant_type"]==1 && !$groupModel->isMember($basic["gid"], Auth::user()->id)){ |
|
| 170 | + if ($basic["registant_type"]==1 && !$groupModel->isMember($basic["gid"], Auth::user()->id)) { |
|
| 171 | 171 | return ResponseModel::err(4005); |
| 172 | 172 | } |
| 173 | 173 | |
@@ -186,15 +186,15 @@ discard block |
||
| 186 | 186 | 'end_time' => 'required|date|after:begin_time', |
| 187 | 187 | 'description' => 'string' |
| 188 | 188 | ]); |
| 189 | - $all_data = $request->all(); |
|
| 190 | - $cid = $all_data['cid']; |
|
| 189 | + $all_data=$request->all(); |
|
| 190 | + $cid=$all_data['cid']; |
|
| 191 | 191 | |
| 192 | - $contestModel = new ContestModel(); |
|
| 193 | - if($contestModel->judgeClearance($all_data['cid'],Auth::user()->id) != 3){ |
|
| 192 | + $contestModel=new ContestModel(); |
|
| 193 | + if ($contestModel->judgeClearance($all_data['cid'], Auth::user()->id)!=3) { |
|
| 194 | 194 | return ResponseModel::err(2001); |
| 195 | 195 | } |
| 196 | 196 | |
| 197 | - if($contestModel->remainingTime($cid) > 0){ |
|
| 197 | + if ($contestModel->remainingTime($cid)>0) { |
|
| 198 | 198 | $problems=explode(",", $all_data["problems"]); |
| 199 | 199 | if (count($problems)>26) { |
| 200 | 200 | return ResponseModel::err(4002); |
@@ -211,32 +211,32 @@ discard block |
||
| 211 | 211 | ]; |
| 212 | 212 | } |
| 213 | 213 | } |
| 214 | - $allow_update = ['name','description','begin_time','end_time']; |
|
| 214 | + $allow_update=['name', 'description', 'begin_time', 'end_time']; |
|
| 215 | 215 | |
| 216 | - foreach($all_data as $key => $value){ |
|
| 217 | - if(!in_array($key,$allow_update)){ |
|
| 216 | + foreach ($all_data as $key => $value) { |
|
| 217 | + if (!in_array($key, $allow_update)) { |
|
| 218 | 218 | unset($all_data[$key]); |
| 219 | 219 | } |
| 220 | 220 | } |
| 221 | - $contestModel->contestUpdate($cid,$all_data,$problemSet); |
|
| 221 | + $contestModel->contestUpdate($cid, $all_data, $problemSet); |
|
| 222 | 222 | return ResponseModel::success(200); |
| 223 | - }else{ |
|
| 224 | - $allow_update = ['name','description']; |
|
| 223 | + } else { |
|
| 224 | + $allow_update=['name', 'description']; |
|
| 225 | 225 | |
| 226 | - foreach($all_data as $key => $value){ |
|
| 227 | - if(!in_array($key,$allow_update)){ |
|
| 226 | + foreach ($all_data as $key => $value) { |
|
| 227 | + if (!in_array($key, $allow_update)) { |
|
| 228 | 228 | unset($all_data[$key]); |
| 229 | 229 | } |
| 230 | 230 | } |
| 231 | - $contestModel->contestUpdate($cid,$all_data,false); |
|
| 232 | - return ResponseModel::success(200,' |
|
| 231 | + $contestModel->contestUpdate($cid, $all_data, false); |
|
| 232 | + return ResponseModel::success(200, ' |
|
| 233 | 233 | Successful! However, only the name and description of the match can be changed for the match that has been finished. |
| 234 | 234 | '); |
| 235 | 235 | } |
| 236 | 236 | |
| 237 | 237 | } |
| 238 | 238 | |
| 239 | - public function issueAnnouncement(Request $request){ |
|
| 239 | + public function issueAnnouncement(Request $request) { |
|
| 240 | 240 | $request->validate([ |
| 241 | 241 | 'cid' => 'required|integer', |
| 242 | 242 | 'title' => 'required|string|max:250', |
@@ -256,7 +256,7 @@ discard block |
||
| 256 | 256 | } |
| 257 | 257 | } |
| 258 | 258 | |
| 259 | - public function replyClarification(Request $request){ |
|
| 259 | + public function replyClarification(Request $request) { |
|
| 260 | 260 | $request->validate([ |
| 261 | 261 | 'cid' => 'required|integer', |
| 262 | 262 | 'ccid' => 'required|integer', |
@@ -276,7 +276,7 @@ discard block |
||
| 276 | 276 | } |
| 277 | 277 | } |
| 278 | 278 | |
| 279 | - public function setClarificationPublic(Request $request){ |
|
| 279 | + public function setClarificationPublic(Request $request) { |
|
| 280 | 280 | $request->validate([ |
| 281 | 281 | 'cid' => 'required|integer', |
| 282 | 282 | 'ccid' => 'required|integer', |
@@ -309,7 +309,7 @@ discard block |
||
| 309 | 309 | $groupModel=new GroupModel(); |
| 310 | 310 | $contestModel=new ContestModel(); |
| 311 | 311 | $verified=$contestModel->isVerified($all_data["cid"]); |
| 312 | - if(!$verified){ |
|
| 312 | + if (!$verified) { |
|
| 313 | 313 | return ResponseModel::err(2001); |
| 314 | 314 | } |
| 315 | 315 | $gid=$contestModel->gid($all_data["cid"]); |
@@ -331,13 +331,13 @@ discard block |
||
| 331 | 331 | $request->validate([ |
| 332 | 332 | 'cid' => 'required|integer' |
| 333 | 333 | ]); |
| 334 | - $cid = $request->input('cid'); |
|
| 334 | + $cid=$request->input('cid'); |
|
| 335 | 335 | |
| 336 | 336 | $contestModel=new ContestModel(); |
| 337 | 337 | $clearance=$contestModel->judgeClearance($cid, Auth::user()->id); |
| 338 | - if ($clearance < 1) { |
|
| 338 | + if ($clearance<1) { |
|
| 339 | 339 | return ResponseModel::err(7002); |
| 340 | 340 | } |
| 341 | - return ResponseModel::success(200,null,$contestModel->praticeAnalysis($cid)); |
|
| 341 | + return ResponseModel::success(200, null, $contestModel->praticeAnalysis($cid)); |
|
| 342 | 342 | } |
| 343 | 343 | } |
@@ -60,7 +60,7 @@ discard block |
||
| 60 | 60 | } |
| 61 | 61 | if($assign_uid != 0){ |
| 62 | 62 | $assignee = $groupModel->userProfile($assign_uid,$contest_detail['gid']); |
| 63 | - }else{ |
|
| 63 | + } else{ |
|
| 64 | 64 | $assignee = null; |
| 65 | 65 | } |
| 66 | 66 | $ret = [ |
@@ -220,7 +220,7 @@ discard block |
||
| 220 | 220 | } |
| 221 | 221 | $contestModel->contestUpdate($cid,$all_data,$problemSet); |
| 222 | 222 | return ResponseModel::success(200); |
| 223 | - }else{ |
|
| 223 | + } else{ |
|
| 224 | 224 | $allow_update = ['name','description']; |
| 225 | 225 | |
| 226 | 226 | foreach($all_data as $key => $value){ |