/** * This function is responsible for displaying the results page. * * It first sends data to the model for insertion into database. * If inserted correctly, displays the results page. */ public function get_results() { if (!($id = Route::input('id'))) { Log::error('Unable to display results. Route ID not found.'); return Redirect::to('error'); } if (!($answers = Session::get('answers'))) { Log::error('Unable to display results. Unable to retreive answers from session.'); return Redirect::to('error'); } if (!($restart = route('home'))) { Log::error('Unable to assign the restart button to a route.'); return Redirect::to('error'); } $responses = self::clean_results($answers); $submission = self::prepare_submission($id, $answers); if (Submission::create_submission($submission)) { return View::make('results', array('heading' => 'Thank you! Your outcome is provided below', 'outcome' => self::$outcomes[$id], 'responses' => $responses, 'restart' => $restart)); } Log::error('Unable to create submission. Database insertion failed'); return Redirect::to('error'); }