Merge pull request #206 from openHPI/fix/working-time-break-highlighting
Fix working time highlighting
This commit is contained in:
@ -3,6 +3,7 @@ class ExercisesController < ApplicationController
|
|||||||
include Lti
|
include Lti
|
||||||
include SubmissionParameters
|
include SubmissionParameters
|
||||||
include SubmissionScoring
|
include SubmissionScoring
|
||||||
|
include TimeHelper
|
||||||
|
|
||||||
before_action :handle_file_uploads, only: [:create, :update]
|
before_action :handle_file_uploads, only: [:create, :update]
|
||||||
before_action :set_execution_environments, only: [:create, :edit, :new, :update]
|
before_action :set_execution_environments, only: [:create, :edit, :new, :update]
|
||||||
@ -347,14 +348,15 @@ class ExercisesController < ApplicationController
|
|||||||
def statistics
|
def statistics
|
||||||
if(@external_user)
|
if(@external_user)
|
||||||
@submissions = Submission.where("user_id = ? AND exercise_id = ?", @external_user.id, @exercise.id).order("created_at")
|
@submissions = Submission.where("user_id = ? AND exercise_id = ?", @external_user.id, @exercise.id).order("created_at")
|
||||||
@submissions_and_interventions = (@submissions + UserExerciseIntervention.where("user_id = ? AND exercise_id = ?", @external_user.id, @exercise.id)).sort_by { |a| a.created_at }
|
interventions = UserExerciseIntervention.where("user_id = ? AND exercise_id = ?", @external_user.id, @exercise.id)
|
||||||
deltas = @submissions.map.with_index do |item, index|
|
@all_events = (@submissions + interventions).sort_by { |a| a.created_at }
|
||||||
delta = item.created_at - @submissions[index - 1].created_at if index > 0
|
@deltas = @all_events.map.with_index do |item, index|
|
||||||
|
delta = item.created_at - @all_events[index - 1].created_at if index > 0
|
||||||
if delta == nil or delta > 10 * 60 then 0 else delta end
|
if delta == nil or delta > 10 * 60 then 0 else delta end
|
||||||
end
|
end
|
||||||
@working_times_until = []
|
@working_times_until = []
|
||||||
@submissions_and_interventions.each_with_index do |submission, index|
|
@all_events.each_with_index do |_, index|
|
||||||
@working_times_until.push((Time.at(deltas[1..index].inject(:+)).utc.strftime("%H:%M:%S") if index > 0))
|
@working_times_until.push((format_time_difference(@deltas[0..index].inject(:+)) if index > 0))
|
||||||
end
|
end
|
||||||
render 'exercises/external_users/statistics'
|
render 'exercises/external_users/statistics'
|
||||||
else
|
else
|
||||||
|
@ -9,4 +9,9 @@ module TimeHelper
|
|||||||
nil
|
nil
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# given a delta in seconds, return a "Hours:Minutes:Seconds" representation
|
||||||
|
def format_time_difference(delta)
|
||||||
|
Time.at(delta).utc.strftime("%H:%M:%S")
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
@ -39,8 +39,8 @@ h1 = "#{@exercise} (external user #{@external_user})"
|
|||||||
- ['.time', '.cause', '.score', '.tests', '.time_difference'].each do |title|
|
- ['.time', '.cause', '.score', '.tests', '.time_difference'].each do |title|
|
||||||
th.header = t(title)
|
th.header = t(title)
|
||||||
tbody
|
tbody
|
||||||
- @submissions_and_interventions.each_with_index do |this, index|
|
- @all_events.each_with_index do |this, index|
|
||||||
- highlight = (index > 0 and @working_times_until[index] == @working_times_until[index - 1] and this.created_at > @submissions_and_interventions[index - 1].created_at)
|
- highlight = (index > 0 and @deltas[index] == 0 and this.created_at.to_s != @all_events[index - 1].created_at.to_s)
|
||||||
tr data-id=this.id class=('highlight' if highlight)
|
tr data-id=this.id class=('highlight' if highlight)
|
||||||
td.clickable = this.created_at.strftime("%F %T")
|
td.clickable = this.created_at.strftime("%F %T")
|
||||||
- if this.is_a?(Submission)
|
- if this.is_a?(Submission)
|
||||||
@ -49,7 +49,7 @@ h1 = "#{@exercise} (external user #{@external_user})"
|
|||||||
td
|
td
|
||||||
-this.testruns.each do |run|
|
-this.testruns.each do |run|
|
||||||
- if run.passed
|
- if run.passed
|
||||||
.unit-test-result.positive-result title=run.output
|
.unit-test-result.positive-result title=run.output
|
||||||
- else
|
- else
|
||||||
.unit-test-result.unknown-result title=run.output
|
.unit-test-result.unknown-result title=run.output
|
||||||
td = @working_times_until[index] if index > 0
|
td = @working_times_until[index] if index > 0
|
||||||
@ -57,7 +57,7 @@ h1 = "#{@exercise} (external user #{@external_user})"
|
|||||||
td = this.intervention.name
|
td = this.intervention.name
|
||||||
td =
|
td =
|
||||||
td =
|
td =
|
||||||
td =
|
td = @working_times_until[index] if index > 0
|
||||||
p = t('.addendum')
|
p = t('.addendum')
|
||||||
.hidden#wtimes data-working_times=ActiveSupport::JSON.encode(@working_times_until);
|
.hidden#wtimes data-working_times=ActiveSupport::JSON.encode(@working_times_until);
|
||||||
div#progress_chart.col-lg-12
|
div#progress_chart.col-lg-12
|
||||||
|
Reference in New Issue
Block a user