Skip to content

Commit

Permalink
Minor bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
zalsader committed Sep 11, 2015
1 parent 353d00a commit d412feb
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 24 deletions.
2 changes: 1 addition & 1 deletion app/Http/Controllers/ProfileController.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class ProfileController extends Controller
*/
public function index() {

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

// Maximum obtainable score from the currently available levels
$maxScore = $levels->reduce(function($carry, $item){
Expand Down
23 changes: 8 additions & 15 deletions resources/views/profile.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,33 +12,26 @@
<hr>
<div class="">
@forelse($levels as $level)
<h3>{{ $level->name }}, Question Score: {{$level->mark}}</h3>
<h3>{{ $level->name }}</h3>
<table class="table table-hover">
<thead>
<tr>
<th>Question Name</th>
@if(false)
<th>Your Score</th>
@endif
<th>Question Score</th>
<th>Last Submitted</th>
</tr>
</thead>
<tbody>
@foreach($level->questions as $question)
<?php
$Qsubmissions = \App\Submission::where('question_id','=',$question->id);
$sorted = $collection->sortBy(function ($sth, $key) {
return $sth['create_at'];
});
?>
<tr>
<td><a href="{{url('question', [$question->id])}}">{{$question->name}}</a></td>
@if(false)
<td>0</td>
<td>{{$level->mark}}</td>
<?php $lastSub = $question->submissions->last(); ?>
@if (!empty($lastSub))
<td>{{$lastSub->created_at}}</td>
@else
<td> Never </td>
@endif
<td>{{$sorted[0]}}</td>
</tr>
@endforeach
</tbody>
Expand Down
13 changes: 5 additions & 8 deletions resources/views/questions/show.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,16 +45,13 @@
@if($observation->hint_used)
<div>
<p id="hintText">{{$question->hint_text}}</p>
@if(!empty($question->hint_image))
<img id="hintImage" src="{{asset('images/hints/'.$question->hint_image)}}" alt="">
@endif
<img id="hintImage" src="{{asset('images/hints/'.$question->hint_image)}}" alt=""
class="{{empty($question->hint_image)? 'hidden': ''}}">
</div>
@else
<div>
<p id="hintText"></p>
@if(!empty($question->hint_image))
<img id="hintImage" src="" alt="">
@endif
<img id="hintImage" src="" alt="" class="{{empty($question->hint_image)? 'hidden': ''}}">
</div>
@endif
</div>
Expand Down Expand Up @@ -84,7 +81,7 @@

@section('scripts')
<script type="text/javascript">
var hintUsed = {{$observation->hint_used}};
var hintUsed = {{$observation->hint_used? 'true': 'false'}};
$(function(){
$('#submit').popover({
Expand Down Expand Up @@ -140,7 +137,7 @@
success: function(response) {
console.log(response);
$('#hintModal').find('#hintText').text(response.data.text);
$('#hintModal').find('#hintImage').src('{{asset("image/hints/")}}/' + response.data.image);
$('#hintModal').find('#hintImage')[0].src = ('{{asset("image/hints/")}}/' + response.data.image);
$('#hintModal').modal('show');
}
});
Expand Down

0 comments on commit d412feb

Please sign in to comment.