If repeating the exam does not go against the school’s rules and is not unfair to others, then there is nothing wrong with it. Unfairness here means that other classes in the same school are not also given the opportunity to repeat the exam or some students in the same class, or other classes, who got good grades and repeating the exam will cause them hardship or may make their grades go down. If the exam can be repeated without unfairness to anyone, there is nothing wrong with it in that case, and some educational systems allow those students who wish to, to repeat tests, and the higher grade will be recorded for them.
But if the system does not allow repeating exams, then it is essential to seek the permission and agreement of the administration.
And Allaah knows best.