1. The sentence is a question about a future event.
2. The structure for 'be going to' questions is: Wh-word + am/is/are + subject + going to + verb? (Here, the 'Wh-word' is implied, and it's a yes/no question).
3. Therefore, the answer is: Are we going to have an exam next week?