Test Setup Failed
Push — master ( 92b796...78abf9 )
by John
05:25
created
app/Models/ContestModel.php 1 patch
Spacing   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -317,11 +317,11 @@  discard block
 block discarded – undo
317 317
 
318 318
     public function isFrozen($cid)
319 319
     {
320
-        $frozen = DB::table("contest")->where(["cid"=>$cid])->select("froze_length",DB::raw("UNIX_TIMESTAMP(end_time)-froze_length as frozen_time"))->first();
321
-        if(empty($frozen["froze_length"])){
320
+        $frozen=DB::table("contest")->where(["cid"=>$cid])->select("froze_length", DB::raw("UNIX_TIMESTAMP(end_time)-froze_length as frozen_time"))->first();
321
+        if (empty($frozen["froze_length"])) {
322 322
             return false;
323 323
         } else {
324
-            return time() > $frozen["frozen_time"];
324
+            return time()>$frozen["frozen_time"];
325 325
         }
326 326
     }
327 327
 
@@ -464,7 +464,7 @@  discard block
 block discarded – undo
464 464
                     "problem_detail" => $prob_detail
465 465
                 ];
466 466
             }
467
-            usort($ret, function ($a, $b) {
467
+            usort($ret, function($a, $b) {
468 468
                 if ($a["score"]==$b["score"]) {
469 469
                     if ($a["penalty"]==$b["penalty"]) {
470 470
                         return 0;
@@ -511,7 +511,7 @@  discard block
 block discarded – undo
511 511
                     "problem_detail" => $prob_detail
512 512
                 ];
513 513
             }
514
-            usort($ret, function ($a, $b) {
514
+            usort($ret, function($a, $b) {
515 515
                 if ($a["score"]==$b["score"]) {
516 516
                     if ($a["solved"]==$b["solved"]) {
517 517
                         return 0;
@@ -597,34 +597,34 @@  discard block
 block discarded – undo
597 597
 
598 598
     public function getContestRecord($cid)
599 599
     {
600
-        $basicInfo = $this->basic($cid);
601
-        $problemSet_temp = DB::table("contest_problem")->join("problem", "contest_problem.pid", "=", "problem.pid")->where([
600
+        $basicInfo=$this->basic($cid);
601
+        $problemSet_temp=DB::table("contest_problem")->join("problem", "contest_problem.pid", "=", "problem.pid")->where([
602 602
             "cid"=>$cid
603 603
         ])->orderBy('ncode', 'asc')->select("ncode", "alias", "contest_problem.pid as pid", "title", "points", "tot_score")->get()->all();
604 604
         $problemSet=[];
605 605
         foreach ($problemSet_temp as $p) {
606
-            $problemSet[(string)$p["pid"]]=["ncode"=>$p["ncode"],"points"=>$p["points"],"tot_score"=>$p["tot_score"]];
606
+            $problemSet[(string) $p["pid"]]=["ncode"=>$p["ncode"], "points"=>$p["points"], "tot_score"=>$p["tot_score"]];
607 607
         }
608
-        if($basicInfo["status_visibility"]==2){
608
+        if ($basicInfo["status_visibility"]==2) {
609 609
             // View all
610
-            $records = DB::table("submission")->where([
610
+            $records=DB::table("submission")->where([
611 611
                 'cid'=>$cid
612
-            ])->join("users","users.id","=","submission.uid")->select("sid","uid","pid","name","color","verdict","time","memory","language","score","submission_date")->orderBy('submission_date', 'desc')->get()->all();
612
+            ])->join("users", "users.id", "=", "submission.uid")->select("sid", "uid", "pid", "name", "color", "verdict", "time", "memory", "language", "score", "submission_date")->orderBy('submission_date', 'desc')->get()->all();
613 613
         } elseif ($basicInfo["status_visibility"]==1) {
614
-            $records = DB::table("submission")->where([
614
+            $records=DB::table("submission")->where([
615 615
                 'cid'=>$cid,
616 616
                 'uid'=>Auth::user()->id
617
-            ])->join("users","users.id","=","submission.uid")->select("sid","uid","pid","name","color","verdict","time","memory","language","score","submission_date")->orderBy('submission_date', 'desc')->get()->all();
617
+            ])->join("users", "users.id", "=", "submission.uid")->select("sid", "uid", "pid", "name", "color", "verdict", "time", "memory", "language", "score", "submission_date")->orderBy('submission_date', 'desc')->get()->all();
618 618
         } else {
619 619
             return [];
620 620
         }
621
-        foreach($records as &$r){
621
+        foreach ($records as &$r) {
622 622
             $r["submission_date_parsed"]=$this->formatSubmitTime(date('Y-m-d H:i:s', $r["submission_date"]));
623 623
             $r["submission_date"]=date('Y-m-d H:i:s', $r["submission_date"]);
624 624
             $r["nick_name"]="";
625
-            $r["ncode"]=$problemSet[(string)$r["pid"]]["ncode"];
626
-            if($r["verdict"]=="Partially Accepted") {
627
-                $score_parsed = round($r["score"] / $problemSet[(string)$r["pid"]]["tot_score"] * $problemSet[(string)$r["pid"]]["points"], 1);
625
+            $r["ncode"]=$problemSet[(string) $r["pid"]]["ncode"];
626
+            if ($r["verdict"]=="Partially Accepted") {
627
+                $score_parsed=round($r["score"] / $problemSet[(string) $r["pid"]]["tot_score"] * $problemSet[(string) $r["pid"]]["points"], 1);
628 628
                 $r["verdict"].=" ($score_parsed)";
629 629
             }
630 630
         }
@@ -669,7 +669,7 @@  discard block
 block discarded – undo
669 669
             }
670 670
         } else {
671 671
             //private
672
-            $isMember = DB::table("group_member")->where([
672
+            $isMember=DB::table("group_member")->where([
673 673
                 "gid"=> $contest_info["gid"],
674 674
                 "uid"=> $uid
675 675
             ])->where("role", ">", 0)->count();
@@ -726,7 +726,7 @@  discard block
 block discarded – undo
726 726
 
727 727
     public function arrangeContest($gid, $config, $problems)
728 728
     {
729
-        DB::transaction(function () use ($gid, $config, $problems) {
729
+        DB::transaction(function() use ($gid, $config, $problems) {
730 730
             $cid=DB::table($this->tableName)->insertGetId([
731 731
                 "gid"=>$gid,
732 732
                 "name"=>$config["name"],
Please login to merge, or discard this patch.