From 1ed36c44ac722a41bf4088f93620d916bdfd48b4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juan=20V=C3=A1squez?= Date: Mon, 22 Jul 2019 10:34:17 -0500 Subject: [PATCH 1/5] add DuskServerProvider for dev env --- app/Providers/AppServiceProvider.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/app/Providers/AppServiceProvider.php b/app/Providers/AppServiceProvider.php index b9e76d484..8c0c86b8b 100644 --- a/app/Providers/AppServiceProvider.php +++ b/app/Providers/AppServiceProvider.php @@ -2,6 +2,7 @@ namespace App\Providers; +use Laravel\Dusk\DuskServiceProvider; use Illuminate\Support\ServiceProvider; use Illuminate\Support\Facades\Schema; use Illuminate\Http\Resources\Json\Resource; @@ -26,6 +27,8 @@ public function boot() */ public function register() { - // + if ($this->app->environment('local', 'testing')) { + $this->app->register(DuskServiceProvider::class); + } } } From c2a5d14bc727b48443c3fefde1f4b15007f751ea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juan=20V=C3=A1squez?= Date: Wed, 24 Jul 2019 14:46:36 -0500 Subject: [PATCH 2/5] Refactor SchoolController manage for master --- app/Http/Controllers/SchoolController.php | 106 +++++------------ app/Http/Requests/SchoolRequest.php | 33 ++++++ database/factories/SchoolFactory.php | 11 +- .../master/create-school-form.blade.php | 80 ------------- resources/views/masters/index.blade.php | 4 +- resources/views/school/edit-school.blade.php | 88 -------------- resources/views/schools/edit.blade.php | 51 ++++++++ resources/views/schools/form.blade.php | 86 ++++++++++++++ resources/views/schools/index.blade.php | 56 +++++++++ routes/web.php | 10 +- .../Browser/MasterUserManagesSchoolsTest.php | 56 +++++++++ tests/Browser/Pages/MasterPage.php | 42 +++++++ tests/Browser/Pages/SchoolPage.php | 76 ++++++++++++ tests/Feature/Manage/ClassModuleTest.php | 4 +- tests/Feature/Manage/SchoolModuleTest.php | 112 ++++++++++-------- 15 files changed, 509 insertions(+), 306 deletions(-) create mode 100644 app/Http/Requests/SchoolRequest.php delete mode 100644 resources/views/layouts/master/create-school-form.blade.php delete mode 100644 resources/views/school/edit-school.blade.php create mode 100644 resources/views/schools/edit.blade.php create mode 100644 resources/views/schools/form.blade.php create mode 100644 resources/views/schools/index.blade.php create mode 100644 tests/Browser/MasterUserManagesSchoolsTest.php create mode 100644 tests/Browser/Pages/MasterPage.php create mode 100644 tests/Browser/Pages/SchoolPage.php diff --git a/app/Http/Controllers/SchoolController.php b/app/Http/Controllers/SchoolController.php index 63676c13b..2b938d9f7 100644 --- a/app/Http/Controllers/SchoolController.php +++ b/app/Http/Controllers/SchoolController.php @@ -2,13 +2,13 @@ namespace App\Http\Controllers; +use App\User; use App\School; use App\Myclass; use App\Section; -use App\User; use App\Department; -//use App\Http\Resources\SchoolResource; use Illuminate\Http\Request; +use App\Http\Requests\SchoolRequest; class SchoolController extends Controller { @@ -17,28 +17,19 @@ class SchoolController extends Controller * * @return \Illuminate\Http\Response */ - public function index() - { - $schools = School::all(); - $classes = Myclass::all(); - $sections = Section::all(); - $teachers = User::join('departments', 'departments.id', '=', 'users.department_id') - ->where('role', 'teacher') - ->orderBy('name','ASC') - ->where('active', 1) - ->get(); - $departments = Department::bySchool(\Auth::user()->school_id)->get(); - return view('school.create-school', compact('schools', 'classes', 'sections', 'teachers', 'departments')); - } + public function index() { + $schools = School::orderBy('created_at', 'desc')->paginate(); - /** - * Show the form for creating a new resource. - * - * @return \Illuminate\Http\Response - */ - public function create() - { - // + return view('schools.index', compact('schools')); + //$classes = Myclass::all(); + //$sections = Section::all(); + //$teachers = User::join('departments', 'departments.id', '=', 'users.department_id') + //->where('role', 'teacher') + //->orderBy('name','ASC') + //->where('active', 1) + //->get(); + //$departments = Department::bySchool(\Auth::user()->school_id)->get(); + //return view('school.create-school', compact('schools', 'classes', 'sections', 'teachers', 'departments')); } /** @@ -47,23 +38,18 @@ public function create() * @param \Illuminate\Http\Request $request * @return \Illuminate\Http\Response */ - public function store(Request $request) + public function store(SchoolRequest $request) { - $request->validate([ - 'school_name' => 'required|string|max:255', - 'school_medium' => 'required', - 'school_about' => 'required', - 'school_established' => 'required', - ]); - $tb = new School; - $tb->name = $request->school_name; - $tb->established = $request->school_established; - $tb->about = $request->school_about; - $tb->medium = $request->school_medium; - $tb->code = date("y").substr(number_format(time() * mt_rand(),0,'',''),0,6); - $tb->theme = 'flatly'; - $tb->save(); - return back()->with('status', 'Created'); + School::create([ + 'name' => $request->name, + 'established' => $request->established, + 'about' => $request->about, + 'medium' => $request->medium, + 'code' => date("y").substr(number_format(time() * mt_rand(), 0, '', ''), 0, 6), + 'theme' => 'flatly' + ]); + + return redirect()->route('schools.index'); } /** @@ -78,25 +64,16 @@ public function show($school_id) return view('school.admin-list',compact('admins')); } - /** - * Show the form for editing the specified resource. - * - * @param int $id - * @return \Illuminate\Http\Response - */ - public function edit(Request $request, $school_id) - { - $school = School::find($school_id); - if (!$school) { - abort(404); - } - if ($request->isMethod('post')) { + public function edit(School $school) { + return view('schools.edit', compact('school')); + } + + public function update(Request $request, School $school) { $school->name = $request->name; $school->about = $request->about; - $school->theme = $request->school_theme; $school->save(); - } - return view('school.edit-school',compact('school')); + + return redirect()->route('schools.index'); } public function addDepartment(Request $request){ @@ -116,25 +93,6 @@ public function changeTheme(Request $request){ $tb->save(); return back(); } - /** - * Update the specified resource in storage. - * - * @param \Illuminate\Http\Request $request - * @param int $id - * @return \Illuminate\Http\Response - */ - public function update(Request $request, $id) - { - $tb = School::find($id); - $tb->name = $request->name; - $tb->about = $request->about; - //$tb->code = $request->code; - return ($tb->save())?response()->json([ - 'status' => 'success' - ]):response()->json([ - 'status' => 'error' - ]); - } /** * Remove the specified resource from storage. diff --git a/app/Http/Requests/SchoolRequest.php b/app/Http/Requests/SchoolRequest.php new file mode 100644 index 000000000..d0484231d --- /dev/null +++ b/app/Http/Requests/SchoolRequest.php @@ -0,0 +1,33 @@ + 'required|string|max:255', + 'medium' => 'required', + 'about' => 'required', + 'established' => 'required', + ]; + } +} diff --git a/database/factories/SchoolFactory.php b/database/factories/SchoolFactory.php index 54e73bbd7..2b807b094 100644 --- a/database/factories/SchoolFactory.php +++ b/database/factories/SchoolFactory.php @@ -5,10 +5,11 @@ $factory->define(School::class, function (Faker $faker) { return [ - 'name' => $faker->name, - 'about' => $faker->sentences(3, true), - 'medium' => $faker->randomElement(['bangla', 'english']), - 'code' => date("y").substr(number_format(time() * mt_rand(),0,'',''),0,6), - 'theme' => 'flatly', + 'name' => $faker->name, + 'about' => $faker->sentences(3, true), + 'medium' => $faker->randomElement(['bangla', 'english']), + 'code' => date("y").substr(number_format(time() * mt_rand(),0,'',''),0,6), + 'established' => $faker->name, + 'theme' => 'flatly', ]; }); diff --git a/resources/views/layouts/master/create-school-form.blade.php b/resources/views/layouts/master/create-school-form.blade.php deleted file mode 100644 index 0da213786..000000000 --- a/resources/views/layouts/master/create-school-form.blade.php +++ /dev/null @@ -1,80 +0,0 @@ - - - diff --git a/resources/views/masters/index.blade.php b/resources/views/masters/index.blade.php index 7e9d72ac7..864a81390 100644 --- a/resources/views/masters/index.blade.php +++ b/resources/views/masters/index.blade.php @@ -8,7 +8,9 @@
@lang('Dashboard')
diff --git a/resources/views/school/edit-school.blade.php b/resources/views/school/edit-school.blade.php deleted file mode 100644 index 948f568e3..000000000 --- a/resources/views/school/edit-school.blade.php +++ /dev/null @@ -1,88 +0,0 @@ -@extends('layouts.app') - -@section('title', 'Edit School') - -@section('content') -
-
- @if(\Auth::user()->role != 'master') -
- @include('layouts.leftside-menubar') -
- @endif -
- @if (session('status')) -
- {{ session('status') }} -
- @endif - @if ($errors->any()) -
-
    - @foreach ($errors->all() as $error) -
  • {{ $error }}
  • - @endforeach -
-
- @endif -
-
- @if(\Auth::user()->role == 'master') -

Edit {{$school->name}}

- -
- {{ csrf_field() }} -
- - -
- - - @if ($errors->has('name')) - - {{ $errors->first('name') }} - - @endif -
-
-
- - -
- - - @if ($errors->has('about')) - - {{ $errors->first('about') }} - - @endif -
-
- {{--
- - -
- @include('layouts.master.theme-select') - - @if ($errors->has('school_theme')) - - {{ $errors->first('school_theme') }} - - @endif -
-
--}} - -
-
- -
-
-
- @endif -
-
-
-
-
-@endsection diff --git a/resources/views/schools/edit.blade.php b/resources/views/schools/edit.blade.php new file mode 100644 index 000000000..35b06aa75 --- /dev/null +++ b/resources/views/schools/edit.blade.php @@ -0,0 +1,51 @@ +@extends('layouts.app') + +@section('title', 'Edit School') + +@section('content') +
+
+

Edit {{$school->name}}

+ +
+ + {{ csrf_field() }} +
+ + +
+ + + @if ($errors->has('name')) + + {{ $errors->first('name') }} + + @endif +
+
+ +
+ + +
+ + + @if ($errors->has('about')) + + {{ $errors->first('about') }} + + @endif +
+
+ +
+
+ back + +
+
+
+
+
+@endsection diff --git a/resources/views/schools/form.blade.php b/resources/views/schools/form.blade.php new file mode 100644 index 000000000..43873b747 --- /dev/null +++ b/resources/views/schools/form.blade.php @@ -0,0 +1,86 @@ + + + + diff --git a/resources/views/schools/index.blade.php b/resources/views/schools/index.blade.php new file mode 100644 index 000000000..b2e9185f5 --- /dev/null +++ b/resources/views/schools/index.blade.php @@ -0,0 +1,56 @@ +@extends('layouts.app') + +@section('title', __('Manage Schools')) + +@section('content') +
+
+
+
+ @include('schools.form') +

@lang('School List')

+

@lang('Manage Departments, Classs, Sections, Student Promotion, Course')

+ + + + + + + + + + + + + + @foreach ($schools as $school) + + + + + + + + + + @endforeach + +
#@lang('Name')@lang('Code')@lang('About')Edit+AdminView Admins
{{($loop->index + 1)}}{{$school->name}}{{$school->code}}{{$school->about}} + + Edit School + + + id.'/'.$school->code)}}"> + + Create Admin + + + id)}}"> + @lang('View Admins') + +
+ {{ $schools->links() }} +
+
+
+
+@endsection diff --git a/routes/web.php b/routes/web.php index 009dde1c8..7b3bd03f3 100644 --- a/routes/web.php +++ b/routes/web.php @@ -40,6 +40,7 @@ class ResultOutput() Route::middleware(['auth', 'master'])->group(function () { Route::get('/masters', 'MasterController@index')->name('masters.index'); + Route::resource('/schools', 'SchoolController')->only(['index', 'edit', 'store', 'update']); }); Route::get('/home', 'HomeController@index')->name('home'); @@ -177,8 +178,6 @@ class ResultOutput() Route::get('delete-expense/{id}','AccountController@deleteExpense'); }); -Route::get('create-school', 'SchoolController@index')->middleware('master.admin'); - Route::middleware(['auth','master'])->group(function (){ Route::get('register/admin/{id}/{code}', function($id, $code){ session([ @@ -191,7 +190,6 @@ class ResultOutput() Route::post('register/admin', 'UserController@storeAdmin'); Route::get('master/activate-admin/{id}','UserController@activateAdmin'); Route::get('master/deactivate-admin/{id}','UserController@deactivateAdmin'); - Route::post('create-school', 'SchoolController@store'); Route::get('school/admin-list/{school_id}','SchoolController@show'); }); @@ -235,12 +233,6 @@ class ResultOutput() Route::post('edit/course/{id}','CourseController@updateNameAndTime'); }); -Route::middleware(['auth', 'master'])->group(function () { - Route::get('school/{school_id}','SchoolController@edit'); - Route::post('school/{school_id}','SchoolController@edit'); -}); - - //use PDF; Route::middleware(['auth','master.admin'])->group(function (){ Route::get('edit/user/{id}','UserController@edit'); diff --git a/tests/Browser/MasterUserManagesSchoolsTest.php b/tests/Browser/MasterUserManagesSchoolsTest.php new file mode 100644 index 000000000..e527267af --- /dev/null +++ b/tests/Browser/MasterUserManagesSchoolsTest.php @@ -0,0 +1,56 @@ +master = factory(User::class)->states('master')->create(); + } + + /** @test */ + public function master_user_can_see_list_schools() { + $this->browse(function (Browser $browser) { + $browser->loginAs($this->master) + ->visit(new MasterPage) + ->clickLink('Manage Schools') + ->assertSee('School List'); + }); + } + + /** @test */ + public function master_user_creates_school() { + $this->browse(function (Browser $browser) { + $browser->loginAs($this->master) + ->visit(new SchoolPage) + ->pause(1000) + ->click('@create-school-button') + ->pause(1000) + ->createSchool('Benito Juárez') + ->assertSee('Benito Juárez'); + }); + } + + /** @test */ + public function master_user_updates_school() { + $this->browse(function (Browser $browser) { + $browser->loginAs($this->master) + ->visit(new SchoolPage) + ->pause(1000) + ->click('@edit-school-link') + ->pause(1000) + ->updateSchool($this->master->school_id, 'New name') + ->assertSee('New name'); + }); + } +} diff --git a/tests/Browser/Pages/MasterPage.php b/tests/Browser/Pages/MasterPage.php new file mode 100644 index 000000000..5c82fab3e --- /dev/null +++ b/tests/Browser/Pages/MasterPage.php @@ -0,0 +1,42 @@ +assertPathIs($this->url()) + ->assertSee('Dashboard'); + } + + /** + * Get the element shortcuts for the page. + * + * @return array + */ + public function elements() + { + return [ + '@element' => '#selector', + ]; + } +} diff --git a/tests/Browser/Pages/SchoolPage.php b/tests/Browser/Pages/SchoolPage.php new file mode 100644 index 000000000..b18354fdf --- /dev/null +++ b/tests/Browser/Pages/SchoolPage.php @@ -0,0 +1,76 @@ +assertPathIs($this->url()) + ->assertSee('School List'); + } + + /** + * Create a new school. + * + * @param \Laravel\Dusk\Browser $browser + * @param string $name + * @return void + */ + public function createSchool(Browser $browser, $name) + { + $browser->assertSee('Create School') + ->type('name', $name) + ->select('medium', 'Bangla') + ->type('established', 'established') + ->type('about', 'about') + ->assertSelected('medium', 'Bangla') + ->press('Save changes'); + } + + /** + * Update a school. + * + * @param \Laravel\Dusk\Browser $browser + * @param int $id + * @param string $name + * @return void + */ + public function updateSchool(Browser $browser, $id, $name) + { + $browser->assertPathIs("/schools/{$id}/edit") + ->type('name', $name) + ->type('about', 'about') + ->press('Save'); + } + + /** + * Get the element shortcuts for the page. + * + * @return array + */ + public function elements() + { + return [ + '@element' => '#selector', + ]; + } +} diff --git a/tests/Feature/Manage/ClassModuleTest.php b/tests/Feature/Manage/ClassModuleTest.php index 73ad7e02d..1be6fb430 100644 --- a/tests/Feature/Manage/ClassModuleTest.php +++ b/tests/Feature/Manage/ClassModuleTest.php @@ -2,8 +2,8 @@ namespace Tests\Feature\Manage; -use App\Myclass; use App\User; +use App\Myclass; use Tests\TestCase; use Illuminate\Foundation\Testing\WithFaker; use Illuminate\Foundation\Testing\RefreshDatabase; @@ -18,11 +18,13 @@ public function setUp() { $this->actingAs($admin); $this->withoutExceptionHandling(); } + /** @test */ public function view_is(){ $this->get('school/sections') ->assertViewIs('school.sections'); } + /** @test */ public function it_shows_the_class_list() { $this->get('school/sections') diff --git a/tests/Feature/Manage/SchoolModuleTest.php b/tests/Feature/Manage/SchoolModuleTest.php index b081ce0ca..463947b1b 100644 --- a/tests/Feature/Manage/SchoolModuleTest.php +++ b/tests/Feature/Manage/SchoolModuleTest.php @@ -2,11 +2,11 @@ namespace Tests\Feature\Manage; +use App\User; use App\School; -use App\Department; use App\Myclass; use App\Section; -use App\User; +use App\Department; use Tests\TestCase; use Illuminate\Foundation\Testing\WithFaker; use Illuminate\Foundation\Testing\RefreshDatabase; @@ -17,64 +17,80 @@ class SchoolModuleTest extends TestCase public function setUp() { parent::setUp(); - $admin = factory(User::class)->states('admin')->create(); - $this->actingAs($admin); - $this->withoutExceptionHandling(); - } - /** @test */ - public function view_is(){ - $this->get('create-school') - ->assertViewIs('school.create-school'); - } - /** @test */ - public function it_shows_the_schools_list() { - $this->get('create-school') - ->assertStatus(200) - ->assertViewHas('schools'); - } - /** @test */ - public function it_shows_edit_school() { $master = factory(User::class)->states('master')->create(); $this->actingAs($master); - $this->followingRedirects() - ->get('school/1') - ->assertStatus(200) - ->assertViewHas('school'); - } - /** @test */ - public function it_shows_the_teachers_list() { - $this->get('create-school') - ->assertStatus(200) - ->assertViewHas('teachers'); + $this->withoutExceptionHandling(); } + /** @test */ - public function it_shows_the_departments_list() { - $this->get('create-school') - ->assertStatus(200) - ->assertViewHas('departments'); + public function it_shows_schools_list() { + $this->get(route('schools.index')) + ->assertStatus(200) + ->assertViewIs('schools.index'); } + /** @test */ - public function it_shows_the_classes_list() { - $this->get('create-school') - ->assertStatus(200) - ->assertViewHas('classes'); + public function it_creates_a_new_school() { + $school = make(School::class); + + $this->post(route('schools.store'), $school->toArray()) + ->assertRedirect(route('schools.index')); } + /** @test */ - public function it_shows_the_sections_list() { - $this->get('create-school') + public function it_shows_edit_school() { + $school = create(School::class); + + $this->get(route('schools.edit', $school)) ->assertStatus(200) - ->assertViewHas('sections'); + ->assertViewIs('schools.edit'); } + /** @test */ - public function admin_can_create_new_department() { - $department = factory(Department::class)->make(); - $this->followingRedirects() - ->post('school/add-department',$department->toArray()) - ->assertStatus(200); + public function a_school_can_being_edited() { + $school = create(School::class, ['name' => 'Benito Juárez']); - $this->assertDatabaseHas('departments',$department->toArray()); + $school->name = 'New name'; - $this->get('create-school') - ->assertSee($department['department_name']); + $this->from(route('schools.edit', $school->id)) + ->put(route('schools.update', $school->id), $school->toArray()) + ->assertRedirect(route('schools.index')); } + + //[>* @test <] + //public function it_shows_the_teachers_list() { + //$this->get('create-school') + //->assertStatus(200) + //->assertViewHas('teachers'); + //} + //[>* @test <] + //public function it_shows_the_departments_list() { + //$this->get('create-school') + //->assertStatus(200) + //->assertViewHas('departments'); + //} + //[>* @test <] + //public function it_shows_the_classes_list() { + //$this->get('create-school') + //->assertStatus(200) + //->assertViewHas('classes'); + //} + //[>* @test <] + //public function it_shows_the_sections_list() { + //$this->get('create-school') + //->assertStatus(200) + //->assertViewHas('sections'); + //} + //[>* @test <] + //public function admin_can_create_new_department() { + //$department = factory(Department::class)->make(); + //$this->followingRedirects() + //->post('school/add-department',$department->toArray()) + //->assertStatus(200); + + //$this->assertDatabaseHas('departments',$department->toArray()); + + //$this->get('create-school') + //->assertSee($department['department_name']); + //} } From 4e7663111949dd62684df0d8cb95aef5ff557fb1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juan=20V=C3=A1squez?= Date: Fri, 26 Jul 2019 00:19:06 -0500 Subject: [PATCH 3/5] add academic settings --- app/Http/Controllers/SchoolController.php | 9 - app/Http/Controllers/SettingController.php | 27 ++ resources/lang/es-MX.json | 5 +- resources/views/auth/register.blade.php | 4 +- .../views/layouts/leftside-menubar.blade.php | 2 +- resources/views/school/admin-list.blade.php | 4 +- .../views/school/create-school.blade.php | 251 ------------------ resources/views/settings/index.blade.php | 186 +++++++++++++ routes/web.php | 7 +- .../AdminUserManagesAcademicSettingsTest.php | 27 ++ tests/Browser/Pages/SettingPage.php | 50 ++++ tests/Feature/Manage/ClassModuleTest.php | 5 +- tests/Feature/Manage/SectionModuleTest.php | 4 +- 13 files changed, 307 insertions(+), 274 deletions(-) create mode 100644 app/Http/Controllers/SettingController.php delete mode 100644 resources/views/school/create-school.blade.php create mode 100644 resources/views/settings/index.blade.php create mode 100644 tests/Browser/AdminUserManagesAcademicSettingsTest.php create mode 100644 tests/Browser/Pages/SettingPage.php diff --git a/app/Http/Controllers/SchoolController.php b/app/Http/Controllers/SchoolController.php index 2b938d9f7..6a94833e6 100644 --- a/app/Http/Controllers/SchoolController.php +++ b/app/Http/Controllers/SchoolController.php @@ -21,15 +21,6 @@ public function index() { $schools = School::orderBy('created_at', 'desc')->paginate(); return view('schools.index', compact('schools')); - //$classes = Myclass::all(); - //$sections = Section::all(); - //$teachers = User::join('departments', 'departments.id', '=', 'users.department_id') - //->where('role', 'teacher') - //->orderBy('name','ASC') - //->where('active', 1) - //->get(); - //$departments = Department::bySchool(\Auth::user()->school_id)->get(); - //return view('school.create-school', compact('schools', 'classes', 'sections', 'teachers', 'departments')); } /** diff --git a/app/Http/Controllers/SettingController.php b/app/Http/Controllers/SettingController.php new file mode 100644 index 000000000..0f6bf9a17 --- /dev/null +++ b/app/Http/Controllers/SettingController.php @@ -0,0 +1,27 @@ +school; + $classes = Myclass::all(); + $sections = Section::all(); + $departments = Department::bySchool(\Auth::user()->school_id)->get(); + $teachers = User::join('departments', 'departments.id', '=', 'users.department_id') + ->where('role', 'teacher') + ->orderBy('name', 'ASC') + ->where('active', 1) + ->get(); + + return view('settings.index', compact('school', 'classes', 'sections', 'departments', 'teachers')); + } +} diff --git a/resources/lang/es-MX.json b/resources/lang/es-MX.json index 720d40b69..96520996e 100644 --- a/resources/lang/es-MX.json +++ b/resources/lang/es-MX.json @@ -494,5 +494,6 @@ "print": "imprimir", "row No": "fila Num.", "section": "Sección", - "uploaded": "Cargado" -} \ No newline at end of file + "uploaded": "Cargado", + "Academic Settings": "Configuración Académica" +} diff --git a/resources/views/auth/register.blade.php b/resources/views/auth/register.blade.php index 01c35c394..9354decfa 100644 --- a/resources/views/auth/register.blade.php +++ b/resources/views/auth/register.blade.php @@ -14,7 +14,7 @@ @@ -547,4 +547,4 @@ $("#registerForm").submit(); }); -@endsection \ No newline at end of file +@endsection diff --git a/resources/views/layouts/leftside-menubar.blade.php b/resources/views/layouts/leftside-menubar.blade.php index e1d7488ba..cd342b1f7 100644 --- a/resources/views/layouts/leftside-menubar.blade.php +++ b/resources/views/layouts/leftside-menubar.blade.php @@ -102,7 +102,7 @@ class="nav-link-text">@lang('Active Exams') @@ -75,4 +75,4 @@ -@endsection \ No newline at end of file +@endsection diff --git a/resources/views/school/create-school.blade.php b/resources/views/school/create-school.blade.php deleted file mode 100644 index 070867689..000000000 --- a/resources/views/school/create-school.blade.php +++ /dev/null @@ -1,251 +0,0 @@ -@extends('layouts.app') - -@section('title', __('Manage Schools')) - -@section('content') -
-
- @if(\Auth::user()->role != 'master') -
- @include('layouts.leftside-menubar') -
- @endif -
- @if (session('status')) -
- {{ session('status') }} -
- @endif - @if ($errors->any()) -
-
    - @foreach ($errors->all() as $error) -
  • {{ $error }}
  • - @endforeach -
-
- @endif -
-
- @if(\Auth::user()->role == 'master') - @include('layouts.master.create-school-form') -

@lang('School List')

- @endif -

@lang('Manage Departments, Classs, Sections, Student Promotion, Course')

- - - - @if(\Auth::user()->role == 'master') - - - - - @endif - @if(\Auth::user()->role == 'admin') - {{----}} - - - {{-- - --}} - @endif - @if(\Auth::user()->role == 'master') - - - - @endif - - - - @foreach($schools as $school) - @if(\Auth::user()->role == 'master' || \Auth::user()->school_id == $school->id) - - @if(\Auth::user()->role == 'master') - - - - - @endif - @if(\Auth::user()->school_id == $school->id) - {{----}} - - - {{-- - --}} - @endif - @if(\Auth::user()->role == 'master') - - - - @endif - - @if(\Auth::user()->school_id == $school->id) - - - - @endif - @endif - @endforeach - -
#@lang('Name')@lang('Code')@lang('About')@lang('Theme')@lang('Department')@lang('Classes')@lang('Students')@lang('Teachers')Edit+AdminView Admins
{{($loop->index + 1)}}{{$school->name}}{{$school->code}}{{$school->about}} - @include('layouts.master.theme-form') - - - - - - - - code.'/1/0')}}">@lang('View All Students') - - code.'/0/1')}}">@lang('View All Teachers') - - id)}}">Edit School - - id.'/'.$school->code)}}">+ Create Admin - - id)}}">@lang('View Admins') -
-
- @foreach($schools as $school) - @if(\Auth::user()->role == 'admin' && \Auth::user()->school_id == $school->id) -

Add Users

- - - - - - - - - - - - - - - - - - -
+@lang('Student')+@lang('Teacher')+@lang('Accountant')+@lang('Librarian')
- + Add Student -
-
Or, Mass upload Excel
- @component('components.excel-upload-form', ['type'=>'student']) - @endcomponent -
- + Add Teacher -
-
Or, Mass upload Excel
- @component('components.excel-upload-form', ['type'=>'teacher']) - @endcomponent -
- + @lang('Add Accountant') - - + @lang('Add Librarian') -
-
-

@lang('Upload')

- - - - - - - - - - - - - -
+@lang('Notice')+@lang('Event')
- developer_board @lang('Upload Notice') - - developer_board @lang('Upload Event') -
- @break - @endif - @endforeach -
-
-
-
-
-@endsection diff --git a/resources/views/settings/index.blade.php b/resources/views/settings/index.blade.php new file mode 100644 index 000000000..7531473ae --- /dev/null +++ b/resources/views/settings/index.blade.php @@ -0,0 +1,186 @@ +@extends('layouts.app') + +@section('title', __('Academic Settings')) + +@section('content') +
+
+
+ @include('layouts.leftside-menubar') +
+
+
+
Academic Settings
+
+ + + + + + + + + + + + + + + + + + + + + + +
@lang('Name')@lang('Code')
{{ $school->name }}{{ $school->code }}
@lang('Department')@lang('Classes')
+ + + + + +
+ +

Add Users

+ + + + + + + + + + + + + + + + + +
+@lang('Student')+@lang('Teacher')+@lang('Accountant')+@lang('Librarian')
+ + Add Student +
+
Or, Mass upload Excel
+ @component('components.excel-upload-form', ['type'=>'student']) + @endcomponent +
+ + Add Teacher +
+
Or, Mass upload Excel
+ @component('components.excel-upload-form', ['type'=>'teacher']) + @endcomponent +
+ + @lang('Add Accountant') + + + @lang('Add Librarian') +
+ +

@lang('Upload')

+ + + + + + + + + + + + + +
+@lang('Notice')+@lang('Event')
+ + developer_board @lang('Upload Notice') + + + + developer_board @lang('Upload Event') + +
+
+
+
+
+
+@endsection diff --git a/routes/web.php b/routes/web.php index 7b3bd03f3..eb0e7effe 100644 --- a/routes/web.php +++ b/routes/web.php @@ -79,9 +79,10 @@ class ResultOutput() }); Route::middleware(['auth','admin'])->group(function (){ - Route::get('gpa/create-gpa', 'GradesystemController@create'); - Route::post('create-gpa', 'GradesystemController@store'); - Route::post('gpa/delete', 'GradesystemController@destroy'); + Route::get('/settings', 'SettingController@index')->name('settings.index'); + Route::get('gpa/create-gpa', 'GradesystemController@create'); + Route::post('create-gpa', 'GradesystemController@store'); + Route::post('gpa/delete', 'GradesystemController@destroy'); }); Route::middleware(['auth','teacher'])->group(function (){ diff --git a/tests/Browser/AdminUserManagesAcademicSettingsTest.php b/tests/Browser/AdminUserManagesAcademicSettingsTest.php new file mode 100644 index 000000000..32f9d7df2 --- /dev/null +++ b/tests/Browser/AdminUserManagesAcademicSettingsTest.php @@ -0,0 +1,27 @@ +admin = factory(User::class)->states('admin')->create(); + } + + /** @test */ + public function admin_user_can_see_academic_settings() { + $this->browse(function (Browser $browser) { + $browser->loginAs($this->admin) + ->visit(new SettingPage); + }); + } +} diff --git a/tests/Browser/Pages/SettingPage.php b/tests/Browser/Pages/SettingPage.php new file mode 100644 index 000000000..e884883fa --- /dev/null +++ b/tests/Browser/Pages/SettingPage.php @@ -0,0 +1,50 @@ +assertPathIs($this->url()) + ->assertSee('Academic Settings') + ->assertSee('Create Department') + ->assertSee('Manage Class, Section') + ->assertSee('+ Add Student') + ->assertSee('+ Add Teacher') + ->assertSee('+ Add Accountant') + ->assertSee('+ Add Librarian') + ->assertSee('Upload Notice') + ->assertSee('Upload Event'); + } + + /** + * Get the element shortcuts for the page. + * + * @return array + */ + public function elements() + { + return [ + '@element' => '#selector', + ]; + } +} diff --git a/tests/Feature/Manage/ClassModuleTest.php b/tests/Feature/Manage/ClassModuleTest.php index 1be6fb430..b5aa02270 100644 --- a/tests/Feature/Manage/ClassModuleTest.php +++ b/tests/Feature/Manage/ClassModuleTest.php @@ -31,6 +31,7 @@ public function it_shows_the_class_list() { ->assertStatus(200) ->assertViewHas('classes'); } + /** @test */ public function admin_can_create_class() { $class = factory(Myclass::class)->make(); @@ -39,8 +40,8 @@ public function admin_can_create_class() { ->assertStatus(200); $this->assertDatabaseHas('classes', $class->toArray()); - - $this->get('create-school') + + $this->get('settings') ->assertSee('Manage '.$class['class_number']); } } diff --git a/tests/Feature/Manage/SectionModuleTest.php b/tests/Feature/Manage/SectionModuleTest.php index b433dfed0..8975a395c 100644 --- a/tests/Feature/Manage/SectionModuleTest.php +++ b/tests/Feature/Manage/SectionModuleTest.php @@ -37,8 +37,8 @@ public function admin_can_create_section() { ->assertStatus(200); $this->assertDatabaseHas('sections', $section->toArray()); - - $this->get('create-school') + + $this->get('settings') ->assertSee('Section '.$section['section_number']); } } From 4fed6535c3c5fb038eac3d0aa700ce8effdd33ed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juan=20V=C3=A1squez?= Date: Fri, 26 Jul 2019 00:31:39 -0500 Subject: [PATCH 4/5] remove unused views --- .../master/create-school-form.blade.php | 80 ------ .../views/school/create-school.blade.php | 251 ------------------ resources/views/school/edit-school.blade.php | 88 ------ 3 files changed, 419 deletions(-) delete mode 100644 resources/views/layouts/master/create-school-form.blade.php delete mode 100644 resources/views/school/create-school.blade.php delete mode 100644 resources/views/school/edit-school.blade.php diff --git a/resources/views/layouts/master/create-school-form.blade.php b/resources/views/layouts/master/create-school-form.blade.php deleted file mode 100644 index ed0289993..000000000 --- a/resources/views/layouts/master/create-school-form.blade.php +++ /dev/null @@ -1,80 +0,0 @@ - - - diff --git a/resources/views/school/create-school.blade.php b/resources/views/school/create-school.blade.php deleted file mode 100644 index 0aa4d84a8..000000000 --- a/resources/views/school/create-school.blade.php +++ /dev/null @@ -1,251 +0,0 @@ -@extends('layouts.app') - -@section('title', __('Manage Schools')) - -@section('content') -
-
- @if(\Auth::user()->role != 'master') -
- @include('layouts.leftside-menubar') -
- @endif -
- @if (session('status')) -
- {{ session('status') }} -
- @endif - @if ($errors->any()) -
-
    - @foreach ($errors->all() as $error) -
  • {{ $error }}
  • - @endforeach -
-
- @endif -
-
- @if(\Auth::user()->role == 'master') - @include('layouts.master.create-school-form') -

@lang('School List')

- @endif -

@lang('Manage Departments, Classs, Sections, Student Promotion, Course')

- - - - @if(\Auth::user()->role == 'master') - - - - - @endif - @if(\Auth::user()->role == 'admin') - {{----}} - - - {{-- - --}} - @endif - @if(\Auth::user()->role == 'master') - - - - @endif - - - - @foreach($schools as $school) - @if(\Auth::user()->role == 'master' || \Auth::user()->school_id == $school->id) - - @if(\Auth::user()->role == 'master') - - - - - @endif - @if(\Auth::user()->school_id == $school->id) - {{----}} - - - {{-- - --}} - @endif - @if(\Auth::user()->role == 'master') - - - - @endif - - @if(\Auth::user()->school_id == $school->id) - - - - @endif - @endif - @endforeach - -
#@lang('Name')@lang('Code')@lang('About')@lang('Theme')@lang('Department')@lang('Classes')@lang('Students')@lang('Teachers')@lang('Edit')+@lang('Admin')@lang('View Admins')
{{($loop->index + 1)}}{{$school->name}}{{$school->code}}{{$school->about}} - @include('layouts.master.theme-form') - - - - - - - - code.'/1/0')}}">@lang('View All Students') - - code.'/0/1')}}">@lang('View All Teachers') - - id)}}">@lang('Edit School') - - id.'/'.$school->code)}}">+ @lang('Create Admin') - - id)}}">@lang('View Admins') -
-
- @foreach($schools as $school) - @if(\Auth::user()->role == 'admin' && \Auth::user()->school_id == $school->id) -

@lang('Add Users')

- - - - - - - - - - - - - - - - - - -
+@lang('Student')+@lang('Teacher')+@lang('Accountant')+@lang('Librarian')
- + @lang('Add Student') -
-
@lang('Or, Mass upload Excel')
- @component('components.excel-upload-form', ['type'=>'student']) - @endcomponent -
- + @lang('Add Teacher') -
-
@lang('Or, Mass upload Excel')
- @component('components.excel-upload-form', ['type'=>'teacher']) - @endcomponent -
- + @lang('Add Accountant') - - + @lang('Add Librarian') -
-
-

@lang('Upload')

- - - - - - - - - - - - - -
+@lang('Notice')+@lang('Event')
- developer_board @lang('Upload Notice') - - developer_board @lang('Upload Event') -
- @break - @endif - @endforeach -
-
-
-
-
-@endsection diff --git a/resources/views/school/edit-school.blade.php b/resources/views/school/edit-school.blade.php deleted file mode 100644 index 697c507ec..000000000 --- a/resources/views/school/edit-school.blade.php +++ /dev/null @@ -1,88 +0,0 @@ -@extends('layouts.app') - -@section('title', __('Edit School')) - -@section('content') -
-
- @if(\Auth::user()->role != 'master') -
- @include('layouts.leftside-menubar') -
- @endif -
- @if (session('status')) -
- {{ session('status') }} -
- @endif - @if ($errors->any()) -
-
    - @foreach ($errors->all() as $error) -
  • {{ $error }}
  • - @endforeach -
-
- @endif -
-
- @if(\Auth::user()->role == 'master') -

Edit {{$school->name}}

- -
- {{ csrf_field() }} -
- - -
- - - @if ($errors->has('name')) - - {{ $errors->first('name') }} - - @endif -
-
-
- - -
- - - @if ($errors->has('about')) - - {{ $errors->first('about') }} - - @endif -
-
- {{--
- - -
- @include('layouts.master.theme-select') - - @if ($errors->has('school_theme')) - - {{ $errors->first('school_theme') }} - - @endif -
-
--}} - -
-
- -
-
-
- @endif -
-
-
-
-
-@endsection From 2cdfcdb7ff3057d434b8290fa8ef3fbc89968532 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juan=20V=C3=A1squez?= Date: Fri, 26 Jul 2019 10:34:28 -0500 Subject: [PATCH 5/5] add feature test for academic settings --- tests/Feature/Manage/SchoolModuleTest.php | 36 ------------- tests/Feature/Manage/SettingModuleTest.php | 61 ++++++++++++++++++++++ 2 files changed, 61 insertions(+), 36 deletions(-) create mode 100644 tests/Feature/Manage/SettingModuleTest.php diff --git a/tests/Feature/Manage/SchoolModuleTest.php b/tests/Feature/Manage/SchoolModuleTest.php index 463947b1b..aaf44675e 100644 --- a/tests/Feature/Manage/SchoolModuleTest.php +++ b/tests/Feature/Manage/SchoolModuleTest.php @@ -57,40 +57,4 @@ public function a_school_can_being_edited() { ->assertRedirect(route('schools.index')); } - //[>* @test <] - //public function it_shows_the_teachers_list() { - //$this->get('create-school') - //->assertStatus(200) - //->assertViewHas('teachers'); - //} - //[>* @test <] - //public function it_shows_the_departments_list() { - //$this->get('create-school') - //->assertStatus(200) - //->assertViewHas('departments'); - //} - //[>* @test <] - //public function it_shows_the_classes_list() { - //$this->get('create-school') - //->assertStatus(200) - //->assertViewHas('classes'); - //} - //[>* @test <] - //public function it_shows_the_sections_list() { - //$this->get('create-school') - //->assertStatus(200) - //->assertViewHas('sections'); - //} - //[>* @test <] - //public function admin_can_create_new_department() { - //$department = factory(Department::class)->make(); - //$this->followingRedirects() - //->post('school/add-department',$department->toArray()) - //->assertStatus(200); - - //$this->assertDatabaseHas('departments',$department->toArray()); - - //$this->get('create-school') - //->assertSee($department['department_name']); - //} } diff --git a/tests/Feature/Manage/SettingModuleTest.php b/tests/Feature/Manage/SettingModuleTest.php new file mode 100644 index 000000000..138b36a09 --- /dev/null +++ b/tests/Feature/Manage/SettingModuleTest.php @@ -0,0 +1,61 @@ +states('admin')->create(); + $this->actingAs($admin); + $this->withoutExceptionHandling(); + } + + /** @test */ + public function it_shows_the_teachers_list() { + $this->get(route('settings.index')) + ->assertStatus(200) + ->assertViewHas('teachers'); + } + + /** @test */ + public function it_shows_the_departments_list() { + $this->get(route('settings.index')) + ->assertStatus(200) + ->assertViewHas('departments'); + } + + /** @test */ + public function it_shows_the_classes_list() { + $this->get(route('settings.index')) + ->assertStatus(200) + ->assertViewHas('classes'); + } + + /** @test */ + public function it_shows_the_sections_list() { + $this->get(route('settings.index')) + ->assertStatus(200) + ->assertViewHas('sections'); + } + + /** @test */ + public function admin_can_create_new_department() { + $department = factory(Department::class)->make(); + $this->followingRedirects() + ->post('school/add-department',$department->toArray()) + ->assertStatus(200); + + $this->assertDatabaseHas('departments',$department->toArray()); + + $this->get(route('settings.index')) + ->assertSee($department['department_name']); + } +}