Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
zalsader committed Sep 11, 2015
2 parents 6aab90b + 740ddda commit 2a09558
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 30 deletions.
19 changes: 0 additions & 19 deletions .env.example

This file was deleted.

16 changes: 8 additions & 8 deletions app/Http/Controllers/ProfileController.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,18 @@ class ProfileController extends Controller
* @return Response
*/
public function index() {

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

// Maximum obtainable score from the currently available levels
$maxScore = $levels->reduce(function($carry, $item){
return $carry + $item->questions->count() * $item->mark;
}, 1);

// For leaderboard.
$leaders = User::orderBy('total_score', 'desc')
->get();

$myRank = 1 + $leaders->search(function($item, $key){
return $item->id == \Auth::user()->id;
});
Expand Down Expand Up @@ -65,7 +65,7 @@ public function store(Request $request)
*/
public function show($id)
{
return 'go inside the $id (sub)';
// return 'go inside the $id (sub)';
}

/**
Expand All @@ -76,7 +76,7 @@ public function show($id)
*/
public function edit($id)
{
return "you're editing $id (sub)";
// return "you're editing $id (sub)";
}

/**
Expand All @@ -88,7 +88,7 @@ public function edit($id)
*/
public function update(Request $request, $id)
{
return "saving the edited $id";
// return "saving the edited $id";
}

/**
Expand All @@ -99,7 +99,7 @@ public function update(Request $request, $id)
*/
public function destroy($id)
{
return "deleting it";
// return "deleting it";
}

}
36 changes: 33 additions & 3 deletions resources/views/profile.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,53 @@
@section('content')
<hr>
<div class="row">

<div class="col-lg-8 col-lg-offset-1" >
<hr>
<p>Welcome {{\Auth::user()->name}}
<br>
<a href="{{url('logout')}}">log out</a>
<hr>
<div class="">
@forelse($levels as $level)
<h3>{{ $level->name }}, Question Score: {{$level->mark}}</h3>
<table class="table table-hover">
<thead>
<tr>
<th>Question Name</th>
@if(false)
<th>Your Score</th>
@endif
<th>Last Submitted</th>
</tr>
</thead>
<tbody>
<tr>
@foreach($level->questions as $question)
<td><a href="{{url('question', [$question->id])}}">{{$question->name}}</a></td>
<?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>
@endif
<td>{{$sorted[0]}}</td>
</tr>
@endforeach
</tr>
</tbody>
</table>
<hr>
@empty
<h1>Competition Has not yet started</h1>
@endforelse
</div>
</div>
@if(false)
<div class=" col-lg-2 col-lg-offset-0 well">
<div class="row">
<center><label style="font-size:21px; color:#19a2e4;">Leaderboard</label></center>
Expand Down Expand Up @@ -52,5 +81,6 @@
</div>
</div>
</div>
@endif
</div>
@stop

0 comments on commit 2a09558

Please sign in to comment.