fixed bug where refreshing on question page during test taking would advance the question
This commit is contained in:
parent
634a43b93d
commit
bde382c1ff
5 changed files with 14 additions and 6 deletions
app/Http/Controllers
resources/views
routes
|
@ -52,5 +52,6 @@ class HomeController extends Controller
|
|||
{
|
||||
$user = Auth::user();
|
||||
$user->updateEmail(request()->all());
|
||||
return redirect('/settings');
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,13 +19,12 @@ class TestController extends Controller
|
|||
//insert session flash
|
||||
return redirect('/home');
|
||||
}
|
||||
session(['questions' => $test->randomizeQuestions(), 'question_counter' => 0, 'test' => $test, 'wrong_answers' => 0, 'is_correct' => false, 'has_failed' => false, 'last_question' => false]);
|
||||
session(['questions' => $test->randomizeQuestions(), 'question_counter' => 1, 'test' => $test, 'wrong_answers' => 0, 'is_correct' => false, 'has_failed' => false, 'last_question' => false]);
|
||||
return redirect()->action('TestController@showQuestion');
|
||||
}
|
||||
|
||||
public function showQuestion()
|
||||
{
|
||||
session(['question_counter' => session('question_counter')+1]);
|
||||
$question = session('questions')->get(session('question_counter')-1);
|
||||
$options = $question->options->shuffle();
|
||||
session(['options' => $options]);
|
||||
|
@ -75,12 +74,13 @@ class TestController extends Controller
|
|||
if (session('test')->lastQuestion(session('question_counter'))) {
|
||||
session(['last_question' => true]);
|
||||
}
|
||||
session(['question_counter' => session('question_counter')+1]);
|
||||
return redirect()->action('TestController@showAnswer');
|
||||
}
|
||||
|
||||
public function showAnswer()
|
||||
{
|
||||
$question = session('questions')->get(session('question_counter')-1);
|
||||
$question = session('questions')->get(session('question_counter')-2);
|
||||
$options = session('options');
|
||||
return view('tests.answer', compact("question"), compact("options"));
|
||||
}
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
<div class="container-fluid">
|
||||
<div class="col-md-6 col-md-offset-3">
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-heading">Question #{{ session("question_counter") }}</div>
|
||||
<div class="panel-heading">Question #{{ session("question_counter")-1 }}</div>
|
||||
<div class="panel-body">
|
||||
<h4><strong>{{ $question->title }}</strong></h4>
|
||||
<p>{{ $question->question }}</p>
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
<div class="col-md-4 col-md-offset-4">
|
||||
<h1>Create New User</h1>
|
||||
</br>
|
||||
<form method="POST" action="/{{ Auth::user()->getAdminPath() }}/users/new">
|
||||
<form method="POST" action="//users/new">
|
||||
{{ csrf_field() }}
|
||||
<div class="form-group">
|
||||
<label>Name</label>
|
||||
|
|
|
@ -101,4 +101,11 @@ Route::group(['prefix' => 'admin'], function () {
|
|||
Route::get('/groups/{group}/delete', 'GroupController@confirmDeleteGroup');
|
||||
Route::delete('/groups/{group}/delete', 'GroupController@DeleteGroup');
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
/*\Event::listen('Illuminate\Database\Events\QueryExecuted', function ($query) {
|
||||
echo "<pre>";
|
||||
var_dump($query->sql);
|
||||
var_dump($query->time);
|
||||
echo "</pre>";
|
||||
});*/
|
Reference in a new issue