/** * Store a newly created resource in storage. * * @param \Illuminate\Http\Request $request * @return \Illuminate\Http\Response */ public function store(Request $request) { // Start Check Authorization $invalid_auth = 1; $authRole = Auth::user()->UserRoles->role; if ($authRole == 1 or $authRole == 3) { $invalid_auth = 0; } if ($invalid_auth == 1) { Alert::error('Anda tidak memilik akses ini')->persistent('close'); return redirect('dashboard'); } // End Check Authorization // Validation // $validation = Validator::make($request->all(), ['name' => 'required|unique:categories|max:255', 'description' => 'required']); // Check if it fails // if ($validation->fails()) { return redirect()->back()->withInput()->with('errors', $validation->errors()); } $grade = new Grade(); // save category data into database // $grade->name = $request->input('name'); $grade->description = $request->input('description'); $grade->save(); Alert::success('Success Create, ' . $request->input('name') . ' !')->persistent("Close"); return redirect('grade/list')->with('message', 'You just uploaded !'); }
public function store() { $grade = new Grade(); $grade->school_id = Input::get('school_id'); $grade->grade = Input::get('grade'); $grade->save(); }
/** * Responds to requests to GET /quizzes/{id} */ public function getQuizzesId($id) { // check that quiz had not already been taken by this user $grade = Grade::where('quiz_id', $id)->where('user_id', Auth::user()->id)->first(); if (isset($grade) && $grade->taken) { \Session::flash('flash_message', 'Quiz already graded!'); return redirect('/'); } // get quiz $quiz = Quiz::with('question.answer')->find($id); // check quiz is exists and is active if (is_null($quiz) || !$quiz->ready) { return view('errors.404'); } // create new grade for this quiz set it to zero if (!isset($grade)) { $grade = new Grade(); } $grade->user_id = Auth::user()->id; $grade->quiz_id = $id; $grade->grade = 0; $grade->taken = TRUE; $grade->save(); return view('quiz.take')->with('quiz', $quiz); }
public function postStudentGrades() { $grade = new Grade(); $grade->grade = Input::get('grade'); $grade->user_id = Input::get('user_id'); $grade->subject_id = Input::get('subject'); $grade->save(); return Redirect::action('TeacherController@getStudentGrades', $grade->user_id)->with('message', 'You have successfully created subject and grade'); }
public function store(Request $request) { $this->validate($request, ['id' => 'required|digits:10|unique:users']); $user = new User(); $user->id = $request->id; $user->name = $request->name; $user->password = Hash::make($user->id); $user->save(); session()->flash('message', $user->name . "同学添加成功"); $grade = new Grade(); $grade->user_id = $request->id; $grade->save(); return Redirect::to('admin'); }
/** * Store a newly created resource in storage. * * @param \Illuminate\Http\Request $request * @return \Illuminate\Http\Response */ public function store(Request $request) { // Validation // $validation = Validator::make($request->all(), ['name' => 'required|unique:categories|max:255', 'description' => 'required']); // Check if it fails // if ($validation->fails()) { return redirect()->back()->withInput()->with('errors', $validation->errors()); } $grade = new Grade(); // save category data into database // $grade->name = $request->input('name'); $grade->description = $request->input('description'); $grade->save(); Alert::success('Success Create, ' . $request->input('name') . ' !')->persistent("Close"); return redirect('grade/list')->with('message', 'You just uploaded !'); }
public function createUserGrade() { $grade = new Grade(); $grade->grade = Input::get('grade'); $grade->user_id = Input::get('user_id'); $grade->subject_id = Input::get('subject'); $grade->save(); return Redirect::action('AdminController@getUserGrade', $grade->user_id)->with('message', 'You have successfully created subject and grade'); }
public static function AddGradesAndLevels($user_id, $school_year_id) { $admin = User::where('id', $user_id)->where('type', 'ecole')->first(); if ($admin) { $creche = new Grade(); $creche->name = 'Crèche'; $creche->user_id = $user_id; $creche->school_year_id = $school_year_id; $creche->save(); if ($creche->id) { $niveau = new Level(); $niveau->niveau = 'Crèche'; $niveau->user_id = $user_id; $niveau->grade_id = $creche->id; $niveau->school_year_id = $school_year_id; $niveau->save(); } $mater = new Grade(); $mater->name = 'Maternelle'; $mater->user_id = $user_id; $mater->school_year_id = $school_year_id; $mater->save(); if ($mater) { $niveau = new Level(); $niveau->niveau = 'Petite Section'; $niveau->user_id = $user_id; $niveau->grade_id = $mater->id; $niveau->school_year_id = $school_year_id; $niveau->save(); $niveau = new Level(); $niveau->niveau = 'Moyenne Section'; $niveau->user_id = $user_id; $niveau->grade_id = $mater->id; $niveau->school_year_id = $school_year_id; $niveau->save(); $niveau = new Level(); $niveau->niveau = 'Grande Section'; $niveau->user_id = $user_id; $niveau->grade_id = $mater->id; $niveau->school_year_id = $school_year_id; $niveau->save(); } $sc = new Grade(); $sc->name = 'Primaire'; $sc->user_id = $user_id; $sc->school_year_id = $school_year_id; $sc->save(); if ($sc) { for ($i = 1; $i <= 6; $i++) { $niveau = new Level(); $niveau->niveau = 'CE' . $i; $niveau->user_id = $user_id; $niveau->grade_id = $sc->id; $niveau->school_year_id = $school_year_id; $niveau->save(); } } $col = new Grade(); $col->name = 'Collège'; $col->user_id = $user_id; $col->school_year_id = $school_year_id; $col->save(); if ($col) { for ($i = 1; $i <= 3; $i++) { if ($i == 1) { $niveau = new Level(); $niveau->niveau = '1ère année Collège'; $niveau->user_id = $user_id; $niveau->grade_id = $col->id; $niveau->school_year_id = $school_year_id; $niveau->save(); } elseif ($i > 1) { $niveau = new Level(); $niveau->niveau = $i . 'ème année Collège'; $niveau->user_id = $user_id; $niveau->grade_id = $col->id; $niveau->school_year_id = $school_year_id; $niveau->save(); } } } $lyc = new Grade(); $lyc->name = 'Lycée'; $lyc->user_id = $user_id; $lyc->school_year_id = $school_year_id; $lyc->save(); if ($lyc) { $niveau = new Level(); $niveau->niveau = 'Tronc Commun'; $niveau->user_id = $user_id; $niveau->grade_id = $lyc->id; $niveau->school_year_id = $school_year_id; $niveau->save(); if ($niveau->id) { $l = Level::where('id', $niveau->id)->where('user_id', $user_id)->first(); $branchesTc = ['Tronc Commun Sciences', 'Tronc Commun Lettres et sciences humaines', 'Tronc Commun Technologique', 'Tronc Commun Enseignement Originel']; foreach ($branchesTc as $br) { $branche = new Branch(); $branche->nom_branche = $br; $branche->code_branche = ""; $branche->user_id = $user_id; $branche->level_id = $niveau->id; $branche->school_year_id = $school_year_id; $branche->save(); if ($branche->id) { $l->onbranches()->attach([$branche->id]); } } } $niveau = new Level(); $niveau->niveau = '1ère Baccalauréat'; $niveau->user_id = $user_id; $niveau->grade_id = $lyc->id; $niveau->school_year_id = $school_year_id; $niveau->save(); if ($niveau->id) { $l = Level::where('id', $niveau->id)->where('user_id', $user_id)->first(); $branches1Bac = ['Sciences mathématiques', 'Sciences expérimentales', 'Bac Sciences et Technologies Electriques', 'Bac Sciences et Technologies Mecaniques', 'Arts appliqués', 'Sciences économiques et gestion', 'Lettres et sciences humaines', 'Langue Arabe', 'Sciences de la Chariaa']; foreach ($branches1Bac as $br) { $branche = new Branch(); $branche->nom_branche = $br; $branche->code_branche = ""; $branche->user_id = $user_id; $branche->level_id = $niveau->id; $branche->school_year_id = $school_year_id; $branche->save(); if ($branche->id) { $l->onbranches()->attach([$branche->id]); } } } $niveau = new Level(); $niveau->niveau = 'Baccalaureat'; $niveau->user_id = $user_id; $niveau->grade_id = $lyc->id; $niveau->school_year_id = $school_year_id; $niveau->save(); if ($niveau->id) { $l = Level::where('id', $niveau->id)->where('user_id', $user_id)->first(); $branchesBac = ['Bac Sciences mathématiques A', 'Bac Sciences Mathématiques B', 'Bac Sciences Physiques', 'SVT Bac', 'Bac Sciences Agronomiques', 'Bac Sciences et Technologies Electriques', 'Bac Sciences et Technologies Mecaniques', 'Arts appliqués', 'Bac Sciences économiques', 'Bac Techniques de gestion et comptabilité', 'Bac Lettres', 'Sciences humaines', 'Langue Arabe', 'Sciences de la Chariaa']; foreach ($branchesBac as $br) { $branche = new Branch(); $branche->nom_branche = $br; $branche->code_branche = ""; $branche->user_id = $user_id; $branche->level_id = $niveau->id; $branche->school_year_id = $school_year_id; $branche->save(); if ($branche->id) { $l->onbranches()->attach([$branche->id]); } } } } } }