diff --git a/app/Http/Controllers/AvaliadorController.php b/app/Http/Controllers/AvaliadorController.php new file mode 100644 index 0000000000000000000000000000000000000000..863acd4e3f9eafccc144af5cb38a76fa44d2c619 --- /dev/null +++ b/app/Http/Controllers/AvaliadorController.php @@ -0,0 +1,226 @@ + 2]); + if(Auth::user()->isTypeAdmin()) { + $pads = Pad::all(); + $index_menu = MenuItemsAdmin::PADS; + return view('pad.admin.index', ['index_menu' => $index_menu, 'pads' => $pads]); + } + + if(Auth::user()->isTypeTeacher()) { + + $index_menu = 1; + $userPads = UserPad::find()->whereUser(Auth::user()->id)->get(); + + return view('pad.avaliacao.index', ['index_menu' => $index_menu, 'userPads' => $userPads]); + } + } + + /** + * @param integer $id + * @return \Illuminate\Http\Response + */ + public function view($id) { + $index_menu = 1; + return view('pad.teacher.view', ['id' => $id, 'index_menu' => $index_menu]); + } + + /** + * Show the form for creating a new resource. + * + * @return \Illuminate\Http\Response + */ + public function create() + { + $status = [ + Constants::STATUS_ATIVO => Constants::listStatus(Constants::STATUS_ATIVO) + ]; + return view('pad.admin.create', ['status' => $status]); + } + + /** + * Store a newly created resource in storage. + * @param \Illuminate\Http\Request $request + */ + public function store(Request $request) + { + $validated = $request->validate([ + 'nome' => ['required', 'string', 'min:6', 'max:255'], + 'status' => ['required', 'integer'], + 'data_inicio' => ['required', 'date', 'before_or_equal:data_fim'], + 'data_fim' => ['required', 'date', 'after_or_equal:data_inicio'], + ], + [ + 'required' => 'O campo de :attribute é obrigatório', + 'nome.min' => 'O campo de :attribute deve ter no mínimo 6 letras', + 'nome.max' => 'O campo de :attribute deve ter no máximo 255 letras', + 'data_inicio.before_or_equal' => 'A :attribute deve ser uma data anterior ou igual a data de fim', + 'data_fim.after_or_equal' => 'A :attribute deve ser uma data posterior ou igual a data de início', + ]); + + if($validated) { + $model = new Pad($request->all()); + + if($model->save()) { + + $users = User::find()->whereType(User::TYPE_TEACHER)->get(); + + foreach($users as $user) { + $modelUserPad = new UserPad(); + $modelUserPad->user_id = $user->id; + $modelUserPad->pad_id = $model->id; + $modelUserPad->save(); + } + + return redirect()->route('pad_index')->with('success', 'PAD cadastrado com sucesso!'); + } else { + return redirect()->route('pad_index')->with('success', 'Erro ao cadastrar o PAD!'); + } + } + } + + public function anexo() + { + return view('pad.anexo', ['index_menu' => 1 ]); + } + + // /** + // * Store a newly created resource in storage. + // * + // * @param \Illuminate\Http\Request $request + // * @return \Illuminate\Http\Response + // */ + // public function store(Request $request) + // { + // $rules = [ + // 'first_name' => 'required|string|min:3|max:255', + // 'city_name' => 'required|string|min:3|max:255', + // 'email' => 'required|string|email|max:255' + // ]; + // $validator = Validator::make($request->all(),$rules); + // if ($validator->fails()) { + // return redirect('insert') + // ->withInput() + // ->withErrors($validator); + // } + // else{ + // $data = $request->input(); + // try{ + // $student = new StudInsert; + // $student->first_name = $data['first_name']; + // $student->last_name = $data['last_name']; + // $student->city_name = $data['city_name']; + // $student->email = $data['email']; + // $student->save(); + // return redirect('insert')->with('status',"Insert successfully"); + // } + // catch(Exception $e){ + // return redirect('insert')->with('failed',"operation failed"); + // } + // } + + // return redirect('/dashboard'); + // } + + /** + * Show the form for editing the specified resource. + * + * @param integer $id + * @return \Illuminate\Http\Response + */ + public function edit($id) + { + $pad = PAD::find($id); + $status = Constants::listStatus(); + + return view('pad.admin.edit', ['pad' => $pad, 'status' => $status]); + } + + /** + * Update the specified resource in storage. + * + * @param \Illuminate\Http\Request $request + * @param integer $id + * @return \Illuminate\Http\Response + */ + public function update(Request $request, $id) + { + $validated = $request->validate([ + 'nome' => ['required', 'string', 'min:6', 'max:255'], + 'status' => ['required', 'integer'], + 'data_inicio' => ['required', 'date', 'before_or_equal:data_fim'], + 'data_fim' => ['required', 'date', 'after_or_equal:data_inicio'], + ], + [ + 'required' => 'O campo de :attribute é obrigatório', + 'nome.min' => 'O campo de :attribute deve ter no mínimo 6 letras', + 'nome.max' => 'O campo de :attribute deve ter no máximo 255 letras', + 'data_inicio.before_or_equal' => 'A :attribute deve ser uma data anterior ou igual a data de fim', + 'data_fim.after_or_equal' => 'A :attribute deve ser uma data posterior ou igual a data de início', + ]); + + if($validated) { + $model = Pad::find($id); + $model->fill($request->all()); + + if($model->save()) { + return redirect()->route('pad_index')->with('success', 'PAD atualizado com sucesso!'); + } else { + return redirect()->route('pad_index')->with('success', 'Erro ao atualizar o PAD!'); + } + } + } + + + public function delete($id) { + $model = Pad::find($id); + + if($model->delete()) { + return redirect()->route('pad_index')->with('success', 'PAD removido com sucesso!'); + } else { + return redirect()->route('pad_index')->with('fail', 'Não foi possível remover o PAD!'); + } + } + + /** + * Remove the specified resource from storage. + * + * @param int $id + * @return \Illuminate\Http\Response + */ + public function destroy($id) + { + $model = PAD::find($id); + $model->delete(); + + return redirect('/pad/index'); + } +} \ No newline at end of file diff --git a/app/Http/Controllers/PadController.php b/app/Http/Controllers/PadController.php index b4427fce18d6b3a73aca9519c29fbd7f4c52675c..019d2ea81f236b8f46848f5f45092dbcf6594979 100644 --- a/app/Http/Controllers/PadController.php +++ b/app/Http/Controllers/PadController.php @@ -84,7 +84,7 @@ class PadController extends Controller if($validated) { $model = new Pad($request->all()); - + if($model->save()) { $users = User::find()->whereType(User::TYPE_TEACHER)->get(); diff --git a/app/Models/Avaliacao.php b/app/Models/Avaliacao.php new file mode 100644 index 0000000000000000000000000000000000000000..4626219b1baec218d5dada4cf7599add6ceef6a8 --- /dev/null +++ b/app/Models/Avaliacao.php @@ -0,0 +1,24 @@ +belongsTo(PAD::class); + } + + public function avaliadorPad() { + return $this->belongsTo(AvaliadorPad::class); + } +} diff --git a/app/Models/AvaliadorPad.php b/app/Models/AvaliadorPad.php new file mode 100644 index 0000000000000000000000000000000000000000..68c4a3b4667cc5594746d6fdb27997a388f6e41e --- /dev/null +++ b/app/Models/AvaliadorPad.php @@ -0,0 +1,28 @@ +belongsTo(User::class); + } + + public function pad() { + return $this->belongsTo(PAD::class); + } + + public static function find() { + return new UserPadQuery(get_called_class()); + } +} diff --git a/app/Models/UserPad.php b/app/Models/UserPad.php index 032f2b1b57a7031ef4915520ef4a205c85c1b538..f5165e10c163c70c3f14070cd22f218cf37bdb17 100644 --- a/app/Models/UserPad.php +++ b/app/Models/UserPad.php @@ -25,5 +25,4 @@ class UserPad extends Model public static function find() { return new UserPadQuery(get_called_class()); } - } diff --git a/app/Models/Util/PadTables.php b/app/Models/Util/PadTables.php index 0b92edd428da776264c9ebe5be8f5f2e150b80cd..e58ffadc5c9039c98959ac5dc188f0a4816c6ce1 100644 --- a/app/Models/Util/PadTables.php +++ b/app/Models/Util/PadTables.php @@ -4,6 +4,11 @@ namespace App\Models\Util; class PadTables { + const TYPE_ENSINO = 0; + const TYPE_EXTENSAO = 1; + const TYPE_PESQUISA = 2; + const TYPE_GESTAO = 3; + public static function tablesEnsino() { return [ ['id' => 'ensino_aulas', 'name' => 'ENSINO (AULAS EM COMPONENTES CURRICULARES)'], diff --git a/app/Queries/AvaliadorPadQuery.php b/app/Queries/AvaliadorPadQuery.php new file mode 100644 index 0000000000000000000000000000000000000000..9b50a17948bec46df3d61d6a405aa3ea2ac03fa7 --- /dev/null +++ b/app/Queries/AvaliadorPadQuery.php @@ -0,0 +1,43 @@ +query = AvaliadorPad::where([]); + } + + /** + * @param integer $id + * @return AvaliadorPadQuery|Builder + */ + public function whereId($id, $expression = '=') + { + $this->query = $this->query->where('id', $expression, $id); + return $this->query; + } + + /** + * @param integer $user_id + * @return AvaliadorPadQuery|Builder + */ + public function whereUser($user_id, $expression = '=') + { + $this->query = $this->query->where('user_id', $expression, $user_id); + return $this->query; + } + + /** + * @return Builder + */ + public function getQuery() + { + return $this->query; + } +} \ No newline at end of file diff --git a/database/migrations/2022_07_15_003939_create_evaluator_pad_table.php b/database/migrations/2022_07_15_003939_create_evaluator_pad_table.php new file mode 100644 index 0000000000000000000000000000000000000000..816115772cdefd2761be10d97bf9a67eefa6e457 --- /dev/null +++ b/database/migrations/2022_07_15_003939_create_evaluator_pad_table.php @@ -0,0 +1,35 @@ +id(); + $table->tinyInteger('dimensao')->notNull(); + $table->foreignId('user_id')->notNull(); + $table->foreignId('pad_id')->notNull(); + $table->timestamps(); + $table->softDeletes(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('avaliador_pad'); + } +} diff --git a/database/migrations/2022_07_17_193918_create_avaliacao_table.php b/database/migrations/2022_07_17_193918_create_avaliacao_table.php new file mode 100644 index 0000000000000000000000000000000000000000..f9162b18127d2eec742e97c5fd45b9d66f7a5120 --- /dev/null +++ b/database/migrations/2022_07_17_193918_create_avaliacao_table.php @@ -0,0 +1,37 @@ +id(); + $table->integer('ch_semanal')->notNull(); + $table->integer('status')->notNull(); + $table->string('descricao')->notNull(); + $table->integer('tarefa_id')->notNull(); + $table->foreignId('avaliador_id')->notNull(); + $table->timestamps(); + $table->softDeletes(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('avaliacao'); + } +} diff --git a/database/seeders/AvaliacaoSeeder.php b/database/seeders/AvaliacaoSeeder.php new file mode 100644 index 0000000000000000000000000000000000000000..524aedef34f29a03b5b92074ad682f1fbea9c079 --- /dev/null +++ b/database/seeders/AvaliacaoSeeder.php @@ -0,0 +1,18 @@ + 1, + 'dimensao' => PadTables::TYPE_ENSINO, + 'user_id' => 8, + 'pad_id' => 1 + ] + ); + } +} diff --git a/database/seeders/PadSeeder.php b/database/seeders/PadSeeder.php index df0ff2d29681c73628bec9caf78c6436a12ae934..bfc2640eed0ea7d364fda983766f77e7702f3372 100644 --- a/database/seeders/PadSeeder.php +++ b/database/seeders/PadSeeder.php @@ -4,6 +4,7 @@ namespace Database\Seeders; use App\Models\PAD; use App\Models\User; + use Illuminate\Database\Seeder; class PadSeeder extends Seeder @@ -15,5 +16,20 @@ class PadSeeder extends Seeder */ public function run() { + PAD::create([ + 'id' => 1, + 'nome' => "2022.1", + 'data_inicio' => "2022-02-01", + 'data_fim' => "2022-06-01", + 'status' => 0 + ]); + + PAD::create([ + 'id' => 2, + 'nome' => "2022.2", + 'data_inicio' => "2022-07-01", + 'data_fim' => "2022-12-01", + 'status' => 1 + ]); } } diff --git a/resources/views/layouts/user-navigation/navigation_coordinator.blade.php b/resources/views/layouts/user-navigation/navigation_coordinator.blade.php index 7e8edbbcfccb42f03f514d9b95daf6fe048322bf..9bf6b0308e81a3ba9903f85f91097c606b42dce3 100644 --- a/resources/views/layouts/user-navigation/navigation_coordinator.blade.php +++ b/resources/views/layouts/user-navigation/navigation_coordinator.blade.php @@ -15,7 +15,7 @@