Skip to content

Instantly share code, notes, and snippets.

@chiraggude
Created May 17, 2014 17:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chiraggude/591ea6b039cd2a0b8199 to your computer and use it in GitHub Desktop.
Save chiraggude/591ea6b039cd2a0b8199 to your computer and use it in GitHub Desktop.
Math Quiz
View
@extends('layouts.master')
@section('content')
<h1>Quiz</h1>
<div class="col-md-6">
{{ Form::open(array('action'=> 'DevController@saveQuiz','class' => 'form-horizontal')) }}
{{ Form::textField('algebra','What is x(2+x) ?', 'Your answer') }}
<div class="form-group">
{{ Form::submit('Submit Answers', array('class' => 'btn btn-primary')) }}
</div>
{{ Form::close() }}
</div>
@stop
Controller
public function quiz()
{
return View::make('quiz');
}
public function saveQuiz()
{
$input = Input::get('algebra');
$answer1 = '2x+x^2';
$answer2 = 'x^2+2x';
if ($input == $answer1 || $input == $answer2){
return Redirect::back()->withInput()->withSuccess('You answer was right');
}
return Redirect::back()->withInput()->withError('You answer was wrong');
}
Route::get('quiz', 'DevController@quiz');
Route::post('quiz', 'DevController@saveQuiz');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment