Skip to content

Commit

Permalink
Don't show completion status for courses which results are hidden
Browse files Browse the repository at this point in the history
  • Loading branch information
jamo committed Oct 27, 2015
1 parent beddb3f commit 26a9226
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
5 changes: 3 additions & 2 deletions app/models/submission.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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?
Expand Down Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions lib/exercise_completion_status_generator.rb
Original file line number Diff line number Diff line change
@@ -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(
Expand Down

0 comments on commit 26a9226

Please sign in to comment.