From 4cc9bc49fec5a7bce8a4bad451c76d260bbb35aa Mon Sep 17 00:00:00 2001 From: Sebastian Serth Date: Wed, 28 Oct 2020 16:26:40 +0100 Subject: [PATCH] Cap points_ratio for tags statistics at 1.0 --- app/models/proxy_exercise.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/models/proxy_exercise.rb b/app/models/proxy_exercise.rb index bb17b30a..96c143b7 100644 --- a/app/models/proxy_exercise.rb +++ b/app/models/proxy_exercise.rb @@ -171,6 +171,8 @@ class ProxyExercise < ApplicationRecord if points_ratio == 0.0 Rails.logger.debug("scoring user #{user.id} for exercise #{ex.id}: points_ratio=#{points_ratio} score: 0" ) return 0.0 + elsif points_ratio > 1.0 + points_ratio = 1.0 # The score of the exercise was adjusted and is now lower than it was end points_ratio_index = ((scoring_matrix.size - 1) * points_ratio).to_i working_time_user = ex.accumulated_working_time_for_only(user)