rwthmoodle / moodle-mod_cardbox

The Card Box activity can help your students memorize vocabulary, technical terms, formulas and definitions.
2 stars 2 forks source link

Bug: restore fails #36

Open koenr opened 1 year ago

koenr commented 1 year ago

I'm trying to restore a course with a large cardbox activity to another site with the cardbox installed. Error message is

Fout bij het schrijven van de databank
[Meer informatie over deze fout](https://docs.moodle.org/400/nl/error/moodle/dmlwriteexception)
Foutopsporingsinformatie:  Field 'numberofcards' doesn't have a default value
INSERT INTO mdl_cardbox_statistics (userid,cardboxid,timeofpractice,percentcorrect) VALUES(?,?,?,?)
[array (
0 => '528',
1 => 6,
2 => 1664705420,
3 => '67',
)]
Error code: dmlwriteexception
Stack trace: 

    line 489 of /lib/dml/moodle_database.php: dml_write_exception thrown
    line 291 of /lib/dml/moodle_read_slave_trait.php: call to moodle_database->query_end()
    line 1357 of /lib/dml/mysqli_native_moodle_database.php: call to mysqli_native_moodle_database->query_end()
    line 1403 of /lib/dml/mysqli_native_moodle_database.php: call to mysqli_native_moodle_database->insert_record_raw()
    line 126 of /mod/cardbox/backup/moodle2/restore_cardbox_stepslib.php: call to mysqli_native_moodle_database->insert_record()
    line 137 of /backup/util/plan/restore_structure_step.class.php: call to restore_cardbox_activity_structure_step->process_cardbox_statistics()
    line 121 of /backup/util/helper/restore_structure_parser_processor.class.php: call to restore_structure_step->process()
    line 178 of /backup/util/xml/parser/processors/grouped_parser_processor.class.php: call to restore_structure_parser_processor->dispatch_chunk()
    line 109 of /backup/util/helper/restore_structure_parser_processor.class.php: call to grouped_parser_processor->postprocess_chunk()
    line 148 of /backup/util/xml/parser/processors/simplified_parser_processor.class.php: call to restore_structure_parser_processor->postprocess_chunk()
    line 92 of /backup/util/xml/parser/processors/progressive_parser_processor.class.php: call to simplified_parser_processor->process_chunk()
    line 190 of /backup/util/xml/parser/progressive_parser.class.php: call to progressive_parser_processor->receive_chunk()
    line 278 of /backup/util/xml/parser/progressive_parser.class.php: call to progressive_parser->publish()
    line ? of unknownfile: call to progressive_parser->end_tag()
    line 179 of /backup/util/xml/parser/progressive_parser.class.php: call to xml_parse()
    line 158 of /backup/util/xml/parser/progressive_parser.class.php: call to progressive_parser->parse()
    line 110 of /backup/util/plan/restore_structure_step.class.php: call to progressive_parser->process()
    line 181 of /backup/util/plan/base_task.class.php: call to restore_structure_step->execute()
    line 219 of /backup/moodle2/restore_activity_task.class.php: call to base_task->execute()
    line 191 of /backup/util/plan/base_plan.class.php: call to restore_activity_task->execute()
    line 168 of /backup/util/plan/restore_plan.class.php: call to base_plan->execute()
    line 408 of /backup/controller/restore_controller.class.php: call to restore_plan->execute()
    line 219 of /backup/util/ui/restore_ui.class.php: call to restore_controller->execute_plan()
    line 144 of /backup/restore.php: call to restore_ui->execute()

I looked at https://docs.moodle.org/400/en/error/moodle/dmlwriteexception#dmlwriteexception_error_when_restoring_a_course and the database tables are Barracuda.

I also added

[mysqld]
max_allowed_packet = 200M

to my mysql configuration.

I'm mentioning the problem here, because of Field 'numberofcards' doesn't have a default value seems to be a problem in the cardbox db configuration.

I can't look any further into it right now, but 'll try to provide some more info in a few days if necessary

koenr commented 1 year ago

I added in db a default value of 0 for the field mdl_cardbox_statistics.numberofcards and got the following error.

Foutopsporingsinformatie: Field 'duration' doesn't have a default value INSERT INTO mdl_cardbox_statistics (userid,cardboxid,timeofpractice,percentcorrect) VALUES(?,?,?,?) [array ( 0 => '528', 1 => 7, 2 => 1664705420, 3 => '67', )] Error code: dmlwriteexception

So I also added a default value of 0 for the field mdl_cardbox_statistics.duration.

Now the restore seems to work. I don't know if choosing a 0 as default value is a good choice, but it works for now