Skip to content

Commit 9181092

Browse files
committed
Refactor teacher access to external user statistics
1 parent 2bce809 commit 9181092

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

app/controllers/exercises_controller.rb

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -512,10 +512,11 @@ def statistics
512512
def external_user_statistics
513513
# Render statistics page for one specific external user
514514

515+
submissions = policy_scope(Submission).where(contributor: @external_user, exercise: @exercise)
516+
.order(:created_at)
517+
.includes(:exercise, testruns: [:testrun_messages, {file: [:file_type]}], files: [:file_type])
518+
515519
if policy(@exercise).detailed_statistics?
516-
submissions = policy_scope(Submission).where(contributor: @external_user, exercise: @exercise)
517-
.order(:created_at)
518-
.includes(:exercise, testruns: [:testrun_messages, {file: [:file_type]}], files: [:file_type])
519520
@show_autosaves = params[:show_autosaves] == 'true' || submissions.where.not(cause: 'autosave').none?
520521

521522
interventions = @external_user.user_exercise_interventions.where(exercise: @exercise)
@@ -548,13 +549,11 @@ def external_user_statistics
548549
end
549550
end
550551
else
551-
final_submissions = policy_scope(Submission).where(contributor: @external_user, exercise: @exercise)
552-
submissions = []
552+
@all_events = []
553553
%i[before_deadline within_grace_period after_late_deadline].each do |filter|
554-
relevant_submission = final_submissions.send(filter).latest
555-
submissions.push relevant_submission if relevant_submission.present?
554+
relevant_submission = submissions.send(filter).latest
555+
@all_events.push relevant_submission if relevant_submission.present?
556556
end
557-
@all_events = submissions
558557
end
559558

560559
render 'exercises/external_users/statistics'

0 commit comments

Comments
 (0)