/**
  * Load survey test data
  *
  * @return void
  */
 public function setUp()
 {
     parent::setUp();
     $this->beginDatabaseTransaction();
     $appBasePath = base_path();
     Artisan::call('surveys:load', ['fileName' => "{$appBasePath}/bear_survey.json"]);
     $this->firstSurvey = \App\Survey::all()->first();
 }
 /**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function index()
 {
     $allSurveys = Survey::all();
     return response()->view('surveys.index', ['surveys' => $allSurveys]);
 }
 public function download_survey(Request $request)
 {
     $surveys = Survey::all()->sortByDesc('created_at');
     $gens = Gen::all()->sortByDesc('created_at');
     $this->data['surveys'] = $surveys;
     $this->data['gens'] = $gens;
     return view('manage.download_survey', $this->data);
 }
Exemple #4
0
 public function index_api(Request $request)
 {
     return \Response::json(["data" => Survey::all()], 200);
 }
Exemple #5
0
 /**
  * Index of surveys
  *
  * @return \Illuminate\Http\Response
  */
 public function getIndex()
 {
     $surveys = Survey::all();
     return view('survey.index', compact('surveys'));
 }
 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index()
 {
     $surveys = Survey::all();
     return view('survey.index', ['surveys' => $surveys]);
 }
 /**
  * Display a summary of all surveys.
  *
  * @return response
  */
 public function summary()
 {
     // Fetch all completed surveys
     $surveys = Survey::all();
     // Stats
     $crumpled = 0;
     $folded = 0;
     $addresses = [];
     $thinking = [];
     foreach ($surveys as $survey) {
         // Folded/Crumpled
         if ($survey->crumpled) {
             $crumpled++;
         } else {
             $folded++;
         }
         // Thinking (seperate thoughts)
         $thinking = array_merge(explode(',', trim($survey->thinking)), $thinking);
         // Location
         $addresses[] = $survey->address;
     }
     // Calculate frequencies
     $addresses = array_count_values($addresses);
     $thinking = array_count_values($thinking);
     // Sort by value in descending order
     arsort($addresses);
     arsort($thinking);
     return view('summary', ['crumpled' => $crumpled, 'folded' => $folded, 'addresses' => $addresses, 'thoughts' => array_keys(array_slice($thinking, 0, 5)), 'numSurveys' => count($surveys)]);
 }