Fix working time statistics for internal and external users
This commit is contained in:
@ -372,11 +372,11 @@ class Exercise < ApplicationRecord
|
|||||||
end
|
end
|
||||||
|
|
||||||
def retrieve_working_time_statistics
|
def retrieve_working_time_statistics
|
||||||
@working_time_statistics = {}
|
@working_time_statistics = {'InternalUser' => {}, 'ExternalUser' => {}}
|
||||||
ActiveRecord::Base.transaction do
|
ActiveRecord::Base.transaction do
|
||||||
self.class.connection.execute("SET LOCAL intervalstyle = 'postgres'")
|
self.class.connection.execute("SET LOCAL intervalstyle = 'postgres'")
|
||||||
self.class.connection.execute(user_working_time_query).each do |tuple|
|
self.class.connection.execute(user_working_time_query).each do |tuple|
|
||||||
@working_time_statistics[tuple['user_id'].to_i] = tuple
|
@working_time_statistics[tuple['user_type']][tuple['user_id'].to_i] = tuple
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -392,9 +392,9 @@ class Exercise < ApplicationRecord
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def average_working_time_for(user_id)
|
def average_working_time_for(user)
|
||||||
retrieve_working_time_statistics if @working_time_statistics.nil?
|
retrieve_working_time_statistics if @working_time_statistics.nil?
|
||||||
@working_time_statistics[user_id]['working_time']
|
@working_time_statistics[user.class.name][user.id]['working_time']
|
||||||
end
|
end
|
||||||
|
|
||||||
def accumulated_working_time_for_only(user)
|
def accumulated_working_time_for_only(user)
|
||||||
|
@ -32,7 +32,7 @@ h1 = link_to_if(policy(@exercise).show?, @exercise, exercise_path(@exercise))
|
|||||||
.card-footer
|
.card-footer
|
||||||
div.clearfix.feedback-header
|
div.clearfix.feedback-header
|
||||||
span.points.flex-grow-1 = "#{t('exercises.statistics.score')}: #{@submissions[index].score}"
|
span.points.flex-grow-1 = "#{t('exercises.statistics.score')}: #{@submissions[index].score}"
|
||||||
span.working_time.pull-right = "#{t('exercises.statistics.worktime')}: #{@exercise.average_working_time_for(feedback.user.id) or 0}"
|
span.working_time.pull-right = "#{t('exercises.statistics.worktime')}: #{@exercise.average_working_time_for(feedback.user) or 0}"
|
||||||
|
|
||||||
= render('shared/pagination', collection: @feedbacks)
|
= render('shared/pagination', collection: @feedbacks)
|
||||||
|
|
||||||
|
@ -48,7 +48,7 @@ h1 = @exercise
|
|||||||
- if symbol==:external_users
|
- if symbol==:external_users
|
||||||
- working_time_array = []
|
- working_time_array = []
|
||||||
- @exercise.send(symbol).distinct().each do |user|
|
- @exercise.send(symbol).distinct().each do |user|
|
||||||
- working_time = @exercise.average_working_time_for(user.id) or 0
|
- working_time = @exercise.average_working_time_for(user) or 0
|
||||||
- working_time_array.push working_time
|
- working_time_array.push working_time
|
||||||
hr
|
hr
|
||||||
.d-none#data data-working-time=ActiveSupport::JSON.encode(working_time_array)
|
.d-none#data data-working-time=ActiveSupport::JSON.encode(working_time_array)
|
||||||
@ -88,4 +88,4 @@ h1 = @exercise
|
|||||||
- elsif latest_user_submission.after_late_deadline?
|
- elsif latest_user_submission.after_late_deadline?
|
||||||
.unit-test-result.negative-result.after_late_deadline
|
.unit-test-result.negative-result.after_late_deadline
|
||||||
td = us['runs'] if policy(@exercise).detailed_statistics?
|
td = us['runs'] if policy(@exercise).detailed_statistics?
|
||||||
td = @exercise.average_working_time_for(user.id) or 0 if policy(@exercise).detailed_statistics?
|
td = @exercise.average_working_time_for(user) or 0 if policy(@exercise).detailed_statistics?
|
||||||
|
Reference in New Issue
Block a user