@@ -19,6 +19,6 @@ |
||
| 19 | 19 | |
| 20 | 20 | public function contest() |
| 21 | 21 | { |
| 22 | - return $this->belongsTo('App\Models\Eloquent\ContestModel','cid','cid'); |
|
| 22 | + return $this->belongsTo('App\Models\Eloquent\ContestModel', 'cid', 'cid'); |
|
| 23 | 23 | } |
| 24 | 24 | } |
@@ -28,12 +28,12 @@ discard block |
||
| 28 | 28 | $users->add($user); |
| 29 | 29 | } |
| 30 | 30 | return $users->unique(); |
| 31 | - }else{ |
|
| 31 | + } else{ |
|
| 32 | 32 | $this->load('submissions.user'); |
| 33 | 33 | if($ignore_frozen){ |
| 34 | 34 | $frozen_time = $this->frozen_time; |
| 35 | 35 | $submissions = $this->submissions()->where('submission_date','<',$frozen_time)->get(); |
| 36 | - }else{ |
|
| 36 | + } else{ |
|
| 37 | 37 | $submissions = $this->submissions; |
| 38 | 38 | } |
| 39 | 39 | $users = new EloquentCollection; |
@@ -102,7 +102,7 @@ discard block |
||
| 102 | 102 | }); |
| 103 | 103 | Cache::tags(['contest', 'rank'])->put($this->cid, $ret, 60); |
| 104 | 104 | return $ret; |
| 105 | - }else{ |
|
| 105 | + } else{ |
|
| 106 | 106 | // IO Mode |
| 107 | 107 | $c = new OutdatedContestModel(); |
| 108 | 108 | return $c->contestRankCache($this->cid); |
@@ -18,28 +18,28 @@ discard block |
||
| 18 | 18 | const CREATED_AT=null; |
| 19 | 19 | |
| 20 | 20 | //Repository function |
| 21 | - public function participants($ignore_frozen = true) |
|
| 21 | + public function participants($ignore_frozen=true) |
|
| 22 | 22 | { |
| 23 | - if($this->registration){ |
|
| 24 | - $participants = ContestParticipant::where('cid',$this->cid)->get(); |
|
| 23 | + if ($this->registration) { |
|
| 24 | + $participants=ContestParticipant::where('cid', $this->cid)->get(); |
|
| 25 | 25 | $participants->load('user'); |
| 26 | - $users = new EloquentCollection; |
|
| 26 | + $users=new EloquentCollection; |
|
| 27 | 27 | foreach ($participants as $participant) { |
| 28 | - $user = $participant->user; |
|
| 28 | + $user=$participant->user; |
|
| 29 | 29 | $users->add($user); |
| 30 | 30 | } |
| 31 | 31 | return $users->unique(); |
| 32 | - }else{ |
|
| 32 | + } else { |
|
| 33 | 33 | $this->load('submissions.user'); |
| 34 | - if($ignore_frozen){ |
|
| 35 | - $frozen_time = $this->frozen_time; |
|
| 36 | - $submissions = $this->submissions()->where('submission_date','<',$frozen_time)->get(); |
|
| 37 | - }else{ |
|
| 38 | - $submissions = $this->submissions; |
|
| 34 | + if ($ignore_frozen) { |
|
| 35 | + $frozen_time=$this->frozen_time; |
|
| 36 | + $submissions=$this->submissions()->where('submission_date', '<', $frozen_time)->get(); |
|
| 37 | + } else { |
|
| 38 | + $submissions=$this->submissions; |
|
| 39 | 39 | } |
| 40 | - $users = new EloquentCollection; |
|
| 40 | + $users=new EloquentCollection; |
|
| 41 | 41 | foreach ($submissions as $submission) { |
| 42 | - $user = $submission->user; |
|
| 42 | + $user=$submission->user; |
|
| 43 | 43 | $users->add($user); |
| 44 | 44 | } |
| 45 | 45 | return $users->unique(); |
@@ -49,18 +49,18 @@ discard block |
||
| 49 | 49 | // Repository/Service? function |
| 50 | 50 | public function rankRefresh() |
| 51 | 51 | { |
| 52 | - $ret = []; |
|
| 53 | - $participants = $this->participants(); |
|
| 54 | - $contest_problems = $this->problems; |
|
| 52 | + $ret=[]; |
|
| 53 | + $participants=$this->participants(); |
|
| 54 | + $contest_problems=$this->problems; |
|
| 55 | 55 | $contest_problems->load('problem'); |
| 56 | - if($this->rule == 1){ |
|
| 56 | + if ($this->rule==1) { |
|
| 57 | 57 | // ACM/ICPC Mode |
| 58 | 58 | foreach ($participants as $participant) { |
| 59 | 59 | $prob_detail=[]; |
| 60 | 60 | $totPen=0; |
| 61 | 61 | $totScore=0; |
| 62 | 62 | foreach ($contest_problems as $contest_problem) { |
| 63 | - $prob_stat = $contest_problem->userStatus($participant); |
|
| 63 | + $prob_stat=$contest_problem->userStatus($participant); |
|
| 64 | 64 | $prob_detail[]=[ |
| 65 | 65 | 'ncode'=>$contest_problem->ncode, |
| 66 | 66 | 'pid'=>$contest_problem->pid, |
@@ -86,7 +86,7 @@ discard block |
||
| 86 | 86 | "problem_detail" => $prob_detail |
| 87 | 87 | ]; |
| 88 | 88 | } |
| 89 | - usort($ret, function ($a, $b) { |
|
| 89 | + usort($ret, function($a, $b) { |
|
| 90 | 90 | if ($a["score"]==$b["score"]) { |
| 91 | 91 | if ($a["penalty"]==$b["penalty"]) { |
| 92 | 92 | return 0; |
@@ -103,43 +103,43 @@ discard block |
||
| 103 | 103 | }); |
| 104 | 104 | Cache::tags(['contest', 'rank'])->put($this->cid, $ret, 60); |
| 105 | 105 | return $ret; |
| 106 | - }else{ |
|
| 106 | + } else { |
|
| 107 | 107 | // IO Mode |
| 108 | - $c = new OutdatedContestModel(); |
|
| 108 | + $c=new OutdatedContestModel(); |
|
| 109 | 109 | return $c->contestRankCache($this->cid); |
| 110 | 110 | } |
| 111 | 111 | } |
| 112 | 112 | |
| 113 | 113 | public function problems() |
| 114 | 114 | { |
| 115 | - return $this->hasMany('App\Models\Eloquent\ContestProblem','cid','cid'); |
|
| 115 | + return $this->hasMany('App\Models\Eloquent\ContestProblem', 'cid', 'cid'); |
|
| 116 | 116 | } |
| 117 | 117 | |
| 118 | 118 | public function submissions() |
| 119 | 119 | { |
| 120 | - return $this->hasMany('App\Models\Eloquent\SubmissionModel','cid','cid'); |
|
| 120 | + return $this->hasMany('App\Models\Eloquent\SubmissionModel', 'cid', 'cid'); |
|
| 121 | 121 | } |
| 122 | 122 | |
| 123 | 123 | public function group() |
| 124 | 124 | { |
| 125 | - return $this->hasOne('App\Models\Eloquent\Group','gid','gid'); |
|
| 125 | + return $this->hasOne('App\Models\Eloquent\Group', 'gid', 'gid'); |
|
| 126 | 126 | } |
| 127 | 127 | |
| 128 | 128 | public function getFrozenTimeAttribute() |
| 129 | 129 | { |
| 130 | - $end_time = strtotime($this->end_time); |
|
| 131 | - return $end_time - $this->froze_length; |
|
| 130 | + $end_time=strtotime($this->end_time); |
|
| 131 | + return $end_time-$this->froze_length; |
|
| 132 | 132 | } |
| 133 | 133 | |
| 134 | 134 | public static function getProblemSet($cid, $renderLatex=false) |
| 135 | 135 | { |
| 136 | 136 | $ret=[]; |
| 137 | - $problemset=ContestProblemModel::where('cid', $cid)->orderBy('number','asc')->get(); |
|
| 138 | - foreach($problemset as $problem){ |
|
| 137 | + $problemset=ContestProblemModel::where('cid', $cid)->orderBy('number', 'asc')->get(); |
|
| 138 | + foreach ($problemset as $problem) { |
|
| 139 | 139 | $problemDetail=ProblemModel::find($problem->pid); |
| 140 | 140 | $problemRet=(new OutdatedProblemModel())->detail($problemDetail->pcode); |
| 141 | - if ($renderLatex){ |
|
| 142 | - foreach (['description','input','output','note'] as $section){ |
|
| 141 | + if ($renderLatex) { |
|
| 142 | + foreach (['description', 'input', 'output', 'note'] as $section) { |
|
| 143 | 143 | $problemRet['parsed'][$section]=latex2Image($problemRet['parsed'][$section]); |
| 144 | 144 | } |
| 145 | 145 | } |
@@ -153,6 +153,6 @@ discard block |
||
| 153 | 153 | |
| 154 | 154 | public function isJudgingComplete() |
| 155 | 155 | { |
| 156 | - return $this->submissions->whereIn('verdict',['Waiting','Pending'])->count()==0; |
|
| 156 | + return $this->submissions->whereIn('verdict', ['Waiting', 'Pending'])->count()==0; |
|
| 157 | 157 | } |
| 158 | 158 | } |
@@ -8,24 +8,24 @@ discard block |
||
| 8 | 8 | { |
| 9 | 9 | protected $table='contest_problem'; |
| 10 | 10 | protected $primaryKey='cpid'; |
| 11 | - public $timestamps = null; |
|
| 11 | + public $timestamps=null; |
|
| 12 | 12 | const DELETED_AT=null; |
| 13 | 13 | const UPDATED_AT=null; |
| 14 | 14 | const CREATED_AT=null; |
| 15 | 15 | |
| 16 | 16 | public function contest() |
| 17 | 17 | { |
| 18 | - return $this->belongsTo('App\Models\Eloquent\ContestModel','cid','cid'); |
|
| 18 | + return $this->belongsTo('App\Models\Eloquent\ContestModel', 'cid', 'cid'); |
|
| 19 | 19 | } |
| 20 | 20 | |
| 21 | 21 | public function problem() |
| 22 | 22 | { |
| 23 | - return $this->belongsTo('App\Models\Eloquent\ProblemModel','pid','pid'); |
|
| 23 | + return $this->belongsTo('App\Models\Eloquent\ProblemModel', 'pid', 'pid'); |
|
| 24 | 24 | } |
| 25 | 25 | |
| 26 | 26 | public function submissions() |
| 27 | 27 | { |
| 28 | - return $this->problem->submissions()->where('cid',$this->contest->cid); |
|
| 28 | + return $this->problem->submissions()->where('cid', $this->contest->cid); |
|
| 29 | 29 | } |
| 30 | 30 | |
| 31 | 31 | //This should be a repository...or service function ? |
@@ -38,34 +38,34 @@ discard block |
||
| 38 | 38 | 'wrong_doings' => 0, |
| 39 | 39 | 'color' => '', |
| 40 | 40 | ]; |
| 41 | - $ac_record = $this->ac_record($user); |
|
| 42 | - if(!empty($ac_record[0])){ |
|
| 43 | - $ret['solved'] = 1; |
|
| 44 | - $ret['solved_time'] = $ac_record[0]->submission_date - strtotime($this->contest->begin_time); |
|
| 45 | - $ret['solved_time_parsed'] = formatProblemSolvedTime($ret['solved_time']); |
|
| 46 | - $ret['wrong_doings'] = $ac_record[2]; |
|
| 47 | - $ret['color'] = $ac_record[1] ? 'wemd-green-text' : 'wemd-teal-text'; |
|
| 48 | - }else{ |
|
| 49 | - $ret['wrong_doings'] = $ac_record[2]; |
|
| 41 | + $ac_record=$this->ac_record($user); |
|
| 42 | + if (!empty($ac_record[0])) { |
|
| 43 | + $ret['solved']=1; |
|
| 44 | + $ret['solved_time']=$ac_record[0]->submission_date-strtotime($this->contest->begin_time); |
|
| 45 | + $ret['solved_time_parsed']=formatProblemSolvedTime($ret['solved_time']); |
|
| 46 | + $ret['wrong_doings']=$ac_record[2]; |
|
| 47 | + $ret['color']=$ac_record[1] ? 'wemd-green-text' : 'wemd-teal-text'; |
|
| 48 | + } else { |
|
| 49 | + $ret['wrong_doings']=$ac_record[2]; |
|
| 50 | 50 | } |
| 51 | 51 | return $ret; |
| 52 | 52 | } |
| 53 | 53 | |
| 54 | 54 | public function ac_record($user) |
| 55 | 55 | { |
| 56 | - $user_ac = $this->submissions()->where([ |
|
| 56 | + $user_ac=$this->submissions()->where([ |
|
| 57 | 57 | 'uid' => $user->id, |
| 58 | 58 | 'verdict' => 'Accepted' |
| 59 | 59 | ])->first(); |
| 60 | 60 | |
| 61 | - $other_ac = 1; |
|
| 62 | - $wrong_trys = 0; |
|
| 63 | - if(!empty($user_ac)){ |
|
| 64 | - $other_ac = $this->submissions() |
|
| 65 | - ->where('verdict','Accepted') |
|
| 61 | + $other_ac=1; |
|
| 62 | + $wrong_trys=0; |
|
| 63 | + if (!empty($user_ac)) { |
|
| 64 | + $other_ac=$this->submissions() |
|
| 65 | + ->where('verdict', 'Accepted') |
|
| 66 | 66 | ->where('submission_date', '<', $user_ac->submission_date) |
| 67 | 67 | ->count(); |
| 68 | - $wrong_trys = $this->submissions()->where([ |
|
| 68 | + $wrong_trys=$this->submissions()->where([ |
|
| 69 | 69 | 'uid' => $user->id, |
| 70 | 70 | ])->whereIn('verdict', [ |
| 71 | 71 | 'Runtime Error', |
@@ -76,8 +76,8 @@ discard block |
||
| 76 | 76 | 'Presentation Error', |
| 77 | 77 | 'Output Limit Exceeded' |
| 78 | 78 | ])->where('submission_date', '<', $user_ac->submission_date)->count(); |
| 79 | - }else{ |
|
| 80 | - $wrong_trys = $this->submissions()->where([ |
|
| 79 | + } else { |
|
| 80 | + $wrong_trys=$this->submissions()->where([ |
|
| 81 | 81 | 'uid' => $user->id, |
| 82 | 82 | ])->whereIn('verdict', [ |
| 83 | 83 | 'Runtime Error', |
@@ -45,7 +45,7 @@ discard block |
||
| 45 | 45 | $ret['solved_time_parsed'] = formatProblemSolvedTime($ret['solved_time']); |
| 46 | 46 | $ret['wrong_doings'] = $ac_record[2]; |
| 47 | 47 | $ret['color'] = $ac_record[1] ? 'wemd-green-text' : 'wemd-teal-text'; |
| 48 | - }else{ |
|
| 48 | + } else{ |
|
| 49 | 49 | $ret['wrong_doings'] = $ac_record[2]; |
| 50 | 50 | } |
| 51 | 51 | return $ret; |
@@ -76,7 +76,7 @@ discard block |
||
| 76 | 76 | 'Presentation Error', |
| 77 | 77 | 'Output Limit Exceeded' |
| 78 | 78 | ])->where('submission_date', '<', $user_ac->submission_date)->count(); |
| 79 | - }else{ |
|
| 79 | + } else{ |
|
| 80 | 80 | $wrong_trys = $this->submissions()->where([ |
| 81 | 81 | 'uid' => $user->id, |
| 82 | 82 | ])->whereIn('verdict', [ |
@@ -12,7 +12,7 @@ discard block |
||
| 12 | 12 | { |
| 13 | 13 | public function svg(Request $request) |
| 14 | 14 | { |
| 15 | - $ltxsource = $request->input('ltxsource'); |
|
| 15 | + $ltxsource=$request->input('ltxsource'); |
|
| 16 | 16 | if (is_null($ltxsource)) { |
| 17 | 17 | return; |
| 18 | 18 | } |
@@ -24,7 +24,7 @@ discard block |
||
| 24 | 24 | |
| 25 | 25 | public function png(Request $request) |
| 26 | 26 | { |
| 27 | - $ltxsource = $request->input('ltxsource'); |
|
| 27 | + $ltxsource=$request->input('ltxsource'); |
|
| 28 | 28 | if (is_null($ltxsource)) { |
| 29 | 29 | return; |
| 30 | 30 | } |
@@ -39,17 +39,17 @@ discard block |
||
| 39 | 39 | if (!Storage::exists('latex-svg/'.urlencode($ltxsource).'.svg')) { |
| 40 | 40 | self::generateSVG($ltxsource); |
| 41 | 41 | } |
| 42 | - $image = new Imagick(); |
|
| 42 | + $image=new Imagick(); |
|
| 43 | 43 | $image->readImageBlob(Storage::get('latex-svg/'.urlencode($ltxsource).'.svg')); |
| 44 | - $res = $image->getImageResolution(); |
|
| 45 | - $x_ratio = $res['x'] / $image->getImageWidth(); |
|
| 46 | - $y_ratio = $res['y'] / $image->getImageHeight(); |
|
| 44 | + $res=$image->getImageResolution(); |
|
| 45 | + $x_ratio=$res['x'] / $image->getImageWidth(); |
|
| 46 | + $y_ratio=$res['y'] / $image->getImageHeight(); |
|
| 47 | 47 | // $ratio=intval(200/$image->getImageHeight()); |
| 48 | 48 | $ratio=10; |
| 49 | - $width=$image->getImageWidth()*$ratio; |
|
| 50 | - $height=$image->getImageHeight()*$ratio; |
|
| 49 | + $width=$image->getImageWidth() * $ratio; |
|
| 50 | + $height=$image->getImageHeight() * $ratio; |
|
| 51 | 51 | $image->removeImage(); |
| 52 | - $image->setResolution($width*$x_ratio, $height*$y_ratio); |
|
| 52 | + $image->setResolution($width * $x_ratio, $height * $y_ratio); |
|
| 53 | 53 | $image->setBackgroundColor(new \ImagickPixel('transparent')); |
| 54 | 54 | $image->readImageBlob(Storage::get('latex-svg/'.urlencode($ltxsource).'.svg')); |
| 55 | 55 | $image->setImageFormat("png32"); |
@@ -58,7 +58,7 @@ discard block |
||
| 58 | 58 | |
| 59 | 59 | private static function generateSVG($ltxsource) |
| 60 | 60 | { |
| 61 | - $contents=str_replace('fill:rgb(0%,0%,0%)', 'fill:rgb(0,0,0)', Requests::get('http://www.tlhiv.org/ltxpreview/ltxpreview.cgi?' . http_build_query([ |
|
| 61 | + $contents=str_replace('fill:rgb(0%,0%,0%)', 'fill:rgb(0,0,0)', Requests::get('http://www.tlhiv.org/ltxpreview/ltxpreview.cgi?'.http_build_query([ |
|
| 62 | 62 | 'width' => 10, |
| 63 | 63 | 'height' => 10, |
| 64 | 64 | 'ltx' => '', |
@@ -19,18 +19,18 @@ |
||
| 19 | 19 | "dojo_id" => "required|integer" |
| 20 | 20 | ]); |
| 21 | 21 | |
| 22 | - $dojo_id = $request->input('dojo_id'); |
|
| 22 | + $dojo_id=$request->input('dojo_id'); |
|
| 23 | 23 | |
| 24 | 24 | try { |
| 25 | 25 | if (!Dojo::findOrFail($dojo_id)->canPass()) { |
| 26 | 26 | return ResponseModel::err(10001); |
| 27 | 27 | } |
| 28 | - }catch(Throwable $e){ |
|
| 28 | + } catch (Throwable $e) { |
|
| 29 | 29 | return ResponseModel::err(10002); |
| 30 | 30 | } |
| 31 | 31 | |
| 32 | - $user_id = Auth::user()->id; |
|
| 33 | - $dojoRecord = DojoPass::firstOrCreate([ |
|
| 32 | + $user_id=Auth::user()->id; |
|
| 33 | + $dojoRecord=DojoPass::firstOrCreate([ |
|
| 34 | 34 | 'dojo_id' => $dojo_id, |
| 35 | 35 | 'user_id' => $user_id, |
| 36 | 36 | ]); |
@@ -25,7 +25,7 @@ |
||
| 25 | 25 | if (!Dojo::findOrFail($dojo_id)->canPass()) { |
| 26 | 26 | return ResponseModel::err(10001); |
| 27 | 27 | } |
| 28 | - }catch(Throwable $e){ |
|
| 28 | + } catch(Throwable $e){ |
|
| 29 | 29 | return ResponseModel::err(10002); |
| 30 | 30 | } |
| 31 | 31 | |
@@ -27,22 +27,22 @@ discard block |
||
| 27 | 27 | 'cid' => 'required|integer', |
| 28 | 28 | 'uid' => 'required|integer' |
| 29 | 29 | ]); |
| 30 | - $cid = $request->input('cid'); |
|
| 31 | - $uid = $request->input('uid'); |
|
| 30 | + $cid=$request->input('cid'); |
|
| 31 | + $uid=$request->input('uid'); |
|
| 32 | 32 | |
| 33 | - $groupModel = new GroupModel(); |
|
| 34 | - $contestModel = new ContestModel(); |
|
| 33 | + $groupModel=new GroupModel(); |
|
| 34 | + $contestModel=new ContestModel(); |
|
| 35 | 35 | |
| 36 | - $contest_info = $contestModel->basic($cid); |
|
| 37 | - if($contestModel->judgeClearance($cid,Auth::user()->id) != 3){ |
|
| 36 | + $contest_info=$contestModel->basic($cid); |
|
| 37 | + if ($contestModel->judgeClearance($cid, Auth::user()->id)!=3) { |
|
| 38 | 38 | return ResponseModel::err(2001); |
| 39 | 39 | } |
| 40 | 40 | |
| 41 | - if($groupModel->judgeClearance($contest_info['gid'],$uid) < 2){ |
|
| 41 | + if ($groupModel->judgeClearance($contest_info['gid'], $uid)<2) { |
|
| 42 | 42 | return ResponseModel::err(7004); |
| 43 | 43 | } |
| 44 | 44 | |
| 45 | - $contestModel->assignMember($cid,$uid); |
|
| 45 | + $contestModel->assignMember($cid, $uid); |
|
| 46 | 46 | return ResponseModel::success(200); |
| 47 | 47 | } |
| 48 | 48 | |
@@ -51,30 +51,30 @@ discard block |
||
| 51 | 51 | $request->validate([ |
| 52 | 52 | 'cid' => 'required|integer', |
| 53 | 53 | ]); |
| 54 | - $cid = $request->input('cid'); |
|
| 54 | + $cid=$request->input('cid'); |
|
| 55 | 55 | |
| 56 | - $contestModel = new ContestModel(); |
|
| 57 | - $groupModel = new GroupModel(); |
|
| 56 | + $contestModel=new ContestModel(); |
|
| 57 | + $groupModel=new GroupModel(); |
|
| 58 | 58 | |
| 59 | - $contest_problems = $contestModel->problems($cid); |
|
| 60 | - $contest_detail = $contestModel->basic($cid); |
|
| 61 | - $contest_detail['problems'] = $contest_problems; |
|
| 62 | - $assign_uid = $contest_detail['assign_uid']; |
|
| 63 | - $clearance = $contestModel->judgeClearance($cid,Auth::user()->id); |
|
| 64 | - if($clearance != 3){ |
|
| 59 | + $contest_problems=$contestModel->problems($cid); |
|
| 60 | + $contest_detail=$contestModel->basic($cid); |
|
| 61 | + $contest_detail['problems']=$contest_problems; |
|
| 62 | + $assign_uid=$contest_detail['assign_uid']; |
|
| 63 | + $clearance=$contestModel->judgeClearance($cid, Auth::user()->id); |
|
| 64 | + if ($clearance!=3) { |
|
| 65 | 65 | return ResponseModel::err(2001); |
| 66 | 66 | } |
| 67 | - if($assign_uid != 0){ |
|
| 68 | - $assignee = $groupModel->userProfile($assign_uid,$contest_detail['gid']); |
|
| 69 | - }else{ |
|
| 70 | - $assignee = null; |
|
| 67 | + if ($assign_uid!=0) { |
|
| 68 | + $assignee=$groupModel->userProfile($assign_uid, $contest_detail['gid']); |
|
| 69 | + } else { |
|
| 70 | + $assignee=null; |
|
| 71 | 71 | } |
| 72 | - $ret = [ |
|
| 72 | + $ret=[ |
|
| 73 | 73 | 'contest_info' => $contest_detail, |
| 74 | 74 | 'assignee' => $assignee, |
| 75 | - 'is_admin' => $clearance == 3, |
|
| 75 | + 'is_admin' => $clearance==3, |
|
| 76 | 76 | ]; |
| 77 | - return ResponseModel::success(200,null,$ret); |
|
| 77 | + return ResponseModel::success(200, null, $ret); |
|
| 78 | 78 | } |
| 79 | 79 | |
| 80 | 80 | public function rejudge(Request $request) |
@@ -108,15 +108,15 @@ discard block |
||
| 108 | 108 | 'end_time' => 'required|date|after:begin_time', |
| 109 | 109 | 'description' => 'string' |
| 110 | 110 | ]); |
| 111 | - $all_data = $request->all(); |
|
| 112 | - $cid = $all_data['cid']; |
|
| 111 | + $all_data=$request->all(); |
|
| 112 | + $cid=$all_data['cid']; |
|
| 113 | 113 | |
| 114 | - $contestModel = new ContestModel(); |
|
| 115 | - if($contestModel->judgeClearance($all_data['cid'],Auth::user()->id) != 3){ |
|
| 114 | + $contestModel=new ContestModel(); |
|
| 115 | + if ($contestModel->judgeClearance($all_data['cid'], Auth::user()->id)!=3) { |
|
| 116 | 116 | return ResponseModel::err(2001); |
| 117 | 117 | } |
| 118 | 118 | |
| 119 | - if($contestModel->remainingTime($cid) > 0){ |
|
| 119 | + if ($contestModel->remainingTime($cid)>0) { |
|
| 120 | 120 | $problems=explode(",", $all_data["problems"]); |
| 121 | 121 | if (count($problems)>26) { |
| 122 | 122 | return ResponseModel::err(4002); |
@@ -133,32 +133,32 @@ discard block |
||
| 133 | 133 | ]; |
| 134 | 134 | } |
| 135 | 135 | } |
| 136 | - $allow_update = ['name','description','begin_time','end_time']; |
|
| 136 | + $allow_update=['name', 'description', 'begin_time', 'end_time']; |
|
| 137 | 137 | |
| 138 | - foreach($all_data as $key => $value){ |
|
| 139 | - if(!in_array($key,$allow_update)){ |
|
| 138 | + foreach ($all_data as $key => $value) { |
|
| 139 | + if (!in_array($key, $allow_update)) { |
|
| 140 | 140 | unset($all_data[$key]); |
| 141 | 141 | } |
| 142 | 142 | } |
| 143 | - $contestModel->contestUpdate($cid,$all_data,$problemSet); |
|
| 143 | + $contestModel->contestUpdate($cid, $all_data, $problemSet); |
|
| 144 | 144 | return ResponseModel::success(200); |
| 145 | - }else{ |
|
| 146 | - $allow_update = ['name','description']; |
|
| 145 | + } else { |
|
| 146 | + $allow_update=['name', 'description']; |
|
| 147 | 147 | |
| 148 | - foreach($all_data as $key => $value){ |
|
| 149 | - if(!in_array($key,$allow_update)){ |
|
| 148 | + foreach ($all_data as $key => $value) { |
|
| 149 | + if (!in_array($key, $allow_update)) { |
|
| 150 | 150 | unset($all_data[$key]); |
| 151 | 151 | } |
| 152 | 152 | } |
| 153 | - $contestModel->contestUpdate($cid,$all_data,false); |
|
| 154 | - return ResponseModel::success(200,' |
|
| 153 | + $contestModel->contestUpdate($cid, $all_data, false); |
|
| 154 | + return ResponseModel::success(200, ' |
|
| 155 | 155 | Successful! However, only the name and description of the match can be changed for the match that has been finished. |
| 156 | 156 | '); |
| 157 | 157 | } |
| 158 | 158 | |
| 159 | 159 | } |
| 160 | 160 | |
| 161 | - public function issueAnnouncement(Request $request){ |
|
| 161 | + public function issueAnnouncement(Request $request) { |
|
| 162 | 162 | $request->validate([ |
| 163 | 163 | 'cid' => 'required|integer', |
| 164 | 164 | 'title' => 'required|string|max:250', |
@@ -178,7 +178,7 @@ discard block |
||
| 178 | 178 | } |
| 179 | 179 | } |
| 180 | 180 | |
| 181 | - public function replyClarification(Request $request){ |
|
| 181 | + public function replyClarification(Request $request) { |
|
| 182 | 182 | $request->validate([ |
| 183 | 183 | 'cid' => 'required|integer', |
| 184 | 184 | 'ccid' => 'required|integer', |
@@ -198,7 +198,7 @@ discard block |
||
| 198 | 198 | } |
| 199 | 199 | } |
| 200 | 200 | |
| 201 | - public function setClarificationPublic(Request $request){ |
|
| 201 | + public function setClarificationPublic(Request $request) { |
|
| 202 | 202 | $request->validate([ |
| 203 | 203 | 'cid' => 'required|integer', |
| 204 | 204 | 'ccid' => 'required|integer', |
@@ -231,7 +231,7 @@ discard block |
||
| 231 | 231 | $groupModel=new GroupModel(); |
| 232 | 232 | $contestModel=new ContestModel(); |
| 233 | 233 | $verified=$contestModel->isVerified($all_data["cid"]); |
| 234 | - if(!$verified){ |
|
| 234 | + if (!$verified) { |
|
| 235 | 235 | return ResponseModel::err(2001); |
| 236 | 236 | } |
| 237 | 237 | $gid=$contestModel->gid($all_data["cid"]); |
@@ -252,18 +252,18 @@ discard block |
||
| 252 | 252 | $request->validate([ |
| 253 | 253 | 'cid' => 'required|integer', |
| 254 | 254 | ]); |
| 255 | - $cid = $request->input('cid'); |
|
| 256 | - $contestModel = new ContestModel(); |
|
| 257 | - if($contestModel->judgeClearance($cid,Auth::user()->id) != 3){ |
|
| 255 | + $cid=$request->input('cid'); |
|
| 256 | + $contestModel=new ContestModel(); |
|
| 257 | + if ($contestModel->judgeClearance($cid, Auth::user()->id)!=3) { |
|
| 258 | 258 | return ResponseModel::err(2001); |
| 259 | 259 | } |
| 260 | - if($contestModel->remainingTime($cid) >= 0){ |
|
| 260 | + if ($contestModel->remainingTime($cid)>=0) { |
|
| 261 | 261 | return ResponseModel::err(4008); |
| 262 | 262 | } |
| 263 | - if($contestModel->basic($cid)['froze_length'] == 0){ |
|
| 263 | + if ($contestModel->basic($cid)['froze_length']==0) { |
|
| 264 | 264 | return ResponseModel::err(4009); |
| 265 | 265 | } |
| 266 | - $data = $contestModel->getScrollBoardData($cid); |
|
| 266 | + $data=$contestModel->getScrollBoardData($cid); |
|
| 267 | 267 | return ResponseModel::success(200, null, $data); |
| 268 | 268 | } |
| 269 | 269 | |
@@ -272,20 +272,20 @@ discard block |
||
| 272 | 272 | $request->validate([ |
| 273 | 273 | "cid"=>"required|integer", |
| 274 | 274 | ]); |
| 275 | - $cid = $request->input('cid'); |
|
| 275 | + $cid=$request->input('cid'); |
|
| 276 | 276 | $groupModel=new GroupModel(); |
| 277 | 277 | $contestModel=new ContestModel(); |
| 278 | - if($contestModel->judgeClearance($cid,Auth::user()->id) != 3){ |
|
| 278 | + if ($contestModel->judgeClearance($cid, Auth::user()->id)!=3) { |
|
| 279 | 279 | return ResponseModel::err(2001); |
| 280 | 280 | } |
| 281 | 281 | |
| 282 | 282 | $zip_name=$contestModel->zipName($cid); |
| 283 | - if(!(Storage::disk("private")->exists("contestCodeZip/$cid/".$cid.".zip"))){ |
|
| 284 | - $contestModel->GenerateZip("contestCodeZip/$cid/",$cid,"contestCode/$cid/",$zip_name); |
|
| 283 | + if (!(Storage::disk("private")->exists("contestCodeZip/$cid/".$cid.".zip"))) { |
|
| 284 | + $contestModel->GenerateZip("contestCodeZip/$cid/", $cid, "contestCode/$cid/", $zip_name); |
|
| 285 | 285 | } |
| 286 | 286 | |
| 287 | 287 | $files=Storage::disk("private")->files("contestCodeZip/$cid/"); |
| 288 | - response()->download(base_path("/storage/app/private/".$files[0]),$zip_name,[ |
|
| 288 | + response()->download(base_path("/storage/app/private/".$files[0]), $zip_name, [ |
|
| 289 | 289 | "Content-Transfer-Encoding" => "binary", |
| 290 | 290 | "Content-Type"=>"application/octet-stream", |
| 291 | 291 | "filename"=>$zip_name |
@@ -298,10 +298,10 @@ discard block |
||
| 298 | 298 | $request->validate([ |
| 299 | 299 | "cid"=>"required|integer", |
| 300 | 300 | ]); |
| 301 | - $cid = $request->input('cid'); |
|
| 301 | + $cid=$request->input('cid'); |
|
| 302 | 302 | $contestModel=new ContestModel(); |
| 303 | 303 | |
| 304 | - if($contestModel->judgeClearance($cid,Auth::user()->id) != 3){ |
|
| 304 | + if ($contestModel->judgeClearance($cid, Auth::user()->id)!=3) { |
|
| 305 | 305 | return ResponseModel::err(2001); |
| 306 | 306 | } |
| 307 | 307 | $name=$contestModel->basic($cid)["name"]; |
@@ -316,17 +316,17 @@ discard block |
||
| 316 | 316 | "config.cover"=>"required", |
| 317 | 317 | "config.advice"=>"required", |
| 318 | 318 | ]); |
| 319 | - $cid = $request->input('cid'); |
|
| 320 | - $config = [ |
|
| 319 | + $cid=$request->input('cid'); |
|
| 320 | + $config=[ |
|
| 321 | 321 | 'cover'=>$request->input('config.cover')=='true', |
| 322 | 322 | 'advice'=>$request->input('config.advice')=='true' |
| 323 | 323 | ]; |
| 324 | 324 | $contestModel=new ContestModel(); |
| 325 | - if ($contestModel->judgeClearance($cid,Auth::user()->id) != 3){ |
|
| 325 | + if ($contestModel->judgeClearance($cid, Auth::user()->id)!=3) { |
|
| 326 | 326 | return ResponseModel::err(2001); |
| 327 | 327 | } |
| 328 | - if(!is_null(Cache::tags(['contest', 'admin', 'PDFGenerate'])->get($cid))) return ResponseModel::err(8001); |
|
| 329 | - $generateProcess=new GeneratePDF($cid,$config); |
|
| 328 | + if (!is_null(Cache::tags(['contest', 'admin', 'PDFGenerate'])->get($cid))) return ResponseModel::err(8001); |
|
| 329 | + $generateProcess=new GeneratePDF($cid, $config); |
|
| 330 | 330 | dispatch($generateProcess)->onQueue('normal'); |
| 331 | 331 | Cache::tags(['contest', 'admin', 'PDFGenerate'])->put($cid, $generateProcess->getJobStatusId()); |
| 332 | 332 | return ResponseModel::success(200, null, [ |
@@ -339,13 +339,13 @@ discard block |
||
| 339 | 339 | $request->validate([ |
| 340 | 340 | "cid"=>"required|integer" |
| 341 | 341 | ]); |
| 342 | - $cid = $request->input('cid'); |
|
| 342 | + $cid=$request->input('cid'); |
|
| 343 | 343 | $contestModel=new ContestModel(); |
| 344 | - if ($contestModel->judgeClearance($cid,Auth::user()->id) != 3){ |
|
| 344 | + if ($contestModel->judgeClearance($cid, Auth::user()->id)!=3) { |
|
| 345 | 345 | return ResponseModel::err(2001); |
| 346 | 346 | } |
| 347 | - if(!is_null(Cache::tags(['contest', 'admin', 'anticheat'])->get($cid))) return ResponseModel::err(8001); |
|
| 348 | - if(EloquentContestModel::find($cid)->isJudgingComplete()) { |
|
| 347 | + if (!is_null(Cache::tags(['contest', 'admin', 'anticheat'])->get($cid))) return ResponseModel::err(8001); |
|
| 348 | + if (EloquentContestModel::find($cid)->isJudgingComplete()) { |
|
| 349 | 349 | $anticheatProcess=new AntiCheat($cid); |
| 350 | 350 | dispatch($anticheatProcess)->onQueue('normal'); |
| 351 | 351 | Cache::tags(['contest', 'admin', 'anticheat'])->put($cid, $anticheatProcess->getJobStatusId()); |
@@ -66,7 +66,7 @@ discard block |
||
| 66 | 66 | } |
| 67 | 67 | if($assign_uid != 0){ |
| 68 | 68 | $assignee = $groupModel->userProfile($assign_uid,$contest_detail['gid']); |
| 69 | - }else{ |
|
| 69 | + } else{ |
|
| 70 | 70 | $assignee = null; |
| 71 | 71 | } |
| 72 | 72 | $ret = [ |
@@ -142,7 +142,7 @@ discard block |
||
| 142 | 142 | } |
| 143 | 143 | $contestModel->contestUpdate($cid,$all_data,$problemSet); |
| 144 | 144 | return ResponseModel::success(200); |
| 145 | - }else{ |
|
| 145 | + } else{ |
|
| 146 | 146 | $allow_update = ['name','description']; |
| 147 | 147 | |
| 148 | 148 | foreach($all_data as $key => $value){ |
@@ -325,7 +325,9 @@ discard block |
||
| 325 | 325 | if ($contestModel->judgeClearance($cid,Auth::user()->id) != 3){ |
| 326 | 326 | return ResponseModel::err(2001); |
| 327 | 327 | } |
| 328 | - if(!is_null(Cache::tags(['contest', 'admin', 'PDFGenerate'])->get($cid))) return ResponseModel::err(8001); |
|
| 328 | + if(!is_null(Cache::tags(['contest', 'admin', 'PDFGenerate'])->get($cid))) { |
|
| 329 | + return ResponseModel::err(8001); |
|
| 330 | + } |
|
| 329 | 331 | $generateProcess=new GeneratePDF($cid,$config); |
| 330 | 332 | dispatch($generateProcess)->onQueue('normal'); |
| 331 | 333 | Cache::tags(['contest', 'admin', 'PDFGenerate'])->put($cid, $generateProcess->getJobStatusId()); |
@@ -344,7 +346,9 @@ discard block |
||
| 344 | 346 | if ($contestModel->judgeClearance($cid,Auth::user()->id) != 3){ |
| 345 | 347 | return ResponseModel::err(2001); |
| 346 | 348 | } |
| 347 | - if(!is_null(Cache::tags(['contest', 'admin', 'anticheat'])->get($cid))) return ResponseModel::err(8001); |
|
| 349 | + if(!is_null(Cache::tags(['contest', 'admin', 'anticheat'])->get($cid))) { |
|
| 350 | + return ResponseModel::err(8001); |
|
| 351 | + } |
|
| 348 | 352 | if(EloquentContestModel::find($cid)->isJudgingComplete()) { |
| 349 | 353 | $anticheatProcess=new AntiCheat($cid); |
| 350 | 354 | dispatch($anticheatProcess)->onQueue('normal'); |
@@ -43,7 +43,7 @@ discard block |
||
| 43 | 43 | $all_data=$request->all(); |
| 44 | 44 | |
| 45 | 45 | $contestModel=new ContestModel(); |
| 46 | - return $contestModel->updateProfessionalRate($all_data["cid"])?ResponseModel::success(200):ResponseModel::err(1001); |
|
| 46 | + return $contestModel->updateProfessionalRate($all_data["cid"]) ?ResponseModel::success(200) : ResponseModel::err(1001); |
|
| 47 | 47 | } |
| 48 | 48 | |
| 49 | 49 | public function requestClarification(Request $request) |
@@ -79,16 +79,16 @@ discard block |
||
| 79 | 79 | $groupModel=new GroupModel(); |
| 80 | 80 | $basic=$contestModel->basic($all_data["cid"]); |
| 81 | 81 | |
| 82 | - if(!$basic["registration"]){ |
|
| 82 | + if (!$basic["registration"]) { |
|
| 83 | 83 | return ResponseModel::err(4003); |
| 84 | 84 | } |
| 85 | - if(strtotime($basic["registration_due"])<time()){ |
|
| 85 | + if (strtotime($basic["registration_due"])<time()) { |
|
| 86 | 86 | return ResponseModel::err(4004); |
| 87 | 87 | } |
| 88 | - if(!$basic["registant_type"]){ |
|
| 88 | + if (!$basic["registant_type"]) { |
|
| 89 | 89 | return ResponseModel::err(4005); |
| 90 | 90 | } |
| 91 | - if($basic["registant_type"]==1 && !$groupModel->isMember($basic["gid"], Auth::user()->id)){ |
|
| 91 | + if ($basic["registant_type"]==1 && !$groupModel->isMember($basic["gid"], Auth::user()->id)) { |
|
| 92 | 92 | return ResponseModel::err(4005); |
| 93 | 93 | } |
| 94 | 94 | |
@@ -102,14 +102,14 @@ discard block |
||
| 102 | 102 | $request->validate([ |
| 103 | 103 | 'cid' => 'required|integer' |
| 104 | 104 | ]); |
| 105 | - $cid = $request->input('cid'); |
|
| 105 | + $cid=$request->input('cid'); |
|
| 106 | 106 | |
| 107 | 107 | $contestModel=new ContestModel(); |
| 108 | 108 | $clearance=$contestModel->judgeClearance($cid, Auth::user()->id); |
| 109 | - if ($clearance < 1) { |
|
| 109 | + if ($clearance<1) { |
|
| 110 | 110 | return ResponseModel::err(7002); |
| 111 | 111 | } |
| 112 | - return ResponseModel::success(200,null,$contestModel->praticeAnalysis($cid)); |
|
| 112 | + return ResponseModel::success(200, null, $contestModel->praticeAnalysis($cid)); |
|
| 113 | 113 | } |
| 114 | 114 | |
| 115 | 115 | public function downloadPDF(Request $request) |
@@ -117,11 +117,11 @@ discard block |
||
| 117 | 117 | $request->validate([ |
| 118 | 118 | 'cid' => 'required|integer' |
| 119 | 119 | ]); |
| 120 | - $cid = $request->input('cid'); |
|
| 120 | + $cid=$request->input('cid'); |
|
| 121 | 121 | |
| 122 | 122 | $info=EloquentContestModel::find($cid); |
| 123 | 123 | |
| 124 | - if (!$info->pdf){ |
|
| 124 | + if (!$info->pdf) { |
|
| 125 | 125 | return abort('403'); |
| 126 | 126 | } |
| 127 | 127 | |
@@ -15,24 +15,24 @@ |
||
| 15 | 15 | $request->validate([ |
| 16 | 16 | 'uid' => 'required|integer' |
| 17 | 17 | ]); |
| 18 | - $uid = $request->input('uid'); |
|
| 19 | - if(!Auth::check() || Auth::user()->id != $uid){ |
|
| 18 | + $uid=$request->input('uid'); |
|
| 19 | + if (!Auth::check() || Auth::user()->id!=$uid) { |
|
| 20 | 20 | return ResponseModel::err(2001); |
| 21 | 21 | } |
| 22 | - $ret = Message::unread($uid); |
|
| 23 | - return ResponseModel::success(200,null,$ret); |
|
| 22 | + $ret=Message::unread($uid); |
|
| 23 | + return ResponseModel::success(200, null, $ret); |
|
| 24 | 24 | } |
| 25 | 25 | |
| 26 | 26 | public function allRead() |
| 27 | 27 | { |
| 28 | - $uid = Auth::user()->id; |
|
| 28 | + $uid=Auth::user()->id; |
|
| 29 | 29 | Message::allRead($uid); |
| 30 | 30 | return ResponseModel::success(200); |
| 31 | 31 | } |
| 32 | 32 | |
| 33 | 33 | public function deleteAll() |
| 34 | 34 | { |
| 35 | - $uid = Auth::user()->id; |
|
| 35 | + $uid=Auth::user()->id; |
|
| 36 | 36 | Message::removeAllRead($uid); |
| 37 | 37 | return ResponseModel::success(200); |
| 38 | 38 | } |
@@ -17,8 +17,8 @@ discard block |
||
| 17 | 17 | { |
| 18 | 18 | protected static $cause=[]; |
| 19 | 19 | |
| 20 | - public static function findCause($causeDesc){ |
|
| 21 | - if(empty($cause)){ |
|
| 20 | + public static function findCause($causeDesc) { |
|
| 21 | + if (empty($cause)) { |
|
| 22 | 22 | self::$cause=array_flip(Abuse::$cause); |
| 23 | 23 | } |
| 24 | 24 | $causeID=Arr::get(self::$cause, $causeDesc, 0); |
@@ -34,24 +34,24 @@ discard block |
||
| 34 | 34 | "subject_id" => "required|integer" |
| 35 | 35 | ]); |
| 36 | 36 | $category2link=[ |
| 37 | - 'group'=>function($id){ |
|
| 38 | - return route('group.detail',['gcode'=>Group::findOrFail($id)->gcode]); |
|
| 37 | + 'group'=>function($id) { |
|
| 38 | + return route('group.detail', ['gcode'=>Group::findOrFail($id)->gcode]); |
|
| 39 | 39 | }, |
| 40 | - 'user'=>function($id){ |
|
| 41 | - return route('user.view',['uid' => $id]); |
|
| 40 | + 'user'=>function($id) { |
|
| 41 | + return route('user.view', ['uid' => $id]); |
|
| 42 | 42 | } |
| 43 | 43 | ]; |
| 44 | - $supplement = $request->input('supplement'); |
|
| 45 | - $category = $request->input('category'); |
|
| 46 | - $subject_id = $request->input('subject_id'); |
|
| 44 | + $supplement=$request->input('supplement'); |
|
| 45 | + $category=$request->input('category'); |
|
| 46 | + $subject_id=$request->input('subject_id'); |
|
| 47 | 47 | try { |
| 48 | - $link = $category2link[$category]($subject_id); |
|
| 49 | - } catch(Throwable $e){ |
|
| 48 | + $link=$category2link[$category]($subject_id); |
|
| 49 | + } catch (Throwable $e) { |
|
| 50 | 50 | return ResponseModel::err(9001); |
| 51 | 51 | } |
| 52 | - $uid = Auth::user()->id; |
|
| 53 | - [$causeID, $causeDesc] = self::findCause('General'); |
|
| 54 | - $abuseRecord = Abuse::create([ |
|
| 52 | + $uid=Auth::user()->id; |
|
| 53 | + [$causeID, $causeDesc]=self::findCause('General'); |
|
| 54 | + $abuseRecord=Abuse::create([ |
|
| 55 | 55 | 'title' => Str::title($category)." #$subject_id Abused - $causeDesc", |
| 56 | 56 | 'category' => array_search($category, Abuse::$supportCategory), |
| 57 | 57 | 'cause' => $causeID, |