From 530916d3ef7ac6021a1f349898a54fbf80e2f425 Mon Sep 17 00:00:00 2001 From: Thomas Hille Date: Wed, 8 Mar 2017 11:35:19 +0100 Subject: [PATCH] added time of user to reach max score in exercise --- app/models/exercise.rb | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/app/models/exercise.rb b/app/models/exercise.rb index 1a399427..15c740f4 100644 --- a/app/models/exercise.rb +++ b/app/models/exercise.rb @@ -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,