Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add progress rating page #300

Merged
merged 2 commits into from
May 31, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
17 changes: 17 additions & 0 deletions app/Http/Controllers/RatingTopProgressController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?php

namespace App\Http\Controllers;

use App\Chapter;
use App\Exercise;

class RatingTopProgressController extends Controller
{
public function index()
{
$rating = getCalculatedRating();
$chapters = Chapter::with('children', 'exercises')->get();
$exercises = Exercise::all();
return view('rating.progress', compact('rating', 'chapters', 'exercises'));
}
}
3 changes: 3 additions & 0 deletions resources/lang/en/rating.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,7 @@
'user' => 'User',
'number_of_points' => 'Number of points',
'number_of_comments' => 'Number of comments',
'progress' => 'Progress',
'read_chapters_from' => 'Read chapters from',
'completed_exercises_from' => 'Completed exercises from',
];
3 changes: 3 additions & 0 deletions resources/lang/ru/rating.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,7 @@
'user' => 'Пользователь',
'number_of_points' => 'Количество очков',
'number_of_comments' => 'Количество комментариев',
'progress' => 'Прогресс',
'read_chapters_from' => 'Прочитано глав из',
'completed_exercises_from' => 'Выполнено заданий из',
];
3 changes: 3 additions & 0 deletions resources/views/rating/menu.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
<a class="btn btn-light" href="{{ route('top.index') }}">
{{ __('rating.page_title') }}
</a>
<a class="btn btn-light" href="{{ route('progress_top.index') }}"/>
{{ __('rating.progress') }}
</a>
<a class="btn btn-light" href="{{ route('comments_top.index') }}"/>
{{ __('rating.page_title_comments') }}
</a>
Expand Down
38 changes: 38 additions & 0 deletions resources/views/rating/progress.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
@extends('layouts.app')
@section('content')
<div class="my-4">
@include('rating.menu')

<h3>{{ __('rating.progress') }}</h3>

<div class="table-responsive">
<table class="table table-striped">
<thead>
<tr>
<th>{{ __('rating.positions') }}</th>
<th>{{ __('rating.user') }}</th>
<th>{{ __('rating.read_chapters_from') }} {{ $chapters->count() }}</th>
<th>{{ __('rating.completed_exercises_from') }} {{ $exercises->count() }}</th>
</tr>
</thead>
<tbody>
@foreach($rating as $position => [
'user' => $user,
])
<tr>
<td>{{ $position }}</td>
<td>
<a class="text-decoration-none" href="{{ route('users.show', $user) }}">
<img class="rounded-circle mr-1" width="30" height="30" src="{{ getProfileImageLink($user) }}" alt="Profile image">
{{ $user->name }}
</a>
</td>
<td>{{ $user->read_chapters_count }}</td>
<td>{{ $user->completed_exercises_count }}</td>
</tr>
@endforeach
</tbody>
</table>
</div>
</div>
@endsection
1 change: 1 addition & 0 deletions routes/web.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
Route::resource('users.exercises', 'UserExerciseController')->only('store', 'update', 'destroy');
Route::prefix('ratings')->group(function () {
Route::resource('top', 'RatingTopController')->only('index');
Route::resource('progress_top', 'RatingTopProgressController')->only('index');
Route::resource('comments_top', 'RatingTopCommentsController')->only('index');
});
Route::resource('chapters', 'ChapterController')->only('index', 'show');
Expand Down
14 changes: 14 additions & 0 deletions tests/Feature/Http/Controllers/RatingTopProgressControllerTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?php

namespace Tests\Feature\Http\Controllers;

use Tests\TestCase;

class RatingTopProgressControllerTest extends TestCase
{
public function testIndex()
{
$this->get(route('progress_top.index'))
->assertOk();
}
}