merge master

This commit is contained in:
Karol
2019-12-03 17:55:58 +01:00
26 changed files with 3405 additions and 1620 deletions

View File

@ -494,12 +494,17 @@ class Exercise < ApplicationRecord
def maximum_score(user = nil)
if user
# FIXME: where(user: user) will not work here!
submissions.where(user: user).where("cause IN ('submit','assess')").where("score IS NOT NULL").order("score DESC").first.score || 0 rescue 0
else
files.teacher_defined_tests.sum(:weight)
end
end
def final_submission(user)
submissions.final.where(user_id: user.id, user_type: user.class.name).order(created_at: :desc).first
end
def has_user_solved(user)
maximum_score(user).to_i == maximum_score.to_i
end