Add score and working time to feedback page

This commit is contained in:
Sebastian Serth
2019-11-29 15:01:04 +01:00
parent 15c9a0daa7
commit 9dfe6b4529
3 changed files with 16 additions and 2 deletions

View File

@ -493,12 +493,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