From 7a1c345ca5cdc4401737ef050abe36bab52f2249 Mon Sep 17 00:00:00 2001 From: Alexander Grob Date: Wed, 27 Feb 2019 13:02:39 -0500 Subject: [PATCH 1/2] added column to display late-days if in gradesheet --- app/helpers/course_spreadsheet.rb | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/app/helpers/course_spreadsheet.rb b/app/helpers/course_spreadsheet.rb index 28a10406..652fc02a 100644 --- a/app/helpers/course_spreadsheet.rb +++ b/app/helpers/course_spreadsheet.rb @@ -34,6 +34,14 @@ def sanity_check end end + def late_days_remaining(u) + 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) @@ -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", "String")) + 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{|| ""})) @@ -270,6 +281,9 @@ def create_name_columns(sheet) section = reg[Section::types[type]]&.fetch(:section) row.push(section&.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 From 00e3b27958196de6072c004fcc8adc2e6d8dd80b Mon Sep 17 00:00:00 2001 From: Alexander Grob Date: Wed, 27 Feb 2019 14:15:15 -0500 Subject: [PATCH 2/2] changed cell.type from string to number --- app/helpers/course_spreadsheet.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/helpers/course_spreadsheet.rb b/app/helpers/course_spreadsheet.rb index 652fc02a..a5656bc2 100644 --- a/app/helpers/course_spreadsheet.rb +++ b/app/helpers/course_spreadsheet.rb @@ -262,7 +262,7 @@ def create_name_columns(sheet) sheet.columns.push(Col.new("#{type.humanize} section", "Number")) end if @course.total_late_days - sheet.columns.push(Col.new("Late Days Remaining", "String")) + 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{|| ""}))