I've assigned this to you rather than the default choice maintainer as I suspect it is a restore issue and I have no clue where to start looking for a solution.
I'm presently working on the course import UI and have hit an snag while attempting to import a course with one choice into the an empty course.
After getting the errors in my script I tried to replicate with a standard backup/restore and found I could.
The problem arrises by following these steps:
- Create a new course.
- Don't assign anyone proceed to turn on editing.
- Create a choice, set some options and save.
- Start a backup of the course.
- Turn off all settings except filter, blocks, and activities.
- Proceed through and run the backup.
- When the backup finished and you see the restorefile.php screen select your backup for restore.
- Proceed through the restore choosing merge into this course but not changing any other settings.
- When the restore executes you will get the notices and errors.
The notices are as follows:
Notice: Undefined property: stdClass::$id in /var/www/moodle/m20_dev1/moodle/mod/choice/backup/moodle2/restore_choice_stepslib.php on line 54
Notice: Undefined property: stdClass::$timeopen in /var/www/moodle/m20_dev1/moodle/mod/choice/backup/moodle2/restore_choice_stepslib.php on line 57
Notice: Undefined property: stdClass::$timeclose in /var/www/moodle/m20_dev1/moodle/mod/choice/backup/moodle2/restore_choice_stepslib.php on line 58
Notice: Undefined property: stdClass::$timemodified in /var/www/moodle/m20_dev1/moodle/mod/choice/backup/moodle2/restore_choice_stepslib.php on line 59
Error writing to database
Debug info: Field 'intro' doesn't have a default value
INSERT INTO choice (course,timeopen,timeclose,timemodified) VALUES(?,?,?,?)
0 => 11,
1 => NULL,
2 => NULL,
3 => NULL,
- line 383 of /lib/dml/moodle_database.php: dml_write_exception thrown
- line 718 of /lib/dml/mysqli_native_moodle_database.php: call to moodle_database->query_end()
- line 760 of /lib/dml/mysqli_native_moodle_database.php: call to mysqli_native_moodle_database->insert_record_raw()
I also call print_r on the $data object right before the notices and got the following objects:
[id] => 8
[name] => A simple choice
[intro] => <p>This is a simple choice for a simple course.</p>
<p>Please choose your favourite number:</p>
[introformat] => 1
[publish] => 0
[showresults] => 0
[display] => 0
[allowupdate] => 0
[limitanswers] => 0
[timeopen] => 0
[timeclose] => 0
[timemodified] => 1281683845
I'll try to look into this myself and will let you know if I get anywhere.
Yell out if you'd like any more information.