I agree that he should technically have used 'biological sex' rather than 'gender', but given how often the two are conflated these days, even on official forms and in scientific literature, I can forgive him for that. From the context, I think it is clear that sex is what was meant (and the teacher missed a prime opportunity to discuss the difference between the two, the fact that sex cannot be changed in a scientific sense, and the fact that gender is a social construct).
What worries me, in part, is the reinforcement of stereotypes through this idea that people can be the wrong 'gender' (as well as the utter intolerance towards anyone who questions this 'truth'). If it's not about stereotypes, then how can a 'boy' really be a 'girl', or a 'girl' really be a 'boy' given that they can't change their underlying biology? I would have no problem with children experimenting with gender while they are figuring themselves out (as we all do as children/adolescents), if it wasn't for the frankly alarming trend of funnelling children who don't feel they fit into their assigned gender stereotypes towards life-altering 'treatments' that I think are extremely damaging, when it could well be a phase. There was a channel 4 documentary about this not too long ago, where some transchildren who later went on to regret it were interviewed.