Hi there!
1. Mary had been studying for ten hours before she went to bed.
2.How long had you been cleaning your room when I arrived yesterday?
3 I had been driving for three hours when the accident happened.
4. When she saw the doctor, she told him that she hadn`t slept for three days.
5. The teacher told us that he had been teaching for ten years before he came to our school.
6 Until I found this job, I had been searching for almost ten months without success.
7. Until yesterday, he had never ridden a motorbike before.
8 She tried to explain why she had been lying to her parents when a policeman called to say that they should go to the police station.
9. By the time I got to the theatre, the play had started.
10. I didn`t start tidying up until all the guests left.
Best of luck!