First, even native Japanese adults can correctly guess the reading of the kanji names of, say, only 90% of students, at most. Quite a few people have names (either first names or surnames) with really unpredictable readings.
How do attendance checks in school classes deal with this one issue? Are students' names written in Kanji only?
The answer is 'yes, mostly', because a class is a small and stable community (40 people at most) and everyone learns how to call one another fairly quickly. There is no true need to disambiguate the reading in such a situation, in the first place. Here's how a typical checklist used in an elementary school looks like (source):
There may be a few people with really difficult or ambiguous kanji readings, but that does not justify you always have to have hiragana alongside the kanji names throughout the school year.
But what about the beginning of each school year, when people are yet to familiarize themselves with one another? In such a case we can always use a name list with hiragana readings, which looks something like this (source):
As @Urukann pointed out, virtually all organizations (schools and companies) maintain a digital list of members with a furigana ("readings") field/column. Without the furigana field, it is even impossible to sort names alphabetically! Basically whenever kanji names need to be correctly read out aloud or sorted, we need furigana (hiragana). Unfortunately, many foreign contact book applications and such are ignorant of this fact and try to sort Japanese names based on their kanji character code, which is nearly meaningless.
Most of the time, teachers do not have to ask how to read the name of a student, because they usually have access to the list with readings. But sometimes teachers may have to ask the reading of a name directly to the students themselves, as shown in @WataruSubridge's answer. This is more true in higher educations where teachers can meet many random students.