@@ -14,7 +14,7 @@ discard block |
||
14 | 14 | $statusCode=200; |
15 | 15 | } |
16 | 16 | $output=[ |
17 | - 'ret' => $statusCode, |
|
17 | + 'ret' => $statusCode, |
|
18 | 18 | 'desc' => is_null($desc) ? self::desc($statusCode) : $desc, |
19 | 19 | 'data' => $data |
20 | 20 | ]; |
@@ -27,7 +27,7 @@ discard block |
||
27 | 27 | $statusCode=1000; |
28 | 28 | } |
29 | 29 | $output=[ |
30 | - 'ret' => $statusCode, |
|
30 | + 'ret' => $statusCode, |
|
31 | 31 | 'desc' => is_null($desc) ? self::desc($statusCode) : $desc, |
32 | 32 | 'data' => $data |
33 | 33 | ]; |
@@ -44,9 +44,9 @@ discard block |
||
44 | 44 | '451' => "Unavailable For Legal Reasons", |
45 | 45 | |
46 | 46 | '1000' => "Unspecified Response", /** Under normal condictions those errors shouldn't been displayed to end users |
47 | - * unless they attempt to do so, some submissions should be intercepted |
|
48 | - * by the frontend before the request sended |
|
49 | - */ |
|
47 | + * unless they attempt to do so, some submissions should be intercepted |
|
48 | + * by the frontend before the request sended |
|
49 | + */ |
|
50 | 50 | '1001' => "Internal Sever Error", |
51 | 51 | '1002' => "Service Currently Unavailable", |
52 | 52 | '1003' => "Missing Params", |
@@ -18,11 +18,31 @@ discard block |
||
18 | 18 | |
19 | 19 | public function login($all_data) |
20 | 20 | { |
21 | - if (isset($all_data["url"])) $url=$all_data["url"]; else throw new Exception("url is not exist in all_data"); |
|
22 | - if (isset($all_data["data"])) $data=$all_data["data"]; else throw new Exception("data is not exist in all_data"); |
|
23 | - if (isset($all_data["oj"])) $oj=$all_data["oj"]; else throw new Exception("oj is not exist in all_data"); |
|
24 | - if (isset($all_data["ret"])) $ret=$all_data["ret"]; else $ret='false'; |
|
25 | - if (isset($all_data["handle"])) $handle=$all_data["handle"]; else $handle="default"; |
|
21 | + if (isset($all_data["url"])) { |
|
22 | + $url=$all_data["url"]; |
|
23 | + } else { |
|
24 | + throw new Exception("url is not exist in all_data"); |
|
25 | + } |
|
26 | + if (isset($all_data["data"])) { |
|
27 | + $data=$all_data["data"]; |
|
28 | + } else { |
|
29 | + throw new Exception("data is not exist in all_data"); |
|
30 | + } |
|
31 | + if (isset($all_data["oj"])) { |
|
32 | + $oj=$all_data["oj"]; |
|
33 | + } else { |
|
34 | + throw new Exception("oj is not exist in all_data"); |
|
35 | + } |
|
36 | + if (isset($all_data["ret"])) { |
|
37 | + $ret=$all_data["ret"]; |
|
38 | + } else { |
|
39 | + $ret='false'; |
|
40 | + } |
|
41 | + if (isset($all_data["handle"])) { |
|
42 | + $handle=$all_data["handle"]; |
|
43 | + } else { |
|
44 | + $handle="default"; |
|
45 | + } |
|
26 | 46 | |
27 | 47 | $datapost=curl_init(); |
28 | 48 | $headers=array("Expect:"); |
@@ -54,12 +74,36 @@ discard block |
||
54 | 74 | |
55 | 75 | public function grab_page($all_data) |
56 | 76 | { |
57 | - if (isset($all_data["site"])) $site=$all_data["site"]; else throw new Exception("site is not exist in all_data"); |
|
58 | - if (isset($all_data["oj"])) $oj=$all_data["oj"]; else throw new Exception("oj is not exist in all_data"); |
|
59 | - if (isset($all_data["headers"])) $headers=$all_data["headers"]; else $headers=[]; |
|
60 | - if (isset($all_data["handle"])) $handle=$all_data["handle"]; else $handle="default"; |
|
61 | - if (isset($all_data["follow"])) $follow=$all_data["follow"]; else $follow=false; |
|
62 | - if (isset($all_data["vcid"])) $vcid=$all_data["vcid"]."_"; else $vcid=""; |
|
77 | + if (isset($all_data["site"])) { |
|
78 | + $site=$all_data["site"]; |
|
79 | + } else { |
|
80 | + throw new Exception("site is not exist in all_data"); |
|
81 | + } |
|
82 | + if (isset($all_data["oj"])) { |
|
83 | + $oj=$all_data["oj"]; |
|
84 | + } else { |
|
85 | + throw new Exception("oj is not exist in all_data"); |
|
86 | + } |
|
87 | + if (isset($all_data["headers"])) { |
|
88 | + $headers=$all_data["headers"]; |
|
89 | + } else { |
|
90 | + $headers=[]; |
|
91 | + } |
|
92 | + if (isset($all_data["handle"])) { |
|
93 | + $handle=$all_data["handle"]; |
|
94 | + } else { |
|
95 | + $handle="default"; |
|
96 | + } |
|
97 | + if (isset($all_data["follow"])) { |
|
98 | + $follow=$all_data["follow"]; |
|
99 | + } else { |
|
100 | + $follow=false; |
|
101 | + } |
|
102 | + if (isset($all_data["vcid"])) { |
|
103 | + $vcid=$all_data["vcid"]."_"; |
|
104 | + } else { |
|
105 | + $vcid=""; |
|
106 | + } |
|
63 | 107 | |
64 | 108 | $handle=urlencode($handle); |
65 | 109 | |
@@ -86,16 +130,56 @@ discard block |
||
86 | 130 | |
87 | 131 | public function post_data($all_data) |
88 | 132 | { |
89 | - if (isset($all_data["site"])) $site=$all_data["site"]; else throw new Exception("site is not exist in all_data"); |
|
90 | - if (isset($all_data["data"])) $data=$all_data["data"]; else throw new Exception("data is not exist in all_data"); |
|
91 | - if (isset($all_data["oj"])) $oj=$all_data["oj"]; else throw new Exception("oj is not exist in all_data"); |
|
92 | - if (isset($all_data["ret"])) $ret=$all_data["ret"]; else $ret=false; |
|
93 | - if (isset($all_data["follow"])) $follow=$all_data["follow"]; else $follow=true; |
|
94 | - if (isset($all_data["returnHeader"])) $returnHeader=$all_data["returnHeader"]; else $returnHeader=true; |
|
95 | - if (isset($all_data["postJson"])) $postJson=$all_data["postJson"]; else $postJson=false; |
|
96 | - if (isset($all_data["extraHeaders"])) $extraHeaders=$all_data["extraHeaders"]; else $extraHeaders=[]; |
|
97 | - if (isset($all_data["handle"])) $handle=$all_data["handle"]; else $handle="default"; |
|
98 | - if (isset($all_data["vcid"])) $vcid=$all_data["vcid"]."_"; else $vcid=""; |
|
133 | + if (isset($all_data["site"])) { |
|
134 | + $site=$all_data["site"]; |
|
135 | + } else { |
|
136 | + throw new Exception("site is not exist in all_data"); |
|
137 | + } |
|
138 | + if (isset($all_data["data"])) { |
|
139 | + $data=$all_data["data"]; |
|
140 | + } else { |
|
141 | + throw new Exception("data is not exist in all_data"); |
|
142 | + } |
|
143 | + if (isset($all_data["oj"])) { |
|
144 | + $oj=$all_data["oj"]; |
|
145 | + } else { |
|
146 | + throw new Exception("oj is not exist in all_data"); |
|
147 | + } |
|
148 | + if (isset($all_data["ret"])) { |
|
149 | + $ret=$all_data["ret"]; |
|
150 | + } else { |
|
151 | + $ret=false; |
|
152 | + } |
|
153 | + if (isset($all_data["follow"])) { |
|
154 | + $follow=$all_data["follow"]; |
|
155 | + } else { |
|
156 | + $follow=true; |
|
157 | + } |
|
158 | + if (isset($all_data["returnHeader"])) { |
|
159 | + $returnHeader=$all_data["returnHeader"]; |
|
160 | + } else { |
|
161 | + $returnHeader=true; |
|
162 | + } |
|
163 | + if (isset($all_data["postJson"])) { |
|
164 | + $postJson=$all_data["postJson"]; |
|
165 | + } else { |
|
166 | + $postJson=false; |
|
167 | + } |
|
168 | + if (isset($all_data["extraHeaders"])) { |
|
169 | + $extraHeaders=$all_data["extraHeaders"]; |
|
170 | + } else { |
|
171 | + $extraHeaders=[]; |
|
172 | + } |
|
173 | + if (isset($all_data["handle"])) { |
|
174 | + $handle=$all_data["handle"]; |
|
175 | + } else { |
|
176 | + $handle="default"; |
|
177 | + } |
|
178 | + if (isset($all_data["vcid"])) { |
|
179 | + $vcid=$all_data["vcid"]."_"; |
|
180 | + } else { |
|
181 | + $vcid=""; |
|
182 | + } |
|
99 | 183 | |
100 | 184 | $handle=urlencode($handle); |
101 | 185 |
@@ -48,16 +48,16 @@ |
||
48 | 48 | */ |
49 | 49 | protected function validator(array $data) |
50 | 50 | { |
51 | - $validator = [ |
|
51 | + $validator=[ |
|
52 | 52 | 'name' => ['required', 'string', 'max:16', 'unique:users'], |
53 | 53 | 'email' => ['required', 'string', 'email', 'max:255', 'unique:users', 'allowed_email_domain'], |
54 | 54 | 'password' => ['required', 'string', 'min:8', 'confirmed'], |
55 | 55 | 'agreement' => ['required'], |
56 | 56 | ]; |
57 | - $messages = []; |
|
58 | - if(config('function.password.strong')) { |
|
59 | - $validator['password'][] = 'regex:/^(?![A-Za-z0-9]+$)(?![a-z0-9\\W]+$)(?![A-Za-z\\W]+$)(?![A-Z0-9\\W]+$)[a-zA-Z0-9\\W]{8,}$/'; |
|
60 | - $messages['password.regex'] = __('validation.password.strong'); |
|
57 | + $messages=[]; |
|
58 | + if (config('function.password.strong')) { |
|
59 | + $validator['password'][]='regex:/^(?![A-Za-z0-9]+$)(?![a-z0-9\\W]+$)(?![A-Za-z\\W]+$)(?![A-Z0-9\\W]+$)[a-zA-Z0-9\\W]{8,}$/'; |
|
60 | + $messages['password.regex']=__('validation.password.strong'); |
|
61 | 61 | } |
62 | 62 | return Validator::make($data, $validator, $messages); |
63 | 63 | } |
@@ -179,7 +179,7 @@ discard block |
||
179 | 179 | if ($clearance<1) { |
180 | 180 | return Redirect::route('group.detail', ['gcode' => $gcode]); |
181 | 181 | } |
182 | - $homeworkInfo = GroupHomework::where(['id' => $homework_id, 'group_id' => $basic_info['gid']])->first(); |
|
182 | + $homeworkInfo=GroupHomework::where(['id' => $homework_id, 'group_id' => $basic_info['gid']])->first(); |
|
183 | 183 | if (blank($homeworkInfo)) { |
184 | 184 | return Redirect::route('group.detail', ['gcode' => $gcode]); |
185 | 185 | } |
@@ -195,13 +195,13 @@ discard block |
||
195 | 195 | |
196 | 196 | public function homeworkStatistics($gcode, $homework_id) |
197 | 197 | { |
198 | - $groupModel = new GroupModel(); |
|
199 | - $basic_info = $groupModel->details($gcode); |
|
200 | - $clearance = $groupModel->judgeClearance($basic_info["gid"], Auth::user()->id); |
|
201 | - if ($clearance < 2) { |
|
198 | + $groupModel=new GroupModel(); |
|
199 | + $basic_info=$groupModel->details($gcode); |
|
200 | + $clearance=$groupModel->judgeClearance($basic_info["gid"], Auth::user()->id); |
|
201 | + if ($clearance<2) { |
|
202 | 202 | return Redirect::route('group.detail', ['gcode' => $gcode]); |
203 | 203 | } |
204 | - $homeworkInfo = GroupHomework::where(['id' => $homework_id, 'group_id' => $basic_info['gid']])->first(); |
|
204 | + $homeworkInfo=GroupHomework::where(['id' => $homework_id, 'group_id' => $basic_info['gid']])->first(); |
|
205 | 205 | if (blank($homeworkInfo)) { |
206 | 206 | return Redirect::route('group.detail', ['gcode' => $gcode]); |
207 | 207 | } |
@@ -84,7 +84,7 @@ |
||
84 | 84 | public function problemExists(Request $request) |
85 | 85 | { |
86 | 86 | $request->validate(["pcode" => "required|string|max:100"]); |
87 | - $problem = Problem::where('pcode', $request->pcode)->first(); |
|
87 | + $problem=Problem::where('pcode', $request->pcode)->first(); |
|
88 | 88 | if (filled($problem)) { |
89 | 89 | return ResponseModel::success(200, null, $problem->only(["pcode", "title"])); |
90 | 90 | } else { |
@@ -319,9 +319,9 @@ discard block |
||
319 | 319 | public function createHomework(Request $request) |
320 | 320 | { |
321 | 321 | try { |
322 | - $all = $request->all(); |
|
323 | - $all['currently_at'] = strtotime('now'); |
|
324 | - $validator = Validator::make($all, [ |
|
322 | + $all=$request->all(); |
|
323 | + $all['currently_at']=strtotime('now'); |
|
324 | + $validator=Validator::make($all, [ |
|
325 | 325 | 'title' => 'required|string|min:1|max:100', |
326 | 326 | 'description' => 'required|string|min:1|max:65535', |
327 | 327 | 'ended_at' => 'required|date|after:currently_at', |
@@ -340,29 +340,29 @@ discard block |
||
340 | 340 | throw new Exception($validator->errors()->first()); |
341 | 341 | } |
342 | 342 | |
343 | - if (count($request->problems) > 26) { |
|
343 | + if (count($request->problems)>26) { |
|
344 | 344 | throw new Exception('Please include no more than 26 problems.'); |
345 | 345 | } |
346 | 346 | |
347 | - if (count($request->problems) < 1) { |
|
347 | + if (count($request->problems)<1) { |
|
348 | 348 | throw new Exception('Please include at least one problem.'); |
349 | 349 | } |
350 | 350 | |
351 | - $proceedProblems = $request->problems; |
|
352 | - $proceedProblemCodes = []; |
|
351 | + $proceedProblems=$request->problems; |
|
352 | + $proceedProblemCodes=[]; |
|
353 | 353 | |
354 | 354 | foreach ($proceedProblems as &$problem) { |
355 | 355 | if (!is_array($problem)) { |
356 | 356 | throw new Exception('Each problem object must be an array.'); |
357 | 357 | } |
358 | 358 | |
359 | - $problem['pcode'] = mb_strtoupper(trim($problem['pcode'])); |
|
359 | + $problem['pcode']=mb_strtoupper(trim($problem['pcode'])); |
|
360 | 360 | |
361 | - if(array_search($problem['pcode'], $proceedProblemCodes) !== false) { |
|
361 | + if (array_search($problem['pcode'], $proceedProblemCodes)!==false) { |
|
362 | 362 | throw new Exception("Duplicate Problem"); |
363 | 363 | } |
364 | 364 | |
365 | - $validator = Validator::make($problem, [ |
|
365 | + $validator=Validator::make($problem, [ |
|
366 | 366 | 'pcode' => 'required|string|min:1|max:100', |
367 | 367 | // 'alias' => 'required|string|min:0|max:100|nullable', |
368 | 368 | // 'points' => 'required|integer|gte:1', |
@@ -376,17 +376,17 @@ discard block |
||
376 | 376 | throw new Exception($validator->errors()->first()); |
377 | 377 | } |
378 | 378 | |
379 | - $proceedProblemCodes[] = $problem['pcode']; |
|
379 | + $proceedProblemCodes[]=$problem['pcode']; |
|
380 | 380 | } |
381 | 381 | |
382 | 382 | unset($problem); |
383 | 383 | |
384 | - $problemsDict = Problem::whereIn('pcode', $proceedProblemCodes)->select('pid', 'pcode')->get()->pluck('pid', 'pcode'); |
|
384 | + $problemsDict=Problem::whereIn('pcode', $proceedProblemCodes)->select('pid', 'pcode')->get()->pluck('pid', 'pcode'); |
|
385 | 385 | |
386 | 386 | try { |
387 | - foreach($proceedProblems as &$proceedProblem) { |
|
388 | - $proceedProblem['pid'] = $problemsDict[$proceedProblem['pcode']]; |
|
389 | - if(blank($proceedProblem['pid'])) { |
|
387 | + foreach ($proceedProblems as &$proceedProblem) { |
|
388 | + $proceedProblem['pid']=$problemsDict[$proceedProblem['pcode']]; |
|
389 | + if (blank($proceedProblem['pid'])) { |
|
390 | 390 | throw new Exception(); |
391 | 391 | } |
392 | 392 | } |
@@ -405,14 +405,14 @@ discard block |
||
405 | 405 | ], 422); |
406 | 406 | } |
407 | 407 | |
408 | - $groupModel = new GroupModel(); |
|
409 | - $clearance = $groupModel->judgeClearance($request->gid, Auth::user()->id); |
|
410 | - if ($clearance < 2) { |
|
408 | + $groupModel=new GroupModel(); |
|
409 | + $clearance=$groupModel->judgeClearance($request->gid, Auth::user()->id); |
|
410 | + if ($clearance<2) { |
|
411 | 411 | return ResponseModel::err(2001); |
412 | 412 | } |
413 | 413 | |
414 | 414 | try { |
415 | - $homeworkID = Group::find($request->gid)->addHomework($request->title, $request->description, Carbon::parse($request->ended_at), $proceedProblems); |
|
415 | + $homeworkID=Group::find($request->gid)->addHomework($request->title, $request->description, Carbon::parse($request->ended_at), $proceedProblems); |
|
416 | 416 | } catch (Exception $e) { |
417 | 417 | return ResponseModel::err(7009); |
418 | 418 | } |
@@ -10,7 +10,7 @@ |
||
10 | 10 | { |
11 | 11 | use HasFactory; |
12 | 12 | |
13 | - protected $with = ['problem']; |
|
13 | + protected $with=['problem']; |
|
14 | 14 | |
15 | 15 | public function homework() |
16 | 16 | { |
@@ -30,17 +30,17 @@ discard block |
||
30 | 30 | |
31 | 31 | public function getStatisticsAttribute() |
32 | 32 | { |
33 | - $cachedStatistics = Cache::tags(['homework', 'statistics'])->get($this->id); |
|
33 | + $cachedStatistics=Cache::tags(['homework', 'statistics'])->get($this->id); |
|
34 | 34 | |
35 | 35 | if (blank($cachedStatistics)) { |
36 | - $cachedStatistics = $this->cacheStatistics(); |
|
36 | + $cachedStatistics=$this->cacheStatistics(); |
|
37 | 37 | } |
38 | 38 | |
39 | - if ($cachedStatistics === false) { |
|
39 | + if ($cachedStatistics===false) { |
|
40 | 40 | return null; |
41 | 41 | } |
42 | 42 | |
43 | - $cachedStatistics['timestamp'] = Carbon::createFromTimestamp($cachedStatistics['timestamp']); |
|
43 | + $cachedStatistics['timestamp']=Carbon::createFromTimestamp($cachedStatistics['timestamp']); |
|
44 | 44 | |
45 | 45 | return $cachedStatistics; |
46 | 46 | } |
@@ -48,25 +48,25 @@ discard block |
||
48 | 48 | public function cacheStatistics() |
49 | 49 | { |
50 | 50 | try { |
51 | - $statistics = []; |
|
52 | - $homeworkProblems = $this->problems->sortBy('order_index'); |
|
53 | - $users = $this->group->members()->where('role', '>=', 1)->get(); |
|
54 | - $userIDArr = $users->pluck('uid'); |
|
55 | - $defaultVerdict = []; |
|
51 | + $statistics=[]; |
|
52 | + $homeworkProblems=$this->problems->sortBy('order_index'); |
|
53 | + $users=$this->group->members()->where('role', '>=', 1)->get(); |
|
54 | + $userIDArr=$users->pluck('uid'); |
|
55 | + $defaultVerdict=[]; |
|
56 | 56 | |
57 | 57 | foreach ($homeworkProblems as $homeworkProblem) { |
58 | - $statistics['problems'][] = [ |
|
58 | + $statistics['problems'][]=[ |
|
59 | 59 | 'pid' => $homeworkProblem->problem_id, |
60 | 60 | 'readable_name' => $homeworkProblem->problem->readable_name, |
61 | 61 | ]; |
62 | - $defaultVerdict[$homeworkProblem->problem_id] = [ |
|
62 | + $defaultVerdict[$homeworkProblem->problem_id]=[ |
|
63 | 63 | "icon" => "checkbox-blank-circle-outline", |
64 | 64 | "color" => "wemd-grey-text" |
65 | 65 | ]; |
66 | 66 | } |
67 | 67 | |
68 | 68 | foreach ($users as $user) { |
69 | - $statistics['data'][$user->uid] = [ |
|
69 | + $statistics['data'][$user->uid]=[ |
|
70 | 70 | 'name' => $user->user->name, |
71 | 71 | 'nick_name' => blank($user->nick_name) ? null : $user->nick_name, |
72 | 72 | 'solved' => 0, |
@@ -75,44 +75,44 @@ discard block |
||
75 | 75 | ]; |
76 | 76 | } |
77 | 77 | |
78 | - $endedAt = Carbon::parse($this->ended_at); |
|
78 | + $endedAt=Carbon::parse($this->ended_at); |
|
79 | 79 | |
80 | 80 | foreach ($homeworkProblems as $homeworkProblem) { |
81 | - $userProbIDArr = []; |
|
81 | + $userProbIDArr=[]; |
|
82 | 82 | |
83 | 83 | foreach ($homeworkProblem->problem->users_latest_submission($userIDArr->diff($userProbIDArr), null, $endedAt, ['Accepted'])->get() as $acceptedRecord) { |
84 | - $statistics['data'][$acceptedRecord['uid']]['verdict'][$homeworkProblem->problem_id] = [ |
|
84 | + $statistics['data'][$acceptedRecord['uid']]['verdict'][$homeworkProblem->problem_id]=[ |
|
85 | 85 | "icon" => "checkbox-blank-circle", |
86 | 86 | "color" => $acceptedRecord['color'] |
87 | 87 | ]; |
88 | 88 | $statistics['data'][$acceptedRecord['uid']]['solved']++; |
89 | - $userProbIDArr[] = $acceptedRecord['uid']; |
|
89 | + $userProbIDArr[]=$acceptedRecord['uid']; |
|
90 | 90 | } |
91 | 91 | |
92 | 92 | foreach ($homeworkProblem->problem->users_latest_submission($userIDArr->diff($userProbIDArr), null, $endedAt, ['Partially Accepted'])->get() as $acceptedRecord) { |
93 | - $statistics['data'][$acceptedRecord['uid']]['verdict'][$homeworkProblem->problem_id] = [ |
|
93 | + $statistics['data'][$acceptedRecord['uid']]['verdict'][$homeworkProblem->problem_id]=[ |
|
94 | 94 | "icon" => "cisco-webex", |
95 | 95 | "color" => $acceptedRecord['color'] |
96 | 96 | ]; |
97 | 97 | $statistics['data'][$acceptedRecord['uid']]['attempted']++; |
98 | - $userProbIDArr[] = $acceptedRecord['uid']; |
|
98 | + $userProbIDArr[]=$acceptedRecord['uid']; |
|
99 | 99 | } |
100 | 100 | |
101 | 101 | foreach ($homeworkProblem->problem->users_latest_submission($userIDArr->diff($userProbIDArr), null, $endedAt)->get() as $acceptedRecord) { |
102 | - $statistics['data'][$acceptedRecord['uid']]['verdict'][$homeworkProblem->problem_id] = [ |
|
102 | + $statistics['data'][$acceptedRecord['uid']]['verdict'][$homeworkProblem->problem_id]=[ |
|
103 | 103 | "icon" => "cisco-webex", |
104 | 104 | "color" => $acceptedRecord['color'] |
105 | 105 | ]; |
106 | 106 | $statistics['data'][$acceptedRecord['uid']]['attempted']++; |
107 | - $userProbIDArr[] = $acceptedRecord['uid']; |
|
107 | + $userProbIDArr[]=$acceptedRecord['uid']; |
|
108 | 108 | } |
109 | 109 | } |
110 | 110 | |
111 | - usort($statistics['data'], function ($a, $b) { |
|
112 | - return $b["solved"] == $a["solved"] ? $b["attempted"] <=> $a["attempted"] : $b["solved"] <=> $a["solved"]; |
|
111 | + usort($statistics['data'], function($a, $b) { |
|
112 | + return $b["solved"]==$a["solved"] ? $b["attempted"] <=> $a["attempted"] : $b["solved"] <=> $a["solved"]; |
|
113 | 113 | }); |
114 | 114 | |
115 | - $statistics['timestamp'] = time(); |
|
115 | + $statistics['timestamp']=time(); |
|
116 | 116 | Cache::tags(['homework', 'statistics'])->put($this->id, $statistics, 360); |
117 | 117 | return $statistics; |
118 | 118 | } catch (Exception $e) { |
@@ -66,21 +66,21 @@ |
||
66 | 66 | |
67 | 67 | // Create Homework Itself |
68 | 68 | |
69 | - $newHomework = new GroupHomework(); |
|
69 | + $newHomework=new GroupHomework(); |
|
70 | 70 | |
71 | - $newHomework->title = $title; |
|
72 | - $newHomework->description = $description; |
|
73 | - $newHomework->ended_at = $endedAt; |
|
74 | - $newHomework->is_simple = 1; |
|
71 | + $newHomework->title=$title; |
|
72 | + $newHomework->description=$description; |
|
73 | + $newHomework->ended_at=$endedAt; |
|
74 | + $newHomework->is_simple=1; |
|
75 | 75 | $this->homework()->save($newHomework); |
76 | 76 | |
77 | 77 | // Created Related Problem List |
78 | 78 | |
79 | - $problemIndex = 1; |
|
79 | + $problemIndex=1; |
|
80 | 80 | foreach ($problems as $problem) { |
81 | - $newProblem = new GroupHomeworkProblem(); |
|
82 | - $newProblem->problem_id = $problem['pid']; |
|
83 | - $newProblem->order_index = $problemIndex++; |
|
81 | + $newProblem=new GroupHomeworkProblem(); |
|
82 | + $newProblem->problem_id=$problem['pid']; |
|
83 | + $newProblem->order_index=$problemIndex++; |
|
84 | 84 | $newHomework->problems()->save($newProblem); |
85 | 85 | } |
86 | 86 |