/**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return Response
  */
 public function show($id)
 {
     if (!Auth::check()) {
         return redirect('home')->with('message', "Veuillez d'abord vous connecter");
     }
     $question = Question::find($id);
     if (is_null($question)) {
         abort(404);
     }
     $total_questions = Question::count();
     $user = Auth::user();
     $total_questions_replied = $user->questionsReplied()->count();
     $total_questions_replied_percent = round($total_questions_replied / $total_questions * 100);
     // Get the current user that will be the origin of our operations
     // Get ID of a User whose autoincremented ID is less than the current user, but because some entries might have been deleted we need to get the max available ID of all entries whose ID is less than current user's
     $previousQuestionID = Question::where('id', '<', $question->id)->max('id');
     // Same for the next user's id as previous user's but in the other direction
     $nextQuestionID = Question::where('id', '>', $question->id)->min('id');
     $replies = $question->getChoices();
     // if user already replied to this particular question
     if ($question->getAnswer()) {
         $replies[$question->getAnswer()]['checked'] = true;
         $question->replied = true;
     }
     return view('questions.show', compact('question', 'previousQuestionID', 'nextQuestionID', 'replies', 'total_questions', 'total_questions_replied', 'total_questions_replied_percent'));
 }
 public function index()
 {
     $title = "Dashboard";
     $questions = Question::count();
     $questioncategories = QuestionCategory::count();
     $users = User::count();
     return view('admin.dashboard.index', compact('title', 'questions', 'questioncategories', 'countries', 'users'));
 }
Example #3
0
 /**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function index()
 {
     $posts_published = Post::published()->count();
     $posts_editing = Post::where('published', 'uc')->count();
     $posts_sticky = Post::where('is_sticky', 'on')->count();
     $posts = Post::count();
     $users = User::count();
     $jobs = Job::count();
     $questions = Question::count();
     $categories = Category::count();
     return view('admin.stats.index', compact('posts', 'posts_published', 'posts_sticky', 'posts_editing', 'users', 'jobs', 'questions', 'categories'));
 }
 /**
  * return the questions from the database
  * 
  * @return array       questions
  */
 public function all(Request $request)
 {
     if (!Auth::check()) {
         return Response::json(['error' => ['message' => 'not authorized, not logged in']]);
     } else {
         if (!Auth::user()->isAdmin()) {
             return Response::json(['error' => ['message' => 'not authorized, elevated permissions needed']]);
         }
     }
     $questionsCount = Question::count();
     // get the questions for that page
     $questions = Question::orderby('sequence')->get();
     // add the number of answers for each question
     for ($i = 0; $i < $questionsCount; $i++) {
         $questions[$i]['answersCount'] = $questions[$i]->answersCount();
     }
     $result = array('questions' => $questions, 'questionsCount' => $questionsCount);
     // return the result
     return $result;
 }
Example #5
0
 /**
  * Determinate if the current member has finished the survey
  * @return boolean
  */
 private function hasFinishedSurvey()
 {
     return $this->getCurrentMember()->answer_position == Question::count();
 }