ndunand / moodle-qtype_matrix

Source code of https://moodle.org/plugins/qtype_matrix
2 stars 10 forks source link

bug: Old Matrix version rows and columns are deleted when new version is created #70

Open a-kempka opened 1 month ago

a-kempka commented 1 month ago

I stumbled upon a bug that removes each item's text from the edit form: Here are the steps to reproduce it:

  1. create a qtype_matrix question rom a quiz and save it (this becomes version 1)
  2. edit the question, set the review status to draft, save the question (this becomes version 2)
  3. try to edit Version 1 of the question: The text of the items now is empty although the preview shows the correct item text.

In the quiz version 1 will be included as it is the most recent with the ready status. Editing question version 1 shows no item text anymore. Clicking the preview of version 1 shows trhe items correctly. In the editor they are empty.

(Tested on Moodle 4.1, qty-e_matrix 3.7 for Moodle 3.9-4.1 (Build: 2023010300)) and 3.7.4 for Moodle 4.1-4.3 (Build: 2024041000)

danowar2k commented 2 weeks ago

Given a matrix question with multiple versions, the newest version seems to have both cols and rows, but all (!) older versions of a matrix question does not have any more entries in qtype_matrix_rows nor in qtype_matrix_cols. But (!) there are still the records in table qtype_matrix.

Which doesn't make any sense whatsoever, because the only place in the code where qtype_matrix_rows entries are deleted is the store function delete_question() which always deletes the entries in the qtype_matrix table, too.