A teachbook says that 'be going to' is the substitute for modal verb 'will'. Example:
When I was going to school, I was preoccupied with good grades.
What tense did use the first clause, and why? Because 'will' produces future tense, but I saw past continuous.