Images get lost when moving question to other context
Description of bug / unexpected behavior
When a question is moved from one context to another, images that are embedded in the part's text get lost.
Expected behavior
The images should still be there, obviously.
How to reproduce the issue
- Create a new question. Embed an image in the text of part 1. Save the question. Preview the question to verify the image is there.
- Move the question to another course. (Moving it to a different category of the same course is not enough.)
- Preview the question again. The image is not there anymore.
The same happens for files embedded in parts' feedback texts.
Additional comments
When moving the files, we use the $questionid:
https://github.com/FormulasQuestion/moodle-qtype_formulas/blob/32395d9289961a3c5bfb4a7a745b40a4e0399f4d/questiontype.php#L90-L106
However, when saving the question, we use $ans->id which is the part's ID.
https://github.com/FormulasQuestion/moodle-qtype_formulas/blob/32395d9289961a3c5bfb4a7a745b40a4e0399f4d/questiontype.php#L261-L261
This will be fixed with #62.
As a side effect, this means that uploaded files (embedded in parts) will not be removed when the question is deleted.