@@ -83,11 +83,11 @@ discard block |
||
83 | 83 | $grid->column('sid', "ID")->sortable(); |
84 | 84 | $grid->time("Time"); |
85 | 85 | $grid->memory("Memory"); |
86 | - $grid->verdict("Verdict")->display(function ($verdict) { |
|
86 | + $grid->verdict("Verdict")->display(function($verdict) { |
|
87 | 87 | return '<i class="fa fa-circle '.$this->color.'"></i> '.$verdict; |
88 | 88 | }); |
89 | 89 | $grid->language("Language"); |
90 | - $grid->submission_date("Submission Date")->display(function ($submission_date) { |
|
90 | + $grid->submission_date("Submission Date")->display(function($submission_date) { |
|
91 | 91 | return date("Y-m-d H:i:s", $submission_date); |
92 | 92 | }); |
93 | 93 | ; |
@@ -97,11 +97,11 @@ discard block |
||
97 | 97 | $grid->jid("JID"); |
98 | 98 | $grid->coid("COID"); |
99 | 99 | $grid->score("Raw Score"); |
100 | - $grid->filter(function (Grid\Filter $filter) { |
|
101 | - $filter->column(6, function ($filter) { |
|
100 | + $grid->filter(function(Grid\Filter $filter) { |
|
101 | + $filter->column(6, function($filter) { |
|
102 | 102 | $filter->like('verdict'); |
103 | 103 | }); |
104 | - $filter->column(6, function ($filter) { |
|
104 | + $filter->column(6, function($filter) { |
|
105 | 105 | $filter->equal('cid', 'Contest ID'); |
106 | 106 | $filter->equal('uid', 'User ID'); |
107 | 107 | $filter->equal('pid', 'Problem ID'); |
@@ -138,14 +138,14 @@ discard block |
||
138 | 138 | $show->coid('COID'); |
139 | 139 | $show->vcid('VCID'); |
140 | 140 | $show->score(); |
141 | - $show->share()->using(['No','Yes']); |
|
141 | + $show->share()->using(['No', 'Yes']); |
|
142 | 142 | return $show; |
143 | 143 | } |
144 | 144 | |
145 | 145 | private function codify($field, $lang=null) |
146 | 146 | { |
147 | - $field->unescape()->as(function ($value) use ($field,$lang) { |
|
148 | - $field->border = false; |
|
147 | + $field->unescape()->as(function($value) use ($field, $lang) { |
|
148 | + $field->border=false; |
|
149 | 149 | $hash=md5($value); |
150 | 150 | if (blank($value)) { |
151 | 151 | $value=" "; |
@@ -186,7 +186,7 @@ discard block |
||
186 | 186 | { |
187 | 187 | $form=new Form(new EloquentSubmissionModel); |
188 | 188 | $form->model()->makeVisible('password'); |
189 | - $form->tab('Basic', function (Form $form) { |
|
189 | + $form->tab('Basic', function(Form $form) { |
|
190 | 190 | $form->display('sid'); |
191 | 191 | $form->text('time')->rules('required'); |
192 | 192 | $form->text('memory')->rules('required'); |
@@ -446,7 +446,9 @@ discard block |
||
446 | 446 | |
447 | 447 | if (!empty($data["sample"])) { |
448 | 448 | foreach ($data["sample"] as $d) { |
449 | - if(!isset($d['sample_note'])) $d['sample_note']=null; |
|
449 | + if(!isset($d['sample_note'])) { |
|
450 | + $d['sample_note']=null; |
|
451 | + } |
|
450 | 452 | DB::table("problem_sample")->insert([ |
451 | 453 | 'pid'=>$pid, |
452 | 454 | 'sample_input'=>$d['sample_input'], |
@@ -492,7 +494,9 @@ discard block |
||
492 | 494 | |
493 | 495 | if (!empty($data["sample"])) { |
494 | 496 | foreach ($data["sample"] as $d) { |
495 | - if(!isset($d['sample_note'])) $d['sample_note']=null; |
|
497 | + if(!isset($d['sample_note'])) { |
|
498 | + $d['sample_note']=null; |
|
499 | + } |
|
496 | 500 | DB::table("problem_sample")->insert([ |
497 | 501 | 'pid'=>$pid, |
498 | 502 | 'sample_input'=>$d['sample_input'], |
@@ -679,7 +683,7 @@ discard block |
||
679 | 683 | $top=DB::table('problem_discussion_comment')->where('pdcid','=',$reply_id)->get()->first()['reply_id']; |
680 | 684 | if(isset($top)){ |
681 | 685 | return $this->replyParent($reply_id); |
682 | - }else{ |
|
686 | + } else{ |
|
683 | 687 | return $reply_id; |
684 | 688 | } |
685 | 689 | } |
@@ -48,11 +48,11 @@ discard block |
||
48 | 48 | $prob_detail["pdf"]=false; |
49 | 49 | $prob_detail["viewerShow"]=false; |
50 | 50 | $prob_detail["file_ext"]=null; |
51 | - if($prob_detail['file'] && !blank($prob_detail['file_url'])){ |
|
52 | - $prob_detail["file_ext"]=explode('.',basename($prob_detail['file_url'])); |
|
51 | + if ($prob_detail['file'] && !blank($prob_detail['file_url'])) { |
|
52 | + $prob_detail["file_ext"]=explode('.', basename($prob_detail['file_url'])); |
|
53 | 53 | $prob_detail["file_ext"]=end($prob_detail["file_ext"]); |
54 | 54 | $prob_detail["pdf"]=Str::is("*.pdf", basename($prob_detail['file_url'])); |
55 | - $prob_detail["viewerShow"]= blank($prob_detail["parsed"]["description"]) && |
|
55 | + $prob_detail["viewerShow"]=blank($prob_detail["parsed"]["description"]) && |
|
56 | 56 | blank($prob_detail["parsed"]["input"]) && |
57 | 57 | blank($prob_detail["parsed"]["output"]) && |
58 | 58 | blank($prob_detail["parsed"]["note"]); |
@@ -194,9 +194,9 @@ discard block |
||
194 | 194 | |
195 | 195 | private function inteliAudit($uid, $content) |
196 | 196 | { |
197 | - if (strpos($content, '```')!==false){ |
|
197 | + if (strpos($content, '```')!==false) { |
|
198 | 198 | $userSolutionHistory=DB::table("problem_solution")->where(['uid'=>$uid])->orderByDesc('updated_at')->first(); |
199 | - if (!empty($userSolutionHistory) && $userSolutionHistory["audit"]==1){ |
|
199 | + if (!empty($userSolutionHistory) && $userSolutionHistory["audit"]==1) { |
|
200 | 200 | return 1; |
201 | 201 | } |
202 | 202 | } |
@@ -292,7 +292,7 @@ discard block |
||
292 | 292 | { |
293 | 293 | // $prob_list = DB::table($this->table)->select("pid","pcode","title")->get()->all(); // return a array |
294 | 294 | $submissionModel=new SubmissionModel(); |
295 | - $preQuery=DB::table($this->table)->where('hide','=',0); |
|
295 | + $preQuery=DB::table($this->table)->where('hide', '=', 0); |
|
296 | 296 | if ($filter['oj']) { |
297 | 297 | $preQuery=$preQuery->where(["OJ"=>$filter['oj']]); |
298 | 298 | } |
@@ -454,7 +454,7 @@ discard block |
||
454 | 454 | |
455 | 455 | if (!empty($data["sample"])) { |
456 | 456 | foreach ($data["sample"] as $d) { |
457 | - if(!isset($d['sample_note'])) $d['sample_note']=null; |
|
457 | + if (!isset($d['sample_note'])) $d['sample_note']=null; |
|
458 | 458 | DB::table("problem_sample")->insert([ |
459 | 459 | 'pid'=>$pid, |
460 | 460 | 'sample_input'=>$d['sample_input'], |
@@ -503,7 +503,7 @@ discard block |
||
503 | 503 | |
504 | 504 | if (!empty($data["sample"])) { |
505 | 505 | foreach ($data["sample"] as $d) { |
506 | - if(!isset($d['sample_note'])) $d['sample_note']=null; |
|
506 | + if (!isset($d['sample_note'])) $d['sample_note']=null; |
|
507 | 507 | DB::table("problem_sample")->insert([ |
508 | 508 | 'pid'=>$pid, |
509 | 509 | 'sample_input'=>$d['sample_input'], |
@@ -518,7 +518,7 @@ discard block |
||
518 | 518 | |
519 | 519 | public function discussionList($pid) |
520 | 520 | { |
521 | - $paginator = DB::table('problem_discussion')->join( |
|
521 | + $paginator=DB::table('problem_discussion')->join( |
|
522 | 522 | "users", |
523 | 523 | "id", |
524 | 524 | "=", |
@@ -537,10 +537,10 @@ discard block |
||
537 | 537 | 'users.name', |
538 | 538 | 'users.id as uid' |
539 | 539 | ])->paginate(15); |
540 | - $list = $paginator->all(); |
|
541 | - foreach($list as &$l){ |
|
542 | - $l['updated_at'] = formatHumanReadableTime($l['updated_at']); |
|
543 | - $l['comment_count'] = DB::table('problem_discussion_comment')->where('pdid','=',$l['pdid'])->count(); |
|
540 | + $list=$paginator->all(); |
|
541 | + foreach ($list as &$l) { |
|
542 | + $l['updated_at']=formatHumanReadableTime($l['updated_at']); |
|
543 | + $l['comment_count']=DB::table('problem_discussion_comment')->where('pdid', '=', $l['pdid'])->count(); |
|
544 | 544 | } |
545 | 545 | return [ |
546 | 546 | 'paginator' => $paginator, |
@@ -550,7 +550,7 @@ discard block |
||
550 | 550 | |
551 | 551 | public function discussionDetail($pdid) |
552 | 552 | { |
553 | - $main = DB::table('problem_discussion')->join( |
|
553 | + $main=DB::table('problem_discussion')->join( |
|
554 | 554 | "users", |
555 | 555 | "id", |
556 | 556 | "=", |
@@ -569,12 +569,12 @@ discard block |
||
569 | 569 | 'users.name', |
570 | 570 | 'users.id as uid' |
571 | 571 | ])->get()->first(); |
572 | - $main['created_at'] = formatHumanReadableTime($main['created_at']); |
|
572 | + $main['created_at']=formatHumanReadableTime($main['created_at']); |
|
573 | 573 | $main['content']=clean(Markdown::convertToHtml($main["content"])); |
574 | 574 | |
575 | - $comment_count = DB::table('problem_discussion_comment')->where('pdid','=',$pdid)->count(); |
|
575 | + $comment_count=DB::table('problem_discussion_comment')->where('pdid', '=', $pdid)->count(); |
|
576 | 576 | |
577 | - $paginator = DB::table('problem_discussion_comment')->join( |
|
577 | + $paginator=DB::table('problem_discussion_comment')->join( |
|
578 | 578 | "users", |
579 | 579 | "id", |
580 | 580 | "=", |
@@ -593,11 +593,11 @@ discard block |
||
593 | 593 | 'users.name', |
594 | 594 | 'users.id as uid' |
595 | 595 | ])->paginate(10); |
596 | - $comment = $paginator->all(); |
|
597 | - foreach($comment as &$c){ |
|
596 | + $comment=$paginator->all(); |
|
597 | + foreach ($comment as &$c) { |
|
598 | 598 | $c['content']=clean(Markdown::convertToHtml($c["content"])); |
599 | - $c['created_at'] = formatHumanReadableTime($c['created_at']); |
|
600 | - $c['reply'] = DB::table('problem_discussion_comment')->join( |
|
599 | + $c['created_at']=formatHumanReadableTime($c['created_at']); |
|
600 | + $c['reply']=DB::table('problem_discussion_comment')->join( |
|
601 | 601 | "users", |
602 | 602 | "id", |
603 | 603 | "=", |
@@ -625,20 +625,20 @@ discard block |
||
625 | 625 | 'users.name', |
626 | 626 | 'users.id as uid' |
627 | 627 | ])->get()->all(); |
628 | - foreach($c['reply'] as $k=>&$cr){ |
|
628 | + foreach ($c['reply'] as $k=>&$cr) { |
|
629 | 629 | $cr['content']=clean(Markdown::convertToHtml($cr["content"])); |
630 | - $cr['reply_uid'] = DB::table('problem_discussion_comment')->where( |
|
630 | + $cr['reply_uid']=DB::table('problem_discussion_comment')->where( |
|
631 | 631 | 'pdcid', |
632 | 632 | '=', |
633 | 633 | $cr['reply_id'] |
634 | 634 | )->get()->first()['uid']; |
635 | - $cr['reply_name'] = DB::table('users')->where( |
|
635 | + $cr['reply_name']=DB::table('users')->where( |
|
636 | 636 | 'id', |
637 | 637 | '=', |
638 | 638 | $cr['reply_uid'] |
639 | 639 | )->get()->first()['name']; |
640 | - $cr['created_at'] = formatHumanReadableTime($cr['created_at']); |
|
641 | - if($this->replyParent($cr['pdcid'])!=$c['pdcid']){ |
|
640 | + $cr['created_at']=formatHumanReadableTime($cr['created_at']); |
|
641 | + if ($this->replyParent($cr['pdcid'])!=$c['pdcid']) { |
|
642 | 642 | unset($c['reply'][$k]); |
643 | 643 | } |
644 | 644 | } |
@@ -653,19 +653,19 @@ discard block |
||
653 | 653 | |
654 | 654 | public function replyParent($pdcid) |
655 | 655 | { |
656 | - $reply_id=DB::table('problem_discussion_comment')->where('pdcid','=',$pdcid)->get()->first()['reply_id']; |
|
657 | - $top=DB::table('problem_discussion_comment')->where('pdcid','=',$reply_id)->get()->first()['reply_id']; |
|
658 | - if(isset($top)){ |
|
656 | + $reply_id=DB::table('problem_discussion_comment')->where('pdcid', '=', $pdcid)->get()->first()['reply_id']; |
|
657 | + $top=DB::table('problem_discussion_comment')->where('pdcid', '=', $reply_id)->get()->first()['reply_id']; |
|
658 | + if (isset($top)) { |
|
659 | 659 | return $this->replyParent($reply_id); |
660 | - }else{ |
|
660 | + } else { |
|
661 | 661 | return $reply_id; |
662 | 662 | } |
663 | 663 | } |
664 | 664 | |
665 | 665 | public function pcodeByPdid($dcode) |
666 | 666 | { |
667 | - $pid = DB::table('problem_discussion')->where('pdid','=',$dcode)->get()->first()['pid']; |
|
668 | - $pcode = $this->pcode($pid); |
|
667 | + $pid=DB::table('problem_discussion')->where('pdid', '=', $dcode)->get()->first()['pid']; |
|
668 | + $pcode=$this->pcode($pid); |
|
669 | 669 | return $pcode; |
670 | 670 | } |
671 | 671 | |
@@ -686,11 +686,11 @@ discard block |
||
686 | 686 | |
687 | 687 | public function pidByPdid($pdid) |
688 | 688 | { |
689 | - $pid = DB::table('problem_discussion')->where('pdid','=',$pdid)->get()->first()['pid']; |
|
689 | + $pid=DB::table('problem_discussion')->where('pdid', '=', $pdid)->get()->first()['pid']; |
|
690 | 690 | return $pid; |
691 | 691 | } |
692 | 692 | |
693 | - public function addComment($uid,$pdid,$content,$reply_id) |
|
693 | + public function addComment($uid, $pdid, $content, $reply_id) |
|
694 | 694 | { |
695 | 695 | $pid=$this->pidByPdid($pdid); |
696 | 696 | $pdcid=DB::table('problem_discussion_comment')->insertGetId([ |
@@ -709,6 +709,6 @@ discard block |
||
709 | 709 | |
710 | 710 | public function isHidden($pid) |
711 | 711 | { |
712 | - return DB::table('problem')->where('pid','=',$pid)->get()->first()['hide']; |
|
712 | + return DB::table('problem')->where('pid', '=', $pid)->get()->first()['hide']; |
|
713 | 713 | } |
714 | 714 | } |
@@ -68,7 +68,7 @@ discard block |
||
68 | 68 | $temp["settings"]=false; |
69 | 69 | $temp["available"]=$installedConfig->status; |
70 | 70 | } |
71 | - }catch (Throwable $e){ |
|
71 | + } catch (Throwable $e){ |
|
72 | 72 | continue; |
73 | 73 | } |
74 | 74 | $ret[]=$temp; |
@@ -80,7 +80,9 @@ discard block |
||
80 | 80 | { |
81 | 81 | $ret=[]; |
82 | 82 | $marketspaceRaw=self::getRemote(); |
83 | - if(empty($marketspaceRaw)) return []; |
|
83 | + if(empty($marketspaceRaw)) { |
|
84 | + return []; |
|
85 | + } |
|
84 | 86 | foreach($marketspaceRaw["packages"] as $extension){ |
85 | 87 | $temp=[ |
86 | 88 | "details"=>$extension, |
@@ -94,7 +96,7 @@ discard block |
||
94 | 96 | try { |
95 | 97 | try { |
96 | 98 | $BabelConfig=json_decode(file_get_contents(babel_path("Extension/{$extension['code']}/babel.json")), true); |
97 | - }catch (Throwable $e){ |
|
99 | + } catch (Throwable $e){ |
|
98 | 100 | $BabelConfig=[]; |
99 | 101 | } |
100 | 102 | if (!empty($BabelConfig)) { |
@@ -120,7 +122,7 @@ discard block |
||
120 | 122 | $temp["available"]=$installedConfig->status; |
121 | 123 | } |
122 | 124 | } |
123 | - }catch (Throwable $e){ |
|
125 | + } catch (Throwable $e){ |
|
124 | 126 | continue; |
125 | 127 | } |
126 | 128 | $ret[]=$temp; |
@@ -136,7 +138,9 @@ discard block |
||
136 | 138 | foreach($dirs as $d){ |
137 | 139 | $extension=basename($d); |
138 | 140 | $BabelConfig=json_decode(file_get_contents(babel_path("Extension/$extension/babel.json")), true); |
139 | - if($extension==$BabelConfig["code"]) $ret[]=$BabelConfig; |
|
141 | + if($extension==$BabelConfig["code"]) { |
|
142 | + $ret[]=$BabelConfig; |
|
143 | + } |
|
140 | 144 | } |
141 | 145 | return $ret; |
142 | 146 | } |
@@ -145,7 +149,7 @@ discard block |
||
145 | 149 | { |
146 | 150 | try { |
147 | 151 | return json_decode(file_get_contents(config('babel.mirror')."/babel.json"), true); |
148 | - }catch(Throwable $e){ |
|
152 | + } catch(Throwable $e){ |
|
149 | 153 | return []; |
150 | 154 | } |
151 | 155 | } |
@@ -153,10 +157,14 @@ discard block |
||
153 | 157 | public static function remoteDetail($code) |
154 | 158 | { |
155 | 159 | $babelConfig=self::getRemote(); |
156 | - if(empty($babelConfig)) return []; |
|
160 | + if(empty($babelConfig)) { |
|
161 | + return []; |
|
162 | + } |
|
157 | 163 | $babelConfigPackages=$babelConfig["packages"]; |
158 | 164 | foreach($babelConfigPackages as $package) { |
159 | - if($package["code"]==$code) return $package; |
|
165 | + if($package["code"]==$code) { |
|
166 | + return $package; |
|
167 | + } |
|
160 | 168 | } |
161 | 169 | return []; |
162 | 170 | } |
@@ -22,13 +22,13 @@ discard block |
||
22 | 22 | $ret=[]; |
23 | 23 | $marketspaceRaw=self::getRemote(); |
24 | 24 | $marketspace=[]; |
25 | - foreach($marketspaceRaw["packages"] as $extension){ |
|
25 | + foreach ($marketspaceRaw["packages"] as $extension) { |
|
26 | 26 | $marketspace[$extension["name"]]=$extension; |
27 | 27 | } |
28 | 28 | |
29 | 29 | $localList=self::getLocal(); |
30 | 30 | |
31 | - foreach($localList as $extension){ |
|
31 | + foreach ($localList as $extension) { |
|
32 | 32 | $temp=[ |
33 | 33 | "details"=>$extension, |
34 | 34 | "status"=>0, |
@@ -37,30 +37,30 @@ discard block |
||
37 | 37 | "settings"=>null, |
38 | 38 | "available"=>null |
39 | 39 | ]; |
40 | - $temp["details"]["typeParsed"]=$temp["details"]["type"]=="virtual-judge"?"VirtualJudge":"OnlineJudge"; |
|
40 | + $temp["details"]["typeParsed"]=$temp["details"]["type"]=="virtual-judge" ? "VirtualJudge" : "OnlineJudge"; |
|
41 | 41 | try { |
42 | 42 | if ($extension["version"]=='__cur__') { |
43 | 43 | $extension["version"]=explode("-", version())[0]; |
44 | 44 | } |
45 | 45 | $downloadedVersion=new Version($extension["version"]); |
46 | 46 | |
47 | - if(isset($marketspace[$extension["name"]])){ |
|
47 | + if (isset($marketspace[$extension["name"]])) { |
|
48 | 48 | //remote extension, else is local extension |
49 | 49 | $remoteVersion=new Version($marketspace[$extension["name"]]["version"]); |
50 | 50 | $temp["updatable"]=$remoteVersion->isGreaterThan($downloadedVersion); |
51 | 51 | $temp["details"]["official"]=$marketspace[$extension["name"]]["official"]; |
52 | - } else{ |
|
52 | + } else { |
|
53 | 53 | $temp["updatable"]=false; |
54 | 54 | $temp["details"]["official"]=0; |
55 | 55 | } |
56 | 56 | |
57 | 57 | $installedConfig=OJ::where(["ocode"=>$extension["code"]])->first(); |
58 | - if (is_null($installedConfig)){ |
|
58 | + if (is_null($installedConfig)) { |
|
59 | 59 | $temp["status"]=1; |
60 | 60 | } else { |
61 | 61 | $temp["version"]=$installedConfig->version; // local installed version |
62 | 62 | $installedVersion=new Version($temp["version"]); |
63 | - if ($downloadedVersion->isGreaterThan($installedVersion)){ |
|
63 | + if ($downloadedVersion->isGreaterThan($installedVersion)) { |
|
64 | 64 | $temp["status"]=1; |
65 | 65 | } else { |
66 | 66 | $temp["status"]=2; |
@@ -68,7 +68,7 @@ discard block |
||
68 | 68 | $temp["settings"]=false; |
69 | 69 | $temp["available"]=$installedConfig->status; |
70 | 70 | } |
71 | - }catch (Throwable $e){ |
|
71 | + } catch (Throwable $e) { |
|
72 | 72 | continue; |
73 | 73 | } |
74 | 74 | $ret[]=$temp; |
@@ -80,8 +80,8 @@ discard block |
||
80 | 80 | { |
81 | 81 | $ret=[]; |
82 | 82 | $marketspaceRaw=self::getRemote(); |
83 | - if(empty($marketspaceRaw)) return []; |
|
84 | - foreach($marketspaceRaw["packages"] as $extension){ |
|
83 | + if (empty($marketspaceRaw)) return []; |
|
84 | + foreach ($marketspaceRaw["packages"] as $extension) { |
|
85 | 85 | $temp=[ |
86 | 86 | "details"=>$extension, |
87 | 87 | "status"=>0, |
@@ -90,11 +90,11 @@ discard block |
||
90 | 90 | "settings"=>null, |
91 | 91 | "available"=>null |
92 | 92 | ]; |
93 | - $temp["details"]["typeParsed"]=$temp["details"]["type"]=="virtual-judge"?"VirtualJudge":"OnlineJudge"; |
|
93 | + $temp["details"]["typeParsed"]=$temp["details"]["type"]=="virtual-judge" ? "VirtualJudge" : "OnlineJudge"; |
|
94 | 94 | try { |
95 | 95 | try { |
96 | 96 | $BabelConfig=json_decode(file_get_contents(babel_path("Extension/{$extension['code']}/babel.json")), true); |
97 | - }catch (Throwable $e){ |
|
97 | + } catch (Throwable $e) { |
|
98 | 98 | $BabelConfig=[]; |
99 | 99 | } |
100 | 100 | if (!empty($BabelConfig)) { |
@@ -106,12 +106,12 @@ discard block |
||
106 | 106 | $temp["updatable"]=$remoteVersion->isGreaterThan($downloadedVersion); |
107 | 107 | |
108 | 108 | $installedConfig=OJ::where(["ocode"=>$extension["code"]])->first(); |
109 | - if (is_null($installedConfig)){ |
|
109 | + if (is_null($installedConfig)) { |
|
110 | 110 | $temp["status"]=1; |
111 | 111 | } else { |
112 | 112 | $temp["version"]=$installedConfig->version; // local installed version |
113 | 113 | $installedVersion=new Version($temp["version"]); |
114 | - if ($downloadedVersion->isGreaterThan($installedVersion)){ |
|
114 | + if ($downloadedVersion->isGreaterThan($installedVersion)) { |
|
115 | 115 | $temp["status"]=1; |
116 | 116 | } else { |
117 | 117 | $temp["status"]=2; |
@@ -120,7 +120,7 @@ discard block |
||
120 | 120 | $temp["available"]=$installedConfig->status; |
121 | 121 | } |
122 | 122 | } |
123 | - }catch (Throwable $e){ |
|
123 | + } catch (Throwable $e) { |
|
124 | 124 | continue; |
125 | 125 | } |
126 | 126 | $ret[]=$temp; |
@@ -132,11 +132,11 @@ discard block |
||
132 | 132 | public static function getLocal() |
133 | 133 | { |
134 | 134 | $ret=[]; |
135 | - $dirs = array_filter(glob(babel_path("Extension/*")), 'is_dir'); |
|
136 | - foreach($dirs as $d){ |
|
135 | + $dirs=array_filter(glob(babel_path("Extension/*")), 'is_dir'); |
|
136 | + foreach ($dirs as $d) { |
|
137 | 137 | $extension=basename($d); |
138 | 138 | $BabelConfig=json_decode(file_get_contents(babel_path("Extension/$extension/babel.json")), true); |
139 | - if($extension==$BabelConfig["code"]) $ret[]=$BabelConfig; |
|
139 | + if ($extension==$BabelConfig["code"]) $ret[]=$BabelConfig; |
|
140 | 140 | } |
141 | 141 | return $ret; |
142 | 142 | } |
@@ -145,7 +145,7 @@ discard block |
||
145 | 145 | { |
146 | 146 | try { |
147 | 147 | return json_decode(file_get_contents(config('babel.mirror')."/babel.json"), true); |
148 | - }catch(Throwable $e){ |
|
148 | + } catch (Throwable $e) { |
|
149 | 149 | return []; |
150 | 150 | } |
151 | 151 | } |
@@ -153,10 +153,10 @@ discard block |
||
153 | 153 | public static function remoteDetail($code) |
154 | 154 | { |
155 | 155 | $babelConfig=self::getRemote(); |
156 | - if(empty($babelConfig)) return []; |
|
156 | + if (empty($babelConfig)) return []; |
|
157 | 157 | $babelConfigPackages=$babelConfig["packages"]; |
158 | - foreach($babelConfigPackages as $package) { |
|
159 | - if($package["code"]==$code) return $package; |
|
158 | + foreach ($babelConfigPackages as $package) { |
|
159 | + if ($package["code"]==$code) return $package; |
|
160 | 160 | } |
161 | 161 | return []; |
162 | 162 | } |
@@ -245,11 +245,17 @@ |
||
245 | 245 | |
246 | 246 | $groupModel=new GroupModel(); |
247 | 247 | $is_user=$groupModel->isUser($all_data["email"]); |
248 | - if(!$is_user) return ResponseModel::err(2006); |
|
248 | + if(!$is_user) { |
|
249 | + return ResponseModel::err(2006); |
|
250 | + } |
|
249 | 251 | $clearance=$groupModel->judgeClearance($all_data["gid"], Auth::user()->id); |
250 | - if($clearance<2) return ResponseModel::err(7002); |
|
252 | + if($clearance<2) { |
|
253 | + return ResponseModel::err(7002); |
|
254 | + } |
|
251 | 255 | $targetClearance=$groupModel->judgeEmailClearance($all_data["gid"], $all_data["email"]); |
252 | - if($targetClearance!=-3) return ResponseModel::err(7003); |
|
256 | + if($targetClearance!=-3) { |
|
257 | + return ResponseModel::err(7003); |
|
258 | + } |
|
253 | 259 | $groupModel->inviteMember($all_data["gid"], $all_data["email"]); |
254 | 260 | $basic = $groupModel->basic($all_data['gid']); |
255 | 261 | $url = route('group.detail',['gcode' => $basic['gcode']]); |
@@ -35,7 +35,7 @@ discard block |
||
35 | 35 | |
36 | 36 | $all_data=$request->all(); |
37 | 37 | |
38 | - if(($all_data['public'] ?? 0) && ($all_data['practice'] ?? 0)){ |
|
38 | + if (($all_data['public'] ?? 0) && ($all_data['practice'] ?? 0)) { |
|
39 | 39 | return ResponseModel::err(4007); |
40 | 40 | } |
41 | 41 | |
@@ -66,7 +66,7 @@ discard block |
||
66 | 66 | return ResponseModel::err(1003); |
67 | 67 | } |
68 | 68 | |
69 | - $cid = $contestModel->arrangeContest($all_data["gid"], [ |
|
69 | + $cid=$contestModel->arrangeContest($all_data["gid"], [ |
|
70 | 70 | "assign_uid"=>Auth::user()->id, |
71 | 71 | "name"=>$all_data["name"], |
72 | 72 | "description"=>$all_data["description"], |
@@ -76,7 +76,7 @@ discard block |
||
76 | 76 | "public"=>$all_data["public"] ?? 0, |
77 | 77 | ], $problemSet); |
78 | 78 | |
79 | - return ResponseModel::success(200,'Successful!',$cid); |
|
79 | + return ResponseModel::success(200, 'Successful!', $cid); |
|
80 | 80 | } |
81 | 81 | |
82 | 82 | public function changeGroupName(Request $request) |
@@ -90,7 +90,7 @@ discard block |
||
90 | 90 | |
91 | 91 | $groupModel=new GroupModel(); |
92 | 92 | $clearance=$groupModel->judgeClearance($all_data["gid"], Auth::user()->id); |
93 | - if ($clearance < 2){ |
|
93 | + if ($clearance<2) { |
|
94 | 94 | return ResponseModel::err(2001); |
95 | 95 | } |
96 | 96 | |
@@ -109,11 +109,11 @@ discard block |
||
109 | 109 | |
110 | 110 | $groupModel=new GroupModel(); |
111 | 111 | $clearance=$groupModel->judgeClearance($all_data["gid"], Auth::user()->id); |
112 | - if ($clearance < 2){ |
|
112 | + if ($clearance<2) { |
|
113 | 113 | return ResponseModel::err(2001); |
114 | 114 | } |
115 | 115 | |
116 | - if ($all_data["join_policy"] < 1 || $all_data["join_policy"] > 3){ |
|
116 | + if ($all_data["join_policy"]<1 || $all_data["join_policy"]>3) { |
|
117 | 117 | return ResponseModel::err(1007); |
118 | 118 | } |
119 | 119 | |
@@ -127,7 +127,7 @@ discard block |
||
127 | 127 | 'gid' => 'required|integer', |
128 | 128 | ]); |
129 | 129 | |
130 | - $all_data = $request->all(); |
|
130 | + $all_data=$request->all(); |
|
131 | 131 | |
132 | 132 | if (!empty($request->file('img')) && $request->file('img')->isValid()) { |
133 | 133 | $extension=$request->file('img')->extension(); |
@@ -139,7 +139,7 @@ discard block |
||
139 | 139 | |
140 | 140 | $groupModel=new GroupModel(); |
141 | 141 | $clearance=$groupModel->judgeClearance($all_data["gid"], Auth::user()->id); |
142 | - if ($clearance < 2){ |
|
142 | + if ($clearance<2) { |
|
143 | 143 | return ResponseModel::err(2001); |
144 | 144 | } |
145 | 145 | |
@@ -177,18 +177,18 @@ discard block |
||
177 | 177 | $clearance=$groupModel->judgeClearance($all_data["gid"], Auth::user()->id); |
178 | 178 | $target_clearance=$groupModel->judgeClearance($all_data["gid"], $all_data['uid']); |
179 | 179 | |
180 | - if($target_clearance == -3){ |
|
180 | + if ($target_clearance==-3) { |
|
181 | 181 | return ResponseModel::err(7004); |
182 | 182 | } |
183 | 183 | |
184 | - if($target_clearance >= $clearance || $clearance < 2 || $all_data['permission'] >= $clearance){ |
|
184 | + if ($target_clearance>=$clearance || $clearance<2 || $all_data['permission']>=$clearance) { |
|
185 | 185 | return ResponseModel::err(2001); |
186 | 186 | } |
187 | 187 | |
188 | 188 | $groupModel->changeClearance($all_data['uid'], $all_data["gid"], $all_data['permission']); |
189 | 189 | |
190 | - $result_info = $groupModel->userProfile($all_data['uid'],$all_data["gid"]); |
|
191 | - return ResponseModel::success(200,null,$result_info); |
|
190 | + $result_info=$groupModel->userProfile($all_data['uid'], $all_data["gid"]); |
|
191 | + return ResponseModel::success(200, null, $result_info); |
|
192 | 192 | } |
193 | 193 | |
194 | 194 | public function approveMember(Request $request) |
@@ -204,7 +204,7 @@ discard block |
||
204 | 204 | $clearance=$groupModel->judgeClearance($all_data["gid"], Auth::user()->id); |
205 | 205 | $targetClearance=$groupModel->judgeClearance($all_data["gid"], $all_data["uid"]); |
206 | 206 | if ($clearance>1) { |
207 | - if($targetClearance!=0) { |
|
207 | + if ($targetClearance!=0) { |
|
208 | 208 | return ResponseModel::err(7003); |
209 | 209 | } |
210 | 210 | $groupModel->changeClearance($all_data["uid"], $all_data["gid"], 1); |
@@ -225,7 +225,7 @@ discard block |
||
225 | 225 | $groupModel=new GroupModel(); |
226 | 226 | $clearance=$groupModel->judgeClearance($all_data["gid"], Auth::user()->id); |
227 | 227 | $targetClearance=$groupModel->judgeClearance($all_data["gid"], $all_data["uid"]); |
228 | - if ($clearance <= 1 || $clearance <= $targetClearance){ |
|
228 | + if ($clearance<=1 || $clearance<=$targetClearance) { |
|
229 | 229 | return ResponseModel::err(7002); |
230 | 230 | } |
231 | 231 | |
@@ -245,16 +245,16 @@ discard block |
||
245 | 245 | |
246 | 246 | $groupModel=new GroupModel(); |
247 | 247 | $is_user=$groupModel->isUser($all_data["email"]); |
248 | - if(!$is_user) return ResponseModel::err(2006); |
|
248 | + if (!$is_user) return ResponseModel::err(2006); |
|
249 | 249 | $clearance=$groupModel->judgeClearance($all_data["gid"], Auth::user()->id); |
250 | - if($clearance<2) return ResponseModel::err(7002); |
|
250 | + if ($clearance<2) return ResponseModel::err(7002); |
|
251 | 251 | $targetClearance=$groupModel->judgeEmailClearance($all_data["gid"], $all_data["email"]); |
252 | - if($targetClearance!=-3) return ResponseModel::err(7003); |
|
252 | + if ($targetClearance!=-3) return ResponseModel::err(7003); |
|
253 | 253 | $groupModel->inviteMember($all_data["gid"], $all_data["email"]); |
254 | - $basic = $groupModel->basic($all_data['gid']); |
|
255 | - $url = route('group.detail',['gcode' => $basic['gcode']]); |
|
256 | - $receiverInfo = UserModel::where('email',$all_data['email'])->first(); |
|
257 | - $sender_name = Auth::user()->name; |
|
254 | + $basic=$groupModel->basic($all_data['gid']); |
|
255 | + $url=route('group.detail', ['gcode' => $basic['gcode']]); |
|
256 | + $receiverInfo=UserModel::where('email', $all_data['email'])->first(); |
|
257 | + $sender_name=Auth::user()->name; |
|
258 | 258 | sendMessage([ |
259 | 259 | 'receiver' => $receiverInfo["id"], |
260 | 260 | 'sender' => Auth::user()->id, |
@@ -296,7 +296,7 @@ discard block |
||
296 | 296 | |
297 | 297 | $groupModel=new GroupModel(); |
298 | 298 | $clearance=$groupModel->judgeClearance($all_data["gid"], Auth::user()->id); |
299 | - if ($clearance < 2){ |
|
299 | + if ($clearance<2) { |
|
300 | 300 | return ResponseModel::err(2001); |
301 | 301 | } |
302 | 302 | $groupModel->createNotice($all_data["gid"], Auth::user()->id, $all_data["title"], $all_data["content"]); |
@@ -110,8 +110,8 @@ discard block |
||
110 | 110 | if (empty($basic)) { |
111 | 111 | return ResponseModel::err(3001); |
112 | 112 | } |
113 | - $ret=$problemModel->addSolution($pid,Auth::user()->id,$content); |
|
114 | - return $ret?ResponseModel::success(200):ResponseModel::err(3003); |
|
113 | + $ret=$problemModel->addSolution($pid, Auth::user()->id, $content); |
|
114 | + return $ret ?ResponseModel::success(200) : ResponseModel::err(3003); |
|
115 | 115 | } |
116 | 116 | /** |
117 | 117 | * The Ajax Problem Solution Discussion Update. |
@@ -126,8 +126,8 @@ discard block |
||
126 | 126 | $problemModel=new ProblemModel(); |
127 | 127 | $psoid=$all_data["psoid"]; |
128 | 128 | $content=$all_data["content"]; |
129 | - $ret=$problemModel->updateSolution($psoid,Auth::user()->id,$content); |
|
130 | - return $ret?ResponseModel::success(200):ResponseModel::err(3004); |
|
129 | + $ret=$problemModel->updateSolution($psoid, Auth::user()->id, $content); |
|
130 | + return $ret ?ResponseModel::success(200) : ResponseModel::err(3004); |
|
131 | 131 | } |
132 | 132 | /** |
133 | 133 | * The Ajax Problem Solution Discussion Delete. |
@@ -141,8 +141,8 @@ discard block |
||
141 | 141 | $all_data=$request->all(); |
142 | 142 | $problemModel=new ProblemModel(); |
143 | 143 | $psoid=$all_data["psoid"]; |
144 | - $ret=$problemModel->removeSolution($psoid,Auth::user()->id); |
|
145 | - return $ret?ResponseModel::success(200):ResponseModel::err(3004); |
|
144 | + $ret=$problemModel->removeSolution($psoid, Auth::user()->id); |
|
145 | + return $ret ?ResponseModel::success(200) : ResponseModel::err(3004); |
|
146 | 146 | } |
147 | 147 | /** |
148 | 148 | * The Ajax Problem Solution Discussion Vote. |
@@ -157,8 +157,8 @@ discard block |
||
157 | 157 | $problemModel=new ProblemModel(); |
158 | 158 | $psoid=$all_data["psoid"]; |
159 | 159 | $type=$all_data["type"]; |
160 | - $ret=$problemModel->voteSolution($psoid,Auth::user()->id,$type); |
|
161 | - return $ret["ret"]?ResponseModel::success(200,null,["votes"=>$ret["votes"],"select"=>$ret["select"]]):ResponseModel::err(3004); |
|
160 | + $ret=$problemModel->voteSolution($psoid, Auth::user()->id, $type); |
|
161 | + return $ret["ret"] ?ResponseModel::success(200, null, ["votes"=>$ret["votes"], "select"=>$ret["select"]]) : ResponseModel::err(3004); |
|
162 | 162 | } |
163 | 163 | /** |
164 | 164 | * The Ajax Problem Solution Submit. |
@@ -252,8 +252,8 @@ discard block |
||
252 | 252 | if (empty($basic)) { |
253 | 253 | return ResponseModel::err(3001); |
254 | 254 | } |
255 | - $ret=$problemModel->addDiscussion(Auth::user()->id,$pid,$title,$content); |
|
256 | - return $ret?ResponseModel::success(200, null, $ret):ResponseModel::err(3003); |
|
255 | + $ret=$problemModel->addDiscussion(Auth::user()->id, $pid, $title, $content); |
|
256 | + return $ret ?ResponseModel::success(200, null, $ret) : ResponseModel::err(3003); |
|
257 | 257 | } |
258 | 258 | |
259 | 259 | public function addComment(Request $request) |
@@ -272,8 +272,8 @@ discard block |
||
272 | 272 | if (empty($basic)) { |
273 | 273 | return ResponseModel::err(3001); |
274 | 274 | } |
275 | - $ret=$problemModel->addComment(Auth::user()->id,$pdid,$content,$reply_id); |
|
276 | - return $ret?ResponseModel::success(200, null, $ret):ResponseModel::err(3003); |
|
275 | + $ret=$problemModel->addComment(Auth::user()->id, $pdid, $content, $reply_id); |
|
276 | + return $ret ?ResponseModel::success(200, null, $ret) : ResponseModel::err(3003); |
|
277 | 277 | } |
278 | 278 | |
279 | 279 | /** |
@@ -292,15 +292,15 @@ discard block |
||
292 | 292 | |
293 | 293 | $submissionData=$submissionModel->basic($all_data["sid"]); |
294 | 294 | |
295 | - if($submissionData["uid"]!=Auth::user()->id){ |
|
295 | + if ($submissionData["uid"]!=Auth::user()->id) { |
|
296 | 296 | return ResponseModel::err(2001); |
297 | 297 | } |
298 | 298 | |
299 | - if($submissionData["verdict"]!="Submission Error"){ |
|
299 | + if ($submissionData["verdict"]!="Submission Error") { |
|
300 | 300 | return ResponseModel::err(6003); |
301 | 301 | } |
302 | 302 | |
303 | - $submissionModel->updateSubmission($all_data["sid"],[ |
|
303 | + $submissionModel->updateSubmission($all_data["sid"], [ |
|
304 | 304 | "verdict"=>"Pending", |
305 | 305 | "time"=>0, |
306 | 306 | "memory"=>0 |
@@ -132,7 +132,7 @@ discard block |
||
132 | 132 | { |
133 | 133 | $extensionList=ExtensionModel::list(); |
134 | 134 | |
135 | - if(empty($extensionList)){ |
|
135 | + if (empty($extensionList)) { |
|
136 | 136 | return view('admin::babel.empty'); |
137 | 137 | } |
138 | 138 | |
@@ -145,7 +145,7 @@ discard block |
||
145 | 145 | { |
146 | 146 | $details=ExtensionModel::remoteDetail($code); |
147 | 147 | |
148 | - if(empty($details)){ |
|
148 | + if (empty($details)) { |
|
149 | 149 | return view('admin::babel.empty'); |
150 | 150 | } |
151 | 151 | |
@@ -158,7 +158,7 @@ discard block |
||
158 | 158 | { |
159 | 159 | $details=ExtensionModel::remoteDetail($extension); |
160 | 160 | |
161 | - if(empty($details)){ |
|
161 | + if (empty($details)) { |
|
162 | 162 | return view('admin::babel.empty'); |
163 | 163 | } |
164 | 164 | |
@@ -169,15 +169,15 @@ discard block |
||
169 | 169 | |
170 | 170 | private static function executeArtisan($command) |
171 | 171 | { |
172 | - $fp = popen('php "'.base_path('artisan').'" '.$command, "r"); |
|
173 | - while($b = fgets($fp, 2048)) { |
|
172 | + $fp=popen('php "'.base_path('artisan').'" '.$command, "r"); |
|
173 | + while ($b=fgets($fp, 2048)) { |
|
174 | 174 | echo str_pad(json_encode([ |
175 | 175 | "ret"=>200, |
176 | 176 | "desc"=>"Succeed", |
177 | 177 | "data"=>[ |
178 | 178 | "message"=>$b |
179 | 179 | ] |
180 | - ])."\n",4096); |
|
180 | + ])."\n", 4096); |
|
181 | 181 | @ob_flush(); |
182 | 182 | flush(); |
183 | 183 | } |
@@ -34,10 +34,10 @@ discard block |
||
34 | 34 | $contestModel=new ContestModel(); |
35 | 35 | $clearance=$contestModel->judgeClearance($cid, Auth::user()->id); |
36 | 36 | $basicInfo=$contestModel->basic($cid); |
37 | - if (!$clearance || time() < strtotime($basicInfo['begin_time'])) { |
|
38 | - if($clearance == 3){ |
|
37 | + if (!$clearance || time()<strtotime($basicInfo['begin_time'])) { |
|
38 | + if ($clearance==3) { |
|
39 | 39 | return Redirect::route('contest.admin', ['cid' => $cid]); |
40 | - }else{ |
|
40 | + } else { |
|
41 | 41 | return Redirect::route('contest.detail', ['cid' => $cid]); |
42 | 42 | } |
43 | 43 | } |
@@ -50,7 +50,7 @@ discard block |
||
50 | 50 | if ($remainingTime<=0) { |
51 | 51 | $remainingTime=0; |
52 | 52 | } |
53 | - if($basicInfo['public'] && !$basicInfo['audit_status']){ |
|
53 | + if ($basicInfo['public'] && !$basicInfo['audit_status']) { |
|
54 | 54 | return Redirect::route('contest.detail', ['cid' => $cid]); |
55 | 55 | } |
56 | 56 | return view('contest.board.challenge', [ |
@@ -83,15 +83,15 @@ discard block |
||
83 | 83 | $accountModel=new AccountModel(); |
84 | 84 | $clearance=$contestModel->judgeClearance($cid, Auth::user()->id); |
85 | 85 | $basicInfo=$contestModel->basic($cid); |
86 | - if (!$clearance || time() < strtotime($basicInfo['begin_time'])) { |
|
87 | - if($clearance == 3){ |
|
86 | + if (!$clearance || time()<strtotime($basicInfo['begin_time'])) { |
|
87 | + if ($clearance==3) { |
|
88 | 88 | return Redirect::route('contest.admin', ['cid' => $cid]); |
89 | - }else{ |
|
89 | + } else { |
|
90 | 90 | return Redirect::route('contest.detail', ['cid' => $cid]); |
91 | 91 | } |
92 | 92 | } |
93 | 93 | $basicInfo=$contestModel->basic($cid); |
94 | - if($basicInfo['public'] && !$basicInfo['audit_status']){ |
|
94 | + if ($basicInfo['public'] && !$basicInfo['audit_status']) { |
|
95 | 95 | return Redirect::route('contest.detail', ['cid' => $cid]); |
96 | 96 | } |
97 | 97 | $contest_name=$contestModel->contestName($cid); |
@@ -122,8 +122,8 @@ discard block |
||
122 | 122 | ]; |
123 | 123 | } |
124 | 124 | |
125 | - $editor_left_width = $accountModel->getExtra(Auth::user()->id, 'editor_left_width'); |
|
126 | - if(empty($editor_left_width)) $editor_left_width='40'; |
|
125 | + $editor_left_width=$accountModel->getExtra(Auth::user()->id, 'editor_left_width'); |
|
126 | + if (empty($editor_left_width)) $editor_left_width='40'; |
|
127 | 127 | |
128 | 128 | return view('contest.board.editor', [ |
129 | 129 | 'page_title'=>"Problem Detail", |
@@ -157,15 +157,15 @@ discard block |
||
157 | 157 | $contestModel=new ContestModel(); |
158 | 158 | $clearance=$contestModel->judgeClearance($cid, Auth::user()->id); |
159 | 159 | $basicInfo=$contestModel->basic($cid); |
160 | - if (!$clearance || time() < strtotime($basicInfo['begin_time'])) { |
|
161 | - if($clearance == 3){ |
|
160 | + if (!$clearance || time()<strtotime($basicInfo['begin_time'])) { |
|
161 | + if ($clearance==3) { |
|
162 | 162 | return Redirect::route('contest.admin', ['cid' => $cid]); |
163 | - }else{ |
|
163 | + } else { |
|
164 | 164 | return Redirect::route('contest.detail', ['cid' => $cid]); |
165 | 165 | } |
166 | 166 | } |
167 | 167 | $basicInfo=$contestModel->basic($cid); |
168 | - if($basicInfo['public'] && !$basicInfo['audit_status']){ |
|
168 | + if ($basicInfo['public'] && !$basicInfo['audit_status']) { |
|
169 | 169 | return Redirect::route('contest.detail', ['cid' => $cid]); |
170 | 170 | } |
171 | 171 | $contest_name=$contestModel->contestName($cid); |
@@ -176,14 +176,14 @@ discard block |
||
176 | 176 | |
177 | 177 | // To determine the ranking |
178 | 178 | foreach ($contestRank as $i => &$r) { |
179 | - if($i != 0) { |
|
180 | - if($r['score'] == $contestRank[$i-1]['score'] && ($contest_rule == 1 ? ($r['penalty'] == $contestRank[$i-1]['penalty']) : 1) ){ |
|
181 | - $r['rank'] = $contestRank[$i-1]['rank']; |
|
182 | - }else{ |
|
183 | - $r['rank'] = $i + 1; |
|
179 | + if ($i!=0) { |
|
180 | + if ($r['score']==$contestRank[$i-1]['score'] && ($contest_rule==1 ? ($r['penalty']==$contestRank[$i-1]['penalty']) : 1)) { |
|
181 | + $r['rank']=$contestRank[$i-1]['rank']; |
|
182 | + } else { |
|
183 | + $r['rank']=$i+1; |
|
184 | 184 | } |
185 | - }else{ |
|
186 | - $r['rank'] = 1; |
|
185 | + } else { |
|
186 | + $r['rank']=1; |
|
187 | 187 | } |
188 | 188 | } |
189 | 189 | $rankFrozen=$contestModel->isFrozen($cid); |
@@ -220,15 +220,15 @@ discard block |
||
220 | 220 | $contestModel=new ContestModel(); |
221 | 221 | $clearance=$contestModel->judgeClearance($cid, Auth::user()->id); |
222 | 222 | $basicInfo=$contestModel->basic($cid); |
223 | - if (!$clearance || time() < strtotime($basicInfo['begin_time'])) { |
|
224 | - if($clearance == 3){ |
|
223 | + if (!$clearance || time()<strtotime($basicInfo['begin_time'])) { |
|
224 | + if ($clearance==3) { |
|
225 | 225 | return Redirect::route('contest.admin', ['cid' => $cid]); |
226 | - }else{ |
|
226 | + } else { |
|
227 | 227 | return Redirect::route('contest.detail', ['cid' => $cid]); |
228 | 228 | } |
229 | 229 | } |
230 | 230 | $basicInfo=$contestModel->basic($cid); |
231 | - if($basicInfo['public'] && !$basicInfo['audit_status']){ |
|
231 | + if ($basicInfo['public'] && !$basicInfo['audit_status']) { |
|
232 | 232 | return Redirect::route('contest.detail', ['cid' => $cid]); |
233 | 233 | } |
234 | 234 | $contest_name=$contestModel->contestName($cid); |
@@ -262,14 +262,14 @@ discard block |
||
262 | 262 | $contestModel=new ContestModel(); |
263 | 263 | $clearance=$contestModel->judgeClearance($cid, Auth::user()->id); |
264 | 264 | $basicInfo=$contestModel->basic($cid); |
265 | - if (!$clearance || time() < strtotime($basicInfo['begin_time'])) { |
|
266 | - if($clearance == 3){ |
|
265 | + if (!$clearance || time()<strtotime($basicInfo['begin_time'])) { |
|
266 | + if ($clearance==3) { |
|
267 | 267 | return Redirect::route('contest.admin', ['cid' => $cid]); |
268 | - }else{ |
|
268 | + } else { |
|
269 | 269 | return Redirect::route('contest.detail', ['cid' => $cid]); |
270 | 270 | } |
271 | 271 | } |
272 | - if($basicInfo['public'] && !$basicInfo['audit_status']){ |
|
272 | + if ($basicInfo['public'] && !$basicInfo['audit_status']) { |
|
273 | 273 | return Redirect::route('contest.detail', ['cid' => $cid]); |
274 | 274 | } |
275 | 275 | $contest_name=$contestModel->contestName($cid); |
@@ -300,14 +300,14 @@ discard block |
||
300 | 300 | $contestModel=new ContestModel(); |
301 | 301 | $clearance=$contestModel->judgeClearance($cid, Auth::user()->id); |
302 | 302 | $basicInfo=$contestModel->basic($cid); |
303 | - if (!$clearance || time() < strtotime($basicInfo['begin_time'])) { |
|
304 | - if($clearance == 3){ |
|
303 | + if (!$clearance || time()<strtotime($basicInfo['begin_time'])) { |
|
304 | + if ($clearance==3) { |
|
305 | 305 | return Redirect::route('contest.admin', ['cid' => $cid]); |
306 | - }else{ |
|
306 | + } else { |
|
307 | 307 | return Redirect::route('contest.detail', ['cid' => $cid]); |
308 | 308 | } |
309 | 309 | } |
310 | - if($basicInfo['public'] && !$basicInfo['audit_status']){ |
|
310 | + if ($basicInfo['public'] && !$basicInfo['audit_status']) { |
|
311 | 311 | return Redirect::route('contest.detail', ['cid' => $cid]); |
312 | 312 | } |
313 | 313 | $contest_name=$contestModel->contestName($cid); |
@@ -324,19 +324,19 @@ discard block |
||
324 | 324 | ]); |
325 | 325 | } |
326 | 326 | |
327 | - public function analysis($cid){ |
|
327 | + public function analysis($cid) { |
|
328 | 328 | $contestModel=new ContestModel(); |
329 | 329 | $clearance=$contestModel->judgeClearance($cid, Auth::user()->id); |
330 | 330 | $basicInfo=$contestModel->basic($cid); |
331 | - if (!$clearance || time() < strtotime($basicInfo['begin_time'])) { |
|
332 | - if($clearance == 3){ |
|
331 | + if (!$clearance || time()<strtotime($basicInfo['begin_time'])) { |
|
332 | + if ($clearance==3) { |
|
333 | 333 | return Redirect::route('contest.admin', ['cid' => $cid]); |
334 | - }else{ |
|
334 | + } else { |
|
335 | 335 | return Redirect::route('contest.detail', ['cid' => $cid]); |
336 | 336 | } |
337 | 337 | } |
338 | 338 | $basicInfo=$contestModel->basic($cid); |
339 | - if($basicInfo['public'] && !$basicInfo['audit_status']){ |
|
339 | + if ($basicInfo['public'] && !$basicInfo['audit_status']) { |
|
340 | 340 | return Redirect::route('contest.detail', ['cid' => $cid]); |
341 | 341 | } |
342 | 342 | $contest_name=$contestModel->contestName($cid); |
@@ -37,7 +37,7 @@ discard block |
||
37 | 37 | if (!$clearance || time() < strtotime($basicInfo['begin_time'])) { |
38 | 38 | if($clearance == 3){ |
39 | 39 | return Redirect::route('contest.admin', ['cid' => $cid]); |
40 | - }else{ |
|
40 | + } else{ |
|
41 | 41 | return Redirect::route('contest.detail', ['cid' => $cid]); |
42 | 42 | } |
43 | 43 | } |
@@ -86,7 +86,7 @@ discard block |
||
86 | 86 | if (!$clearance || time() < strtotime($basicInfo['begin_time'])) { |
87 | 87 | if($clearance == 3){ |
88 | 88 | return Redirect::route('contest.admin', ['cid' => $cid]); |
89 | - }else{ |
|
89 | + } else{ |
|
90 | 90 | return Redirect::route('contest.detail', ['cid' => $cid]); |
91 | 91 | } |
92 | 92 | } |
@@ -123,7 +123,9 @@ discard block |
||
123 | 123 | } |
124 | 124 | |
125 | 125 | $editor_left_width = $accountModel->getExtra(Auth::user()->id, 'editor_left_width'); |
126 | - if(empty($editor_left_width)) $editor_left_width='40'; |
|
126 | + if(empty($editor_left_width)) { |
|
127 | + $editor_left_width='40'; |
|
128 | + } |
|
127 | 129 | |
128 | 130 | return view('contest.board.editor', [ |
129 | 131 | 'page_title'=>"Problem Detail", |
@@ -160,7 +162,7 @@ discard block |
||
160 | 162 | if (!$clearance || time() < strtotime($basicInfo['begin_time'])) { |
161 | 163 | if($clearance == 3){ |
162 | 164 | return Redirect::route('contest.admin', ['cid' => $cid]); |
163 | - }else{ |
|
165 | + } else{ |
|
164 | 166 | return Redirect::route('contest.detail', ['cid' => $cid]); |
165 | 167 | } |
166 | 168 | } |
@@ -179,10 +181,10 @@ discard block |
||
179 | 181 | if($i != 0) { |
180 | 182 | if($r['score'] == $contestRank[$i-1]['score'] && ($contest_rule == 1 ? ($r['penalty'] == $contestRank[$i-1]['penalty']) : 1) ){ |
181 | 183 | $r['rank'] = $contestRank[$i-1]['rank']; |
182 | - }else{ |
|
184 | + } else{ |
|
183 | 185 | $r['rank'] = $i + 1; |
184 | 186 | } |
185 | - }else{ |
|
187 | + } else{ |
|
186 | 188 | $r['rank'] = 1; |
187 | 189 | } |
188 | 190 | } |
@@ -223,7 +225,7 @@ discard block |
||
223 | 225 | if (!$clearance || time() < strtotime($basicInfo['begin_time'])) { |
224 | 226 | if($clearance == 3){ |
225 | 227 | return Redirect::route('contest.admin', ['cid' => $cid]); |
226 | - }else{ |
|
228 | + } else{ |
|
227 | 229 | return Redirect::route('contest.detail', ['cid' => $cid]); |
228 | 230 | } |
229 | 231 | } |
@@ -265,7 +267,7 @@ discard block |
||
265 | 267 | if (!$clearance || time() < strtotime($basicInfo['begin_time'])) { |
266 | 268 | if($clearance == 3){ |
267 | 269 | return Redirect::route('contest.admin', ['cid' => $cid]); |
268 | - }else{ |
|
270 | + } else{ |
|
269 | 271 | return Redirect::route('contest.detail', ['cid' => $cid]); |
270 | 272 | } |
271 | 273 | } |
@@ -303,7 +305,7 @@ discard block |
||
303 | 305 | if (!$clearance || time() < strtotime($basicInfo['begin_time'])) { |
304 | 306 | if($clearance == 3){ |
305 | 307 | return Redirect::route('contest.admin', ['cid' => $cid]); |
306 | - }else{ |
|
308 | + } else{ |
|
307 | 309 | return Redirect::route('contest.detail', ['cid' => $cid]); |
308 | 310 | } |
309 | 311 | } |
@@ -331,7 +333,7 @@ discard block |
||
331 | 333 | if (!$clearance || time() < strtotime($basicInfo['begin_time'])) { |
332 | 334 | if($clearance == 3){ |
333 | 335 | return Redirect::route('contest.admin', ['cid' => $cid]); |
334 | - }else{ |
|
336 | + } else{ |
|
335 | 337 | return Redirect::route('contest.detail', ['cid' => $cid]); |
336 | 338 | } |
337 | 339 | } |
@@ -371,7 +371,7 @@ discard block |
||
371 | 371 | ->where(['verdict'=>'Waiting']) |
372 | 372 | ->get() |
373 | 373 | ->all(); |
374 | - foreach($ret as &$r){ |
|
374 | + foreach ($ret as &$r) { |
|
375 | 375 | $r["ocode"]=DB::table("oj")->where(["oid"=>$r["oid"]])->first()["ocode"]; |
376 | 376 | } |
377 | 377 | return $ret; |
@@ -389,14 +389,14 @@ discard block |
||
389 | 389 | if (isset($sub['verdict'])) { |
390 | 390 | $sub["color"]=$this->colorScheme[$sub['verdict']]; |
391 | 391 | } |
392 | - $result = DB::table($this->tableName)->where(['sid'=>$sid])->update($sub); |
|
393 | - $contestModel = new ContestModel(); |
|
394 | - $submission_info = DB::table($this->tableName) -> where(['sid'=>$sid]) -> get() -> first(); |
|
395 | - if ($result==1 && $submission_info['cid'] && $contestModel->isContestRunning($submission_info['cid'])){ |
|
396 | - $sub['pid'] = $submission_info['pid']; |
|
397 | - $sub['uid'] = $submission_info['uid']; |
|
398 | - $sub['cid'] = $submission_info['cid']; |
|
399 | - $sub['sid'] = $sid; |
|
392 | + $result=DB::table($this->tableName)->where(['sid'=>$sid])->update($sub); |
|
393 | + $contestModel=new ContestModel(); |
|
394 | + $submission_info=DB::table($this->tableName) -> where(['sid'=>$sid]) -> get() -> first(); |
|
395 | + if ($result==1 && $submission_info['cid'] && $contestModel->isContestRunning($submission_info['cid'])) { |
|
396 | + $sub['pid']=$submission_info['pid']; |
|
397 | + $sub['uid']=$submission_info['uid']; |
|
398 | + $sub['cid']=$submission_info['cid']; |
|
399 | + $sub['sid']=$sid; |
|
400 | 400 | // $contestModel->updateContestRankTable($submission_info['cid'],$sub); |
401 | 401 | } |
402 | 402 | return $result; |
@@ -468,15 +468,15 @@ discard block |
||
468 | 468 | 'desc' |
469 | 469 | ); |
470 | 470 | |
471 | - if($filter["pcode"]){ |
|
471 | + if ($filter["pcode"]) { |
|
472 | 472 | $paginator=$paginator->where(["pcode"=>$filter["pcode"]]); |
473 | 473 | } |
474 | 474 | |
475 | - if($filter["result"]){ |
|
475 | + if ($filter["result"]) { |
|
476 | 476 | $paginator=$paginator->where(["verdict"=>$filter["result"]]); |
477 | 477 | } |
478 | 478 | |
479 | - if($filter["account"]){ |
|
479 | + if ($filter["account"]) { |
|
480 | 480 | $paginator=$paginator->where(["name"=>$filter["account"]]); |
481 | 481 | } |
482 | 482 |
@@ -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', [ |
@@ -9,36 +9,36 @@ discard block |
||
9 | 9 | { |
10 | 10 | protected $table='contest_problem'; |
11 | 11 | protected $primaryKey='cpid'; |
12 | - public $timestamps = null; |
|
12 | + public $timestamps=null; |
|
13 | 13 | const DELETED_AT=null; |
14 | 14 | const UPDATED_AT=null; |
15 | 15 | const CREATED_AT=null; |
16 | 16 | |
17 | 17 | public function contest() |
18 | 18 | { |
19 | - return $this->belongsTo('App\Models\Eloquent\Contest','cid','cid'); |
|
19 | + return $this->belongsTo('App\Models\Eloquent\Contest', 'cid', 'cid'); |
|
20 | 20 | } |
21 | 21 | |
22 | 22 | public function problem() |
23 | 23 | { |
24 | - return $this->belongsTo('App\Models\Eloquent\Problem','pid','pid'); |
|
24 | + return $this->belongsTo('App\Models\Eloquent\Problem', 'pid', 'pid'); |
|
25 | 25 | } |
26 | 26 | |
27 | 27 | public function submissions() |
28 | 28 | { |
29 | - return $this->problem->submissions()->where('cid',$this->contest->cid); |
|
29 | + return $this->problem->submissions()->where('cid', $this->contest->cid); |
|
30 | 30 | } |
31 | 31 | |
32 | 32 | public function getCompilersAttribute() |
33 | 33 | { |
34 | - $special = $this->problem->special_compiler; |
|
35 | - $compilers = Compiler::where([ |
|
34 | + $special=$this->problem->special_compiler; |
|
35 | + $compilers=Compiler::where([ |
|
36 | 36 | 'oid' => $this->problem->OJ, |
37 | 37 | 'available' => 1, |
38 | 38 | 'deleted' => 0 |
39 | 39 | ]); |
40 | - if(!empty($special)) { |
|
41 | - $compilers = $compilers->whereIn('coid', explode(',', $special)); |
|
40 | + if (!empty($special)) { |
|
41 | + $compilers=$compilers->whereIn('coid', explode(',', $special)); |
|
42 | 42 | } |
43 | 43 | return $compilers; |
44 | 44 | } |
@@ -53,34 +53,34 @@ discard block |
||
53 | 53 | 'wrong_doings' => 0, |
54 | 54 | 'color' => '', |
55 | 55 | ]; |
56 | - $ac_record = $this->ac_record($user); |
|
57 | - if(!empty($ac_record[0])){ |
|
58 | - $ret['solved'] = 1; |
|
59 | - $ret['solved_time'] = $ac_record[0]->submission_date - strtotime($this->contest->begin_time); |
|
60 | - $ret['solved_time_parsed'] = formatProblemSolvedTime($ret['solved_time']); |
|
61 | - $ret['wrong_doings'] = $ac_record[2]; |
|
62 | - $ret['color'] = $ac_record[1] ? 'wemd-green-text' : 'wemd-teal-text'; |
|
63 | - }else{ |
|
64 | - $ret['wrong_doings'] = $ac_record[2]; |
|
56 | + $ac_record=$this->ac_record($user); |
|
57 | + if (!empty($ac_record[0])) { |
|
58 | + $ret['solved']=1; |
|
59 | + $ret['solved_time']=$ac_record[0]->submission_date-strtotime($this->contest->begin_time); |
|
60 | + $ret['solved_time_parsed']=formatProblemSolvedTime($ret['solved_time']); |
|
61 | + $ret['wrong_doings']=$ac_record[2]; |
|
62 | + $ret['color']=$ac_record[1] ? 'wemd-green-text' : 'wemd-teal-text'; |
|
63 | + } else { |
|
64 | + $ret['wrong_doings']=$ac_record[2]; |
|
65 | 65 | } |
66 | 66 | return $ret; |
67 | 67 | } |
68 | 68 | |
69 | 69 | public function ac_record($user) |
70 | 70 | { |
71 | - $user_ac = $this->submissions()->where([ |
|
71 | + $user_ac=$this->submissions()->where([ |
|
72 | 72 | 'uid' => $user->id, |
73 | 73 | 'verdict' => 'Accepted' |
74 | 74 | ])->first(); |
75 | 75 | |
76 | - $other_ac = 1; |
|
77 | - $wrong_trys = 0; |
|
78 | - if(!empty($user_ac)){ |
|
79 | - $other_ac = $this->submissions() |
|
80 | - ->where('verdict','Accepted') |
|
76 | + $other_ac=1; |
|
77 | + $wrong_trys=0; |
|
78 | + if (!empty($user_ac)) { |
|
79 | + $other_ac=$this->submissions() |
|
80 | + ->where('verdict', 'Accepted') |
|
81 | 81 | ->where('submission_date', '<', $user_ac->submission_date) |
82 | 82 | ->count(); |
83 | - $wrong_trys = $this->submissions()->where([ |
|
83 | + $wrong_trys=$this->submissions()->where([ |
|
84 | 84 | 'uid' => $user->id, |
85 | 85 | ])->whereIn('verdict', [ |
86 | 86 | 'Runtime Error', |
@@ -91,8 +91,8 @@ discard block |
||
91 | 91 | 'Presentation Error', |
92 | 92 | 'Output Limit Exceeded' |
93 | 93 | ])->where('submission_date', '<', $user_ac->submission_date)->count(); |
94 | - }else{ |
|
95 | - $wrong_trys = $this->submissions()->where([ |
|
94 | + } else { |
|
95 | + $wrong_trys=$this->submissions()->where([ |
|
96 | 96 | 'uid' => $user->id, |
97 | 97 | ])->whereIn('verdict', [ |
98 | 98 | 'Runtime Error', |