Hi, there.
In answer to your question about "lie" - the word "did" is just a helping verb here. In other sentences with "did" as a helper, you would use "did" as follows:
Did he go? Yes, he did go to town.
Did he jump? Yes, he did jump with his parachute.
Did he run the race. Yes, he did run the race.
So, now, let's do "lie."
Did he lie there? Yes, he did lie there all afternoon. In the quiz question, the answer is correct: How long did he lie there?