moodle-qtype_formulas icon indicating copy to clipboard operation
moodle-qtype_formulas copied to clipboard

Images get lost when moving question to other context

Open PhilippImhof opened this issue 2 years ago • 2 comments

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

  1. 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.
  2. Move the question to another course. (Moving it to a different category of the same course is not enough.)
  3. 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

PhilippImhof avatar May 24 '23 15:05 PhilippImhof

This will be fixed with #62.

PhilippImhof avatar May 24 '23 15:05 PhilippImhof

As a side effect, this means that uploaded files (embedded in parts) will not be removed when the question is deleted.

PhilippImhof avatar May 24 '23 15:05 PhilippImhof