From a6744c20e6213af882bb47459c5f615f96650b51 Mon Sep 17 00:00:00 2001 From: Maximilian Grundke Date: Sun, 10 Dec 2017 19:17:02 +0100 Subject: [PATCH] Improve exercise list and link to statistics --- .../exercise_collections_controller.rb | 1 + app/views/exercise_collections/show.html.slim | 20 ++++++++++++++++--- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/app/controllers/exercise_collections_controller.rb b/app/controllers/exercise_collections_controller.rb index 1f6da6c2..415c77f8 100644 --- a/app/controllers/exercise_collections_controller.rb +++ b/app/controllers/exercise_collections_controller.rb @@ -9,6 +9,7 @@ class ExerciseCollectionsController < ApplicationController end def show + @exercises = @exercise_collection.exercises.paginate(:page => params[:page]) end def new diff --git a/app/views/exercise_collections/show.html.slim b/app/views/exercise_collections/show.html.slim index 23a68cb5..fd643f3f 100644 --- a/app/views/exercise_collections/show.html.slim +++ b/app/views/exercise_collections/show.html.slim @@ -7,6 +7,20 @@ h1 = row(label: 'exercise_collections.updated_at', value: @exercise_collection.updated_at) h4 = t('activerecord.attributes.exercise_collections.exercises') -ul.list-unstyled - - @exercise_collection.exercises.sort_by{|c| c.title}.each do |exercise| - li = link_to(exercise, exercise) +.table-responsive + table.table + thead + tr + th = t('activerecord.attributes.exercise.title') + th = t('activerecord.attributes.exercise.execution_environment') + th = t('activerecord.attributes.exercise.user') + th = t('shared.actions') + tbody + - @exercises.sort_by{|c| c.title}.each do |exercise| + tr + td = link_to(exercise.title, exercise) + td = link_to_if(exercise.execution_environment && policy(exercise.execution_environment).show?, exercise.execution_environment, exercise.execution_environment) + td = exercise.user.name + td = link_to(t('shared.statistics'), statistics_exercise_path(exercise)) + += render('shared/pagination', collection: @exercises)