Skip to content

Commit 1badc57

Browse files
author
Jon Janelle
committed
linked home rows to problem views
1 parent 2c744e6 commit 1badc57

5 files changed

Lines changed: 23 additions & 13 deletions

File tree

app/Http/Controllers/HomeController.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,9 +82,11 @@ public function getUserSolved($user) {
8282
*/
8383
public function deleteComment($cid)
8484
{
85-
//TODO Make sure that ownly comment owner can delete it!
86-
87-
Comment::destroy($cid);
85+
//Make sure that only owner can delete
86+
$c = Comment::find($cid);
87+
if ($c!=null && $c->user->id==Auth::user()->id) {
88+
Comment::destroy($cid);
89+
}
8890
return $this->index();
8991
}
9092

app/Http/Controllers/ProblemController.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,8 @@ public function show($category, $pid, $feedback=false, $correct=false, $userResp
105105
* $pid : Problem id code
106106
*/
107107
public function checkResponse(Request $request, $category, $pid) {
108+
$this -> validate($request, ['answer-input'=>'required|alphanum|min:1',]);
109+
108110
if (!Session::has($category)) { //load problem data if needed
109111
$this->loadProblemData($category);
110112
}

resources/views/master/master.blade.php

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -71,18 +71,12 @@
7171
</div><!--/.container-fluid -->
7272
</nav>
7373

74-
@if (count($errors) > 0)
75-
<div class="alert alert-danger">
76-
<ul>
77-
@foreach ($errors->all() as $error)
78-
<li>{{ $error }}</li>
79-
@endforeach
80-
</ul>
81-
</div>
82-
@endif
74+
8375

8476
<div class="back-panel">
77+
8578
@yield('content')
79+
8680
</div>
8781

8882

resources/views/problem.blade.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,18 @@
6161
</div>
6262
@endif
6363
@endif
64+
@if (count($errors) > 0)
65+
<div class="alert alert-danger feedback-box" id="incorrectAns">
66+
<button type="button" class="close" data-target="#incorrectAns" data-dismiss="alert">
67+
<span aria-hidden="true">X</span>
68+
</button>
69+
<ul>
70+
@foreach ($errors->all() as $error)
71+
<li>{{ $error }}</li>
72+
@endforeach
73+
</ul>
74+
</div>
75+
@endif
6476
<!-- begin problem answer input form -->
6577
<div class="answer-form-div">
6678
<form id="answer-form" method="POST" action="/problems/{{$problem->category}}/problem/{{$problem->id}}/check">

routes/web.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
Route::get('/problems/{category}/problem/{pid}','ProblemController@show'); //pid = problem id
2727
Route::post('/problems/{category}/problem/{pid}/check','ProblemController@checkResponse');
2828
Route::post('/problems/{category}/problem/{pid}/comment','ProblemController@postNewComment');
29-
29+
Route::get('/problems/{category}/problem/{pid}/check','ProblemController@checkResponse');
3030
//Route for viewing problem listing
3131
Route::get('/problems/{category}','ProblemController@index');
3232
//Route for viewing sorted listing

0 commit comments

Comments
 (0)