Yes, your teacher has it right - both of those are correct English, and make sense. There’s quite a good description of the Passive voice in English on Wiki.
“The noun or noun phrase that would be the object of an active
sentence (such as Our troops defeated the enemy) appears as the
subject of a sentence or clause in the passive voice (e.g. The enemy
was defeated by our troops).”
So, in the first example the object of ‘painted’ in the active sentence is ‘the picture’, which becomes the subject of the verb ‘painted’ in the passive version. It’s slightly complicated because it’s in the form of a question, so the ‘who was’ makes it more confusing.
I painted this picture >>> This picture was painted by me.
The above would be a clearer example.