public function storeSurvey(Request $request)
 {
     $survey = Survey::where('created_at', '>', Carbon::today())->first();
     if ($survey) {
         $survey->status = $request->get('status');
     } else {
         $survey = new Survey($request->all());
     }
     $survey->save();
     return redirect(route('home'))->with('success', TRUE);
 }
 /**
  * Store a newly created resource in storage.
  *
  * @param  request  $request
  * @return response
  */
 public function store(Request $request)
 {
     // Create a Survey Model object
     $survey = new Survey();
     // Set attributes from form
     $survey->thinking = Input::get('thinkingTxt');
     $survey->crumpled = Input::get('method') == 'crumpled';
     $survey->address = Input::get('address');
     // Persist to DB
     $survey->save();
     // Redirect to Summary
     return redirect()->action('SurveyController@summary');
 }
 public function testShowQuestion()
 {
     $survey = new Survey(['title' => 'Testing survey']);
     $question = new Question(['body' => 'What is this?', 'kind' => 'voice']);
     $survey->save();
     $question->survey()->associate($survey)->save();
     $response = $this->call('GET', route('question.show', ['id' => $question->id]));
     $savingUrl = route('question.question_response.store', ['question_id' => $question->id], false);
     $absoluteSavingUrl = route('question.question_response.store', ['question_id' => $question->id]);
     $this->assertContains($question->body, $response->getContent());
     $this->assertContains($savingUrl . '?Kind=voice', $response->getContent());
     $this->assertNotContains($absoluteSavingUrl, $response->getContent());
 }
 public function testStoreResponse()
 {
     $survey = new Survey(['title' => 'Testing survey']);
     $questionOne = new Question(['body' => 'What is this?', 'kind' => 'voice']);
     $questionTwo = new Question(['body' => 'What is that?', 'kind' => 'voice']);
     $survey->save();
     $questionOne->survey()->associate($survey)->save();
     $questionTwo->survey()->associate($survey)->save();
     $responseForQuestion = ['RecordingUrl' => '//somefake.mp3', 'CallSid' => '7h1515un1qu3', 'Kind' => 'voice'];
     $firstResponse = $this->call('POST', route('question.question_response.store', ['question_id' => $questionOne->id]), $responseForQuestion);
     $routeToNextQuestion = route('question.show', ['id' => $questionTwo->id], false);
     $routeToNextQuestionAbsolute = route('question.show', ['id' => $questionTwo->id], true);
     $this->assertContains($routeToNextQuestion, $firstResponse->getContent());
     $secondResponse = $this->call('POST', route('question.question_response.store', ['question_id' => $questionTwo->id]), $responseForQuestion);
     $this->assertNotContains('Redirect', $secondResponse->getContent());
 }
Example #5
0
 public function postSurvey(Request $request)
 {
     $this->validate($request, ['email' => 'required|email']);
     $survey = Survey::firstOrCreate(['email' => $request->input('email')]);
     $request->session()->put('survey', $survey);
     return redirect()->action('SurveyController@getSurveyStep', ['step' => 1]);
 }
Example #6
0
 public function store(Request $request, MailRepo $mailRepo)
 {
     $survey = Survey::where('id', $request->input('id'))->with('recruit')->first();
     $survey->updateOrCreate(['id' => $request->input('id')], $request->all());
     $mailRepo->emailAdmin('Survey Complete', 'Survey was completed', ['Recruit Name' => $survey->recruit->first_name . ' ' . $survey->recruit->last_name]);
     return view('admin.surveys.thank_you');
 }
 private function _questionAfter($question)
 {
     $survey = Survey::find($question->survey_id);
     $allQuestions = $survey->questions()->orderBy('id', 'asc')->get();
     $position = $allQuestions->search($question);
     $nextQuestion = $allQuestions->get($position + 1);
     return $nextQuestion;
 }
 /**
  * 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 the specified resource.
  *
  * @param  int  $id
  * @return Response
  */
 public function show()
 {
     // a guard is needed here to force the user to login if not already logged in...
     $surveys = Survey::orderBy('created_at', 'DESC')->get();
     //        $surveys = Survey::all();
     //        $surveys = DB::table('surveys')->select('*')->orderBy('created_at')->get();
     return view('pages.admin', compact('surveys'));
 }
Example #10
0
 /**
  * Store survey response
  *
  * @param int $id
  * @return \Illuminate\Http\Response
  */
 public function postSurvey($id, Request $request)
 {
     $survey = Survey::findOrFail($id);
     $this->validate($request, $survey->rules());
     $response = new Response(['ip' => $request->ip()]);
     $survey->addResponse($response);
     $response->answerQuestions($survey->questions, collect($request->all()));
     return redirect()->action('SurveyController@getSurveyDone', ['id' => $survey->id]);
 }
 private function _redirectWithFirstSurvey($routeName)
 {
     $firstSurvey = Survey::first();
     if (is_null($firstSurvey)) {
         $voiceResponse = new \Services_Twilio_Twiml();
         return $this->_noSuchSurvey($voiceResponse);
     }
     return redirect(route($routeName, ['id' => $firstSurvey->id]))->setStatusCode(303);
 }
 private function _questionAfter($questionId)
 {
     $question = \App\Question::find($questionId);
     $survey = \App\Survey::find($question->survey_id);
     $allQuestions = $survey->questions()->orderBy('id', 'asc')->get();
     $position = $allQuestions->search($question);
     $nextQuestion = $allQuestions->get($position + 1);
     return $this->_idIfNotNull($nextQuestion);
 }
 public function postSurvey(Request $request)
 {
     $this->validate($request, ['email' => 'required|email']);
     $survey = Survey::firstOrNew(['email' => $request->input('email')]);
     if (!$survey->exists) {
         $survey->current_step = 1;
         $survey->save();
     }
     $request->session()->put('survey_id', $survey->id);
     return redirect()->action('SurveyController@getSurveyStep', ['step' => $survey->current_step]);
 }
 /**
  * Store a newly created resource in storage.
  *
  * @param  SurveyRequest  $request
  * @return Response
  */
 public function store(SurveyRequest $request)
 {
     // validation performed via SurveyRequest.php
     // persist the Survey to the db.
     $survey = Survey::create($request->all());
     // send email
     $this->sendEmail($survey);
     // send a flash message that Survey was added.
     flash()->success('Success', 'Survey added... Thanks!');
     // redirect back to the Survey page.
     return redirect()->back();
 }
Example #15
0
 public function submit_survey()
 {
     $input = Request::all();
     $gender = $input['gender'];
     $satisfaction = $input['satisfaction'];
     $country = $input['country'];
     $state = $input['state'];
     $city = $input['city'];
     $now = date("Y-m-d h:i:s");
     Survey::create(['Gender' => $gender, 'Satisfaction' => $satisfaction, 'Country' => $country, 'State' => $state, 'City' => $city, 'Created' => $now]);
     return redirect('/home');
 }
 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     if (!($request->survey = Survey::find($request->session()->get('survey_id')))) {
         return redirect()->action('SurveyController@getSurvey');
     }
     $request->maxStep = Question::max('step');
     if ($request->survey->current_step > $request->maxStep) {
         return redirect()->action('SurveyController@getSurveyDone');
     } elseif ($request->route('step') > $request->survey->current_step) {
         return redirect()->action('SurveyController@getSurveyStep', ['step' => $request->survey->current_step]);
     }
     return $next($request);
 }
Example #17
0
 /**
  * Delete a question attached to the survey
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  int $survey_id
  * @param  int $question_id
  * @return \Illuminate\Http\Response
  */
 public function destroyQuestion(Request $request, $survey_id, $question_id)
 {
     $survey = Survey::findOrFail($survey_id);
     $question = $survey->questions()->whereId($question_id)->firstOrFail();
     $question->delete();
     return redirect()->route('admin.surveys.edit', ['id' => $survey->id])->with('success', 'Question deleted!');
 }
Example #18
0
 public function getSurvey($id)
 {
     $survey = Survey::where('id', $id)->with('user', 'recruit')->first();
     return $survey;
 }
 private function _getFirstSurvey()
 {
     return Survey::orderBy('id', 'DESC')->get()->first();
 }
Example #20
0
 /**
  * Admin index
  *
  * @return \Illuminate\Http\Response
  */
 public function getIndex()
 {
     $surveys = Survey::all();
     return view('admin.index', compact('surveys'));
 }
 /**
  * Update the specified resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function update(StoreSurveyRequest $request)
 {
     $survey = Survey::findOrFail($request->get('id'));
     $survey->category_id = $request->get('category_id');
     $survey->title = $request->get('title');
     list($start_date, $end_date) = explode(' - ', $request->get('poll_date_range'));
     $survey->start_date = Carbon::createFromFormat('m/d/Y', $start_date)->format('Y-m-d');
     $survey->end_date = Carbon::createFromFormat('m/d/Y', $end_date)->format('Y-m-d');
     $survey->allowed_survey_no = $request->get('allowed_survey_no');
     $survey->survey_restriction = $request->get('survey_restriction');
     $survey->redirect_url = $request->get('redirect_url');
     $survey->survey_status = $request->get('survey_status');
     $survey->save();
     return \Redirect::route('index-survey')->with('message', 'Record has been added');
 }
Example #22
0
 public function show($id)
 {
     $survey = Survey::findOrFail($id);
     return view('survey.show', compact('survey'));
 }
@extends('layouts.master')

@section('title', 'Question List')

@section('bread_crump')
  <li><a href="{{ route('create-question', [Request::segment(1)]) }}"><i class="fa fa-dashboard"></i> Add New</a></li>
  <li class="active">View List</li>
@endsection

@section('content')
<?php 
$survey = \App\Survey::findOrFail(Request::segment(1));
?>
	<div class="box">
            <div class="box-header with-border">
            <h3 class="box-title">Question List </h3><span class="pull-right"><a href="{{ route('create-question', ['id' => $survey->id]) }}" class="btn btn-success">New Question</a></span>
            </div>
            <!-- /.box-header -->
            <div class="box-body">
            <h2>Survey ::  {{ $survey->title }}</h2>
              <table class="table table-bordered">
                <tr>
                  <th style="width: 10px">#</th>
                  <th>Question</th>
                  <th>Answer Type</th>
                  <th>Status</th>
                  <th>Action</th>
                </tr>

                @foreach($questions as $question)
                
Example #24
0
 public function classes(Request $request = null)
 {
     $gen = Gen::find($request->gen_id);
     $this->data['survey'] = Survey::find($request->survey_id);
     $this->data['gen'] = $gen;
     $this->data['gens'] = Gen::all();
     return view('manage.classes_survey', $this->data);
 }
 /**
  * Remove the specified resource from storage.
  *
  * @param  Survey $survey
  * @return \Illuminate\Http\Response
  */
 public function destroy(Survey $survey)
 {
     $survey->delete();
     return redirect()->action('SurveyController@index');
 }
Example #26
0
 /**
  * Show the form for editing the specified resource.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function edit($id)
 {
     $survey = Survey::find($id);
     $areas = SurveyArea::where('survey_id', $id)->get();
     return view('survey.edit')->with('survey', $survey)->with('areas', $areas);
 }
Example #27
0
 public function store(SurveyRequest $request)
 {
     Survey::create($request->all());
     return redirect('/');
     // TODO Make this redirect to a thank you page
 }