Grammarly is confusing me. When I use dialogue as in,
when the teacher asked the question. "What is your name?"
according to everything I have been told after the word question I either use a comma or a full stop.
In Grammarly, a full colon is inserted :
I know that no one can tell me what is 'right' way but what is preferred?
'When the teacher asked the question, "What is your name?"' needs a comma after 'question'. A colon is incorrect in UK English usage. So is a full stop in this instance because if you read the whole sentence it begs to continue: a full stop creates a fragment, not a complete sentence, which makes no sense.
From your last comment about Grammarly, and this one, I confess I'd be reluctant to trust it.
Not a full stop. Either a comma or colon, a comma is more common and I only generally use a colon if it is a dramatic statement but that's a style issue - the important thing is being consistent.