Did she write in her diary yesterday?

Literal

She [topic-は] yesterday, diary [object-を] wrote-politely [question-か]?

The polite past interrogative ~ましたか chains polite past 書きました with question particle か, hitting both the courtesy and the inquiry in two morphemes. 日記 ('diary, journal') is paired with 書く ('write') in this sentence, but the more idiomatic Japanese collocation is 日記をつける ('keep a diary,' literally 'attach a diary' — using つける in its sense of 'log, record'). Both are usable; 書く emphasizes the act of putting words on the page, while つける emphasizes keeping the practice ongoing.