Inherits:
Object
• Object
show all
Defined in:

## Class Method Summary collapse

• Looking at the calendar, we want current_semester to have these characteristics Spring starts roughly around Christmas and ends 1 week after last day of semester Summer starts 1 week before and end 1 week after semester Fall starts 1 week before and goes to roughly around Christmas.

• F12, S12, M12.

• Last day of class December 6, 2013 May 2, 2013 August 7, 2014.

## Class Method Details

### .break_length_between_minis(semester) ⇒ Object

 ``` 169 170 171 172 173 174 175 176 177 178``` ```# File 'app/services/academic_calendar.rb', line 169 def self.break_length_between_minis(semester) case semester when "Fall" 1 when "Spring" 2 when "Summer" 0 end end```

### .current_mini ⇒ Object

 ``` 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63``` ```# File 'app/services/academic_calendar.rb', line 37 def self.current_mini cweek = Date.today.cweek() cwyear = Date.today.cwyear() spring_a = AcademicCalendar.semester_start("Spring", cwyear) summer_a = AcademicCalendar.semester_start("Summer", cwyear) fall_a = AcademicCalendar.semester_start("Fall", cwyear) case cweek when (spring_a)..(spring_a + 6) then "A" when (spring_a + 9)..(spring_a + 15) then "B" when (summer_a)..(summer_a + 5) then "A" when (summer_a + 6)..(summer_a + 11) then "B" when (fall_a)..(fall_a + 6) then "A" when (fall_a + 8)..(fall_a + 14) then "B" else "Unknown" end end```

### .current_semester ⇒ Object

 ``` 21 22 23 24 25 26``` ```# File 'app/services/academic_calendar.rb', line 21 def self.current_semester return "Spring" if Date.today <= AcademicCalendar.grades_due_for("Spring", Date.today.year) return "Summer" if Date.today <= AcademicCalendar.grades_due_for("Summer", Date.today.year) return "Fall" if Date.today <= AcademicCalendar.grades_due_for("Fall", Date.today.year) return "Spring" end```

### .current_semester_old ⇒ Object

Looking at the calendar, we want current_semester to have these characteristics Spring starts roughly around Christmas and ends 1 week after last day of semester Summer starts 1 week before and end 1 week after semester Fall starts 1 week before and goes to roughly around Christmas

In reality, this should be based upon when grades are due.

 ``` 14 15 16 17 18 19``` ```# File 'app/services/academic_calendar.rb', line 14 def self.current_semester_old cweek = Date.today.cweek() return "Spring" if cweek < AcademicCalendar.semester_start("Summer", Date.today.cwyear) - 1 || cweek > 51 return "Summer" if cweek < AcademicCalendar.semester_start("Fall", Date.today.cwyear) - 1 return "Fall" end```

### .current_semester_year ⇒ Object

 ``` 28 29 30 31 32 33 34 35``` ```# File 'app/services/academic_calendar.rb', line 28 def self.current_semester_year cweek = Date.today.cweek() if cweek > 51 Date.today.cwyear + 1 else Date.today.cwyear end end```

### .date_for_mini_end(semester, mini, year) ⇒ Object

 ``` 387 388 389 390 391 392 393 394 395``` ```# File 'app/services/academic_calendar.rb', line 387 def self.date_for_mini_end(semester, mini, year) cweek = semester_start(semester, year) cweek += self.term_length(semester, "A") - 1 if mini == "B" cweek += self.break_length_between_minis(semester) cweek += self.term_length(semester, mini) end Date.commercial(year, cweek, 5) #Friday end```

### .date_for_mini_start(semester, mini, year) ⇒ Object

 ``` 378 379 380 381 382 383 384 385``` ```# File 'app/services/academic_calendar.rb', line 378 def self.date_for_mini_start(semester, mini, year) cweek = semester_start(semester, year) if mini == "B" cweek += self.term_length(semester, mini) - 1 cweek += self.break_length_between_minis(semester) + 1 end Date.commercial(year, cweek, 1) end```

### .date_for_semester_end(semester, year) ⇒ Object

 ``` 372 373 374 375 376``` ```# File 'app/services/academic_calendar.rb', line 372 def self.date_for_semester_end(semester, year) cweek = semester_start(semester, year) cweek += self.term_length(semester, "Both") Date.commercial(year, cweek, 5) #Friday end```

### .date_for_semester_start(semester, year) ⇒ Object

 ``` 367 368 369 370``` ```# File 'app/services/academic_calendar.rb', line 367 def self.date_for_semester_start(semester, year) cweek = semester_start(semester, year) Date.commercial(year, cweek) end```

 ``` 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256``` ```# File 'app/services/academic_calendar.rb', line 180 def self.grades_due_for(semester, year) case year when 2015 case semester when "Spring" return Date.new(2015, 5, 19) when "Summer" return Date.new(2015, 8, 11) when "Fall" return Date.new(2015, 12, 23) end when 2014 case semester when "Spring" return Date.new(2014, 5, 21) when "Summer" return Date.new(2014, 8, 12) when "Fall" return Date.new(2014, 12, 18) end when 2013 case semester when "Spring" return Date.new(2013, 5, 22) when "Summer" return Date.new(2013, 8, 13) when "Fall" return Date.new(2013, 12, 18) end when 2012 case semester when "Spring" return Date.new(2012, 5, 22) when "Summer" return Date.new(2012, 8, 14) when "Fall" return Date.new(2012, 12, 20) end when 2011 case semester when "Spring" return Date.new(2011, 5, 17) when "Summer" return Date.new(2011, 8, 9) when "Fall" return Date.new(2011, 12, 22) end when 2010 case semester when "Spring" return Date.new(2010, 5, 18) when "Summer" return Date.new(2010, 8, 10) when "Fall" return Date.new(2010, 12, 16) end else options = {:to => "[email protected]", :subject => "(Real) Academic Calendar needs updating: grades_due_for", :message => "Please modify app/services/AcademicCalendar.rb grades_due_for(#{semester}, #{year})", :url_label => "", :url => "" } GenericMailer.email(options).deliver case semester when 'Spring' return Date.new(year, 5, 19) when 'Summer' return Date.new(year, 8, 11) when 'Fall' return Date.new(year, 12, 23) end end end```

### .next_semester ⇒ Object

 ``` 65 66 67 68 69 70 71 72 73 74``` ```# File 'app/services/academic_calendar.rb', line 65 def self.next_semester case AcademicCalendar.current_semester when "Spring" return "Summer" when "Summer" return "Fall" when "Fall" return "Spring" end end```

### .next_semester_is_soon ⇒ Object

 ``` 84 85 86 87 88 89 90 91 92 93 94 95``` ```# File 'app/services/academic_calendar.rb', line 84 def self.next_semester_is_soon case self.current_mini when "A" false when "B" true when "Unknown" true else true end end```

### .next_semester_year ⇒ Object

 ``` 76 77 78 79 80 81 82``` ```# File 'app/services/academic_calendar.rb', line 76 def self.next_semester_year if AcademicCalendar.next_semester == "Spring" || Date.today.cweek > 51 return Date.today.cwyear + 1 else return Date.today.cwyear end end```

### .parse_HUB_semester(short_form) ⇒ Object

F12, S12, M12

 ``` 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417``` ```# File 'app/services/academic_calendar.rb', line 398 def self.parse_HUB_semester(short_form) return "", "" if short_form.blank? case short_form[0] when 'F' semester = 'Fall' when 'S' semester = 'Spring' when 'M' semester = 'Summer' else semester = "" end year = '20' + short_form[1..2] year = year.to_i year = "" if year == 20 return semester, year end```

### .parse_semester_and_year(semester_year_string) ⇒ Object

 ``` 419 420 421 422 423 424 425``` ```# File 'app/services/academic_calendar.rb', line 419 def self.parse_semester_and_year(semester_year_string) semester = semester_year_string[0..-5] semester = semester.capitalize if semester year = semester_year_string[-4..-1].to_i year = "" if year == 0 return semester, year end```

### .semester_start(semester, year) ⇒ Object

Last day of class December 6, 2013 May 2, 2013 August 7, 2014

 ``` 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365``` ```# File 'app/services/academic_calendar.rb', line 272 def self.semester_start(semester, year) case year when 2015 case semester when "Spring" #Not official yet (4/1/2014) return 3 when "Summer" #Not official yet (4/1/2014) return 21 when "Fall" #Not official yet (4/1/2014) return 35 end when 2014 case semester when "Spring" return 3 when "Summer" return 21 when "Fall" #Not official yet (1/2/2012) return 35 end when 2013 case semester when "Spring" return 3 when "Summer" return 21 when "Fall" return 35 end when 2012 case semester when "Spring" return 3 when "Summer" return 21 when "Fall" return 35 end when 2011 case semester when "Spring" return 2 when "Summer" return 20 when "Fall" return 35 end when 2010 case semester when "Spring" return 2 when "Summer" return 20 when "Fall" return 34 end when 2009 case semester when "Spring" return 3 when "Summer" return 21 when "Fall" return 34 end when 2008 #This calendar is not aligned to the CMU Pittsburgh calendar case semester when "Spring" return 2 when "Summer" return 16 when "Fall" return 35 end else options = {:to => "[email protected]", :subject => "(Real) Academic Calendar needs updating: semester_start", :message => "Please modify app/services/AcademicCalendar.rb semester_start(#{semester}, #{year}) #{year.class}", :url_label => "", :url => "" } GenericMailer.email(options).deliver case semester when 'Spring' return 3 when 'Summer' return 21 when 'Fall' return 35 end end end```

### .spring_break(year) ⇒ Object

 ``` 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134``` ```# File 'app/services/academic_calendar.rb', line 110 def self.spring_break(year) case year when 2015 return 11 when 2014 return 10..11 when 2013 return 10..11 when 2012 return 10..11 when 2011 return 9..10 when 2010 return 9..10 else options = {:to => "[email protected]", :subject => "(Real) Academic Calendar needs updating: spring_break", :message => "Please modify app/services/AcademicCalendar.rb spring_break(#{year})", :url_label => "", :url => "" } GenericMailer.email(options).deliver return 11 end end```

### .term_length(semester, mini) ⇒ Object

 ``` 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167``` ```# File 'app/services/academic_calendar.rb', line 137 def self.term_length(semester, mini) case semester when "Fall" case mini when "A" 7 when "B" 7 when "Both" 15 end when "Spring" case mini when "A" 7 when "B" 7 when "Both" 16 end when "Summer" case mini when "A" 6 when "B" 6 when "Both" 12 end end end```

### .valid_semester_and_year(string) ⇒ Object

 ``` 428 429 430 431 432 433 434 435 436 437 438``` ```# File 'app/services/academic_calendar.rb', line 428 def self.valid_semester_and_year(string) (semester, year) = self.parse_semester_and_year(string) (semester, year) = self.parse_HUB_semester(string) if (semester.empty? || year.is_a?(String)) semester = "" unless ["Fall", "Summer", "Spring"].include?(semester) if year.is_a?(Fixnum) year = "" unless year > 2007 && year <= (Date.today.year + 1) end return semester, year end```

### .week_during_semester?(year, week_number) ⇒ Boolean

Returns:

• (Boolean)
 ``` 97 98 99 100 101 102 103 104 105 106 107 108``` ```# File 'app/services/academic_calendar.rb', line 97 def self.week_during_semester?(year, week_number) case week_number when self.semester_start("Spring", year)..(self.semester_start("Spring", year)+16) return true when self.semester_start("Summer", year)..(self.semester_start("Summer", year)+11) return true when self.semester_start("Fall", year)..(self.semester_start("Fall", year)+15) return true else return false end end```