Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions app/helpers/course_spreadsheet.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,14 @@ def sanity_check
end
end

def late_days_remaining(u)

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As I'm looking at the code for lateness, I worry a bit that we're hardcoding "days" as the unit of measurement. Especially since the lateness_per_hour penalty cares about hours of lateness...

I wonder whether we ought to change LatenessConfig to have a method seconds_late, and then build minutes_late, hours_late, and days_late etc on top of that:

  def time_late(assignment, submission, raw = false)
    return 0 unless raw or late?(assignment, submission)
    due_on = assignment.effective_due_date(submission.user, submission.team)
    sub_on = submission.created_at || DateTime.current
    (sub_on.to_f - due_on.to_f).seconds
  end
  def units_late(assignment, submission, raw = false, unit = :hours)
    unit = :hours unless ActiveSupport::Duration::PARTS.member?(unit)
    (time_late(assignment, submission, raw) / 1.send(unit).to_f).ceil
  end
  def seconds_late(assignment, submission, raw = false)
    units_late(assignment, submission, raw, :seconds)
  end
  def minutes_late(assignment, submission, raw = false)
    units_late(assignment, submission, raw, :minutes)
  end
  def hours_late(assignment, submission, raw = false)
    units_late(assignment, submission, raw, :hours)
  end
  def days_late(assignment, submission, raw = false)
    units_late(assignment, submission, raw, :days)
  end
  def weeks_late(assignment, submission, raw = false)
    units_late(assignment, submission, raw, :weeks)
  end

  def friendly_lateness(assignment, submission, raw = false, unit = :hours)
    lateness = units_late(assignment, submission, raw, unit)
    return "On time" if lateness.to_f == 0
    
    unit = unit.to_s.singularize
    "#{lateness} #{unit.pluralize(lateness)}"
  end

Then lateness policies can use whichever one is most appropriate, and our lateness reporting can use friendly_lateness to summarize the magnitude of the problem

@grobalex grobalex Feb 27, 2019

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This feels like it should be a separate feature / issue

assns = @course.assignments.where("available <= ?", DateTime.current)
total_latedays = u.used_submissions_for(assns).to_a.reduce(0) do |acc, s|
acc + s.submission.days_late
end
return @course.total_late_days - total_latedays
end

def create_exams(sheet)
labels, weight = create_name_columns(sheet)

Expand Down Expand Up @@ -253,6 +261,9 @@ def create_name_columns(sheet)
course_section_types.each do |type|
sheet.columns.push(Col.new("#{type.humanize} section", "Number"))
end
if @course.total_late_days
sheet.columns.push(Col.new("Late Days Remaining", "Number"))
end
sheet.columns.push(Col.new("Withdrawn?", "DateTime"), Col.new(""), Col.new(""))
labels = sheet.push_header_row(nil, ["", "", "", "", "", "", "", "", ""].push(*course_section_types.count.times.map{|| ""}))
weight = sheet.push_header_row(nil, ["", "", "", "", "", "", "", "", ""].push(*course_section_types.count.times.map{|| ""}))
Expand All @@ -270,6 +281,9 @@ def create_name_columns(sheet)
section = reg[Section::types[type]]&.fetch(:section)
row.push(section&.crn || "<no CRN>")
end
if @course.total_late_days
row.push(late_days_remaining(u) || "")
end
row.push(lecture&.dig(:dropped_date) || "", "", "")
sheet.push_row(nil, row)
end

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if we should add a column for each assignment, splitting the "Lateness" column into "Lateness" and "Lateness penalty"

@grobalex grobalex Feb 27, 2019

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was wondering that too; It would be great for assignment analytics but is that information that would be used (?) but I see no reason not to have it

Expand Down