I'm trying to create a plugin that uses images as answers. I'm planning to use the filemanager control to add images to a question instead of the standard answer fields to make it more user-friendly. I'm trying to figure out how to get the URLs of the newly-uploaded files and store them in the question table.
Assuming you are storing the files in a files area of your plugin you probably want to use \moodle_url::make_pluginfile_ulr() to create urls.
You would probably not want to store the url though. Instead you should store the information required to identify the correct file and generate the url each time you wish to display it in a request.
Questions are special, or at least the core question system provdies helpers on top of the standard uploaded file serving stuff that probably reduces the amount of work you need to do, once you understand it.
The core question types already support images everywhere. E.g. if you want a multiple choice question where all the choices are images, well, you can just do that with the standard qtype_multichoice.
Anyway, looking at the code of the question types already in Moodle is probably the way to work out what you need to do.