Hide exercise statistics for empty user group
Fixes ODEOCEAN-M5
This commit is contained in:
@ -21,18 +21,17 @@ $(document).on('turbolinks:load', function() {
|
||||
minutes_array = _.map(working_times, function(item){return get_minutes(item)});
|
||||
minutes_array_length = minutes_array.length;
|
||||
|
||||
maximum_minutes = _.max(minutes_array);
|
||||
var minutes_count = new Array(maximum_minutes);
|
||||
if (minutes_array_length === 0){
|
||||
return;
|
||||
}
|
||||
maximum_minutes = _.max(minutes_array) + 1; // We need to respect the last minute as well
|
||||
const minutes_count = new Array(maximum_minutes).fill(0);
|
||||
|
||||
for (var i = 0; i < minutes_array_length; i++){
|
||||
var studentTime = minutes_array[i];
|
||||
|
||||
for (var j = 0; j < studentTime; j++){
|
||||
if (minutes_count[j] === undefined){
|
||||
minutes_count[j] = 0;
|
||||
} else{
|
||||
minutes_count[j] += 1;
|
||||
}
|
||||
minutes_count[j] += 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -43,26 +43,25 @@ h1 = @exercise
|
||||
p = @exercise.average_working_time
|
||||
|
||||
- Hash[:internal_users => t('.internal_users'), :external_users => t('.external_users')].each_pair do |symbol, label|
|
||||
- if symbol==:internal_users && current_user.admin?
|
||||
strong = label
|
||||
- if symbol==:external_users
|
||||
- working_time_array = []
|
||||
- @exercise.send(symbol).distinct().each do |user|
|
||||
- working_time = @exercise.average_working_time_for(user) or 0
|
||||
- working_time_array.push working_time
|
||||
hr
|
||||
.d-none#data data-working-time=ActiveSupport::JSON.encode(working_time_array)
|
||||
.working-time-graphs
|
||||
div#chart_1
|
||||
hr
|
||||
div#chart_2
|
||||
hr
|
||||
- submissions = Submission.where(user: @exercise.send(symbol).distinct, exercise: @exercise).in_study_group_of(current_user)
|
||||
- if !policy(@exercise).detailed_statistics?
|
||||
- submissions = submissions.final
|
||||
- if submissions.any?
|
||||
strong = label
|
||||
- if symbol==:external_users
|
||||
- working_time_array = []
|
||||
- @exercise.send(symbol).distinct().each do |user|
|
||||
- working_time = @exercise.average_working_time_for(user) or 0
|
||||
- working_time_array.push working_time
|
||||
hr
|
||||
.d-none#data data-working-time=ActiveSupport::JSON.encode(working_time_array)
|
||||
.working-time-graphs
|
||||
div#chart_1
|
||||
hr
|
||||
div#chart_2
|
||||
hr
|
||||
- users = symbol.to_s.classify.constantize.where(id: submissions.joins(symbol).group(:user_id).select(:user_id).distinct)
|
||||
.table-responsive
|
||||
.table-responsive.mb-4
|
||||
table.table.table-striped class="#{users.present? ? 'sortable' : ''}"
|
||||
thead
|
||||
tr
|
||||
|
Reference in New Issue
Block a user