added time of user to reach max score in exercise

This commit is contained in:
Thomas Hille
2017-03-08 11:35:19 +01:00
parent c1209e4972
commit 530916d3ef

View File

@ -57,6 +57,10 @@ class Exercise < ActiveRecord::Base
return user_count == 0 ? 0 : submissions.count() / user_count.to_f()
end
def time_maximum_score(user)
submissions.where(user: user).where("cause IN ('submit','assess')").where("score IS NOT NULL").order("score DESC, created_at ASC").first.created_at rescue Time.zone.at(0)
end
def user_working_time_query
"""
SELECT user_id,