Please check out the following sentences.
1. When class started, I suddenly realized that I forgot to do my homework.
2. My teacher was angry at my laziness and had me stand in front of the class.
3. How embarrassed I was !
They're all OK, though I'd write "I suddenly realised that I had forgotten ..." because this sentence has all the requirements for the use of the past perfect:
- one thing happening before another, both in the past
PLUS
- the two events being logically related.
PLUS
- an absence of adverbs, such as "before, last night", which would make the past perfect unnecessary.