From 26a92269c4438ec4793c23ffc984dd2d2bc8cfce Mon Sep 17 00:00:00 2001 From: Jarmo Isotalo Date: Wed, 14 Oct 2015 20:51:57 +0000 Subject: [PATCH] Don't show completion status for courses which results are hidden --- app/models/submission.rb | 5 +++-- lib/exercise_completion_status_generator.rb | 3 +++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/app/models/submission.rb b/app/models/submission.rb index 738000343..9eb480e5b 100644 --- a/app/models/submission.rb +++ b/app/models/submission.rb @@ -102,7 +102,8 @@ def status(user) if !processed? :processing elsif !can_see_results?(user) - :hidden + :ok + #:hidden elsif all_tests_passed? :ok elsif tests_ran? @@ -298,7 +299,7 @@ def public? end def readable_by?(user) - user.administrator? || user.teacher?(self.course.organization) || self.user_id == user.id + user.administrator? || user.teacher?(self.course.organization) || self.user_id == user.id && self.exercise.visible_to?(user) end def set_paste_key_if_paste_available diff --git a/lib/exercise_completion_status_generator.rb b/lib/exercise_completion_status_generator.rb index 03d409fc7..140757da9 100644 --- a/lib/exercise_completion_status_generator.rb +++ b/lib/exercise_completion_status_generator.rb @@ -1,6 +1,9 @@ # Generates a progress percentage [0..100] telling how much a user has completed of a course's exercises. class ExerciseCompletionStatusGenerator def self.completion_status(user, course) + if course.hide_submission_results? + return {} + end awarded_points = user.awarded_points.where(course_id: course.id).map(&:name) all_exercises = Exercise.where(course: course).includes(:available_points) attempted_exercise_names = Submission.where(