Moodle

Shared questions not backed up, leading to DB data corruption and SQL errors

Details

  • Type: Bug Bug
  • Status: Open Open
  • Priority: Minor Minor
  • Resolution: Unresolved
  • Affects Version/s: 1.9.5, 2.2
  • Fix Version/s: DEV backlog
  • Component/s: Backup, Questions
  • Labels:
    None
  • Environment:
    observed at MySQL servers
  • Affected Branches:
    MOODLE_19_STABLE, MOODLE_22_STABLE

Description

Symptoms
========

  • unable to add questions to a quiz
  • after debugging turned on, an SQL error complains. Invalid arguments passed to IN() operator like in "questionid IN (,,,,,,,,189,188,187)"
  • the field "questions" in mdl_quiz table contains data like ,,,,,189,188,187 (it est missing integers)

Reasons
=======
The data of the field "questions" got corrupted during a restore procedure. A course backup with a quiz was restored. However, questions used by the quiz were not included in the backup. During the restore, the id of not included question casts to empty string '' which leads to corrupted data in mdl_quiz.questions field.

The reason why the questions were not included in the backup is that all the questions were shared at the course category context. However, at the end of the term, the course were moved out of the category to an archive so it was not descendant of the category containing the questions any more. The quiz itself continued working so the teacher did not notice anything weird. During the backup procedure, the number of questions being backed-up was reported as 0. But it itself is not alarming too much if the backup is done by administrator, for example, who does not know the course so much.

How to reproduce
==============
1. Create a top level category CAT1
2. Create course COURSE under CAT1
3. Create a QUIZ in COURSE containing three or so questions. Save the questions in the context of CAT1
4. Create another top level category CAT2
5. Move the COURSE into CAT2
6. Check the QUIZ still works
7. Backup the COURSE
8. Restore the COURSE into CLONE
9. Try to add a question to the QUIZ in CLONE (with debugging on, of course)

Issue Links

Activity

Hide
David Mudrak added a comment -

Added How to reproduce to the issue Description

Show
David Mudrak added a comment - Added How to reproduce to the issue Description
Hide
Tim Hunt added a comment -

Well done for diagnosing that. It means that it is really a consequence of MDL-14802, but not really a duplicate.

Show
Tim Hunt added a comment - Well done for diagnosing that. It means that it is really a consequence of MDL-14802, but not really a duplicate.
Hide
Michael de Raadt added a comment -

Thanks for reporting this issue.

We have detected that this issue has been inactive for over a year has been recorded as affecting versions that are no longer supported.

If you believe that this issue is still relevant to current versions (2.1 and beyond), please comment on the issue. Issues left inactive for a further month will be closed.

Michael d;

lqjjLKA0p6

Show
Michael de Raadt added a comment - Thanks for reporting this issue. We have detected that this issue has been inactive for over a year has been recorded as affecting versions that are no longer supported. If you believe that this issue is still relevant to current versions (2.1 and beyond), please comment on the issue. Issues left inactive for a further month will be closed. Michael d; lqjjLKA0p6
Hide
David Mudrak added a comment -

Leaving this to Tim to decide.

Show
David Mudrak added a comment - Leaving this to Tim to decide.
Hide
Tim Hunt added a comment -

Regrettably this is still an issue, but still hard to fix, so I am sticking it on the DEV backlog.

Show
Tim Hunt added a comment - Regrettably this is still an issue, but still hard to fix, so I am sticking it on the DEV backlog.

People

Vote (0)
Watch (1)

Dates

  • Created:
    Updated: