Change the author automatically on publish

So on my site I’ve got unregistered user submitted posts (students) and a custom role for teachers who modify those posts and then publish them.

When the unregistered (ie. not logged in) users submit the question form, a plugin turns them into posts. These post get attributed to the user 0 (yes, that doesn’t exists but it doesn’t really matter) and are set as ‘drafts’.

I’ve also made a custom role, ‘teacher’, that has limited capabilities since all they’re supposed to do is publish the students questions.

So logged in teachers answer the student’s question (fill in a custom field) and publish the post. Now currently, after publishing, the post is attributed to the lowest ID user with the role ‘teacher’.

What I would like to happen is for the posts to be attributed to the teacher who published said post. Changing the author is of course possible from the edit screen’s author dropdown, but this requires the teachers to manually do it and, well, they’re not very tech savvy and I’d like to keep things simple and automatic.

Any help?

Cheers.