@@ -20,22 +20,22 @@ discard block |
||
20 | 20 | 'cid' => 'required|integer', |
21 | 21 | 'uid' => 'required|integer' |
22 | 22 | ]); |
23 | - $cid = $request->input('cid'); |
|
24 | - $uid = $request->input('uid'); |
|
23 | + $cid=$request->input('cid'); |
|
24 | + $uid=$request->input('uid'); |
|
25 | 25 | |
26 | - $groupModel = new GroupModel(); |
|
27 | - $contestModel = new ContestModel(); |
|
26 | + $groupModel=new GroupModel(); |
|
27 | + $contestModel=new ContestModel(); |
|
28 | 28 | |
29 | - $contest_info = $contestModel->basic($cid); |
|
30 | - if($contestModel->judgeClearance($cid,Auth::user()->id) != 3){ |
|
29 | + $contest_info=$contestModel->basic($cid); |
|
30 | + if ($contestModel->judgeClearance($cid, Auth::user()->id)!=3) { |
|
31 | 31 | return ResponseModel::err(2001); |
32 | 32 | } |
33 | 33 | |
34 | - if($groupModel->judgeClearance($contest_info['gid'],$uid) < 2){ |
|
34 | + if ($groupModel->judgeClearance($contest_info['gid'], $uid)<2) { |
|
35 | 35 | return ResponseModel::err(7004); |
36 | 36 | } |
37 | 37 | |
38 | - $contestModel->assignMember($cid,$uid); |
|
38 | + $contestModel->assignMember($cid, $uid); |
|
39 | 39 | return ResponseModel::success(200); |
40 | 40 | } |
41 | 41 | |
@@ -44,30 +44,30 @@ discard block |
||
44 | 44 | $request->validate([ |
45 | 45 | 'cid' => 'required|integer', |
46 | 46 | ]); |
47 | - $cid = $request->input('cid'); |
|
47 | + $cid=$request->input('cid'); |
|
48 | 48 | |
49 | - $contestModel = new ContestModel(); |
|
50 | - $groupModel = new GroupModel(); |
|
49 | + $contestModel=new ContestModel(); |
|
50 | + $groupModel=new GroupModel(); |
|
51 | 51 | |
52 | - $contest_problems = $contestModel->problems($cid); |
|
53 | - $contest_detail = $contestModel->basic($cid); |
|
54 | - $contest_detail['problems'] = $contest_problems; |
|
55 | - $assign_uid = $contest_detail['assign_uid']; |
|
56 | - $clearance = $contestModel->judgeClearance($cid,Auth::user()->id); |
|
57 | - if($clearance != 3){ |
|
52 | + $contest_problems=$contestModel->problems($cid); |
|
53 | + $contest_detail=$contestModel->basic($cid); |
|
54 | + $contest_detail['problems']=$contest_problems; |
|
55 | + $assign_uid=$contest_detail['assign_uid']; |
|
56 | + $clearance=$contestModel->judgeClearance($cid, Auth::user()->id); |
|
57 | + if ($clearance!=3) { |
|
58 | 58 | return ResponseModel::err(2001); |
59 | 59 | } |
60 | - if($assign_uid != 0){ |
|
61 | - $assignee = $groupModel->userProfile($assign_uid,$contest_detail['gid']); |
|
62 | - }else{ |
|
63 | - $assignee = null; |
|
60 | + if ($assign_uid!=0) { |
|
61 | + $assignee=$groupModel->userProfile($assign_uid, $contest_detail['gid']); |
|
62 | + } else { |
|
63 | + $assignee=null; |
|
64 | 64 | } |
65 | - $ret = [ |
|
65 | + $ret=[ |
|
66 | 66 | 'contest_info' => $contest_detail, |
67 | 67 | 'assignee' => $assignee, |
68 | - 'is_admin' => $clearance == 3, |
|
68 | + 'is_admin' => $clearance==3, |
|
69 | 69 | ]; |
70 | - return ResponseModel::success(200,null,$ret); |
|
70 | + return ResponseModel::success(200, null, $ret); |
|
71 | 71 | } |
72 | 72 | |
73 | 73 | public function rejudge(Request $request) |
@@ -101,15 +101,15 @@ discard block |
||
101 | 101 | 'end_time' => 'required|date|after:begin_time', |
102 | 102 | 'description' => 'string' |
103 | 103 | ]); |
104 | - $all_data = $request->all(); |
|
105 | - $cid = $all_data['cid']; |
|
104 | + $all_data=$request->all(); |
|
105 | + $cid=$all_data['cid']; |
|
106 | 106 | |
107 | - $contestModel = new ContestModel(); |
|
108 | - if($contestModel->judgeClearance($all_data['cid'],Auth::user()->id) != 3){ |
|
107 | + $contestModel=new ContestModel(); |
|
108 | + if ($contestModel->judgeClearance($all_data['cid'], Auth::user()->id)!=3) { |
|
109 | 109 | return ResponseModel::err(2001); |
110 | 110 | } |
111 | 111 | |
112 | - if($contestModel->remainingTime($cid) > 0){ |
|
112 | + if ($contestModel->remainingTime($cid)>0) { |
|
113 | 113 | $problems=explode(",", $all_data["problems"]); |
114 | 114 | if (count($problems)>26) { |
115 | 115 | return ResponseModel::err(4002); |
@@ -126,32 +126,32 @@ discard block |
||
126 | 126 | ]; |
127 | 127 | } |
128 | 128 | } |
129 | - $allow_update = ['name','description','begin_time','end_time']; |
|
129 | + $allow_update=['name', 'description', 'begin_time', 'end_time']; |
|
130 | 130 | |
131 | - foreach($all_data as $key => $value){ |
|
132 | - if(!in_array($key,$allow_update)){ |
|
131 | + foreach ($all_data as $key => $value) { |
|
132 | + if (!in_array($key, $allow_update)) { |
|
133 | 133 | unset($all_data[$key]); |
134 | 134 | } |
135 | 135 | } |
136 | - $contestModel->contestUpdate($cid,$all_data,$problemSet); |
|
136 | + $contestModel->contestUpdate($cid, $all_data, $problemSet); |
|
137 | 137 | return ResponseModel::success(200); |
138 | - }else{ |
|
139 | - $allow_update = ['name','description']; |
|
138 | + } else { |
|
139 | + $allow_update=['name', 'description']; |
|
140 | 140 | |
141 | - foreach($all_data as $key => $value){ |
|
142 | - if(!in_array($key,$allow_update)){ |
|
141 | + foreach ($all_data as $key => $value) { |
|
142 | + if (!in_array($key, $allow_update)) { |
|
143 | 143 | unset($all_data[$key]); |
144 | 144 | } |
145 | 145 | } |
146 | - $contestModel->contestUpdate($cid,$all_data,false); |
|
147 | - return ResponseModel::success(200,' |
|
146 | + $contestModel->contestUpdate($cid, $all_data, false); |
|
147 | + return ResponseModel::success(200, ' |
|
148 | 148 | Successful! However, only the name and description of the match can be changed for the match that has been finished. |
149 | 149 | '); |
150 | 150 | } |
151 | 151 | |
152 | 152 | } |
153 | 153 | |
154 | - public function issueAnnouncement(Request $request){ |
|
154 | + public function issueAnnouncement(Request $request) { |
|
155 | 155 | $request->validate([ |
156 | 156 | 'cid' => 'required|integer', |
157 | 157 | 'title' => 'required|string|max:250', |
@@ -171,7 +171,7 @@ discard block |
||
171 | 171 | } |
172 | 172 | } |
173 | 173 | |
174 | - public function replyClarification(Request $request){ |
|
174 | + public function replyClarification(Request $request) { |
|
175 | 175 | $request->validate([ |
176 | 176 | 'cid' => 'required|integer', |
177 | 177 | 'ccid' => 'required|integer', |
@@ -191,7 +191,7 @@ discard block |
||
191 | 191 | } |
192 | 192 | } |
193 | 193 | |
194 | - public function setClarificationPublic(Request $request){ |
|
194 | + public function setClarificationPublic(Request $request) { |
|
195 | 195 | $request->validate([ |
196 | 196 | 'cid' => 'required|integer', |
197 | 197 | 'ccid' => 'required|integer', |
@@ -224,7 +224,7 @@ discard block |
||
224 | 224 | $groupModel=new GroupModel(); |
225 | 225 | $contestModel=new ContestModel(); |
226 | 226 | $verified=$contestModel->isVerified($all_data["cid"]); |
227 | - if(!$verified){ |
|
227 | + if (!$verified) { |
|
228 | 228 | return ResponseModel::err(2001); |
229 | 229 | } |
230 | 230 | $gid=$contestModel->gid($all_data["cid"]); |
@@ -245,18 +245,18 @@ discard block |
||
245 | 245 | $request->validate([ |
246 | 246 | 'cid' => 'required|integer', |
247 | 247 | ]); |
248 | - $cid = $request->input('cid'); |
|
249 | - $contestModel = new ContestModel(); |
|
250 | - if($contestModel->judgeClearance($cid,Auth::user()->id) != 3){ |
|
248 | + $cid=$request->input('cid'); |
|
249 | + $contestModel=new ContestModel(); |
|
250 | + if ($contestModel->judgeClearance($cid, Auth::user()->id)!=3) { |
|
251 | 251 | return ResponseModel::err(2001); |
252 | 252 | } |
253 | - if($contestModel->remainingTime($cid) >= 0){ |
|
253 | + if ($contestModel->remainingTime($cid)>=0) { |
|
254 | 254 | return ResponseModel::err(4008); |
255 | 255 | } |
256 | - if($contestModel->basic($cid)['froze_length'] == 0){ |
|
256 | + if ($contestModel->basic($cid)['froze_length']==0) { |
|
257 | 257 | return ResponseModel::err(4009); |
258 | 258 | } |
259 | - $data = $contestModel->getScrollBoardData($cid); |
|
259 | + $data=$contestModel->getScrollBoardData($cid); |
|
260 | 260 | return ResponseModel::success(200, null, $data); |
261 | 261 | } |
262 | 262 | } |
@@ -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 = MessageModel::unread($uid); |
|
23 | - return ResponseModel::success(200,null,$ret); |
|
22 | + $ret=MessageModel::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 | MessageModel::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 | MessageModel::removeAllRead($uid); |
37 | 37 | return ResponseModel::success(200); |
38 | 38 | } |
@@ -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 |
@@ -57,10 +57,10 @@ discard block |
||
57 | 57 | foreach ($trending_groups as &$t) { |
58 | 58 | $t["members"]=$this->countGroupMembers($t["gid"]); |
59 | 59 | } |
60 | - usort($trending_groups, function ($a, $b) { |
|
60 | + usort($trending_groups, function($a, $b) { |
|
61 | 61 | return $b["members"]<=>$a["members"]; |
62 | 62 | }); |
63 | - Cache::tags(['group'])->put('trending', array_slice($trending_groups,0,12), 3600*24); |
|
63 | + Cache::tags(['group'])->put('trending', array_slice($trending_groups, 0, 12), 3600 * 24); |
|
64 | 64 | } |
65 | 65 | |
66 | 66 | public function userGroups($uid) |
@@ -100,13 +100,13 @@ discard block |
||
100 | 100 | |
101 | 101 | public function changeGroupName($gid, $GroupName) |
102 | 102 | { |
103 | - return DB::table("group")->where('gid',$gid)->update([ |
|
103 | + return DB::table("group")->where('gid', $gid)->update([ |
|
104 | 104 | "name"=>$GroupName |
105 | 105 | ]); |
106 | 106 | } |
107 | 107 | |
108 | - public function changeJoinPolicy($gid, $JoinPolicy){ |
|
109 | - return DB::table("group")->where('gid',$gid)->update([ |
|
108 | + public function changeJoinPolicy($gid, $JoinPolicy) { |
|
109 | + return DB::table("group")->where('gid', $gid)->update([ |
|
110 | 110 | "join_policy"=>$JoinPolicy |
111 | 111 | ]); |
112 | 112 | } |
@@ -120,7 +120,7 @@ discard block |
||
120 | 120 | public function details($gcode) |
121 | 121 | { |
122 | 122 | $basic_info=DB::table($this->tableName)->where(["gcode"=>$gcode])->first(); |
123 | - if(empty($basic_info)) return []; |
|
123 | + if (empty($basic_info)) return []; |
|
124 | 124 | $basic_info["members"]=$this->countGroupMembers($basic_info["gid"]); |
125 | 125 | $basic_info["tags"]=$this->getGroupTags($basic_info["gid"]); |
126 | 126 | $basic_info["create_time_foramt"]=date_format(date_create($basic_info["create_time"]), 'M jS, Y'); |
@@ -137,10 +137,10 @@ discard block |
||
137 | 137 | public function userProfile($uid, $gid) |
138 | 138 | { |
139 | 139 | $info=DB::table("group_member") |
140 | - ->join('users','users.id','=','group_member.uid') |
|
140 | + ->join('users', 'users.id', '=', 'group_member.uid') |
|
141 | 141 | ->where(["gid"=>$gid, "uid"=>$uid]) |
142 | 142 | ->where("role", ">", 0) |
143 | - ->select('avatar','describes','email','gid','uid','name','nick_name','professional_rate','role','sub_group') |
|
143 | + ->select('avatar', 'describes', 'email', 'gid', 'uid', 'name', 'nick_name', 'professional_rate', 'role', 'sub_group') |
|
144 | 144 | ->first(); |
145 | 145 | if (!empty($info)) { |
146 | 146 | $info["role_parsed"]=$this->role[$info["role"]]; |
@@ -168,7 +168,7 @@ discard block |
||
168 | 168 | foreach ($user_list as &$u) { |
169 | 169 | $u["role_parsed"]=$this->role[$u["role"]]; |
170 | 170 | $u["role_color"]=$this->role_color[$u["role"]]; |
171 | - if(is_null($u["sub_group"])) $u["sub_group"]="None"; |
|
171 | + if (is_null($u["sub_group"])) $u["sub_group"]="None"; |
|
172 | 172 | } |
173 | 173 | return $user_list; |
174 | 174 | } |
@@ -229,16 +229,16 @@ discard block |
||
229 | 229 | ])->where("role", ">", 0)->count(); |
230 | 230 | } |
231 | 231 | |
232 | - public function problemTags($gid,$pid = -1) |
|
232 | + public function problemTags($gid, $pid=-1) |
|
233 | 233 | { |
234 | - if($pid == -1){ |
|
235 | - $tags = DB::table('group_problem_tag') |
|
234 | + if ($pid==-1) { |
|
235 | + $tags=DB::table('group_problem_tag') |
|
236 | 236 | ->select('tag') |
237 | - ->where('gid',$gid) |
|
237 | + ->where('gid', $gid) |
|
238 | 238 | ->distinct() |
239 | 239 | ->get()->all(); |
240 | - }else{ |
|
241 | - $tags = DB::table('group_problem_tag') |
|
240 | + } else { |
|
241 | + $tags=DB::table('group_problem_tag') |
|
242 | 242 | ->select('tag') |
243 | 243 | ->where('gid', $gid) |
244 | 244 | ->where('pid', $pid) |
@@ -246,10 +246,10 @@ discard block |
||
246 | 246 | ->get()->all(); |
247 | 247 | } |
248 | 248 | |
249 | - $tags_arr = []; |
|
250 | - if(!empty($tags)){ |
|
249 | + $tags_arr=[]; |
|
250 | + if (!empty($tags)) { |
|
251 | 251 | foreach ($tags as $value) { |
252 | - array_push($tags_arr,$value['tag']); |
|
252 | + array_push($tags_arr, $value['tag']); |
|
253 | 253 | } |
254 | 254 | } |
255 | 255 | return $tags_arr; |
@@ -257,28 +257,28 @@ discard block |
||
257 | 257 | |
258 | 258 | public function problems($gid) |
259 | 259 | { |
260 | - $contestModel = new ContestModel(); |
|
261 | - $problems = DB::table('contest_problem') |
|
262 | - ->join('contest','contest_problem.cid', '=', 'contest.cid') |
|
263 | - ->join('problem','contest_problem.pid', '=', 'problem.pid' ) |
|
260 | + $contestModel=new ContestModel(); |
|
261 | + $problems=DB::table('contest_problem') |
|
262 | + ->join('contest', 'contest_problem.cid', '=', 'contest.cid') |
|
263 | + ->join('problem', 'contest_problem.pid', '=', 'problem.pid') |
|
264 | 264 | ->select('contest_problem.cid as cid', 'problem.pid as pid', 'pcode', 'title') |
265 | - ->where('contest.gid',$gid) |
|
266 | - ->where('contest.practice',1) |
|
267 | - ->orderBy('contest.create_time','desc') |
|
265 | + ->where('contest.gid', $gid) |
|
266 | + ->where('contest.practice', 1) |
|
267 | + ->orderBy('contest.create_time', 'desc') |
|
268 | 268 | ->distinct() |
269 | 269 | ->get()->all(); |
270 | - $user_id = Auth::user()->id; |
|
271 | - foreach($problems as $key => $value){ |
|
272 | - if($contestModel->judgeClearance($value['cid'],$user_id) != 3){ |
|
270 | + $user_id=Auth::user()->id; |
|
271 | + foreach ($problems as $key => $value) { |
|
272 | + if ($contestModel->judgeClearance($value['cid'], $user_id)!=3) { |
|
273 | 273 | unset($problems[$key]); |
274 | - }else{ |
|
275 | - $problems[$key]['tags'] = $this->problemTags($gid,$value['pid']); |
|
274 | + } else { |
|
275 | + $problems[$key]['tags']=$this->problemTags($gid, $value['pid']); |
|
276 | 276 | } |
277 | 277 | } |
278 | 278 | return $problems; |
279 | 279 | } |
280 | 280 | |
281 | - public function problemAddTag($gid,$pid,$tag) |
|
281 | + public function problemAddTag($gid, $pid, $tag) |
|
282 | 282 | { |
283 | 283 | return DB::table("group_problem_tag")->insert([ |
284 | 284 | "gid"=>$gid, |
@@ -287,7 +287,7 @@ discard block |
||
287 | 287 | ]); |
288 | 288 | } |
289 | 289 | |
290 | - public function problemRemoveTag($gid,$pid,$tag) |
|
290 | + public function problemRemoveTag($gid, $pid, $tag) |
|
291 | 291 | { |
292 | 292 | return DB::table("group_problem_tag")->where([ |
293 | 293 | "gid"=>$gid, |
@@ -332,7 +332,7 @@ discard block |
||
332 | 332 | public function judgeEmailClearance($gid, $email) |
333 | 333 | { |
334 | 334 | $user=DB::table("users")->where(["email"=>$email])->first(); |
335 | - if(empty($user)) return -4; |
|
335 | + if (empty($user)) return -4; |
|
336 | 336 | $ret=DB::table("group_member")->where([ |
337 | 337 | "gid"=>$gid, |
338 | 338 | "uid"=>$user["id"], |
@@ -423,20 +423,20 @@ discard block |
||
423 | 423 | |
424 | 424 | public function groupMemberPracticeContestStat($gid) |
425 | 425 | { |
426 | - $contestModel = new ContestModel(); |
|
426 | + $contestModel=new ContestModel(); |
|
427 | 427 | |
428 | - $allPracticeContest = DB::table('contest') |
|
428 | + $allPracticeContest=DB::table('contest') |
|
429 | 429 | ->where([ |
430 | 430 | 'gid' => $gid, |
431 | 431 | 'practice' => 1, |
432 | 432 | ]) |
433 | - ->select('cid','name') |
|
433 | + ->select('cid', 'name') |
|
434 | 434 | ->get()->all(); |
435 | - $user_list = $this->userList($gid); |
|
435 | + $user_list=$this->userList($gid); |
|
436 | 436 | |
437 | - $memberData = []; |
|
437 | + $memberData=[]; |
|
438 | 438 | foreach ($user_list as $u) { |
439 | - $memberData[$u['uid']] = [ |
|
439 | + $memberData[$u['uid']]=[ |
|
440 | 440 | 'name' => $u['name'], |
441 | 441 | 'nick_name' => $u['nick_name'], |
442 | 442 | 'elo' => $u['ranking'], |
@@ -447,61 +447,61 @@ discard block |
||
447 | 447 | ]; |
448 | 448 | } |
449 | 449 | foreach ($allPracticeContest as $c) { |
450 | - $contestRankRaw = $contestModel->contestRank($c['cid']); |
|
451 | - foreach($contestRankRaw as $key => $contestRank){ |
|
452 | - if(isset($contestRank['remote']) && $contestRank['remote']){ |
|
450 | + $contestRankRaw=$contestModel->contestRank($c['cid']); |
|
451 | + foreach ($contestRankRaw as $key => $contestRank) { |
|
452 | + if (isset($contestRank['remote']) && $contestRank['remote']) { |
|
453 | 453 | unset($contestRankRaw[$key]); |
454 | 454 | } |
455 | 455 | } |
456 | - $contestRank = array_values($contestRankRaw); |
|
457 | - $problemsCount = DB::table('contest_problem') |
|
458 | - ->where('cid',$c['cid']) |
|
456 | + $contestRank=array_values($contestRankRaw); |
|
457 | + $problemsCount=DB::table('contest_problem') |
|
458 | + ->where('cid', $c['cid']) |
|
459 | 459 | ->count(); |
460 | - $index = 1; |
|
461 | - $rank = 1; |
|
462 | - $last_cr = []; |
|
463 | - $last_rank = 1; |
|
460 | + $index=1; |
|
461 | + $rank=1; |
|
462 | + $last_cr=[]; |
|
463 | + $last_rank=1; |
|
464 | 464 | foreach ($contestRank as $cr) { |
465 | - $last_rank = $index; |
|
466 | - if(!empty($last_cr)){ |
|
467 | - if($cr['solved'] == $last_cr['solved'] && $cr['penalty'] == $last_cr['penalty'] ){ |
|
468 | - $rank = $last_rank; |
|
469 | - }else{ |
|
470 | - $rank = $index; |
|
471 | - $last_rank = $rank; |
|
465 | + $last_rank=$index; |
|
466 | + if (!empty($last_cr)) { |
|
467 | + if ($cr['solved']==$last_cr['solved'] && $cr['penalty']==$last_cr['penalty']) { |
|
468 | + $rank=$last_rank; |
|
469 | + } else { |
|
470 | + $rank=$index; |
|
471 | + $last_rank=$rank; |
|
472 | 472 | } |
473 | 473 | } |
474 | - if(in_array($cr['uid'],array_keys($memberData))) { |
|
475 | - $memberData[$cr['uid']]['solved_all'] += $cr['solved']; |
|
476 | - $memberData[$cr['uid']]['problem_all'] += $problemsCount; |
|
477 | - $memberData[$cr['uid']]['penalty'] += $cr['penalty']; |
|
478 | - $memberData[$cr['uid']]['contest_detial'][$c['cid']] = [ |
|
474 | + if (in_array($cr['uid'], array_keys($memberData))) { |
|
475 | + $memberData[$cr['uid']]['solved_all']+=$cr['solved']; |
|
476 | + $memberData[$cr['uid']]['problem_all']+=$problemsCount; |
|
477 | + $memberData[$cr['uid']]['penalty']+=$cr['penalty']; |
|
478 | + $memberData[$cr['uid']]['contest_detial'][$c['cid']]=[ |
|
479 | 479 | 'rank' => $rank, |
480 | 480 | 'solved' => $cr['solved'], |
481 | 481 | 'problems' => $problemsCount, |
482 | 482 | 'penalty' => $cr['penalty'] |
483 | 483 | ]; |
484 | 484 | } |
485 | - $last_cr = $cr; |
|
485 | + $last_cr=$cr; |
|
486 | 486 | $index++; |
487 | 487 | } |
488 | 488 | } |
489 | - $new_memberData = []; |
|
489 | + $new_memberData=[]; |
|
490 | 490 | foreach ($memberData as $uid => $data) { |
491 | - $contest_count = 0; |
|
492 | - $rank_sum = 0; |
|
491 | + $contest_count=0; |
|
492 | + $rank_sum=0; |
|
493 | 493 | foreach ($data['contest_detial'] as $cid => $c) { |
494 | - $rank_sum += $c['rank']; |
|
495 | - $contest_count += 1; |
|
494 | + $rank_sum+=$c['rank']; |
|
495 | + $contest_count+=1; |
|
496 | 496 | } |
497 | - $temp = $data; |
|
498 | - $temp['uid'] = $uid; |
|
499 | - if($contest_count != 0){ |
|
500 | - $temp['rank_ave'] = $rank_sum/$contest_count; |
|
497 | + $temp=$data; |
|
498 | + $temp['uid']=$uid; |
|
499 | + if ($contest_count!=0) { |
|
500 | + $temp['rank_ave']=$rank_sum / $contest_count; |
|
501 | 501 | } |
502 | - array_push($new_memberData,$temp); |
|
502 | + array_push($new_memberData, $temp); |
|
503 | 503 | } |
504 | - $ret = [ |
|
504 | + $ret=[ |
|
505 | 505 | 'contest_list' => $allPracticeContest, |
506 | 506 | 'member_data' => $new_memberData |
507 | 507 | ]; |
@@ -510,58 +510,58 @@ discard block |
||
510 | 510 | |
511 | 511 | public function groupMemberPracticeTagStat($gid) |
512 | 512 | { |
513 | - $tags = $this->problemTags($gid); |
|
514 | - $tag_problems = []; |
|
513 | + $tags=$this->problemTags($gid); |
|
514 | + $tag_problems=[]; |
|
515 | 515 | |
516 | - $user_list = $this->userList($gid); |
|
516 | + $user_list=$this->userList($gid); |
|
517 | 517 | foreach ($tags as $tag) { |
518 | - $tag_problems[$tag] = DB::table('problem') |
|
519 | - ->join('group_problem_tag','problem.pid','=','group_problem_tag.pid') |
|
518 | + $tag_problems[$tag]=DB::table('problem') |
|
519 | + ->join('group_problem_tag', 'problem.pid', '=', 'group_problem_tag.pid') |
|
520 | 520 | ->where([ |
521 | 521 | 'group_problem_tag.gid' => $gid, |
522 | 522 | 'tag' => $tag |
523 | 523 | ]) |
524 | - ->select('group_problem_tag.pid as pid','pcode','title') |
|
524 | + ->select('group_problem_tag.pid as pid', 'pcode', 'title') |
|
525 | 525 | ->get()->all(); |
526 | 526 | } |
527 | - $all_problems = []; |
|
527 | + $all_problems=[]; |
|
528 | 528 | foreach ($tag_problems as &$tag_problem_set) { |
529 | 529 | foreach ($tag_problem_set as $problem) { |
530 | - $all_problems[$problem['pid']] = $problem; |
|
530 | + $all_problems[$problem['pid']]=$problem; |
|
531 | 531 | } |
532 | - $tag_problem_set = array_column($tag_problem_set,'pid'); |
|
532 | + $tag_problem_set=array_column($tag_problem_set, 'pid'); |
|
533 | 533 | } |
534 | - $submission_data = DB::table('submission') |
|
535 | - ->whereIn('pid',array_keys($all_problems)) |
|
536 | - ->whereIn('uid',array_column($user_list,'uid')) |
|
537 | - ->where('verdict','Accepted') |
|
538 | - ->select('pid','uid') |
|
534 | + $submission_data=DB::table('submission') |
|
535 | + ->whereIn('pid', array_keys($all_problems)) |
|
536 | + ->whereIn('uid', array_column($user_list, 'uid')) |
|
537 | + ->where('verdict', 'Accepted') |
|
538 | + ->select('pid', 'uid') |
|
539 | 539 | ->get()->all(); |
540 | 540 | |
541 | - $memberData = []; |
|
541 | + $memberData=[]; |
|
542 | 542 | foreach ($user_list as $member) { |
543 | - $completion = []; |
|
544 | - foreach($tag_problems as $tag => $problems) { |
|
545 | - $completion[$tag] = []; |
|
543 | + $completion=[]; |
|
544 | + foreach ($tag_problems as $tag => $problems) { |
|
545 | + $completion[$tag]=[]; |
|
546 | 546 | foreach ($problems as $problem) { |
547 | - $is_accepted = 0; |
|
547 | + $is_accepted=0; |
|
548 | 548 | foreach ($submission_data as $sd) { |
549 | - if($sd['pid'] == $problem && $sd['uid'] == $member['uid']){ |
|
550 | - $is_accepted = 1; |
|
549 | + if ($sd['pid']==$problem && $sd['uid']==$member['uid']) { |
|
550 | + $is_accepted=1; |
|
551 | 551 | break; |
552 | 552 | } |
553 | 553 | } |
554 | - $completion[$tag][$problem] = $is_accepted; |
|
554 | + $completion[$tag][$problem]=$is_accepted; |
|
555 | 555 | } |
556 | 556 | } |
557 | - array_push($memberData,[ |
|
557 | + array_push($memberData, [ |
|
558 | 558 | 'uid' => $member['uid'], |
559 | 559 | 'name' => $member['name'], |
560 | 560 | 'nick_name' => $member['nick_name'], |
561 | 561 | 'completion' => $completion, |
562 | 562 | ]); |
563 | 563 | } |
564 | - $ret = [ |
|
564 | + $ret=[ |
|
565 | 565 | 'all_problems' => $all_problems, |
566 | 566 | 'tag_problems' => $tag_problems, |
567 | 567 | 'member_data' => $memberData |
@@ -571,10 +571,10 @@ discard block |
||
571 | 571 | |
572 | 572 | public function refreshAllElo() |
573 | 573 | { |
574 | - $result = []; |
|
575 | - $gids = DB::table('group')->select('gid','name')->get()->all(); |
|
574 | + $result=[]; |
|
575 | + $gids=DB::table('group')->select('gid', 'name')->get()->all(); |
|
576 | 576 | foreach ($gids as $gid) { |
577 | - $result[$gid['gid']] = [ |
|
577 | + $result[$gid['gid']]=[ |
|
578 | 578 | 'name' => $gid['name'], |
579 | 579 | 'result' => $this->refreshElo($gid['gid']), |
580 | 580 | ]; |
@@ -585,41 +585,41 @@ discard block |
||
585 | 585 | public function refreshElo($gid) |
586 | 586 | { |
587 | 587 | DB::table('group_rated_change_log') |
588 | - ->where('gid',$gid) |
|
588 | + ->where('gid', $gid) |
|
589 | 589 | ->delete(); |
590 | 590 | DB::table('group_member') |
591 | - ->where('gid',$gid) |
|
591 | + ->where('gid', $gid) |
|
592 | 592 | ->update([ |
593 | 593 | 'ranking' => 1500 |
594 | 594 | ]); |
595 | - $contests = DB::table('contest') |
|
595 | + $contests=DB::table('contest') |
|
596 | 596 | ->where([ |
597 | 597 | 'gid' => $gid, |
598 | 598 | 'practice' => 1 |
599 | 599 | ]) |
600 | - ->where('end_time','<',date("Y-m-d H:i:s")) |
|
601 | - ->select('cid','name') |
|
600 | + ->where('end_time', '<', date("Y-m-d H:i:s")) |
|
601 | + ->select('cid', 'name') |
|
602 | 602 | ->orderBy('end_time') |
603 | 603 | ->get()->all(); |
604 | 604 | |
605 | - if(empty($contests)) { |
|
605 | + if (empty($contests)) { |
|
606 | 606 | return []; |
607 | 607 | } |
608 | - $result = []; |
|
609 | - $contestModel = new ContestModel(); |
|
608 | + $result=[]; |
|
609 | + $contestModel=new ContestModel(); |
|
610 | 610 | foreach ($contests as $contest) { |
611 | - $judge_status = $contestModel->judgeOver($contest['cid']); |
|
612 | - if($judge_status['result'] == true){ |
|
613 | - $calc = new GroupRatingCalculator($contest['cid']); |
|
611 | + $judge_status=$contestModel->judgeOver($contest['cid']); |
|
612 | + if ($judge_status['result']==true) { |
|
613 | + $calc=new GroupRatingCalculator($contest['cid']); |
|
614 | 614 | $calc->calculate(); |
615 | 615 | $calc->storage(); |
616 | - $result[] = [ |
|
616 | + $result[]=[ |
|
617 | 617 | 'ret' => 'success', |
618 | 618 | 'cid' => $contest['cid'], |
619 | 619 | 'name' => $contest['name'] |
620 | 620 | ]; |
621 | - }else{ |
|
622 | - $result[] = [ |
|
621 | + } else { |
|
622 | + $result[]=[ |
|
623 | 623 | 'ret' => 'judging', |
624 | 624 | 'cid' => $contest['cid'], |
625 | 625 | 'name' => $contest['name'], |
@@ -631,23 +631,23 @@ discard block |
||
631 | 631 | return $result; |
632 | 632 | } |
633 | 633 | |
634 | - public function getEloChangeLog($gid,$uid) |
|
634 | + public function getEloChangeLog($gid, $uid) |
|
635 | 635 | { |
636 | - $ret = DB::table('group_rated_change_log') |
|
637 | - ->join('contest','group_rated_change_log.cid','=','contest.cid') |
|
636 | + $ret=DB::table('group_rated_change_log') |
|
637 | + ->join('contest', 'group_rated_change_log.cid', '=', 'contest.cid') |
|
638 | 638 | ->where([ |
639 | 639 | 'group_rated_change_log.gid' => $gid, |
640 | 640 | 'group_rated_change_log.uid' => $uid |
641 | 641 | ])->select('group_rated_change_log.cid as cid', 'contest.name as name', 'ranking', 'end_time') |
642 | 642 | ->orderBy('contest.end_time') |
643 | 643 | ->get()->all(); |
644 | - $begin = [ |
|
644 | + $begin=[ |
|
645 | 645 | 'cid' => -1, |
646 | 646 | 'name' => '', |
647 | 647 | 'ranking' => '1500', |
648 | - 'end_time' => date("Y-m-d H:i:s",(strtotime($ret[0]['end_time'] ?? time()) - 3600*24)), |
|
648 | + 'end_time' => date("Y-m-d H:i:s", (strtotime($ret[0]['end_time'] ?? time())-3600 * 24)), |
|
649 | 649 | ]; |
650 | - $ret = array_prepend($ret,$begin); |
|
650 | + $ret=array_prepend($ret, $begin); |
|
651 | 651 | return $ret; |
652 | 652 | } |
653 | 653 | } |