The functionality looks ok, but the code is hard to read, test, (and maintain). I believe you could do an early exit or next if the 9 digit check fails but I'm not sure. The nesting could be reduced a lot if any if or else clause over 5 lines long was made into a separate method. Also, IMHO, it would be clearer if the loops were just used to manage feeding chunks of data to a method. E.g. have a loop to hand each term to a method that handles a single term, which, in turn, hands each course in that term to a method that handles a single course.
The functionality looks ok, but the code is hard to read, test, (and maintain). I believe you could do an early exit or next if the 9 digit check fails but I'm not sure. The nesting could be reduced a lot if any if or else clause over 5 lines long was made into a separate method. Also, IMHO, it would be clearer if the loops were just used to manage feeding chunks of data to a method. E.g. have a loop to hand each term to a method that handles a single term, which, in turn, hands each course in that term to a method that handles a single course.