From adf8707c82063c7402d168a1782205ad14ce6808 Mon Sep 17 00:00:00 2001 From: jorg-vr Date: Fri, 20 May 2022 09:31:44 +0200 Subject: [PATCH] Only show submission without course in the submission history of a submission without a course --- app/controllers/submissions_controller.rb | 2 +- app/models/submission.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/controllers/submissions_controller.rb b/app/controllers/submissions_controller.rb index 3a73da5de5..8058bc593b 100644 --- a/app/controllers/submissions_controller.rb +++ b/app/controllers/submissions_controller.rb @@ -78,7 +78,7 @@ def show end @submissions = @submissions.of_exercise(@submission.exercise) @submissions = @submissions.of_user(@submission.user) - @submissions = @submissions.in_course(course) if course.present? + @submissions = @submissions.in_course(course) @submissions_time_stamps = [] prev = nil diff --git a/app/models/submission.rb b/app/models/submission.rb index 0a2d87eedb..d850f40aef 100644 --- a/app/models/submission.rb +++ b/app/models/submission.rb @@ -55,7 +55,7 @@ class Submission < ApplicationRecord scope :of_exercise, ->(exercise) { where exercise_id: exercise.id } scope :before_deadline, ->(deadline) { where('submissions.created_at < ?', deadline) } scope :in_time_range, ->(start_date, end_date) { where(created_at: start_date.to_datetime..end_date.to_datetime) } - scope :in_course, ->(course) { where course_id: course.id } + scope :in_course, ->(course) { where course_id: course&.id } scope :in_series, ->(series) { where(course_id: series.course.id).where(exercise: series.exercises) } scope :of_judge, ->(judge) { where(exercise_id: Exercise.where(judge_id: judge.id)) } scope :from_students, ->(course) { where(user: course.enrolled_members) }