示例#1
0
 public function index()
 {
     $questions = Question::all();
     $tpl['user'] = \Auth::user();
     $tpl['questions'] = $questions;
     return view('home', $tpl);
 }
 /**
  * Show the form for creating a new resource.
  *
  * @return Response
  */
 public function createQuestion()
 {
     $questions = \App\Question::all();
     $user = \Auth::user();
     $fiche_id = Session::get('fiche_id');
     return view('back.newQuestion', compact('questions', 'fiche_id', 'user'));
 }
示例#3
0
 /**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function index()
 {
     $questions = Question::all();
     $data = array();
     $data['questions'] = $questions;
     $data['languages'] = Language::all();
     return view('questions.index', $data);
 }
 /**
  * The game page itself
  *
  * @return Response
  */
 public function index()
 {
     $ws = Websitespel::where("ended", false)->orderBy('start_date')->first();
     if ($ws == null) {
         //no games in progress and none planned
         //return done
         return view('game.ended')->with('countDown', false);
     } else {
         if ($ws->start_date > \Carbon\Carbon::now()) {
             // do the countdown
             // return countdown
             return view('game.countdown')->with('countDown', $ws);
         }
     }
     // else carry on
     $team = Auth::user()->team()->first();
     $questionNr = count(Progress::where('team_id', $team->id)->get());
     $question = null;
     $tip = false;
     $times = [];
     if ($questionNr != count(Question::all())) {
         $question = Question::where('sequence', $questionNr + 1)->first();
         $result = QuestionTime::where('team_id', $team->id)->where('question_id', $question->id)->get();
         if (count($result) == 0) {
             $questionTime = new QuestionTime();
             $questionTime->team_id = $team->id;
             $questionTime->question_id = $question->id;
             $questionTime->tip = false;
             $questionTime->start_time = \Carbon\Carbon::now()->timestamp;
             $questionTime->save();
             $tip = false;
         } else {
             $tip = $result->first()->tip;
         }
     } else {
         $teams = Team::all();
         $teamsCount = count($teams);
         $question_id = Question::where('sequence', Question::max('sequence'))->first()->id;
         for ($i = 0; $i < $teamsCount; $i++) {
             $qt = QuestionTime::where('team_id', $teams[$i]->id)->where('question_id', $question_id)->first();
             if ($qt == null) {
                 continue;
             }
             $end_time = $qt->end_time;
             if ($end_time == null) {
                 continue;
             }
             $end_time_string = \Carbon\Carbon::createFromTimestamp($end_time);
             array_push($times, array('name' => $teams[$i]->teamname, 'time' => $end_time_string, 'countDown' => 0));
         }
         usort($times, function ($a, $b) {
             return $a['time']->timestamp - $b['time']->timestamp;
         });
     }
     return view('game.index')->with(array('question' => $question, 'tip' => $tip, 'end_times' => $times, 'countDown', null));
 }
示例#5
0
 public static function questions()
 {
     if (Gate::allows('view_question')) {
         return Question::all();
     } elseif (Auth::check() && Gate::allows('view_own_question')) {
         return Question::where('user_id', Auth::id())->get();
     } else {
         return null;
     }
 }
 public function show()
 {
     /*return Datatables::of(Question::all())
       ->addColumn('qtitle', function($model){
           return $model->qtitle;
       })
       ->addColumn('answer', function($model){
           return $model->answer;
       })
       ->searchColumns('qtitle', 'answer')
       ->orderColumns('qtitle', 'answer')
       ->make(true);*/
     $questions = Question::all();
     return view('questions.show', compact('questions'));
 }
示例#7
0
 /**
  * Show the questions list to the user.
  *
  * @return Response
  */
 public function index()
 {
     try {
         $data['questions'] = Question::all();
         if (isset($data['questions']) && count($data['questions']) > 0) {
             //get Answers of first question with added user name
             $data['firstAnswers'] = Answer::leftJoin('users', function ($join) {
                 $join->on('answers.user_id', '=', 'users.id');
             })->where("question_id", "=", $data['questions'][0]->id)->get(['answers.id', 'answers.answer', 'answers.question_id', 'users.id', 'users.name']);
         }
         return view('question.view', $data);
     } catch (Exception $e) {
         return redirect()->back()->withInput()->withErrors($e->getMessage());
     }
 }
 /**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function index()
 {
     // this should limit the number of queries but need more digging
     // eager loading
     //$questions = Question::with('replies')->get();
     $questions = Question::all();
     $user = Auth::user();
     if (!Auth::check()) {
         return redirect('home')->with('message', "Veuillez d'abord vous connecter");
     }
     foreach ($questions as $question) {
         if ($question->getAnswer()) {
             $question->replied = true;
         } else {
             $question->replied = false;
         }
     }
     return view('questions.index')->with('questions', $questions);
 }
 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index()
 {
     $questions = Question::all()->sortByDesc('created_at');
     return view('questions.index', compact('questions'));
 }
 public function edit_question()
 {
     $data = Input::all();
     $event = Event::where('id', Session::get('event_id'))->first();
     $question = Question::where('id', '=', Session::get('qid'))->first();
     $question->event_id = Session::get('event_id');
     $question->question = $data['question'];
     $image = array();
     if (isset($data['file'])) {
         if (Input::file('file')->isValid()) {
             $destinationPathvfile = 'uploads';
             $extensionvfile = Input::file('file')->getClientOriginalExtension();
             $fileNamevfile = $event->id . '.' . $extensionvfile;
             // renaming image
             Input::file('file')->move($destinationPathvfile, $fileNamevfile);
             $question->image = $fileNamevfile;
         }
     }
     if (isset($data['html'])) {
         $question->html = $data['html'];
     }
     if (intval($event->type) > 2) {
         $question->options = serialize($data['options']);
         $answers = $data['answers'];
         $question->save();
         Session::put('qid', Question::all()->last()->id);
         $answer = Answer::where('ques_id', '=', Session::get('qid'))->delete();
         foreach ($answers as $ans) {
             $answer = new Answer();
             $answer->ques_id = Session::get('qid');
             $answer->answer = $ans;
             $answer->score = 1;
             $answer->incorrect = 0;
             $answer->save();
         }
     } else {
         $question->level = $data['level'];
         $question->save();
         Session::put('qid', Question::all()->last()->id);
         $answer = Answer::where('ques_id', '=', Session::get('qid'))->first();
         $answer->ques_id = Session::get('qid');
         $answer->answer = $data['answer'];
         $answer->score = 1;
         $answer->incorrect = 0;
         $answer->save();
     }
     Session::put('event_id', $event->id);
     return Redirect::route('viewquestions', ['event_id' => $event->id])->with('message', 'Question Successfully Edited');
 }
 public function index()
 {
     $questions = \App\Question::all();
     return view('admin.questions.index', compact('questions'));
 }
 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index()
 {
     $questions = Question::all();
     return $questions->toJson();
 }
示例#13
0
 /**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function index()
 {
     $questions = Question::all();
     return view('questions.index');
 }
 public function create()
 {
     $questions = Question::all()->groupBy('topic_id');
     $topics = Topic::all()->pluck('text', 'id')->all();
     return view('questionaire.create', compact('questions', 'topics'));
 }
 /**
  * stores a new question in the database.
  * 
  * @param  Request $request the request
  * @return redirect           back to the questions overview
  */
 public function store(Request $request)
 {
     $question = $request->all();
     if (!array_key_exists('tip_alters_question', $question)) {
         $question['tip_alters_question'] = false;
     }
     $question['sequence'] = count(Question::all()) + 1;
     $question = Question::create($question);
     return redirect("admin/questions/" . $question->id);
 }
示例#16
0
 public function apiload(Request $request)
 {
     //$req = $request::instance();
     $data = json_decode($request->getContent());
     $id = 0;
     if (isset($data->id)) {
         $id = $data->id;
     }
     $obj = Question::all();
     if ($id > 0) {
         $obj = Question::where('category_id', $id)->get();
     }
     foreach ($obj as $row) {
         $row->possibilities = json_decode($row->possibilities);
     }
     return Response::json(['data' => $obj]);
 }
示例#17
0
 public function index()
 {
     $action = 'forum';
     $questions = Question::all();
     return view('member.forum.index', compact('action', 'questions'));
 }
示例#18
0
Route::get('/about', 'PagesController@about');
Route::get('/Register', 'RegisterController@create');
Route::post('/Register', 'RegisterController@store');
Route::get('/index', 'RegisterController@index');
Route::get('/Login', 'LoginController@create');
Route::post('/Login', 'LoginController@store');
Route::group(['middleware' => 'auth'], function () {
    Route::get('/Userhome', 'UserhomeController@create');
    Route::get('/Question', 'QuestionController@create');
    Route::post('/Question', 'QuestionController@store');
    Route::get('/List', function () {
        $title = Question::all();
        return view('List', ['title' => $title]);
    });
    Route::get('Answer/{id}/{question}', function ($id, $question) {
        $user1 = User::all();
        $answer1 = Answer::all();
        $question1 = Question::all();
        $vote2 = Vote::all();
        return view('/Answer', ['question1' => $question1, 'answer1' => $answer1, 'id' => $id, 'user1' => $user1, 'vote2' => $vote2]);
    });
    Route::post('Answer/{id}/{question}', 'AnswerController@store');
    Route::get('Vote/{aid}/{vote1}', 'VoteController@store');
    Route::get('/Logout', 'LogoutController@create');
});
Route::get('auth/login', function () {
    Cache::flush();
    Session::flush();
    return view('/Login');
});
Route::post('auth/login', 'LoginController@store');
示例#19
0
 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index()
 {
     return Question::all();
 }
示例#20
0
 /**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function index()
 {
     $questions = Question::all();
     return view('question.index')->withQuestions($questions);
 }