Show up to three submissions for teachers and add overview to table
This commit is contained in:
@ -418,9 +418,11 @@ class ExercisesController < ApplicationController
|
||||
@working_times_until.push((format_time_difference(@deltas[0..index].inject(:+)) if index > 0))
|
||||
end
|
||||
else
|
||||
latest_submissions = Submission.where(user: @external_user, exercise_id: @exercise.id).in_study_group_of(current_user).final.latest
|
||||
relevant_submissions = latest_submissions.before_deadline.or(latest_submissions.within_grace_period).or(latest_submissions.after_late_deadline)
|
||||
@submissions = relevant_submissions.sort_by(&:created_at)
|
||||
final_submissions = Submission.where(user: @external_user, exercise_id: @exercise.id).in_study_group_of(current_user).final
|
||||
@submissions = []
|
||||
@submissions.push final_submissions.before_deadline.latest
|
||||
@submissions.push final_submissions.within_grace_period.latest
|
||||
@submissions.push final_submissions.after_late_deadline.latest
|
||||
@all_events = @submissions
|
||||
end
|
||||
render 'exercises/external_users/statistics'
|
||||
|
@ -27,7 +27,7 @@ class Submission < ApplicationRecord
|
||||
scope :within_grace_period, -> { joins(:exercise).where('(submissions.updated_at > exercises.submission_deadline) AND (submissions.updated_at <= exercises.late_submission_deadline OR exercises.late_submission_deadline IS NULL)') }
|
||||
scope :after_late_deadline, -> { joins(:exercise).where('submissions.updated_at > exercises.late_submission_deadline') }
|
||||
|
||||
scope :latest, -> { order(updated_at: :desc).limit(1) }
|
||||
scope :latest, -> { order(updated_at: :desc).first }
|
||||
|
||||
scope :in_study_group_of, ->(user) { where(study_group_id: user.study_groups) unless user.admin? }
|
||||
|
||||
|
@ -43,7 +43,7 @@ h1 = "#{@exercise} (external user #{link_to_if(policy(@external_user).show?, @ex
|
||||
th.header = t('.time_difference') if policy(@exercise).detailed_statistics?
|
||||
tbody
|
||||
- @all_events.each_with_index do |this, index|
|
||||
- highlight = (index > 0 and @deltas[index] == 0 and this.created_at.to_s != @all_events[index - 1].created_at.to_s)
|
||||
- highlight = (index > 0 and @deltas.present? and @deltas[index] == 0 and this.created_at.to_s != @all_events[index - 1].created_at.to_s)
|
||||
- row_classes = ''
|
||||
- row_classes += ' highlight' if highlight
|
||||
- row_classes += ' before_deadline' if this.is_a?(Submission) && this.before_deadline?
|
||||
|
@ -42,14 +42,15 @@ h1 = @exercise
|
||||
- submissions = Submission.where(user: @exercise.send(symbol).distinct, exercise: @exercise).in_study_group_of(current_user)
|
||||
- if !policy(@exercise).detailed_statistics?
|
||||
- submissions = submissions.final
|
||||
- any_viewable_submission = submissions.first
|
||||
- if any_viewable_submission
|
||||
- latest_submission = submissions.latest
|
||||
- if latest_submission
|
||||
.table-responsive
|
||||
table.table.table-striped.sortable
|
||||
thead
|
||||
tr
|
||||
th.header = t('.user')
|
||||
th.header = t('.score')
|
||||
th.header = t('.deadline')
|
||||
th.header = t('.runs') if policy(@exercise).detailed_statistics?
|
||||
th.header = t('.worktime') if policy(@exercise).detailed_statistics?
|
||||
tbody
|
||||
@ -60,5 +61,12 @@ h1 = @exercise
|
||||
tr
|
||||
td = link_to_if symbol==:external_users && policy(user).statistics?, label, {controller: "exercises", action: "statistics", external_user_id: user.id, id: @exercise.id}
|
||||
td = us['maximum_score'] or 0
|
||||
td.align-middle
|
||||
- if latest_submission.before_deadline?
|
||||
.unit-test-result.positive-result.before_deadline
|
||||
- elsif latest_submission.within_grace_period?
|
||||
.unit-test-result.unknown-result.within_grace_period
|
||||
- elsif latest_submission.after_late_deadline?
|
||||
.unit-test-result.negative-result.after_late_deadline
|
||||
td = us['runs'] if policy(@exercise).detailed_statistics?
|
||||
td = @exercise.average_working_time_for(user.id) or 0 if policy(@exercise).detailed_statistics?
|
||||
|
@ -4,15 +4,16 @@ h1 = t('.title')
|
||||
- exercises = Exercise.where(id: submissions.joins(:exercise).group(:exercise_id).select(:exercise_id).distinct)
|
||||
- if !policy(exercises.first).detailed_statistics?
|
||||
- submissions = submissions.final
|
||||
- any_viewable_submission = submissions.first
|
||||
- latest_viewable_submission = submissions.latest
|
||||
|
||||
- if any_viewable_submission && policy(any_viewable_submission).show_study_group?
|
||||
- if latest_viewable_submission && policy(latest_viewable_submission).show_study_group?
|
||||
.table-responsive
|
||||
table.table.table-striped.sortable
|
||||
thead
|
||||
tr
|
||||
th.header = t('.exercise')
|
||||
th.header = t('.score')
|
||||
th.header = t('.deadline')
|
||||
th.header = t('.runs') if policy(exercises.first).detailed_statistics?
|
||||
th.header = t('.worktime') if policy(exercises.first).detailed_statistics?
|
||||
tbody
|
||||
@ -24,6 +25,13 @@ h1 = t('.title')
|
||||
tr
|
||||
td = link_to exercise, controller: "exercises", action: "statistics", external_user_id: @user.id, id: exercise.id
|
||||
td = stats["maximum_score"] or 0
|
||||
td.align-middle
|
||||
- if latest_viewable_submission.before_deadline?
|
||||
.unit-test-result.positive-result.before_deadline
|
||||
- elsif latest_viewable_submission.within_grace_period?
|
||||
.unit-test-result.unknown-result.within_grace_period
|
||||
- elsif latest_viewable_submission.after_late_deadline?
|
||||
.unit-test-result.negative-result.after_late_deadline
|
||||
td = stats["runs"] or 0 if policy(exercises.first).detailed_statistics?
|
||||
td = stats["working_time"] or 0 if policy(exercises.first).detailed_statistics?
|
||||
- else
|
||||
|
@ -414,6 +414,7 @@ de:
|
||||
users: '%{count} verschiedene Nutzer'
|
||||
user: Nutzer
|
||||
score: Maximale Punktzahl
|
||||
deadline: Abgabefrist
|
||||
runs: Versuche
|
||||
worktime: Arbeitszeit
|
||||
average_worktime: Durchschnittliche Arbeitszeit
|
||||
@ -434,7 +435,7 @@ de:
|
||||
external_users:
|
||||
statistics:
|
||||
no_data_available: Keine Daten verfügbar oder fehlende Berechtigungen.
|
||||
time: Zeit
|
||||
time: Zeit (UTC)
|
||||
cause: Grund
|
||||
score: Punktzahl
|
||||
tests: Unit Tests
|
||||
@ -453,6 +454,7 @@ de:
|
||||
title: Statistiken für Externe Benutzer
|
||||
exercise: Übung
|
||||
score: Maximale Punktzahl
|
||||
deadline: Abgabefrist
|
||||
runs: Abgaben
|
||||
worktime: Arbeitszeit
|
||||
show:
|
||||
|
@ -414,6 +414,7 @@ en:
|
||||
users: '%{count} distinct users'
|
||||
user: User
|
||||
score: Maximum Score
|
||||
deadline: Deadline
|
||||
runs: Runs
|
||||
worktime: Working Time
|
||||
average_worktime: Average Working Time
|
||||
@ -434,7 +435,7 @@ en:
|
||||
external_users:
|
||||
statistics:
|
||||
no_data_available: No data available or insufficient permissions
|
||||
time: Time
|
||||
time: Time (UTC)
|
||||
cause: Cause
|
||||
score: Score
|
||||
tests: Unit Test Results
|
||||
@ -453,6 +454,7 @@ en:
|
||||
title: External User Statistics
|
||||
exercise: Exercise
|
||||
score: Maximum Score
|
||||
deadline: Deadline
|
||||
runs: Submissions
|
||||
worktime: Working Time
|
||||
show:
|
||||
|
Reference in New Issue
Block a user