Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 2 additions & 7 deletions app/models/uni_module.rb
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,6 @@ def correct_weight_sum?
exams.sum(:weight) == 100
end

def progress(user)
return 100 if final_score.present?

exams_with_results(user).sum(:weight)
end

# Gets the average score of all of the completed exams so far, weighted by credits
def weighted_average(user)
valid_exams = exams_with_results(user)
Expand All @@ -72,12 +66,13 @@ def achieved_score(user)

# Gets the percentage completion of the module based on the exams taken
def completion_percentage(user)
return 0 unless exams.exists?
return 100 if final_score.present?

exams_with_results(user).sum(:weight)
end

alias progress completion_percentage

def target(user)
target = UniModuleTarget.find_by(user: user, uni_module: self)
return nil if target.nil? || target.score.nil?
Expand Down
Loading