/**
  * Update the specified resource in storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function update($id, Request $request)
 {
     //$this->validate($request, ['name' => 'required']); // Uncomment and modify if you need to validate any input.
     $subject = Subject::findOrFail($id);
     $subject->update($request->all());
     return redirect('subject');
 }
Exemplo n.º 2
0
 /**
  * @param $id
  * @param \Illuminate\Http\Request $request
  * @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
  */
 public function store($id, \Illuminate\Http\Request $request)
 {
     $this->validate($request, ['grade' => 'required', 'factor' => 'required']);
     $subject = Subject::findOrFail($id);
     $grade = new Grade(Request::all());
     $subject->grades()->save($grade);
     return redirect('groups');
 }
Exemplo n.º 3
0
 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request)
 {
     $this->validate($request, ['name' => 'required|min:5', 'subject_id' => 'required', 'class' => 'required']);
     $subject = Subject::findOrFail($request->get('subject_id'));
     $input = $request->all();
     Partition::create($input);
     \Session::flash('flash_message', 'Разделът беше успешно добавен!');
     return redirect()->route('admin.partition.index');
 }
Exemplo n.º 4
0
 /**
  * @param $id
  * @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
  */
 public function destroy($id)
 {
     $subject = Subject::findOrFail($id);
     if ($subject->group->user->id != Auth::id()) {
         return redirect('groups');
     }
     $subject->delete();
     return redirect('groups');
 }
Exemplo n.º 5
0
 function show($id)
 {
     $subject_id = Subjects::findOrFail($id);
     $owner = Api::getCollege();
     if ($subject_id instanceof ModelNotFoundException) {
         return view('errors.404');
     }
     return view('dean.subject', ['subject' => $subject_id, 'owner' => $owner]);
 }
Exemplo n.º 6
0
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function destroy($id)
 {
     $subject = Subject::findOrFail($id);
     $partitions = Partition::where('subject_id', '=', $id);
     foreach ($partitions->get() as $value) {
         $questions = Question::where('subject_id', '=', $id)->where('partition_id', '=', $value->id);
         foreach ($questions->get() as $value) {
             $answers = Answer::where('question_id', '=', $value->id);
             $answers->update(['trash' => true]);
         }
         $questions->update(['trash' => true]);
     }
     $partitions->update(['trash' => true]);
     $subject->update(['trash' => true]);
     \Session::flash('flash_message', 'Предметът беше успешно преместено в кошчето!');
     return redirect()->route('admin.subject.index');
 }
 public function save_person(Request $request, $id)
 {
     $subject = Subject::findOrFail($id);
     $person = new Person($request->all());
     $subject->books()->save($person);
     \Auth::user()->studied_books()->save($person);
     session()->flash('info', 'Thêm chuyên gia thành công!');
     return redirect('subjects/' . $id);
 }
Exemplo n.º 8
0
 /**
  * Present the Edit view of the resource
  *
  * @param mixed   $id    Object ID
  * @param Subject $model Model Object
  *
  * @return \Illuminate\View\View
  */
 public function edit($id, Subject $model)
 {
     $subject = $model->findOrFail($id);
     return view('admin.subject.edit', compact('subject'));
 }
Exemplo n.º 9
0
 public function getShowResultOfSubjectForGuest($id)
 {
     $subject = Subject::findOrFail($id);
     $answers = Answer::whereSubjectId($id)->get();
     if ($answers->count()) {
         $cnt = $answers->count();
         $cnt_right_answ = 0;
         foreach ($answers as $a) {
             if ($a->user_answer == $a->right_answer) {
                 $cnt_right_answ++;
             }
         }
         $persetnages = ceil($cnt_right_answ * 100 / $cnt);
         $time_taken = gmdate("H:i:s", Answer::whereSubjectId($id)->orderBy('id', 'desc')->first()->time_taken);
         $title = 'Results of test';
         session()->flash('flash_mess', 'Your Exam data has been saved successfully');
         return view('subject.result', compact('subject', 'title', 'cnt', 'cnt_right_answ', 'persetnages', 'time_taken'));
     } else {
         return redirect('/');
     }
 }
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function destroy($id)
 {
     DB::transaction(function () use($id) {
         $user = Auth::user();
         $subject = Subject::findOrFail($id);
         $subject->updated_by = $user->name;
         $subject->deleted_by = $user->name;
         $subject->key = $subject->key . '-' . microtime(true);
         $subject->save();
         // soft delete
         $subject->delete();
     });
 }
Exemplo n.º 11
0
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function destroy($id)
 {
     $subject = Subject::findOrFail($id);
     $subject->delete();
     Session::flash('message', 'Fach wurde gelöscht');
     return redirect('subject');
 }
Exemplo n.º 12
0
 /**
  * Update the specified resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function update(SubjectRequest $request, $id)
 {
     $input = $request->except('_method', '_token');
     $subject = Subject::findOrFail($id);
     if ($subject->update($input)) {
         return redirect('/subjects');
     }
 }
Exemplo n.º 13
0
 public function delete($id)
 {
     $subject = Subject::findOrFail($id);
     $subject->delete();
     return redirect(route('subjects.index'))->with('flash_success', 'subject deleted successfully.');
 }