Issue Details (XML | Word | Printable)

Key: MDL-6597
Type: Bug Bug
Status: Reopened Reopened
Priority: Major Major
Assignee: Pierre Pichet
Reporter: Mikio IKEDA
Votes: 0
Watchers: 5
Operations

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

Cloze questions sometimes get corrupted

Created: 19/Sep/06 04:41 PM   Updated: 12/Feb/08 09:39 PM
Component/s: Quiz
Affects Version/s: 1.6.2
Fix Version/s: None

File Attachments: 1. XML File quiz-excel-grammar-20080206-1735.xml (18 kB)

Environment: Red Hat Linux SE4, MySQL (5.0.24), moodle 1.6.2 (with SSL)
Issue Links:
Cloners
 
Dependency
 

Database: Any
Participants: Joseph Rézeau, Mikio IKEDA, Pierre Pichet, Steve Dubrick and Tim Hunt
Security Level: None
Resolved date: 16/Oct/06
Affected Branches: MOODLE_16_STABLE


 Description  « Hide
While editing cloze type QUIZ, previewing (when answered) destroys the quiz.

before preview

{1:NUMERICAL:=40:0} {1:NUMERICAL:=60:0}

after preview

{#1} {#2}

this happens only answering while previewing.



 All   Comments   Change History   Version Control      Sort Order: Ascending order - Click to sort in descending order
Joseph Rézeau added a comment - 20/Sep/06 03:35 PM
Can you please provide more info. on this bug.
1- What do you mean by "cloze type QUIZ" : a quiz consisting of one (or several?) questions of the cloze type?
2- What do you mean by "when editing ... previewing (when answered)"
3- I do NOT understand "his happens only answering while previewing"
Joseph

Mikio IKEDA added a comment - 20/Sep/06 04:54 PM
I was login as a teacher. While i was editing a quiz, I clicked the preview icon. Then a preview window had poped up. On the preview window, I chose an answer from menu of MULTICHOICE type (or submited a digit string of NUMERICAL type). and i clicked the 'submit all and finish' button. After that, i returned to quiz editing and found the quiz of cloze type had broken.

1. a quiz both one and several questions of the cloze type. i checked both cases.
2. quizzes -> edit -> preview (click preview icon)
3. previewed as a teacher

Before previewing as a teacher

{1:NUMERICAL:=40:0} {2:NUMERCAL :=60:0}

After preview

{#1} {#2}

Joseph Rézeau added a comment - 24/Sep/06 04:31 PM
Impossible to replicate this bug.
Using Moodle 1.6.2+ and Windows
1- Create a new quiz
2- Create a new Cloze type question named Q01. The text of this question is:
First numerical answer is 40 {1:NUMERICAL:=40:0} and second numerical answer is 60 {2:NUMERICAL:=60:0}.
3- Move question Q01 into Quiz
4- Still in Quiz edit mode, click on Preview button
5- In Preview mode, enter correct (or incorrect) answer
6- Click the 'submit all and finish' button
7- Return to edit mode
8- Try to edit question Q01 : question text is intact, no problem at all.
-------------------------------------------------------------------------------------------
The only thing we can do if for you to export your quiz and attach it to this bug report so we can look at it.

Joseph


Tim Hunt added a comment - 16/Oct/06 11:16 PM
No response from the original reporter, so closing this bug. If anyone can give us exact steps to reproduce, please reopen the bug with more information. Thanks.

Steve Dubrick added a comment - 06/Feb/08 04:29 PM
I have this same problem, and it drives me up the wall. It seems to happen if I make a very long cloze question. I have found a sort-of-workaround for it.. when I make the cloze question I must be in HTML source mode, and it will save it correctly.

Joseph Rézeau added a comment - 06/Feb/08 04:53 PM
Steve Dubrick > ...It seems to happen if I make a very long cloze question...
OK, why don't you attach one example of such "very long cloze question" which causes you problems so we can have a look at it? We can' to anything if we can't replicate your problem...
Joseph

Tim Hunt added a comment - 06/Feb/08 07:15 PM
From MDL-13350:

------

Cloze questions sometimes become corrupted in the database. For example, what used to be:

Buses aren't as {1:MULTICHOICE:fast~fast than~=fast as~faster than} trains.

becomes:

Buses aren't as {#1} trains.

This has happened a few different times in the past, but most recently it's happened to a cloze question which had 50 points in it. This time when I tried to fix it, it kept reverting back to the broken form. It finally worked when I tried saving it as a "new question". Also, in the past i've got around the problem by editing the cloze question when it was in "HTML editing mode".. the WYSIWYG editor often corrupted it. However, i'm not sure what brought on the corruption this time.. it just seemed to happen on its own.

------

The assertion is that previewing is the cause of this problem, but that is hard to believe because nothing it the question previewing code should change the question definitions in the database. It is more likely that they are getting screwed up during the save process.

Also, a problem that only happens 'sometimes' is almost impossible to investigate, especially if it never does it on my computer. Before we can make any progress, we really need to try to pin down what is different between the times it works, and the times it fails. Then we able to work out a way of reproducing it, then we can fix it.


Steve Dubrick added a comment - 06/Feb/08 07:36 PM
Unlike the OP, I don't believe it has anything to do with the previewing either, which is one reason I opened a new bug report.

I can give you an example of cloze question, but I'll need to go track down a backup copy of the question from before it got corrupted. At this point the copy i have on hand is in "post-corrupted" format, so I doubt that will help you with the problem (if if does, let me know and i'll post it). It happened at some point within the past few months and I didn't realize it at the time, so i'll need to dig through my collection of backups.

However, I still have the original cloze question that i cannot properly save anymore without saving as a "new question" on my server. If you would like, I can give you access to my moodle install and you can see for yourself.. just let me know.


Steve Dubrick added a comment - 06/Feb/08 07:55 PM
This is the result after this happened....

You can see in this XML export all the cloze questions have been changed to {#1} {#2} etc...

Question 1245 is the only exception, because I just re-saved it as a new question today when I was trying to fix the problem.

Note: Question 420 is the only question I was actively using in a quiz, I made it as a combined question of all the others.. so this was the "long question" i was referring to in the post above.


Joseph Rézeau added a comment - 06/Feb/08 10:17 PM
Steve > You can see in this XML export all the cloze questions have been changed to {#1} {#2} etc...
This is not much help, once questions have become corrupted there is nothing we can do. What we need to look at is questions BEFORE corruption happened.
There are many questions in your XML file. Please, what is the TEXT of question 1245?
Question 1245 is the only exception, because I just re-saved it as a new question today when I was trying to fix the problem.

Note: Question 420 is the only question I was actively using in a quiz, I made it as a combined question of all the others.. so this was the "long question" i was referring to in the post above.
What might help is having access to the complete code of one or more of your Cloze questions which became corrupted, but in their "pre-corruption" state...
Joseph


Pierre Pichet added a comment - 07/Feb/08 04:08 PM
The XML display showing {#1} is the normal way that the multianswer questions are stored.
each {#1}, {#2} contents are stored in subquestions that contain the subquestion text as entered.
When you edit the question, the original text is rebuilt and display.
If you change something, the old subquestions are reused or deleted. see MDL-12063.
I will merge in the next week probably down to 1.6 some of the recent changes I have done to the HEAD code on cloze questions.(as MDL-3274).

Pierre Pichet added a comment - 08/Feb/08 09:32 AM
I have to check if when saving as a new question , there is not a potential problem as this process is somewhat only identified by setting the question id = 0.
In the multianswer/questiontype.php there is a function save_question($authorizedquestion, $form, $course) {}
that proceeds the subquestions before having a call to the parent save_question() (i.e. the general save_question().).

This multianswer/questiontype.php function save_question() has no provision to handle differently the different saving processes.

Tim
You are more frendly with this saving as new process than me, can you give us some clue about this.


Steve Dubrick added a comment - 11/Feb/08 06:31 PM
Unfortunately, after searching around I couldn't find any backups that were before the corruption. This is not the first time i've had this problem though, so i'll let you know if it happens again. I've increased the number of backups to keep so that next time i'll be safe.

I've been racking my brain trying to think of what might have caused this to happen. The one thing I can think of is that at some point about 2 months ago I moved these questions from a course in sub-category to the main front page category. Perhaps this broke the questions?


Pierre Pichet added a comment - 11/Feb/08 09:42 PM
Have you access to the database?
If so locate in the mdl_question_multianswer table the item having question == your question id and look at the sequence.
You should have a list of subquestion ids like 1223,4556, etc.
look at the question table to locate these subquestions.
You can also look at the question table for questions having parent == your question_id.
When you move the question, the subquestions are not moved (MDL-10899).
This should cause no problem because the call to the subquestion does not use the category id but perhaps the subquestions where deleted if the category was deleted.

Steve Dubrick added a comment - 12/Feb/08 04:09 PM
Ah.. well that must be the problem. I believe I did delete that category after moving everything from it

After following your directions I can confirm that the subquestions are no longer there.

Here's a sample from my database.. first the mdl_question_multianswer and then mdl_question. You can see that the subquestions (e.g. 111,113,115,117,etc) don't exist anymore in mdl_question

INSERT INTO `mdl_question_multianswer` (`id`, `question`, `sequence`) VALUES (1, 4, '5'),
(54, 110, '111'),
(55, 112, '113'),
(56, 114, '115'),
(57, 116, '117'),
(58, 118, '119'),
(59, 120, '121'),

INSERT INTO `mdl_question` (`id`, `category`, `parent`, `name`, `questiontext`, `questiontextformat`, `image`, `generalfeedback`, `defaultgrade`, `penalty`, `qtype`, `length`, `stamp`, `version`, `hidden`) VALUES (6, 18, 0, 'leg', '<font size="5">L _ _<br />L{#1}<br /></font>', 0, 'placement_test/vocab2.jpg', '', 1, 1, 'multianswer', 1, 'www.excel-english.com+070703092855+6jQbZy', 'www.excel-english.com+071106043401+dsjuIK', 0),

(110, 20, 0, 'He''d like to be a doctor.', 'He''d like {#1} a doctor.', 0, '', '', 1, 0.5, 'multianswer', 1, 'www.excel-english.com+070712075742+fskwHt', 'www.excel-english.com+070712075742+GwLSxf', 0),
(112, 20, 0, 'Chefs have to work long hours.', 'Chefs {#1} to work long hours.', 0, '', '', 1, 0.5, 'multianswer', 1, 'www.excel-english.com+070712075843+zMqqTc', 'www.excel-english.com+070718072344+fz9WJo', 0),
(114, 20, 0, 'I am reading this book at the moment.', 'I {#1} this book at the moment.', 0, '', '', 1, 0.5, 'multianswer', 1, 'www.excel-english.com+070712075933+cGYIgO', 'www.excel-english.com+070712075934+Sivm5U', 0),
(116, 20, 0, 'Have you ever been to Laos?', 'Have you ever {#1} Laos?', 0, '', '', 1, 0.5, 'multianswer', 1, 'www.excel-english.com+070712080131+hTxI5j', 'www.excel-english.com+070712080131+R4DtTi', 0),
(118, 20, 0, 'The painting is interesting.', 'The painting is {#1}.', 0, '', '', 1, 0.5, 'multianswer', 1, 'www.excel-english.com+070712080217+ySJtqH', 'www.excel-english.com+070712080217+TNCFpn', 0),
(120, 20, 0, 'David: I passed my exam. John: Well done.', '<p>David: I passed my exam.<br />John: {#1}.<br /></p>', 0, '', '', 1, 0.5, 'multianswer', 1, 'www.excel-english.com+070712080355+ZDdcPW', 'www.excel-english.com+070718073054+p59a8f', 0),

Thanks for your help on this.