Merge pull request #110 from ThommyH/reduceInterventionAmount

do not show interventions on solved exercises, reduce to 2 interventions per day
This commit is contained in:
rteusner
2017-04-03 18:52:51 +02:00
committed by GitHub
8 changed files with 24 additions and 12 deletions

View File

@@ -67,7 +67,7 @@ class Exercise < ActiveRecord::Base
sum(working_time_new) AS working_time
FROM
(SELECT user_id,
CASE WHEN working_time >= '0:30:00' THEN '0' ELSE working_time END AS working_time_new
CASE WHEN working_time >= '0:05:00' THEN '0' ELSE working_time END AS working_time_new
FROM
(SELECT user_id,
id,
@@ -169,7 +169,7 @@ class Exercise < ActiveRecord::Base
exercise_id,
max_score,
CASE
WHEN working_time >= '0:30:00' THEN '0'
WHEN working_time >= '0:05:00' THEN '0'
ELSE working_time
END AS working_time_new
FROM all_working_times_until_max ), result AS
@@ -263,7 +263,7 @@ class Exercise < ActiveRecord::Base
FILTERED_TIMES_UNTIL_MAX AS
(
SELECT user_id,exercise_id, max_score, CASE WHEN working_time >= '0:30:00' THEN '0' ELSE working_time END AS working_time_new
SELECT user_id,exercise_id, max_score, CASE WHEN working_time >= '0:05:00' THEN '0' ELSE working_time END AS working_time_new
FROM ALL_WORKING_TIMES_UNTIL_MAX
)
SELECT e.external_id AS external_user_id, f.user_id, exercise_id, MAX(max_score) AS max_score, sum(working_time_new) AS working_time
@@ -341,6 +341,10 @@ class Exercise < ActiveRecord::Base
end
end
def has_user_solved(user)
return maximum_score(user).to_i == maximum_score.to_i
end
def set_default_values
set_default_values_if_present(public: false)
end