I'm practicing active to passive voice transformation and trying to determine the best way to transform the following sentence - **"Who has written Hamlet?"**

My answer is: By whom has Hamlet been written?

I got a suggestion that **"Who has Hamlet been written by?"** may also be a correct passive form. But it doesn't sound grammatically correct to me.