First, I would try to tease out whether this is a medication related issue. Can you try writing at home with similar assignments during a more optimal time of day for him and see how it goes? If it's better, can you visit his doctor to try a dose adjustment or a longer acting medication? If it's not better, I'd recommend an OT eval to try to help figure out what's going on.