@@ -85,12 +85,12 @@ discard block |
||
85 | 85 | * |
86 | 86 | * @return Response |
87 | 87 | */ |
88 | - public function analysis($gcode){ |
|
89 | - $groupModel = new GroupModel(); |
|
88 | + public function analysis($gcode) { |
|
89 | + $groupModel=new GroupModel(); |
|
90 | 90 | $basic_info=$groupModel->details($gcode); |
91 | 91 | $clearance=$groupModel->judgeClearance($basic_info["gid"], Auth::user()->id); |
92 | - if($clearance < 1) return Redirect::route('group.detail',['gcode' => $gcode]); |
|
93 | - $group_info = $groupModel->details($gcode); |
|
92 | + if ($clearance<1) return Redirect::route('group.detail', ['gcode' => $gcode]); |
|
93 | + $group_info=$groupModel->details($gcode); |
|
94 | 94 | return view('group.settings.analysis', [ |
95 | 95 | 'page_title'=>"Group Analysis", |
96 | 96 | 'site_title'=>"NOJ", |
@@ -100,13 +100,13 @@ discard block |
||
100 | 100 | ]); |
101 | 101 | } |
102 | 102 | |
103 | - public function analysisDownload($gcode,Request $request){ |
|
104 | - $all_data = $request->all(); |
|
105 | - $groupModel = new GroupModel(); |
|
106 | - $group_info = $groupModel->details($gcode); |
|
107 | - $mode = $all_data['mode'] ?? 'contest'; |
|
108 | - if($mode == 'contest'){ |
|
109 | - $data = $groupModel->groupMemberPracticeContestStat($group_info['gid']); |
|
103 | + public function analysisDownload($gcode, Request $request) { |
|
104 | + $all_data=$request->all(); |
|
105 | + $groupModel=new GroupModel(); |
|
106 | + $group_info=$groupModel->details($gcode); |
|
107 | + $mode=$all_data['mode'] ?? 'contest'; |
|
108 | + if ($mode=='contest') { |
|
109 | + $data=$groupModel->groupMemberPracticeContestStat($group_info['gid']); |
|
110 | 110 | return Excel::download( |
111 | 111 | new GroupAnalysisExport( |
112 | 112 | [ |
@@ -119,10 +119,10 @@ discard block |
||
119 | 119 | 'percent' => $all_data['percent'] ?? false, |
120 | 120 | ] |
121 | 121 | ), |
122 | - $gcode . '_Group_Contest_Analysis.xlsx' |
|
122 | + $gcode.'_Group_Contest_Analysis.xlsx' |
|
123 | 123 | ); |
124 | - }else{ |
|
125 | - $data = $groupModel->groupMemberPracticeTagStat($group_info['gid']); |
|
124 | + } else { |
|
125 | + $data=$groupModel->groupMemberPracticeTagStat($group_info['gid']); |
|
126 | 126 | return Excel::download( |
127 | 127 | new GroupAnalysisExport( |
128 | 128 | [ |
@@ -135,7 +135,7 @@ discard block |
||
135 | 135 | 'percent' => $all_data['percent'] ?? false, |
136 | 136 | ] |
137 | 137 | ), |
138 | - $gcode . '_Group_Tag_Analysis.xlsx' |
|
138 | + $gcode.'_Group_Tag_Analysis.xlsx' |
|
139 | 139 | ); |
140 | 140 | } |
141 | 141 | } |
@@ -21,7 +21,7 @@ discard block |
||
21 | 21 | */ |
22 | 22 | public function settings($gcode) |
23 | 23 | { |
24 | - return Redirect::route('group.settings.general', ['gcode' => $gcode]);; |
|
24 | + return Redirect::route('group.settings.general', ['gcode' => $gcode]); ; |
|
25 | 25 | } |
26 | 26 | |
27 | 27 | /** |
@@ -31,7 +31,7 @@ discard block |
||
31 | 31 | */ |
32 | 32 | public function settingsReturn($gcode) |
33 | 33 | { |
34 | - return Redirect::route('group.detail', ['gcode' => $gcode]);; |
|
34 | + return Redirect::route('group.detail', ['gcode' => $gcode]); ; |
|
35 | 35 | } |
36 | 36 | |
37 | 37 | /** |
@@ -60,10 +60,10 @@ discard block |
||
60 | 60 | * |
61 | 61 | * @return Response |
62 | 62 | */ |
63 | - public function problems($gcode){ |
|
64 | - $groupModel = new GroupModel(); |
|
65 | - $group_info = $groupModel->details($gcode); |
|
66 | - $problems = $groupModel->problems($group_info['gid']); |
|
63 | + public function problems($gcode) { |
|
64 | + $groupModel=new GroupModel(); |
|
65 | + $group_info=$groupModel->details($gcode); |
|
66 | + $problems=$groupModel->problems($group_info['gid']); |
|
67 | 67 | $basic_info=$groupModel->details($gcode); |
68 | 68 | return view('group.settings.problems', [ |
69 | 69 | 'page_title'=>"Group Problems", |
@@ -17,25 +17,25 @@ |
||
17 | 17 | public function handle($request, Closure $next) |
18 | 18 | { |
19 | 19 | //check login |
20 | - if(!Auth::check()){ |
|
20 | + if (!Auth::check()) { |
|
21 | 21 | return $next($request); |
22 | 22 | } |
23 | - $user = Auth::user(); |
|
24 | - $banned = $user->banneds()->orderBy('removed_at', 'desc')->first(); |
|
23 | + $user=Auth::user(); |
|
24 | + $banned=$user->banneds()->orderBy('removed_at', 'desc')->first(); |
|
25 | 25 | //check if there are any banned records |
26 | - if(empty($banned)) { |
|
26 | + if (empty($banned)) { |
|
27 | 27 | return $next($request); |
28 | 28 | } |
29 | 29 | //check the time of the last record |
30 | - if(strtotime($banned->removed_at) <= time()){ |
|
30 | + if (strtotime($banned->removed_at)<=time()) { |
|
31 | 31 | return $next($request); |
32 | 32 | } |
33 | 33 | //return error page |
34 | - if($request->method() == 'GET'){ |
|
35 | - return response()->view('errors.451',[ |
|
34 | + if ($request->method()=='GET') { |
|
35 | + return response()->view('errors.451', [ |
|
36 | 36 | 'description' => "Your account is currently blocked and will remain so until {$banned->removed_at}. Here's why: {$banned->reason}", |
37 | 37 | ]); |
38 | - }else{ |
|
38 | + } else { |
|
39 | 39 | return response()->json([ |
40 | 40 | 'ret' => 451, |
41 | 41 | 'desc' => 'Unavailable For Legal Reasons', |
@@ -17,12 +17,12 @@ |
||
17 | 17 | */ |
18 | 18 | public function handle($request, Closure $next) |
19 | 19 | { |
20 | - $gcode = $request->gcode; |
|
21 | - $group = Group::where('gcode',$gcode)->first(); |
|
22 | - $banneds = $group->banneds()->where('removed_at','>',date('Y-m-d H:i:s'))->first(); |
|
23 | - $user = Auth::user(); |
|
24 | - if(!empty($banneds) && $user->id != $group->leader->id) { |
|
25 | - return response()->view('errors.451',[ |
|
20 | + $gcode=$request->gcode; |
|
21 | + $group=Group::where('gcode', $gcode)->first(); |
|
22 | + $banneds=$group->banneds()->where('removed_at', '>', date('Y-m-d H:i:s'))->first(); |
|
23 | + $user=Auth::user(); |
|
24 | + if (!empty($banneds) && $user->id!=$group->leader->id) { |
|
25 | + return response()->view('errors.451', [ |
|
26 | 26 | 'description' => 'This group is currently banned. Please contact the group administrator.' |
27 | 27 | ]); |
28 | 28 | } |
@@ -16,11 +16,11 @@ |
||
16 | 16 | */ |
17 | 17 | public function handle($request, Closure $next) |
18 | 18 | { |
19 | - $gcode = $request->gcode; |
|
20 | - $group = Group::where('gcode',$gcode)->first(); |
|
21 | - if(!empty($group)){ |
|
19 | + $gcode=$request->gcode; |
|
20 | + $group=Group::where('gcode', $gcode)->first(); |
|
21 | + if (!empty($group)) { |
|
22 | 22 | return $next($request); |
23 | - }else{ |
|
23 | + } else { |
|
24 | 24 | return redirect('/group'); |
25 | 25 | } |
26 | 26 |
@@ -23,7 +23,7 @@ discard block |
||
23 | 23 | * |
24 | 24 | * @var string |
25 | 25 | */ |
26 | - protected $title = 'Abuses'; |
|
26 | + protected $title='Abuses'; |
|
27 | 27 | |
28 | 28 | /** |
29 | 29 | * Make a grid builder. |
@@ -32,7 +32,7 @@ discard block |
||
32 | 32 | */ |
33 | 33 | protected function grid() |
34 | 34 | { |
35 | - $grid = new Grid(new Abuse); |
|
35 | + $grid=new Grid(new Abuse); |
|
36 | 36 | |
37 | 37 | $grid->column('id', __('Id')); |
38 | 38 | $grid->column('title', __('Title')); |
@@ -58,7 +58,7 @@ discard block |
||
58 | 58 | */ |
59 | 59 | protected function detail($id) |
60 | 60 | { |
61 | - $show = new Show(Abuse::findOrFail($id)); |
|
61 | + $show=new Show(Abuse::findOrFail($id)); |
|
62 | 62 | |
63 | 63 | $show->field('id', __('Id')); |
64 | 64 | $show->field('title', __('Title')); |
@@ -81,7 +81,7 @@ discard block |
||
81 | 81 | */ |
82 | 82 | protected function form() |
83 | 83 | { |
84 | - $form = new Form(new Abuse); |
|
84 | + $form=new Form(new Abuse); |
|
85 | 85 | |
86 | 86 | $form->text('title', __('Title')); |
87 | 87 | $form->number('cause', __('Cause')); |
@@ -92,23 +92,23 @@ discard block |
||
92 | 92 | |
93 | 93 | $form->ignore(['created_at']); |
94 | 94 | |
95 | - $form->saving(function (Form $form) { |
|
96 | - $abuse = $form->model(); |
|
95 | + $form->saving(function(Form $form) { |
|
96 | + $abuse=$form->model(); |
|
97 | 97 | //get gategory and subject id |
98 | - $regex = '/^([A-Za-z]+) #(\d+)/'; |
|
99 | - $matches = []; |
|
100 | - preg_match($regex,$abuse->title,$matches); |
|
101 | - $category = array_search(strtolower($matches[1]),Abuse::$supportCategory); |
|
102 | - $subject_id = (int)$matches[2]; |
|
103 | - switch($abuse->category) { |
|
98 | + $regex='/^([A-Za-z]+) #(\d+)/'; |
|
99 | + $matches=[]; |
|
100 | + preg_match($regex, $abuse->title, $matches); |
|
101 | + $category=array_search(strtolower($matches[1]), Abuse::$supportCategory); |
|
102 | + $subject_id=(int) $matches[2]; |
|
103 | + switch ($abuse->category) { |
|
104 | 104 | case 0: |
105 | - $gid = $subject_id; |
|
106 | - $group = Group::find($gid); |
|
107 | - if(empty($group)) { |
|
108 | - return ; |
|
105 | + $gid=$subject_id; |
|
106 | + $group=Group::find($gid); |
|
107 | + if (empty($group)) { |
|
108 | + return; |
|
109 | 109 | } |
110 | - if($form->audit) { |
|
111 | - $ban_time = request()->created_at; |
|
110 | + if ($form->audit) { |
|
111 | + $ban_time=request()->created_at; |
|
112 | 112 | sendMessage([ |
113 | 113 | 'sender' => 1, |
114 | 114 | 'receiver' => $abuse->user_id, |
@@ -128,8 +128,8 @@ discard block |
||
128 | 128 | 'reason' => $abuse->supplement, |
129 | 129 | 'removed_at' => $ban_time |
130 | 130 | ]); |
131 | - return ; |
|
132 | - }else{ |
|
131 | + return; |
|
132 | + } else { |
|
133 | 133 | sendMessage([ |
134 | 134 | 'sender' => 1, |
135 | 135 | 'receiver' => $abuse->user_id, |
@@ -137,11 +137,11 @@ discard block |
||
137 | 137 | 'content' => "Hi, Dear **{$abuse->user->name}**,\n\n We have checked your Abuse report about group **[{$group->name}]({$group->link})**.\n\n However, we regret to say that the information you submitted is not sufficient for us to take action.\n\n Of course, we will continue to follow up the investigation.\n\n Thank you for your contribution to our community environment.\n\n Sincerely, NOJ" |
138 | 138 | ]); |
139 | 139 | $abuse->delete(); |
140 | - return ; |
|
140 | + return; |
|
141 | 141 | } |
142 | 142 | return; |
143 | 143 | case 1: |
144 | - $ban_time = request()->created_at; |
|
144 | + $ban_time=request()->created_at; |
|
145 | 145 | UserBanned::create([ |
146 | 146 | 'abuse_id' => $abuse->id, |
147 | 147 | 'user_id' => $subject_id, |
@@ -170,15 +170,15 @@ discard block |
||
170 | 170 | |
171 | 171 | protected function check_form() |
172 | 172 | { |
173 | - $form = new Form(new Abuse); |
|
174 | - $form->display('id',__('Abuse id')); |
|
173 | + $form=new Form(new Abuse); |
|
174 | + $form->display('id', __('Abuse id')); |
|
175 | 175 | $form->display('title', __('Title')); |
176 | 176 | $form->display('cause', __('Cause')); |
177 | 177 | $form->display('supplement', __('Supplement')); |
178 | 178 | $form->display('link', __('Group Link')); |
179 | 179 | $form->display('user_id', __('Submitter')); |
180 | - $form->radio('audit','result')->options(['0' => 'Reject', '1'=> 'Pass']); |
|
181 | - $form->datetime('created_at','ban until'); |
|
180 | + $form->radio('audit', 'result')->options(['0' => 'Reject', '1'=> 'Pass']); |
|
181 | + $form->datetime('created_at', 'ban until'); |
|
182 | 182 | |
183 | 183 | return $form; |
184 | 184 | } |
@@ -20,7 +20,7 @@ |
||
20 | 20 | $router->resource('groups', GroupController::class); |
21 | 21 | $router->resource('abuses', AbuseController::class); |
22 | 22 | |
23 | - Route::group(['prefix' => 'babel'], function (Router $router) { |
|
23 | + Route::group(['prefix' => 'babel'], function(Router $router) { |
|
24 | 24 | $router->get('/', 'BabelController@index')->name('admin.babel.index'); |
25 | 25 | $router->get('installed', 'BabelController@installed')->name('admin.babel.installed'); |
26 | 26 | $router->get('marketspace', 'BabelController@marketspace')->name('admin.babel.marketspace'); |
@@ -17,7 +17,7 @@ discard block |
||
17 | 17 | * |
18 | 18 | * @var string |
19 | 19 | */ |
20 | - public $title = 'Import'; |
|
20 | + public $title='Import'; |
|
21 | 21 | |
22 | 22 | /** |
23 | 23 | * Handle the form request. |
@@ -28,29 +28,29 @@ discard block |
||
28 | 28 | */ |
29 | 29 | public function handle(Request $request) |
30 | 30 | { |
31 | - $err = function ($msg) { |
|
32 | - $error = new MessageBag([ |
|
31 | + $err=function($msg) { |
|
32 | + $error=new MessageBag([ |
|
33 | 33 | 'title' => 'POEM parse failed.', |
34 | 34 | 'message' => $msg, |
35 | 35 | ]); |
36 | 36 | return back()->with(compact('error')); |
37 | 37 | }; |
38 | - $success_message = ''; |
|
38 | + $success_message=''; |
|
39 | 39 | |
40 | - $file = $request->file('Files'); |
|
41 | - if(!$file->isValid()){ |
|
40 | + $file=$request->file('Files'); |
|
41 | + if (!$file->isValid()) { |
|
42 | 42 | $err('Invalid POEM files'); |
43 | 43 | } |
44 | 44 | |
45 | - $path = $file->getRealPath(); |
|
46 | - $poetryRaw = file_get_contents($path); |
|
47 | - $parser = new POEMParser(); |
|
48 | - $poem = $parser->parse($poetryRaw); |
|
49 | - if(empty($poem)){ |
|
45 | + $path=$file->getRealPath(); |
|
46 | + $poetryRaw=file_get_contents($path); |
|
47 | + $parser=new POEMParser(); |
|
48 | + $poem=$parser->parse($poetryRaw); |
|
49 | + if (empty($poem)) { |
|
50 | 50 | $err('Malformed POEM files'); |
51 | 51 | } |
52 | 52 | |
53 | - $success_message .= " |
|
53 | + $success_message.=" |
|
54 | 54 | POEM standard : {$poem['standard']} <br /> |
55 | 55 | generator : {$poem['generator']} <br /> |
56 | 56 | url : {$poem['url']} <br /> |
@@ -58,31 +58,31 @@ discard block |
||
58 | 58 | problems: <br /> |
59 | 59 | "; |
60 | 60 | |
61 | - $memory_unit = [ |
|
61 | + $memory_unit=[ |
|
62 | 62 | 'kb' => 1, |
63 | 63 | 'mb' => 1024, |
64 | - 'gb' => 1024*1024 |
|
64 | + 'gb' => 1024 * 1024 |
|
65 | 65 | ]; |
66 | - $time_unit = [ |
|
66 | + $time_unit=[ |
|
67 | 67 | 'ms' => 1, |
68 | 68 | 's' => 1000, |
69 | 69 | 'm' => 60000, |
70 | 70 | 'h' => 3600000 |
71 | 71 | ]; |
72 | 72 | |
73 | - $prefix = 'NOJ'; |
|
74 | - $p = ProblemModel::where('pcode','like',$prefix.'%')->orderBy('pcode','desc')->select('pcode')->first(); |
|
75 | - if(empty($p)){ |
|
76 | - $count = 1000; |
|
77 | - }else{ |
|
78 | - $count = (int) str_replace($prefix,'',$p['pcode']); |
|
73 | + $prefix='NOJ'; |
|
74 | + $p=ProblemModel::where('pcode', 'like', $prefix.'%')->orderBy('pcode', 'desc')->select('pcode')->first(); |
|
75 | + if (empty($p)) { |
|
76 | + $count=1000; |
|
77 | + } else { |
|
78 | + $count=(int) str_replace($prefix, '', $p['pcode']); |
|
79 | 79 | } |
80 | 80 | |
81 | 81 | foreach ($poem['problems'] as $problem) { |
82 | 82 | //insert problem |
83 | - $title = $problem['title']; |
|
84 | - $pro = [ |
|
85 | - 'pcode' => $prefix . (++$count), |
|
83 | + $title=$problem['title']; |
|
84 | + $pro=[ |
|
85 | + 'pcode' => $prefix.(++$count), |
|
86 | 86 | 'solved_count' => 0, |
87 | 87 | 'difficulty' => -1, |
88 | 88 | 'file' => 0, |
@@ -101,49 +101,49 @@ discard block |
||
101 | 101 | 'force_raw' => $problem['extra']['forceRaw'], |
102 | 102 | 'partial' => $problem['extra']['partial'] |
103 | 103 | ]; |
104 | - $pid = ProblemModel::insertGetId($pro); |
|
104 | + $pid=ProblemModel::insertGetId($pro); |
|
105 | 105 | |
106 | 106 | //migrate sample |
107 | - $sample_count = 0; |
|
108 | - foreach($problem['sample'] as $sample){ |
|
109 | - $sam = [ |
|
107 | + $sample_count=0; |
|
108 | + foreach ($problem['sample'] as $sample) { |
|
109 | + $sam=[ |
|
110 | 110 | 'pid' => $pid, |
111 | 111 | 'sample_input' => $sample['input'], |
112 | 112 | 'sample_output' => $sample['output'], |
113 | 113 | ]; |
114 | - $psid = DB::table('problem_sample')->insert($sam); |
|
115 | - $sample_count += 1; |
|
114 | + $psid=DB::table('problem_sample')->insert($sam); |
|
115 | + $sample_count+=1; |
|
116 | 116 | } |
117 | 117 | |
118 | 118 | //create test case file |
119 | - if(Storage::exists(storage_path().'/test_case/'.$pro['pcode'])){ |
|
119 | + if (Storage::exists(storage_path().'/test_case/'.$pro['pcode'])) { |
|
120 | 120 | Storage::deleteDirectory(storage_path().'/test_case/'.$pro['pcode']); |
121 | 121 | } |
122 | 122 | Storage::makeDirectory(storage_path().'/test_case/'.$pro['pcode']); |
123 | - $test_case_count = 0; |
|
124 | - $test_case_info = [ |
|
123 | + $test_case_count=0; |
|
124 | + $test_case_info=[ |
|
125 | 125 | 'spj' => false, |
126 | 126 | 'test_cases' => [] |
127 | 127 | ]; |
128 | - foreach($problem['testCases'] as $test_case){ |
|
129 | - $test_case_count += 1; |
|
130 | - $test_case_arr = [ |
|
128 | + foreach ($problem['testCases'] as $test_case) { |
|
129 | + $test_case_count+=1; |
|
130 | + $test_case_arr=[ |
|
131 | 131 | 'input_name' => "data{$test_case_count}.in", |
132 | 132 | 'output_name' => "data{$test_case_count}.out", |
133 | 133 | 'input_size' => strlen($test_case['input']), |
134 | 134 | 'output_size' => strlen($test_case['output']), |
135 | 135 | 'stripped_output_md5' => md5(trim($test_case['output'])) |
136 | 136 | ]; |
137 | - array_push($test_case_info['test_cases'],$test_case_arr); |
|
137 | + array_push($test_case_info['test_cases'], $test_case_arr); |
|
138 | 138 | Storage::disk('test_case')->put('/'.$pro['pcode'].'/'.$test_case_arr['input_name'], $test_case['input']); |
139 | 139 | Storage::disk('test_case')->put('/'.$pro['pcode'].'/'.$test_case_arr['output_name'], $test_case['output']); |
140 | 140 | } |
141 | 141 | Storage::disk('test_case')->put('/'.$pro['pcode'].'/info', json_encode($test_case_info)); |
142 | 142 | |
143 | 143 | //migrate solutions |
144 | - $solution_count = 0; |
|
145 | - foreach($problem['solution'] as $solution) { |
|
146 | - $s = [ |
|
144 | + $solution_count=0; |
|
145 | + foreach ($problem['solution'] as $solution) { |
|
146 | + $s=[ |
|
147 | 147 | 'uid' => 1, |
148 | 148 | 'pid' => $pid, |
149 | 149 | 'content' => '``` '.$solution['source'], |
@@ -152,10 +152,10 @@ discard block |
||
152 | 152 | 'created_at' => date('Y-m-d H:i:s') |
153 | 153 | ]; |
154 | 154 | DB::table('problem_solution')->insert($s); |
155 | - $solution_count += 1; |
|
155 | + $solution_count+=1; |
|
156 | 156 | } |
157 | 157 | |
158 | - $success_message .= ' '. |
|
158 | + $success_message.=' '. |
|
159 | 159 | $pro['pcode'].': " |
160 | 160 | '.$title.'" with |
161 | 161 | '.$sample_count.' samples, |
@@ -163,7 +163,7 @@ discard block |
||
163 | 163 | '.$solution_count.' solutions |
164 | 164 | <br />'; |
165 | 165 | } |
166 | - admin_success('Import successfully',$success_message); |
|
166 | + admin_success('Import successfully', $success_message); |
|
167 | 167 | return back(); |
168 | 168 | } |
169 | 169 |
@@ -96,7 +96,7 @@ |
||
96 | 96 | '7002' => "Insufficient Clearance", |
97 | 97 | '7003' => "No Need to Approve", |
98 | 98 | '7004' => "Group Member Not Found", |
99 | - '7005' => "Don't play just for fun",//gcode=="create" |
|
99 | + '7005' => "Don't play just for fun", //gcode=="create" |
|
100 | 100 | '7006' => "A group with the same gcode already exists", |
101 | 101 | '7007' => "Group Problem Tag Exist", |
102 | 102 | '7008' => "The group leader cannot leave the group", |