Пример #1
0
 public function index()
 {
     $subjects = collect(Subject::where('trash', '=', false)->get()->toArray())->groupBy('name')->count();
     $partitions = Partition::where('trash', '=', false)->count();
     $invites = Invite::count();
     $questions = Question::where('trash', '=', false)->count();
     $users = User::count();
     $trash = '';
     $testrooms = '';
     if (\Entrust::hasRole('admin')) {
         $trash = Question::where('trash', '=', true)->count() + Subject::where('trash', '=', true)->count() + Partition::where('trash', '=', true)->count() + TestRoom::where('teacher_id', '=', \Auth::user()->id)->where('trash', '=', true)->count();
     } elseif (\Entrust::hasRole('teacher')) {
         $testrooms = TestRoom::where('teacher_id', '=', \Auth::user()->id)->count();
     }
     return view('admin.welcome', ['subjects' => $subjects, 'partitions' => $partitions, 'invites' => $invites, 'questions' => $questions, 'users' => $users, 'trash' => $trash, 'testrooms' => $testrooms]);
 }
Пример #2
0
 public function destroy($code)
 {
     $testroom = TestRoom::where('code', '=', $code)->update(['trash' => true]);
     $testroom_students = TestRoomStudents::where('code', '=', $code)->update(['trash' => true]);
     Session::flash('flash_message', 'Стаята беше изтрита!');
     return redirect()->route('admin.testroom.index');
 }
Пример #3
0
 public function startTestRoomTest($code)
 {
     $testroom = TestRoom::where('code', '=', $code)->get()[0];
     $questions_id = explode(', ', $testroom->questions_id);
     foreach ($questions_id as $key => $value) {
         $questions[$key] = Question::find($value);
     }
     shuffle($questions);
     Session::put('questions', $questions);
     foreach ($questions as $key => $value) {
         $answers[$key] = Answer::where('question_id', '=', $value->id)->orderByRaw("RAND()")->get();
     }
     Session::put('answers', $answers);
     return view('test.test', ['question' => $questions['0'], 'answers' => $answers['0'], 'type' => $questions[0]->type, 'key' => '0', 'testroomcode' => $code]);
 }
Пример #4
0
 public function deleteTestRoom($code)
 {
     $testroom = TestRoom::where('code', '=', $code)->where('trash', '=', true)->delete();
     $testroom_students = TestRoomStudents::where('code', '=', $code)->where('trash', '=', true)->delete();
     return back();
 }