From ff6b04c0511e79130abd666f2be01ea10bead205 Mon Sep 17 00:00:00 2001 From: Sebastian Serth Date: Tue, 24 Nov 2020 01:37:12 +0100 Subject: [PATCH] Check for existence of submissions before accessing them --- app/views/external_users/statistics.html.slim | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/views/external_users/statistics.html.slim b/app/views/external_users/statistics.html.slim index d5b8e6d8..c5a3582a 100644 --- a/app/views/external_users/statistics.html.slim +++ b/app/views/external_users/statistics.html.slim @@ -1,8 +1,8 @@ h1 = t('.title') - submissions = Submission.where(user: @user).in_study_group_of(current_user) -- exercises = Exercise.where(id: submissions.joins(:exercise).group(:exercise_id).select(:exercise_id).distinct) -- if !policy(exercises.reject(&:nil?).first).detailed_statistics? +- exercises = Exercise.where(id: submissions.joins(:exercise).group(:exercise_id).select(:exercise_id).distinct).reject(&:nil?) +- if submissions.any? && !policy(exercises.first).detailed_statistics? - submissions = submissions.final - if submissions.any?