|
The patches that Paulo created are available here:
I would make some effort to update it to 1.6.3! I'm moving from 1.5.4 to 1.6.3 in a few days.
Yes I did, I also sent you an email with some questions, did you got it?
Hi Tim! I finally got the time to rewrite this patch to 1.6.x.
Unfortunatelly I was unable to test it as good as I wanted. Because my most complex course backups This 20m test cycles are just killing me. Do you have any course with a considerably number of different questions and question types, Anyway. I just releasing the code for your review and test. Multichoice qtype had restore_recode_answer Please take some time with this, and get back to me. Paulo Patch Updated/Verified against moodle tree v1.6.4+ (2006050540).
This still need some production testing. If you reached here this might be your chance, please report your experiences (good or bad)! I found an error on my previous submitted patches, on file moodle/question/type/random/questiontype.php
which I can't explain how it happened because restore simply breaks, well it's a worng table name on get_field, so instead of: $wrappedquestion->qtype = get_field('quiz_questions', 'qtype', 'id', $wrapped->new_id); it must be: $wrappedquestion->qtype = get_field('question', 'qtype', 'id', $wrapped->new_id); Along the way I found out a more subtle one, with qtype on moodle/question/restorelib.php, now it's used The other differences are new corrections. Hunt it Tim! Here goes another version of the patch, this time I made a few verifications to make it stronger against backups with problems on random questions.
Sometimes backups are messed up and there are present some attempts that should not be there. Tim... does this code area has changed much in 1.7 and 1.8?
If not, this might be easy to merge. Hope to hear your thoughts on this. Paulo I was just having a bit of a look at this.
Question: Why does the patch only changes some, but not all of the question types? (Perhaps I just need to study it more.) Also, note, the latest patch applies cleanly to 1.6 stable. It mostly applies to 1.7 and 1.8 stable. Only the multichoice and truefalse parts don't, and they look pretty easy to fix. Answering to your question: I fixed errors on match, multichoice and truefalse and implemented restore_recode_answer() on random the others are correct.
Paulo Tim.. I know you're burried until your neck with work, but don't let this baby without it's 1st birthday present.
Cheers, Paulo. I managed to find a bit of time to work on this! I managed to apply the patch to Moodle 1.9 beta2+, with a few changes. The result is attached. Unfortunately, I have not run out of time again, and this needs a lot of testing. Any help anyone can give me is greatly appreciated.
Yes, random questions have parent field set to its own id. Most of other types set to zero (0) and, if recall correctly, multi* are set to the "real" parents. I can't recall where, only thing i can say is that it was done correctly on 1.6.x.
Hi Tim et al!
I reviewd your update patch and fixed parent id of random questions. I rewrote that part, moving the code from the "if ($question_exists)" block on restorelib to a bit after, so now it's less complicated and more readable. Hopefully this part of the code has not changed in CVS, so I think this time you'll be able to merge it into the tree. Cheers, Paulo Just reviewing the latest patch.
1. In applies cleanly to the latest MOODLE_18_STABLE. 2. do we really need the else { // Handle old-style states in restore_recode_answer in random_qtype? I have never seen a state like that in the database. - Oh, I see, this matches code in restore_session_and_responses, so yes, we must correctly handle this case. 3. It does not apply cleanly to MOODLE_19_STABLE ... trying to merge by hand ... good, it is easy to merge. Right, I think that is everything. I'm going to check this in - and we have not even got to this bug's 2nd birthday Fix checked in.
I was also able to apply the patch to 1.6 and 1.7 stable branches, with a small amount of manual merger, so I applied the fix there too. Thanks for you patience on this Paulo. To any testers out there, further testing on this would be greatly appreciated. |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
I took the liberty of adding the people involved so far in this issue. Hope my numbers can provide some trust for a code commit.
Last but not least thanks Julian: you save my day.
From Eloy Lafuente (stronk7 at moodle.org) Thursday, 11 May 2006, 11:54 PM:
IMO it will be really great to have attempts working on 1.5.4!
If somebody can check the patch (it's a huge one) works as expected (bug 3159)... I'm really out of time now
Thanks Paulo!
From Eloy Lafuente (stronk7 at moodle.org) Thursday, 11 May 2006, 11:54 PM:
Adding the boss here too!
From Gustav Delius (gwd2 at york.ac.uk) Friday, 12 May 2006, 02:27 PM:
I think it is highly unlikely that we can afford the manpower to implement this in 1.5.4. I do remember looking at the code when doing the restore for 1.6 and felt that it was not stable enough to go into Moodle 1.5. I think we have to devote our efforts to testing the restore code in 1.6 more before contemplating backporting it to 1.5.4.
From Eloy Lafuente (stronk7 at moodle.org) Friday, 12 May 2006, 05:21 PM:
Aha. That's another interesting path, backporting 1.6 restore code to 1.5.x... if the patch attached here doesn't suit your requirements for 1.5.x... nothing against it from me, of course.
Ciao
From Paulo Matos (paulo.matos at fct.unl.pt) Wednesday, 24 May 2006, 09:53 PM:
Well, as promissed here are some bug we found out:
Error: Missing question options! (multichoice)
Can someone give me a hint where to look?
I put a testcase that is too big to be attached here:
http://moodle.fct.unl.pt/bug_report/
TIA. Paulo.
From Gustav Delius (gwd2 at york.ac.uk) Friday, 26 May 2006, 05:12 PM:
Paulo, thanks for your help with testing the restore code. Tim has now taken over maintenance of the question engine and I am assigning this bug to him.
From Paulo Matos (paulo.matos at fct.unl.pt) Friday, 26 May 2006, 09:58 PM:
Ok Delius! Tim, I'm willing to help to solve this issue, just too complicated to get it done without help in a reasonable amount of time. Don't hesitate in contact me. As I said before I experiencied an overall disk crash, I have a huge pressure to solve this issue.
Keep the good work guys.
Paulo.
From Paulo Matos (paulo.matos at fct.unl.pt) Thursday, 1 June 2006, 06:37 AM:
Tim, any hints on this?
From Paulo Matos (paulo.matos at fct.unl.pt) Tuesday, 6 June 2006, 02:35 AM:
I think I found the problem... options order are not recoded to the new IDs, as you can see bellow ($states[$i] for a single question)
$states->options->order is incorrect, as well as $states->seq_number...
I manage to see that the options reach the correct print_question_formulation_and_controls() function but as the order is incorrect it prints nothing....
Can now someone give me a small hint where to dig on??
Regards,
Paulo
Bellow is an smaple output of $states for a question while reviewing an attempt (mod/quiz/review.php?q=617&attempt=15581)
------------------------------------------------ STATES --------------------------------
stdClass Object
(
[question] => 9793
[0] => 251594
[id] => 251594
[1] => 15581
[attempt] => 15581
[2] => 9793
[3] => 0
[originalquestion] => 0
[4] => 2
[seq_number] => 2
[5] => random9768-20216,20213,20214,20215,20217:20217
[6] => 1141912664
[timestamp] => 1141912664
[7] => 6
[event] => 6
[8] => 1
[grade] => 1
[9] => 1
[raw_grade] => 1
[10] => 0.1
[penalty] => 0.1
[11] => 0.0
[sumpenalty] => 0.0
[responses] => Array
(
[] => 20217
)
[changed] =>
[options] => stdClass Object
(
[order] => Array
(
[0] => 20216
[1] => 20213
[2] => 20214
[3] => 20215
[4] => 20217
)
[question] => stdClass Object
(
[0] => 9768
[id] => 9768
[1] => 621
[category] => 621
[2] => 0
[parent] => 0
[3] => 13. (7.0 × 106)/(2.0 × 10-6)=
[name] => 13. (7.0 × 106)/(2.0 × 10-6)=
[4] => $$
\frac{{7.0 \times 10^6 }}
{{2.0 \times 10^{ - 6} }} =
$$
[questiontext] => $$
\frac{{7.0 \times 10^6 }}
{{2.0 \times 10^{ - 6} }} =
$$
[5] => 1
[questiontextformat] => 1
[6] =>
[image] =>
[7] => 1
[defaultgrade] => 1
[8] => 0.1
[penalty] => 0.1
[9] => 3
[qtype] => 3
[10] => 1
[length] => 1
[11] => moodle.fct.unl.pt+060305202237+vwz4EM
[stamp] => moodle.fct.unl.pt+060305202237+vwz4EM
[12] => 4
[version] => 4
[13] => 0
[hidden] => 0
[options] => stdClass Object
(
[0] => 6229
[id] => 6229
[1] => 9768
[question] => 9768
[2] => 0
[layout] => 0
[3] => 27611,27612,27613,27614,27615
[answers] => Array
(
[27611] => stdClass Object
(
[id] => 27611
[0] => 9768
[question] => 9768
[1] => $$3.5 \times 10^{ - 12}$$
[answer] => $$3.5 \times 10^{ - 12}$$
[2] => 0
[fraction] => 0
[3] =>
[feedback] =>
)
[27612] => stdClass Object
(
[id] => 27612
[0] => 9768
[question] => 9768
[1] => $$3.5 \times 10^{ - 6}$$
[answer] => $$3.5 \times 10^{ - 6}$$
[2] => 0
[fraction] => 0
[3] =>
[feedback] =>
)
[27613] => stdClass Object
(
[id] => 27613
[0] => 9768
[question] => 9768
[1] => 3.5
[answer] => 3.5
[2] => 0
[fraction] => 0
[3] =>
[feedback] =>
)
[27614] => stdClass Object
(
[id] => 27614
[0] => 9768
[question] => 9768
[1] => $$3.5 \times 10^{ 6}$$
[answer] => $$3.5 \times 10^{ 6}$$
[2] => 0
[fraction] => 0
[3] =>
[feedback] =>
)
[27615] => stdClass Object
(
[id] => 27615
[0] => 9768
[question] => 9768
[1] => $$3.5 \times 10^{ 12}$$
[answer] => $$3.5 \times 10^{ 12}$$
[2] => 1
[fraction] => 1
[3] =>
[feedback] =>
)
[20216] =>
[20213] =>
[20214] =>
[20215] =>
[20217] =>
)
[4] => 1
[single] => 1
)
[name_prefix] => resp9793_
[maxgrade] => 1
)
)
[last_graded] => stdClass Object
(
[question] => 9793
[0] => 251594
[id] => 251594
[1] => 15581
[attempt] => 15581
[2] => 9793
[3] => 0
[originalquestion] => 0
[4] => 2
[seq_number] => 2
[5] => random9768-20216,20213,20214,20215,20217:20217
[6] => 1141912664
[timestamp] => 1141912664
[7] => 6
[event] => 6
[8] => 1
[grade] => 1
[9] => 1
[raw_grade] => 1
[10] => 0.1
[penalty] => 0.1
[11] => 0.0
[sumpenalty] => 0.0
[responses] => Array
(
[] => 20217
)
[changed] =>
[options] => stdClass Object
(
[order] => Array
(
[0] => 20216
[1] => 20213
[2] => 20214
[3] => 20215
[4] => 20217
)
[question] => stdClass Object
(
[0] => 9768
[id] => 9768
[1] => 621
[category] => 621
[2] => 0
[parent] => 0
[3] => 13. (7.0 × 106)/(2.0 × 10-6)=
[name] => 13. (7.0 × 106)/(2.0 × 10-6)=
[4] => $$
\frac{{7.0 \times 10^6 }}
{{2.0 \times 10^{ - 6} }} =
$$
[questiontext] => $$
\frac{{7.0 \times 10^6 }}
{{2.0 \times 10^{ - 6} }} =
$$
[5] => 1
[questiontextformat] => 1
[6] =>
[image] =>
[7] => 1
[defaultgrade] => 1
[8] => 0.1
[penalty] => 0.1
[9] => 3
[qtype] => 3
[10] => 1
[length] => 1
[11] => moodle.fct.unl.pt+060305202237+vwz4EM
[stamp] => moodle.fct.unl.pt+060305202237+vwz4EM
[12] => 4
[version] => 4
[13] => 0
[hidden] => 0
[options] => stdClass Object
(
[0] => 6229
[id] => 6229
[1] => 9768
[question] => 9768
[2] => 0
[layout] => 0
[3] => 27611,27612,27613,27614,27615
[answers] => Array
(
[27611] => stdClass Object
(
[id] => 27611
[0] => 9768
[question] => 9768
[1] => $$3.5 \times 10^{ - 12}$$
[answer] => $$3.5 \times 10^{ - 12}$$
[2] => 0
[fraction] => 0
[3] =>
[feedback] =>
)
[27612] => stdClass Object
(
[id] => 27612
[0] => 9768
[question] => 9768
[1] => $$3.5 \times 10^{ - 6}$$
[answer] => $$3.5 \times 10^{ - 6}$$
[2] => 0
[fraction] => 0
[3] =>
[feedback] =>
)
[27613] => stdClass Object
(
[id] => 27613
[0] => 9768
[question] => 9768
[1] => 3.5
[answer] => 3.5
[2] => 0
[fraction] => 0
[3] =>
[feedback] =>
)
[27614] => stdClass Object
(
[id] => 27614
[0] => 9768
[question] => 9768
[1] => $$3.5 \times 10^{ 6}$$
[answer] => $$3.5 \times 10^{ 6}$$
[2] => 0
[fraction] => 0
[3] =>
[feedback] =>
)
[27615] => stdClass Object
(
[id] => 27615
[0] => 9768
[question] => 9768
[1] => $$3.5 \times 10^{ 12}$$
[answer] => $$3.5 \times 10^{ 12}$$
[2] => 1
[fraction] => 1
[3] =>
[feedback] =>
)
)
[4] => 1
[single] => 1
)
[name_prefix] => resp9793_
[maxgrade] => 1
)
)
)
)
From Tim Hunt (T.J.Hunt at open.ac.uk) Wednesday, 7 June 2006, 01:14 AM:
Paulo,
Sorry, no hints. I am still very new to this, and I suspect you now understand this part of the code better than me.
It's really great that you are investigating this, and I hope your efforts are rewarded.
From Paulo Matos (paulo.matos at fct.unl.pt) Thursday, 22 June 2006, 09:07 AM:
Hi folks!
Good news, seems that I finally get arround this one!!!
The problem with random questions was that at restore time, parent field was not recoded at all on quiz_restore_questions(), and before calling quiz_recode_state_answer_field() recursively the $wrappedquestion was not set correctly.
I tested intensively this procedure with a lot of quiz attempts, all types of questions, however I had no questions of type
random+('MATCH' or 'RANDOMSAMATCH'), but they were afected for sure.
After all this work, I realized I had to do it by hand for some quizzes because they had new attempts (oh dear murphy ...
).
I forgot to mention the number of states involved on the big restore operation, just 507149.
See the new version of restorelib.php and give it a try!
Regards,
Paulo Matos
From Paulo Matos (paulo.matos at fct.unl.pt) Thursday, 22 June 2006, 09:21 AM:
Just upload the patch for those who want to see the differences between versions. Just +10 and -1 lines of code make the difference.
If someone could take the time to merge this it would be great.
Cheers,
Paulo Matos