One expression is, from Farlex
read the riot act
To scold, reprimand, or reprove one severely for an error or mistake.I was read the riot act by my boss last week for messing up the accounting software.
So in the OP's example, perhaps
After Jim failed the first two exams, Prof. X read Jim the riot act, which set Jim straight.
The expression is possibly related to the Riot Act of the 18th century, which involved making a proclamation to the parties who needed to be brought to order.