Created
May 17, 2014 17:48
-
-
Save chiraggude/591ea6b039cd2a0b8199 to your computer and use it in GitHub Desktop.
Math Quiz
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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