You can apply for a CAS to extend your visa to retake modules if you need to remain in the UK to complete your studies. We recommend that you check our "CAS for extending your visa" webpage to make sure you meet all eligibility requirements for a new CAS, as there are a number of factors that we must take into account. The webpages also have instructions on how to complete a CAS request.
Make sure to submit your CAS request in plenty of time before your visa expires as it can take up to 10 working days to process your request. Please note that you can only apply a maximum of 3 months before the end date of your current visa.