@@ -148,8 +148,8 @@ |
||
| 148 | 148 | $form->number('order', __('admin.dojos.order'))->default(0)->rules('required'); |
| 149 | 149 | $form->multipleSelect('precondition', __('admin.dojos.precondition'))->options(Dojo::all()->pluck('name', 'id')); |
| 150 | 150 | $form->hasMany('problems', __('admin.dojos.problems'), function(Form\NestedForm $form) { |
| 151 | - $form->select('problem_id', __('admin.dojos.problem'))->options(function ($pid) { |
|
| 152 | - $problem = Problem::find($pid); |
|
| 151 | + $form->select('problem_id', __('admin.dojos.problem'))->options(function($pid) { |
|
| 152 | + $problem=Problem::find($pid); |
|
| 153 | 153 | if ($problem) { |
| 154 | 154 | return [$problem->pid => $problem->readable_name]; |
| 155 | 155 | } |
@@ -139,8 +139,8 @@ |
||
| 139 | 139 | ])->default(1); |
| 140 | 140 | $form->image('img', 'Custom Group Focus Image')->uniqueName()->move("static/img/group"); |
| 141 | 141 | if ($form->isCreating()) { |
| 142 | - $form->select('leader_uid', 'Group Leader')->options(function ($id) { |
|
| 143 | - $user = User::find($id); |
|
| 142 | + $form->select('leader_uid', 'Group Leader')->options(function($id) { |
|
| 143 | + $user=User::find($id); |
|
| 144 | 144 | if ($user) { |
| 145 | 145 | return [$user->id => $user->readable_name]; |
| 146 | 146 | } |
@@ -137,8 +137,8 @@ discard block |
||
| 137 | 137 | $form=new Form(new Contest); |
| 138 | 138 | $form->tab('Basic', function(Form $form) { |
| 139 | 139 | $form->select('gid', 'Contest Creator Group')->options(Group::all()->pluck('name', 'gid'))->required(); |
| 140 | - $form->select('assign_uid', 'Contest Assign User')->options(function ($id) { |
|
| 141 | - $user = User::find($id); |
|
| 140 | + $form->select('assign_uid', 'Contest Assign User')->options(function($id) { |
|
| 141 | + $user=User::find($id); |
|
| 142 | 142 | if ($user) { |
| 143 | 143 | return [$user->id => $user->readable_name]; |
| 144 | 144 | } |
@@ -210,8 +210,8 @@ discard block |
||
| 210 | 210 | $ncodeArr[$alpha]=$alpha; |
| 211 | 211 | } |
| 212 | 212 | $form->select('ncode', 'Problem Alphabetical Index')->options($ncodeArr)->default("A")->required(); |
| 213 | - $form->select('pid', 'Problem')->options(function ($pid) { |
|
| 214 | - $problem = Problem::find($pid); |
|
| 213 | + $form->select('pid', 'Problem')->options(function($pid) { |
|
| 214 | + $problem=Problem::find($pid); |
|
| 215 | 215 | if ($problem) { |
| 216 | 216 | return [$problem->pid => $problem->readable_name]; |
| 217 | 217 | } |
@@ -44,7 +44,7 @@ discard block |
||
| 44 | 44 | public function show($id, Content $content) |
| 45 | 45 | { |
| 46 | 46 | $problem=Problem::findOrFail($id); |
| 47 | - if(!$problem->markdown || $problem->onlinejudge->ocode !== 'noj'){ |
|
| 47 | + if (!$problem->markdown || $problem->onlinejudge->ocode!=='noj') { |
|
| 48 | 48 | return abort('403', 'Problem managed by BABEL cannot be accessed by Admin Portal.'); |
| 49 | 49 | } |
| 50 | 50 | return $content |
@@ -63,7 +63,7 @@ discard block |
||
| 63 | 63 | public function edit($id, Content $content) |
| 64 | 64 | { |
| 65 | 65 | $problem=Problem::findOrFail($id); |
| 66 | - if(!$problem->markdown || $problem->onlinejudge->ocode !== 'noj'){ |
|
| 66 | + if (!$problem->markdown || $problem->onlinejudge->ocode!=='noj') { |
|
| 67 | 67 | return abort('403', 'Problem managed by BABEL cannot be accessed by Admin Portal.'); |
| 68 | 68 | } |
| 69 | 69 | return $content |
@@ -111,7 +111,7 @@ discard block |
||
| 111 | 111 | $grid->model()->where([ |
| 112 | 112 | 'markdown'=>1, |
| 113 | 113 | 'OJ'=>OJ::where(['ocode'=>'noj'])->first()->oid, |
| 114 | - ])->orderBy('pcode','asc'); |
|
| 114 | + ])->orderBy('pcode', 'asc'); |
|
| 115 | 115 | $grid->column('pid', "ID")->sortable(); |
| 116 | 116 | $grid->column('pcode', "PCode")->editable()->sortable(); |
| 117 | 117 | $grid->title("Title")->editable(); |
@@ -205,7 +205,7 @@ discard block |
||
| 205 | 205 | 1 => 'YES', |
| 206 | 206 | ])->default(0)->rules('required'); |
| 207 | 207 | $form->clang('spj_src', 'SPJ Source Code'); |
| 208 | - if($form->isCreating()) { |
|
| 208 | + if ($form->isCreating()) { |
|
| 209 | 209 | $form->chunk_file('test_case')->rules('required'); |
| 210 | 210 | } else { |
| 211 | 211 | $form->chunk_file('test_case'); |
@@ -251,13 +251,13 @@ discard block |
||
| 251 | 251 | return $err('The SPJ problem must provide spj_src', 'create problem error'); |
| 252 | 252 | } |
| 253 | 253 | |
| 254 | - $test_case = null; |
|
| 254 | + $test_case=null; |
|
| 255 | 255 | |
| 256 | - if(!is_null(request()->get('test_case'))) { |
|
| 257 | - $test_case = explode('http://fake.path/',request()->get('test_case'), 2)[1]; |
|
| 256 | + if (!is_null(request()->get('test_case'))) { |
|
| 257 | + $test_case=explode('http://fake.path/', request()->get('test_case'), 2)[1]; |
|
| 258 | 258 | $path=Storage::disk('temp')->path($test_case); |
| 259 | 259 | |
| 260 | - if (pathinfo($path, PATHINFO_EXTENSION) !== 'zip') { |
|
| 260 | + if (pathinfo($path, PATHINFO_EXTENSION)!=='zip') { |
|
| 261 | 261 | return $err('You must upload a zip file iuclude test case info and content.'); |
| 262 | 262 | } |
| 263 | 263 | |
@@ -281,7 +281,7 @@ discard block |
||
| 281 | 281 | $files[]=$filename; |
| 282 | 282 | } |
| 283 | 283 | $files_in=array_filter($files, function($filename) { |
| 284 | - return pathinfo($filename, PATHINFO_EXTENSION) == 'in'; |
|
| 284 | + return pathinfo($filename, PATHINFO_EXTENSION)=='in'; |
|
| 285 | 285 | }); |
| 286 | 286 | sort($files_in); |
| 287 | 287 | $testcase_index=1; |
@@ -316,7 +316,7 @@ discard block |
||
| 316 | 316 | $files[]=$filename; |
| 317 | 317 | } |
| 318 | 318 | $files_in=array_filter($files, function($filename) { |
| 319 | - return pathinfo($filename, PATHINFO_EXTENSION) == 'in'; |
|
| 319 | + return pathinfo($filename, PATHINFO_EXTENSION)=='in'; |
|
| 320 | 320 | }); |
| 321 | 321 | sort($files_in); |
| 322 | 322 | $testcase_index=1; |
@@ -376,7 +376,7 @@ discard block |
||
| 376 | 376 | $form->spj_version="{$form->pcode}#".time(); |
| 377 | 377 | } |
| 378 | 378 | //Set default data |
| 379 | - if($form->isCreating() && empty($test_case)) { |
|
| 379 | + if ($form->isCreating() && empty($test_case)) { |
|
| 380 | 380 | $form->tot_score=0; |
| 381 | 381 | } |
| 382 | 382 | $form->markdown=true; |
@@ -10,21 +10,21 @@ discard block |
||
| 10 | 10 | |
| 11 | 11 | class ApiController extends AdminController |
| 12 | 12 | { |
| 13 | - protected function paginate($items, $perPage = 15, $pageStart = 1) |
|
| 13 | + protected function paginate($items, $perPage=15, $pageStart=1) |
|
| 14 | 14 | { |
| 15 | - $offSet = ($pageStart * $perPage) - $perPage; |
|
| 16 | - $itemsForCurrentPage = array_slice($items, $offSet, $perPage, true); |
|
| 17 | - $paginator = new LengthAwarePaginator($itemsForCurrentPage, count($items), $perPage, Paginator::resolveCurrentPage(), ['path' => Paginator::resolveCurrentPath()]); |
|
| 15 | + $offSet=($pageStart * $perPage)-$perPage; |
|
| 16 | + $itemsForCurrentPage=array_slice($items, $offSet, $perPage, true); |
|
| 17 | + $paginator=new LengthAwarePaginator($itemsForCurrentPage, count($items), $perPage, Paginator::resolveCurrentPage(), ['path' => Paginator::resolveCurrentPath()]); |
|
| 18 | 18 | return $paginator; |
| 19 | 19 | } |
| 20 | 20 | |
| 21 | 21 | public function problems() |
| 22 | 22 | { |
| 23 | - $q = request()->q; |
|
| 23 | + $q=request()->q; |
|
| 24 | 24 | |
| 25 | - return $this->paginate(Problem::orderBy('pcode', 'asc')->get()->filter(function ($problem) use ($q) { |
|
| 26 | - return stripos($problem->readable_name, $q) !== false; |
|
| 27 | - })->values()->transform(function ($problem) { |
|
| 25 | + return $this->paginate(Problem::orderBy('pcode', 'asc')->get()->filter(function($problem) use ($q) { |
|
| 26 | + return stripos($problem->readable_name, $q)!==false; |
|
| 27 | + })->values()->transform(function($problem) { |
|
| 28 | 28 | return [ |
| 29 | 29 | 'id' => $problem->pid, |
| 30 | 30 | 'text' => $problem->readable_name, |
@@ -34,11 +34,11 @@ discard block |
||
| 34 | 34 | |
| 35 | 35 | public function users() |
| 36 | 36 | { |
| 37 | - $q = request()->q; |
|
| 37 | + $q=request()->q; |
|
| 38 | 38 | |
| 39 | - return $this->paginate(User::get()->filter(function ($user) use ($q) { |
|
| 40 | - return stripos($user->readable_name, $q) !== false; |
|
| 41 | - })->values()->transform(function ($user) { |
|
| 39 | + return $this->paginate(User::get()->filter(function($user) use ($q) { |
|
| 40 | + return stripos($user->readable_name, $q)!==false; |
|
| 41 | + })->values()->transform(function($user) { |
|
| 42 | 42 | return [ |
| 43 | 43 | 'id' => $user->id, |
| 44 | 44 | 'text' => $user->readable_name, |
@@ -93,8 +93,8 @@ discard block |
||
| 93 | 93 | |
| 94 | 94 | $grid->filter(function(Grid\Filter $filter) { |
| 95 | 95 | $filter->like('title', __('admin.announcements.title')); |
| 96 | - $filter->equal('uid', __('admin.announcements.user'))->select(function ($id) { |
|
| 97 | - $user = User::find($id); |
|
| 96 | + $filter->equal('uid', __('admin.announcements.user'))->select(function($id) { |
|
| 97 | + $user=User::find($id); |
|
| 98 | 98 | if ($user) { |
| 99 | 99 | return [$user->id => $user->readable_name]; |
| 100 | 100 | } |
@@ -134,8 +134,8 @@ discard block |
||
| 134 | 134 | $form=new Form(new Announcement()); |
| 135 | 135 | $form->text('title', __('admin.announcements.title'))->required(); |
| 136 | 136 | $form->simplemde('content', __('admin.announcements.content'))->help(__('admin.announcements.help.markdown'))->required(); |
| 137 | - $form->select('uid', __('admin.announcements.user'))->options(function ($id) { |
|
| 138 | - $user = User::find($id); |
|
| 137 | + $form->select('uid', __('admin.announcements.user'))->options(function($id) { |
|
| 138 | + $user=User::find($id); |
|
| 139 | 139 | if ($user) { |
| 140 | 140 | return [$user->id => $user->readable_name]; |
| 141 | 141 | } |
@@ -123,14 +123,14 @@ discard block |
||
| 123 | 123 | }); |
| 124 | 124 | $filter->column(6, function($filter) { |
| 125 | 125 | $filter->equal('cid', __('admin.submissions.cid'))->select(Contest::all()->pluck('name', 'cid')); |
| 126 | - $filter->equal('uid', __('admin.submissions.uid'))->select(function ($id) { |
|
| 127 | - $user = User::find($id); |
|
| 126 | + $filter->equal('uid', __('admin.submissions.uid'))->select(function($id) { |
|
| 127 | + $user=User::find($id); |
|
| 128 | 128 | if ($user) { |
| 129 | 129 | return [$user->id => $user->readable_name]; |
| 130 | 130 | } |
| 131 | 131 | })->config('minimumInputLength', 4)->ajax(route('admin.api.users')); |
| 132 | - $filter->equal('pid', __('admin.submissions.pid'))->select(function ($pid) { |
|
| 133 | - $problem = Problem::find($pid); |
|
| 132 | + $filter->equal('pid', __('admin.submissions.pid'))->select(function($pid) { |
|
| 133 | + $problem=Problem::find($pid); |
|
| 134 | 134 | if ($problem) { |
| 135 | 135 | return [$problem->pid => $problem->readable_name]; |
| 136 | 136 | } |
@@ -226,15 +226,15 @@ discard block |
||
| 226 | 226 | $form->text('color', __('admin.submissions.color'))->rules('required'); |
| 227 | 227 | $form->textarea('language', __('admin.submissions.language'))->rules('required'); |
| 228 | 228 | $form->display('submission_date', __('admin.submissions.submission_date')); |
| 229 | - $form->select('uid', __('admin.submissions.uid'))->options(function ($id) { |
|
| 230 | - $user = User::find($id); |
|
| 229 | + $form->select('uid', __('admin.submissions.uid'))->options(function($id) { |
|
| 230 | + $user=User::find($id); |
|
| 231 | 231 | if ($user) { |
| 232 | 232 | return [$user->id => $user->readable_name]; |
| 233 | 233 | } |
| 234 | 234 | })->config('minimumInputLength', 4)->ajax(route('admin.api.users'))->required(); |
| 235 | 235 | $form->select('cid', __('admin.submissions.cid'))->options(Contest::all()->pluck('name', 'cid')); |
| 236 | - $form->select('pid', __('admin.submissions.pid'))->options(function ($pid) { |
|
| 237 | - $problem = Problem::find($pid); |
|
| 236 | + $form->select('pid', __('admin.submissions.pid'))->options(function($pid) { |
|
| 237 | + $problem=Problem::find($pid); |
|
| 238 | 238 | if ($problem) { |
| 239 | 239 | return [$problem->pid => $problem->readable_name]; |
| 240 | 240 | } |
@@ -98,8 +98,8 @@ discard block |
||
| 98 | 98 | $filter->equal('dojo_id', __('admin.dojopasses.dojo'))->select(Dojo::all()->pluck('name', 'id')); |
| 99 | 99 | }); |
| 100 | 100 | $filter->column(6, function($filter) { |
| 101 | - $filter->equal('user_id', __('admin.dojopasses.user'))->select(function ($id) { |
|
| 102 | - $user = User::find($id); |
|
| 101 | + $filter->equal('user_id', __('admin.dojopasses.user'))->select(function($id) { |
|
| 102 | + $user=User::find($id); |
|
| 103 | 103 | if ($user) { |
| 104 | 104 | return [$user->id => $user->readable_name]; |
| 105 | 105 | } |
@@ -140,8 +140,8 @@ discard block |
||
| 140 | 140 | $form->tab('Basic', function(Form $form) { |
| 141 | 141 | $form->display('id', 'ID'); |
| 142 | 142 | $form->select('dojo_id', __('admin.dojopasses.dojo'))->options(Dojo::all()->pluck('name', 'id'))->rules('required'); |
| 143 | - $form->select('user_id', __('admin.dojopasses.user'))->options(function ($id) { |
|
| 144 | - $user = User::find($id); |
|
| 143 | + $form->select('user_id', __('admin.dojopasses.user'))->options(function($id) { |
|
| 144 | + $user=User::find($id); |
|
| 145 | 145 | if ($user) { |
| 146 | 146 | return [$user->id => $user->readable_name]; |
| 147 | 147 | } |
@@ -129,14 +129,14 @@ |
||
| 129 | 129 | $form->model()->makeVisible('password'); |
| 130 | 130 | $form->tab('Basic', function(Form $form) { |
| 131 | 131 | $form->display("psoid"); |
| 132 | - $form->select('uid', 'Author')->options(function ($id) { |
|
| 133 | - $user = User::find($id); |
|
| 132 | + $form->select('uid', 'Author')->options(function($id) { |
|
| 133 | + $user=User::find($id); |
|
| 134 | 134 | if ($user) { |
| 135 | 135 | return [$user->id => $user->readable_name]; |
| 136 | 136 | } |
| 137 | 137 | })->config('minimumInputLength', 4)->ajax(route('admin.api.users'))->required(); |
| 138 | - $form->select('pid', 'Problem')->options(function ($pid) { |
|
| 139 | - $problem = Problem::find($pid); |
|
| 138 | + $form->select('pid', 'Problem')->options(function($pid) { |
|
| 139 | + $problem=Problem::find($pid); |
|
| 140 | 140 | if ($problem) { |
| 141 | 141 | return [$problem->pid => $problem->readable_name]; |
| 142 | 142 | } |