I think it's normal not to function that well when switching these shifts like that. In my twenties I used to work at a gas station and we had night shifts too, I loved the night shifts because they were usually filled with fun people and only a few rush hours to get through (big tips too lol) but we'd never be on nights long, sadly.
Nope, they used to toss us around from 2 day shifts to several nights and then evenings and stuff like that. Often they'd call for a sick colleague and kind of demanded you to come in even though you weren't properly rested yet.
Even though I could handle such things much better when I was younger, even back then that was too much for me to deal with. I surely couldn't do it anymore now in my fourties lol.
But seems for you this is just a one time thing because of the exams so hopefully you'll be back to normal soon!