csmberkeley / scheduler

For managing our students, mentors, and sections
MIT License
8 stars 5 forks source link

Convert week numbers into dates on mentor spreadsheet #31

Open attang opened 8 years ago

attang commented 8 years ago

Currently, the attendance views give an arbitrary week number that doesn't mean much to the viewer. Changing them to the Sunday of that week will give a better understanding of which attendance item corresponds to which week. This problem shows up on two pages - both the mentor and the student.

Relevant files to look at

I'd recommend starting scheduler up, and trying to find the two pages on your browser that corresponds to these two pages. Login with the admin account and enroll yourself to get to where you need to be. Then, you can refresh the page to see if works the way you want it to.

The current implementation is that each course object holds a variable called base_week, which stores a ruby datetime object that specifies when does each course start. The base_week is always the Sunday of the starting week. If the course does not have a specified base_week, it uses a global base_week stored in the Settings table instead.

To get the week number, there's a function called getCurrentWeek() which calculates the difference between the current datetime and the base_week datetime modulo 7.

Each attendance object also stores that week number. A lack of an attendance object means the student was unexcused.

I wouldn't recommend changing any existing code of the controller; rather add code by writing in a new method that function method_show and function show can call so that it can calculate the Sunday of the current week given a week number. Then update the view so that it shows that datetime rather than a simple number. You may need to look up on how to play around with datetime objects, which are built-in to Ruby.