The professor could just ask the student: how did you come up with this solution? What was your thinking?
To prepare for this question, the student has to think really hard both about the problem and about the solution. While doing so, we learn a lot - maybe more than we would learn otherwise.