I'm not currently in school but I do work and this was a concern for me as well. Since I don't have versions that I can pause (mine are first gen and iPhone app), I make sure their needs are fulfilled while I'm getting ready for work. I do this again while I'm on the bus to work, and then again before my shift starts. I work three days a week, and two of those days I have shifts where I get two 15-minute breaks and an hour-long lunch. My other shift is shorter so I only get a 15. On my breaks I check on my tamagotchis and fulfill their needs, even if they only have one empty heart for hunger and/or fun. This is how I've kept them from dying on me. However, I don't play with them when I'm not on break because I'm there to work, not goof off. If I check my phone during work hours (not on breaks), it's just to see if anyone has texted me; yesterday it was because I was getting a ride home from my mom and just needed to verify our plans. The same will be for when I go back to school, though I may just put mine away since I'm going to be taking online classes (the way my shifts are scheduled, I can't actually take classes on-site) and I don't want them to be a distraction when this is the first time I'll be doing online classes.
Anyway, my advice for this is to take care of their needs while you're getting ready for school, as well as when you're on the way to school (assuming you get a ride or take the bus or something, though if you walk it should work just fine as well). If you can pause it, then just pause it when class starts and check up on it during your breaks. But don't play with it during class. You're there to learn, after all, and you can get in trouble if you're caught with it out. I'd also put it on mute so it won't be distracting if you can't pause it. My keychain tamagotchi is muted (I've got roommates and thin walls) and my phone is always on vibrate anyway.
Hope this helps!