Issue Details (XML | Word | Printable)

Key: MDL-17809
Type: Bug Bug
Status: Resolved Resolved
Resolution: Duplicate
Priority: Blocker Blocker
Assignee: Tim Hunt
Reporter: Barry Oosthuizen
Votes: 1
Watchers: 1
Operations

Add/Edit UI Mockup to this issue
If you were logged in you would be able to see more operations.
Moodle

Matching Question Type Answers do not restore from backup

Created: 08/Jan/09 12:24 AM   Updated: 18/Jan/09 01:16 AM
Component/s: Backup, Questions
Affects Version/s: 1.9.3
Fix Version/s: None

File Attachments: 1. Zip Archive backup-_matching_question-20090107-0954.zip (6 kB)

Issue Links:
Duplicate
 

Database: Any
Participants: Barry Oosthuizen, Eloy Lafuente (stronk7), John T. Macklin and Tim Hunt
Security Level: None
Resolved date: 14/Jan/09
Affected Branches: MOODLE_19_STABLE


 Description  « Hide
1. Steps to reproduce:
a. A create a matching question type in a quiz
b. Have a student take the quiz containing the matching question type.
c. Manually backup the course containing the quiz including grade histories
d. Try to restore the course either as a new course or by adding it to an existing course
e. The answers the student gave for the matching question type will be missing from the mdl_question_states.answer field in the database.
f. As a consequence of step 1e above, if the results are regraded the student will loose the grades scored in step 1b.

2. Actual Behaviour:
I backed up my courses and combined them all into one course using Restore. After checking the exams and regrading all students lost their marks for all the matching questions. I was able to trace it back to the Restore function failing to recode in the answers. I found that the original copy and the restored copy of the same attempted quiz had different data inside mdl_question_states.answers i.e. the answers were missing from the restored copy. Multiple choice and True/False questions were unaffected.

E.g.

  1. Quiz "Exam"
  2. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Quiz "matching question"
    Could not recode answer in question_match_sub 185006379
    Could not recode answer in question_match_sub 191396361

This causes the submitted answers to not be viewable to the teacher/student in a restored copy of the quiz.

This causes the grades to be lost when regrading seeing as there are no answers in mdl_question_states of the restored copy.

3. Expected behaviour:
When restoring a course containing matching question types in a quizzes the answers selected by students should be in mdl_question_states.answers. When a teacher/student reviews an attempted quiz they would expect to be able to see which answers were selected in the attempt. This is not possible for matching question types with attempts restored from backup.



 All   Comments   Change History   Version Control      Sort Order: Ascending order - Click to sort in descending order
Barry Oosthuizen added a comment - 08/Jan/09 12:58 AM
I tried reproducing from this error from scratch and it still happens. I attach an example backup file which fails to restore properly

John T. Macklin added a comment - 10/Jan/09 05:34 AM
Barry,

I have found an issue with this as well in the question/restorelib.php where function question_states_restore_mods fails (function which restores the question_states)
upon course restore due to existing question_states which cannot be recreated due to table insert prevention of a duplicate record
being inserted into mdl_question_states during restore of a course.

Although at this point I do not know if your conditions were exactly as mine I did have more
success at restoring my question states after implementing a few more checks in function question_states_restore_mods.

The patch I have created (question_restorelib.patch) addresses this issue ..

After application I have was then able to recreate the course from restore and the questions and answers seemed to be intact.
Please give this a try if you would like and let me know if it help to reduce your issue.


John T. Macklin added a comment - 10/Jan/09 05:36 AM
question_restorelib.patch implements additional checks during course question states restore.

John T. Macklin added a comment - 10/Jan/09 05:44 AM
Barry,

The question_restorelib.patch file I attached implements a few more checks and balances before inserting new states into question_states.
In my case I noticed the same issue upon restore of a course from backup which was causing the restore of question_states to fail the
restore completely due to question_states_restore_mods returning a state of false.


Barry Oosthuizen added a comment - 10/Jan/09 11:08 AM
Hi John,

Thanks for the patch, desperately needed. I'll try it out and let you know how it went.

The attached zip file is a manual backup of a course which contains an attempted quiz with a matching question type which I was unable to restore with answers. Should be the same on any Moodle 1.9.3 installation (without your patch).


Barry Oosthuizen added a comment - 12/Jan/09 07:46 AM
Hi John,

I've applied your patch but I still have the same problem.

The only difference now is that I DON'T get these kind of messages any more when restoring the backup file: "Could not recode answer in question_match_sub 191396361" This message actually helps to identify the bug so we still need it.

The bug only seems to affect the "Matching" Question type. Other question types are restored without any missing answers in question_states.

Were you able to reproduce this error with the description I gave?


Eloy Lafuente (stronk7) added a comment - 14/Jan/09 11:35 AM
Assigning to Tim

Tim Hunt added a comment - 14/Jan/09 02:12 PM
The attached patch was wrong. I deleted it to avoid accidents.

Tim Hunt added a comment - 14/Jan/09 02:23 PM
Ah, this is a duplicate of a bug I fixed just before Christmas. You just need to upgrade to the latest 1.9.3+.

Barry Oosthuizen added a comment - 18/Jan/09 01:16 AM
Thanks Tim,

I upgraded and it works fine.