The officer checks as much as he can at the time of the stop. He determined that the student was in violation. End of story. It's up to the courts to decide. As Carl said, where he works the courts tend to favor the strict view that the students need CA licenses.
This is not only a California issue - it does happen in other states as well.
Intent to return "home" is certainly no indication of residency either. If someone moves to my state (NY) for 6 months, let's say, with the intent of returning home to California, he still needs a New York license during his stay here.