Moodle

Question backup does not work on MSSQL

Details

  • Type: Bug Bug
  • Status: Closed Closed
  • Priority: Major Major
  • Resolution: Fixed
  • Affects Version/s: 1.9.3
  • Fix Version/s: 1.9.4
  • Component/s: Questions
  • Labels:
    None
  • Affected Branches:
    MOODLE_19_STABLE
  • Fixed Branches:
    MOODLE_19_STABLE

Description

First reported by Luis de Vasconcelos in http://moodle.org/mod/forum/discuss.php?d=114294:

Notice: The data types ntext and nvarchar are incompatible in the equal to operator.

Followed by:

INSERT INTO mdl_backup_ids (backup_code, table_name, old_id, info) SELECT '1232364873', 'question', q.id, '' FROM mdl_question q, mdl_backup_ids bk WHERE q.category = bk.old_id AND bk.table_name = 'question_categories' AND bk.info = 'course' AND bk.backup_code = '1232364873'

line 103 of lib\dmllib.php: call to debugging()
line 461 of question\backuplib.php: call to execute_sql()
line 445 of question\backuplib.php: call to question_insert_q_ids()
line 49 of mod\quiz\backuplib.php: call to question_insert_c_and_q_ids_for_course()
line 501 of mod\quiz\backuplib.php: call to quiz_insert_category_and_question_ids()
line 179 of in C:\Moodle\lib\weblib.php on line 6923

When I created the backup I selected just the following options on the backup screen (\backup\backup.php):

Include:

  • Quizzes
  • Certificates

Users: None
Logs: No
User Files: No
Course files: Yes
Site files used in this course: Yes
Grade histories: No

I don't want, and am not including, any user data in the backup.

Both instances of Moodle are on the same server and are running Moodle 1.9.3+ Build 20081112 (2007101531)

Is there a solution to the above error so that I can restore the Courses with all the quiz questions?

I had a look at the moodle.xml file in the course backup file and it does not contain any of the quiz questions.

Also, I was able to export the questions from MoodleDev1 to a GIFT file and then import the GIFT file into the quiz on MoodleDev2, but that isn't the ideal solution. Is there a way to get around the above data types error?

Server config:
Windows Server 2003 SP2 Std Edition
IIS 6 (6.0.3790.3959)
PHP 5.2.6 (Non Thread Safe)
FastCGI from Microsoft
FreeTDS 5.2.9.9 (the NTS version built by Trevor Johnson, MDL-14725)
MS SQL Server 2005 SP2 Std Edition (9.00.1399.00)

Modules:
Certificate Module
Certificate - Site Wide Report (080513)

Activity

Hide
Tim Hunt added a comment -

I think this patch is the correct fix.

Show
Tim Hunt added a comment - I think this patch is the correct fix.
Hide
Tim Hunt added a comment -

Fix committed to CVS.

Show
Tim Hunt added a comment - Fix committed to CVS.
Hide
Luis de Vasconcelos added a comment -

To get around the problem in 1.9.3+ I made the following change to the question_insert_q_ids function in question/backuplib.php as per Tim's recommendation in http://moodle.org/mod/forum/discuss.php?d=114294#p501847

I changed line 460 from:

AND bk.info = '$info'

to:

AND " . sql_compare_text('bk.info') . " = '$info'

and it fixed the problem. I am able to do a backup of the course and it does contain all the quiz questions. When I restore the backup everything seems to be working.

Then, just to have some fun, I copied the new 1.9.4 question/backuplib.php file that Tim has attached to this issue to my Moodle /question folder and backed up my course again. This time I got the following fatal error:

Fatal error: Call to a member function execute() on a non-object in D:\Moodle\question\backuplib.php on line 431

I reverted back to the above AND " . sql_compare_text('bk.info') . " = '$info' version and the backup is working again - no errors are produced and a good backup file is created (including all quiz questions).

Thanks Tim.

Show
Luis de Vasconcelos added a comment - To get around the problem in 1.9.3+ I made the following change to the question_insert_q_ids function in question/backuplib.php as per Tim's recommendation in http://moodle.org/mod/forum/discuss.php?d=114294#p501847 I changed line 460 from: AND bk.info = '$info' to: AND " . sql_compare_text('bk.info') . " = '$info' and it fixed the problem. I am able to do a backup of the course and it does contain all the quiz questions. When I restore the backup everything seems to be working. Then, just to have some fun, I copied the new 1.9.4 question/backuplib.php file that Tim has attached to this issue to my Moodle /question folder and backed up my course again. This time I got the following fatal error: Fatal error: Call to a member function execute() on a non-object in D:\Moodle\question\backuplib.php on line 431 I reverted back to the above AND " . sql_compare_text('bk.info') . " = '$info' version and the backup is working again - no errors are produced and a good backup file is created (including all quiz questions). Thanks Tim.
Hide
Tim Hunt added a comment -

I did not attach any file to this bug. The tracker automatically makes links to relevant information from the CVS repository. And it looks like you took version 1.24 with is for Moodle 2.0, rather than version 1.13.2.7 which works with Moodle 1.9. So nothing to worry about here.

You need to look at the line tjhunt committed 1 file to 'Moodle CVS' on branch 'MOODLE_19_STABLE', of which on branch 'MOODLE_19_STABLE' is the vital bit.

Show
Tim Hunt added a comment - I did not attach any file to this bug. The tracker automatically makes links to relevant information from the CVS repository. And it looks like you took version 1.24 with is for Moodle 2.0, rather than version 1.13.2.7 which works with Moodle 1.9. So nothing to worry about here. You need to look at the line tjhunt committed 1 file to 'Moodle CVS' on branch 'MOODLE_19_STABLE', of which on branch 'MOODLE_19_STABLE' is the vital bit.
Hide
Luis de Vasconcelos added a comment -

You're right Tim! I used the wrong version. Silly me!

I tried version 1.13.2.7 and it works beautifully.

Show
Luis de Vasconcelos added a comment - You're right Tim! I used the wrong version. Silly me! I tried version 1.13.2.7 and it works beautifully.

People

Vote (0)
Watch (1)

Dates

  • Created:
    Updated:
    Resolved: