Moodle

Can't restore quiz questions, nor add questions to the restored EMPTY quizes

Details

  • Type: Bug Bug
  • Status: Closed Closed
  • Priority: Major Major
  • Resolution: Fixed
  • Affects Version/s: 1.6.2
  • Fix Version/s: 1.7, 1.8
  • Component/s: Backup, Quiz
  • Labels:
    None
  • Environment:
    Moodle 1.6.2+ (2006050521) on LAMP using IE
  • Database:
    MySQL
  • Affected Branches:
    MOODLE_16_STABLE
  • Fixed Branches:
    MOODLE_17_STABLE, MOODLE_18_STABLE

Description

The backup (see attachment) created empty quizes despite the fact that there were about 120 questions and it even says so in the restore.

This is quite a problem for me since I rely on back up and restore of quizes.

In more detail.

I have three courses Monday, Wednesday and Thursday with lots of quizes. Normally I created the quizes in monday's course and then move them to Wed and then Fri.

There was a Monday bank holiday recently, so I created the categories and questions in Monday, making them "public" as usual, since I wanted to keep the home of all the categories in one place. I then created the quizes in Wednesday, backed them up and moved them to friday. All was fine.

Then this morning I backed up the quizes again in Wednesay to move to Monday. I first of all restored them in a dummy course because I wanted to move the week (the bank holiday meant that the Monday week is the 3rd not the 2nd). This works okay but takes AGES - about three minutes even though I am only restoring one week (8 quizes, 125 questions 50 categories). The questions are there.

Then I backup this dummy course and restore it to Monday.

The quizes are created but there are NO questions inside them.

Also when I try and add questions to the quizes thus created, I press the "add a random question" button and nothing happens. No question is added.

Bear in mind that the categories and questions were created and remain extant in Monday and I guess that this is the cause of the error.

In other words, this bug is PERHAPS "quizes using publically available questions can not be reimported into the quiz from which the questions and categories came. "NOOOO!

Hold on! Looking inside the backup it seems that the questions are not even there only the quizes. So it is not surprising that that the questions did not appear.

I have no idea how I managed to backup quizes without their questions....

Issue Links

Activity

Hide
Eloy Lafuente (stronk7) added a comment -

Assigning to Tim...

Show
Eloy Lafuente (stronk7) added a comment - Assigning to Tim...
Hide
Tim Hunt added a comment -

Actually, I checked in the fix to this issue a couple of hours ago after I noticed it myself!

Show
Tim Hunt added a comment - Actually, I checked in the fix to this issue a couple of hours ago after I noticed it myself!
Hide
Eloy Lafuente (stronk7) added a comment -

Timothy's turn then! Cool!

Show
Eloy Lafuente (stronk7) added a comment - Timothy's turn then! Cool!
Hide
Skip Marshall added a comment -

I just backed-up and restored a couple courses with quizzes and encountered the following error causing the restoration to fail:

"Error checking backup file. moodle.xml not found at root level of zip file."

Upon examining the zip file, it appears to be taking on the structure of the folders on our server. The files (moodle.xml, user_files, moddata, and course_files) are nested within 3 other folders.

Show
Skip Marshall added a comment - I just backed-up and restored a couple courses with quizzes and encountered the following error causing the restoration to fail: "Error checking backup file. moodle.xml not found at root level of zip file." Upon examining the zip file, it appears to be taking on the structure of the folders on our server. The files (moodle.xml, user_files, moddata, and course_files) are nested within 3 other folders.
Hide
Skip Marshall added a comment -

When I removed the extra folder structure, the back-up restore properly.

Show
Skip Marshall added a comment - When I removed the extra folder structure, the back-up restore properly.
Hide
Tim Hunt added a comment -

There was a bug with the backup process that meant that the questions were not included in the backup file at all. That was a back-up problem, as described in this bug report, and I fixed it.

If someone else has introduced a new bug that means that the folder structure inside backup files is screwed up, then that is a totally separate issue that cannot possibly have anything to do with the quiz module (that has no control over the way that different parts of the backup zip are assembled). So file a separate bug report about it.

Re-closing this bug.

Show
Tim Hunt added a comment - There was a bug with the backup process that meant that the questions were not included in the backup file at all. That was a back-up problem, as described in this bug report, and I fixed it. If someone else has introduced a new bug that means that the folder structure inside backup files is screwed up, then that is a totally separate issue that cannot possibly have anything to do with the quiz module (that has no control over the way that different parts of the backup zip are assembled). So file a separate bug report about it. Re-closing this bug.
Hide
Timothy Takemoto added a comment -

Dear Tim
I don't see anythign in the change history this time.
Any chance of pointers to how I might fix this?
I hack my quiz/edit.php and other places so a complete upgrade takes about a day.
Tim

Show
Timothy Takemoto added a comment - Dear Tim I don't see anythign in the change history this time. Any chance of pointers to how I might fix this? I hack my quiz/edit.php and other places so a complete upgrade takes about a day. Tim
Hide
Tim Hunt added a comment -

It was in mod/quiz/backuplib.php

Replace

//Detect used categories (by category in questions)
$status = execute_sql("INSERT INTO {$CFG->prefix}backup_ids

  • (backup_code, table_name, old_id)
  • SELECT DISTINCT $backup_unique_code,'question_categories',t.category
    FROM {$CFG->prefix}question t,
    {$CFG->prefix}quiz_question_instances g
    $from
    WHERE $where g.question = t.id",false);

With

//Detect used categories (by category in questions)
$status = execute_sql("INSERT INTO {$CFG->prefix}backup_ids
+ (backup_code, table_name, old_id, info)
+ SELECT DISTINCT $backup_unique_code,'question_categories',t.category,''
FROM {$CFG->prefix}question t,
{$CFG->prefix}quiz_question_instances g
$from
WHERE $where g.question = t.id",false);

That is, you need to tell it to insert a blank string into the info column.

Show
Tim Hunt added a comment - It was in mod/quiz/backuplib.php Replace //Detect used categories (by category in questions) $status = execute_sql("INSERT INTO {$CFG->prefix}backup_ids
  • (backup_code, table_name, old_id)
  • SELECT DISTINCT $backup_unique_code,'question_categories',t.category FROM {$CFG->prefix}question t, {$CFG->prefix}quiz_question_instances g $from WHERE $where g.question = t.id",false);
With //Detect used categories (by category in questions) $status = execute_sql("INSERT INTO {$CFG->prefix}backup_ids + (backup_code, table_name, old_id, info) + SELECT DISTINCT $backup_unique_code,'question_categories',t.category,'' FROM {$CFG->prefix}question t, {$CFG->prefix}quiz_question_instances g $from WHERE $where g.question = t.id",false); That is, you need to tell it to insert a blank string into the info column.
Hide
Timothy Takemoto added a comment -

Superb, thank you. That is the one!
Fixed
Timothy

Show
Timothy Takemoto added a comment - Superb, thank you. That is the one! Fixed Timothy
Hide
Skip Marshall added a comment -

Thanks, Tim. I will report that file structure issue as another bug. Closing issue.

Show
Skip Marshall added a comment - Thanks, Tim. I will report that file structure issue as another bug. Closing issue.
Hide
Nexus Learning added a comment -

Our issue is that when we backup/restore a course, no matter how we do it (via backup/restore, import, zip file, etc), the quizzes created but there are NO questions inside them. And we are unable to ADD any questions to those quizzes. The error "No Questions Found" comes up. When I use a previous backup of the course, one that was done about 3 or 4 weeks ago, the quiz questions will restore with the quiz.

We've run MYSQL-ADMIN to repair any tables.
copying in the quizzes, then copying in the questions.
importing the questions directly into the course using zip files
We've setup a dev moodle and moved the database over, but the problem seems to stick with the data
We tried following the code in this bug tracker, but to no avail - http://tracker.moodle.org/browse/MDL-7033
We then upgraded from Moodle 1.6.1 to 1.6.5. It didn't help.

For example:

Geometry( 2005) - Ch8-13 copy 1 (G-Geom05-8-13_1)
Category: Geometry
Not using an idnumber to avoid collisions
Could not recode question id 37241 for state 254627
Could not recode question id 37242 for state 254628
Could not recode question id 37243 for state 254629
Could not recode question id 37244 for state 254630
Could not recode question id 37240
Could not recode question id 37241

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ',,,,0) AND q.category = c.id' at line 4 SELECT q.*,c.course FROM mdl_question q, mdl_question_categories c WHERE q.id in (,,,,,0) AND q.category = c.id

or You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ',,,)' at line 1

SELECT q.*, i.grade AS maxgrade, i.id AS instance FROM mdl_question q, mdl_quiz_question_instances i WHERE i.quiz = '25053' AND q.id = i.question AND q.id IN (,,,,)

or

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near',,,,,,,,,605,606,607,608,609,610,611,612,613,614)' at line 1 SELECT q.*, i.grade AS maxgrade, i.id AS instance FROMmdl_question q, mdl_quiz_question_instances i WHERE i.quiz ='23540' AND q.id = i.question AND q.id IN(,,,,,,,,,,605,606,607,608,609,610,611,612,613,614)

Show
Nexus Learning added a comment - Our issue is that when we backup/restore a course, no matter how we do it (via backup/restore, import, zip file, etc), the quizzes created but there are NO questions inside them. And we are unable to ADD any questions to those quizzes. The error "No Questions Found" comes up. When I use a previous backup of the course, one that was done about 3 or 4 weeks ago, the quiz questions will restore with the quiz. We've run MYSQL-ADMIN to repair any tables. copying in the quizzes, then copying in the questions. importing the questions directly into the course using zip files We've setup a dev moodle and moved the database over, but the problem seems to stick with the data We tried following the code in this bug tracker, but to no avail - http://tracker.moodle.org/browse/MDL-7033 We then upgraded from Moodle 1.6.1 to 1.6.5. It didn't help. For example: Geometry( 2005) - Ch8-13 copy 1 (G-Geom05-8-13_1) Category: Geometry Not using an idnumber to avoid collisions Could not recode question id 37241 for state 254627 Could not recode question id 37242 for state 254628 Could not recode question id 37243 for state 254629 Could not recode question id 37244 for state 254630 Could not recode question id 37240 Could not recode question id 37241 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ',,,,0) AND q.category = c.id' at line 4 SELECT q.*,c.course FROM mdl_question q, mdl_question_categories c WHERE q.id in (,,,,,0) AND q.category = c.id or You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ',,,)' at line 1 SELECT q.*, i.grade AS maxgrade, i.id AS instance FROM mdl_question q, mdl_quiz_question_instances i WHERE i.quiz = '25053' AND q.id = i.question AND q.id IN (,,,,) or You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near',,,,,,,,,605,606,607,608,609,610,611,612,613,614)' at line 1 SELECT q.*, i.grade AS maxgrade, i.id AS instance FROMmdl_question q, mdl_quiz_question_instances i WHERE i.quiz ='23540' AND q.id = i.question AND q.id IN(,,,,,,,,,,605,606,607,608,609,610,611,612,613,614)

People

Vote (0)
Watch (3)

Dates

  • Created:
    Updated:
    Resolved: