Skip to content

Commit

Permalink
Fixed grader views
Browse files Browse the repository at this point in the history
  • Loading branch information
zalsader committed Sep 16, 2015
1 parent 482bcb8 commit 15ba1a1
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 22 deletions.
9 changes: 7 additions & 2 deletions app/Http/Controllers/ProfileController.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,13 @@ class ProfileController extends Controller
* @return Response
*/
public function index() {

$levels = Level::where('active', '=', true)->with('questions.submissions')->get();

if(\Auth::user()->cannot('grade', null)) {
$levels = Level::where('active', '=', true)->with('questions.submissions')->get();

} else {
$levels = Level::with('questions.submissions')->get();
}

// Maximum obtainable score from the currently available levels
$maxScore = $levels->reduce(function($carry, $item){
Expand Down
31 changes: 16 additions & 15 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion resources/views/profile.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
</thead>
<tbody>
@foreach($level->questions as $question)
@if($question->active)
@if($question->active || \Auth::user()->can('grade', $question))
<tr>
<td><a href="{{url('question', [$question->id])}}">{{$question->name}}</a></td>
<td>{{round($level->mark,1)}}</td>
Expand Down
8 changes: 5 additions & 3 deletions resources/views/submissions/index.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,25 @@
@section('content')
<div class="container">
<div class="row">
<div class="col-md-8" >
<div class="col-md-10" >
<div class="">
<h1>Submissions for Question #{{$question->id}}: {{ $question->name }}</h1>
<div class="table-responsive">
<table class="table table-hover">
<thead>
<tr>
<th width="30%">User</th>
<th width="20%">User</th>
<th width="20%">Email</th>
<th width="20%">Score</th>
<th width="30%">Last Assessed</th>
<th width="20%">View<th>
<th width="10%">View<th>
</tr>
</thead>
<tbody>
@foreach($submissions as $submission)
<tr>
<td>{{$submission->user->name}}</td>
<td>{{$submission->user->email}}</td>
<td>{{round($submission->score,3)}}</td>
<?php $lastAssessment = $submission->assessments()
->orderBy('created_at', 'desc')->first(); ?>
Expand Down
2 changes: 1 addition & 1 deletion resources/views/submissions/show.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<div class="row">
<div class="col-md-6" >
<h1>{{ $question->name }}</h1>
<h3>Submitted by {{$submission->user->name}}</h3>
<h3>Submitted by {{$submission->user->name}}, {{$submission->user->email}}</h3>
<p>{{ $question->description }}</p>
</div>
</div>
Expand Down

0 comments on commit 15ba1a1

Please sign in to comment.