Commit 5e0cb55e authored by Zac Wood's avatar Zac Wood

Schedule generation works regardless of semester.

Added test back for schedule generation
parent 56f2722b
......@@ -28,10 +28,10 @@ class Schedule
@cal.add_event(event)
end
# if section.days.start_with? "M"
# col_day_makeup = generate_event_after_columbus_day(section)
# @cal.add_event(col_day_makeup)
# end
if section.course.semester.season == "Fall" && section.days.start_with?("M")
col_day_makeup = generate_event_after_columbus_day(section)
@cal.add_event(col_day_makeup)
end
end
end
......@@ -41,7 +41,7 @@ class Schedule
event = Icalendar::Event.new
event.summary = section.name
event.description = "#{section.title}\nTaught by #{section.instructor.name}"
event.description = "#{section.title}. Taught by #{section.instructor.name}"
event.location = section.location
event.dtstart = Icalendar::Values::DateTime.new(formatted_datetime_str(section.start_date, section.start_time))
event.dtend = Icalendar::Values::DateTime.new(formatted_datetime_str(section.start_date, section.end_time))
......@@ -96,7 +96,14 @@ class Schedule
# Every section's start_date is the first Monday of the semester.
# So we need to add an exclusion for that day unless the class is held on Mondays
unless section.days.start_with? "T"
if section.course.semester.season == 'Fall' && !section.days.start_with?("M")
exdates << generate_exdate(
section.start_date.to_formatted_s(:number),
section.start_time
)
end
if section.course.semester.season == 'Spring' && !section.days.start_with?("T")
exdates << generate_exdate(
section.start_date.to_formatted_s(:number),
section.start_time
......@@ -104,12 +111,12 @@ class Schedule
end
# If the section meets on Tuesdays, add an exdate for the day after columbus day
# if section.days.start_with? "T"
# exdates << generate_exdate(
# Date.new(2018, 10, 9).to_formatted_s(:number),
# section.start_time
# )
# end
if (section.course.semester.season == "Fall") && section.days.start_with?("T")
exdates << generate_exdate(
Date.new(2018, 10, 9).to_formatted_s(:number),
section.start_time
)
end
exdates
end
......@@ -130,7 +137,7 @@ class Schedule
event = Icalendar::Event.new
event.summary = section.name + " (Columbus Day makeup)"
event.description = section.title + " (Columbus Day makeup)"
event.description = section.title + " (Columbus Day makeup) Taught by #{section.instructor.name}"
event.location = section.location
after_columbus_day = Date.new 2018, 10, 9
......
......@@ -9,8 +9,8 @@ class API::SchedulesControllerTest < ActionDispatch::IntegrationTest
# DTSTAMP and UID lines uniquely identify events, so we can't test against them.
# so remove all the lines starting with them.
# the \r characters are also annoying so just remove them too
# gen = @response.body.split("\n").reject { |line| line.include?("DTSTAMP") || line.include?("UID") }.join("\n").delete("\r")
# correct_ical = File.open("test/test.ics").read.delete("\r")
# assert_equal correct_ical, gen
gen = @response.body.split("\n").reject { |line| line.include?("DTSTAMP") || line.include?("UID") }.join("\n").delete("\r")
correct_ical = File.open("test/test.ics").read.delete("\r")
assert_equal correct_ical, gen
end
end
# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
may1st: # tuesday
date: <%= Date.new(2018, 5, 30) %>
date: <%= Date.new(2018, 10, 8) %>
semester: fall2018
may2nd: # wednesday
date: <%= Date.new(2018, 5, 31) %>
date: <%= Date.new(2018, 10, 17) %>
semester: fall2018
......@@ -4,8 +4,8 @@ cs112001:
name: CS 112 001
crn: 70192
title: Introduction to Computing
start_date: 2018-05-21
end_date: 2018-06-04
start_date: 2018-08-27
end_date: 2018-12-07
days: MWF
start_time: 12:00 pm
end_time: 1:00 pm
......@@ -17,12 +17,12 @@ cs112002:
name: CS 112 002
crn: 70193
title: Introduction to Computing
start_date: 2018-05-21
end_date: 2018-06-04
start_date: 2018-08-27
end_date: 2018-12-07
location: Merten Hall 102
days: TR
start_time: 11:00 am
end_time: 2:00 pm
start_time: 3:00 pm
end_time: 4:00 pm
course: cs112
instructor: luke
......
BEGIN:VCALENDAR
VERSION:2.0
PRODID:icalendar-ruby
CALSCALE:GREGORIAN
X-WR-CALNAME:GMU Schedule
BEGIN:VEVENT
DTSTART:20180521T120000
DTEND:20180521T130000
DESCRIPTION:Introduction to Computing
LOCATION:Innovation Hall 204
SUMMARY:CS 112 001
RRULE:FREQ=WEEKLY;UNTIL=20180604T130000;BYDAY=MO,WE,FR
EXDATE:20180530T120000
EXDATE:20180531T120000
END:VEVENT
BEGIN:VEVENT
DTSTART:20181009T120000
DTEND:20181009T130000
DESCRIPTION:Introduction to Computing (Columbus Day makeup)
LOCATION:Innovation Hall 204
SUMMARY:CS 112 001 (Columbus Day makeup)
END:VEVENT
BEGIN:VEVENT
DTSTART:20180521T110000
DTEND:20180521T140000
DESCRIPTION:Introduction to Computing
LOCATION:Merten Hall 102
SUMMARY:CS 112 002
RRULE:FREQ=WEEKLY;UNTIL=20180604T140000;BYDAY=TU,TH
EXDATE:20180530T110000
EXDATE:20180531T110000
EXDATE:20180521T110000
EXDATE:20181009T110000
END:VEVENT
BEGIN:VCALENDAR
VERSION:2.0
PRODID:icalendar-ruby
CALSCALE:GREGORIAN
X-WR-CALNAME:GMU Schedule
BEGIN:VEVENT
DTSTART:20180827T120000
DTEND:20180827T130000
DESCRIPTION:Introduction to Computing. Taught by Kinga
LOCATION:Innovation Hall 204
SUMMARY:CS 112 001
RRULE:FREQ=WEEKLY;UNTIL=20181207T130000;BYDAY=MO,WE,FR
EXDATE:20181008T120000
EXDATE:20181017T120000
END:VEVENT
BEGIN:VEVENT
DTSTART:20181009T120000
DTEND:20181009T130000
DESCRIPTION:Introduction to Computing (Columbus Day makeup) Taught by Kinga
LOCATION:Innovation Hall 204
SUMMARY:CS 112 001 (Columbus Day makeup)
END:VEVENT
BEGIN:VEVENT
DTSTART:20180827T150000
DTEND:20180827T160000
DESCRIPTION:Introduction to Computing. Taught by Sean Luke
LOCATION:Merten Hall 102
SUMMARY:CS 112 002
RRULE:FREQ=WEEKLY;UNTIL=20181207T160000;BYDAY=TU,TH
EXDATE:20181008T150000
EXDATE:20181017T150000
EXDATE:20180827T150000
EXDATE:20181009T150000
END:VEVENT
END:VCALENDAR
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment