If you do not pass a course examination, you can repeat it once for free.
You will find the application form to do this here.
If you fail it a second time, a fee is generally charged to take the exam again. In exceptional cases, it is possible to submit a hardship application. It is best to ask your course leader about this.