Global Constant
Steve Nay's ramblings

Rethinking the Office Hours app

It’s Winter Semester at BYU, and I’m again the TA for Phil Windley’s Distributed System Design class (CS 462). This time, we roped Reed into being a TA as well. We really liked the idea of the Office Hours app from last year, but we have a few different requirements this year:

  • There are two of us now, instead of just one, so the Google Calendar holding the hours got more complicated.
  • Since Reed and I both work in a research lab, we want to be available to the students without having to sit down in the TA cubicles all day. We created "on-call" office hours, during which we are available to help students but we won't be physically present until someone actually shows up.

Those two things increased the complexity of the problem fourfold. We used the same basic model as before (texting via Twilio) but chose a more distributed design:

Here is how this works in terms of events:

  1. The SMS is received by Twilio, raising a twilio:sms event to the dispatch ruleset.
  2. The dispatch ruleset checks the Google Calendar to see if anyone is on the schedule. If so, it raises a schedule_inquiry event to the rulesets handling hours for each TA. If not, it raises an absent event.
  3. The dispatch ruleset responds to the absent event by sending a text to the student that no TAs are on the schedule now. It also includes the date and time of the next office hours.
  4. The individual TA rulesets respond to the schedule_inquiry event by checking the calendar to see whether that TA is on the schedule right now. There are two possibilities: in office and on call. The former raises a present event; the latter raises an on_call_request event. The default behavior is to respond this way:
    • present: Text the student that {Steve|Reed} should be in the cubicle already.
    • on_call_request: Text {Steve|Reed} to get downstairs and reply to the student that he's on his way.

Separating the TA rulesets allows me and Reed to have the application behave differently for each of us. I prefer texting (or XMPP if I ever figure out a good way to do it), but Reed would prefer email, since his AT&T iPhone gets bad reception in our lab. All I have to do is add another rule to respond to the on_call_request event and make it do whatever I want.

Here is what my version of the TA ruleset looks like: