In my opinion, the first sentence should be the correct one because students are supposed to do their homework before class begins. etc'. The structural relationship is between 'always gets mad' and 'when I don't', so #2 is the correct structure.
New words, one handy idiom, and a 2-minute quiz — delivered to your inbox to keep your streak alive.