Error writing to database

Error writing to database

by Eduardo Veliz -
Number of replies: 2

I am trying to minimize the size of the grader report, when I click on the - sign of each category to minimize it, I get the error shown below. Does anyone know how to fix this?. 

Error writing to database

More information about this error

Debug info: Data too long for column 'value' at row 1
UPDATE mdl_user_preferences SET value = ? WHERE id = ?
[array (
0 => 'a:2:{s:14:"aggregatesonly";a:15:{i:1;s:1:"3";i:4;s:2:"12";i:5;s:2:"13";i:6;s:2:"14";i:7;s:2:"15";i:8;s:2:"17";i:9;s:2:"18";i:10;s:2:"16";i:11;s:1:"6";i:12;s:1:"7";i:14;s:1:"8";i:15;s:2:"19";i:16;s:2:"20";i:17;s:1:"9";i:18;s:1:"2";}s:10:"gradesonly";a:0:{}}',
1 => '4',
)]
Stack trace:
  • line 397 of /lib/dml/moodle_database.php: dml_write_exception thrown
  • line 1071 of /lib/dml/mysqli_native_moodle_database.php: call to moodle_database->query_end()
  • line 1475 of /lib/dml/moodle_database.php: call to mysqli_native_moodle_database->set_field_select()
  • line 1441 of /lib/moodlelib.php: call to moodle_database->set_field()
  • line 1540 of /grade/report/grader/lib.php: call to set_user_preference()
  • line 104 of /grade/report/grader/index.php: call to grade_report_grader::process_action()
 
Attachment Capture.PNG
In reply to Eduardo Veliz

Re: Error writing to database

by Tim Hunt -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

This happens when you have a lot of columns in your gradebook.

The value in the 'user_preferences' table has type CHAR(255), and if you look at the error message, you can see that it is trying to store a much longer string than that.

The simplest solution is to go into the database, and alter the value column to be CHAR( ... something bigger ...). You should have a look at what range of values your DB will accept there.

In reply to Tim Hunt

Re: Error writing to database

by Eduardo Veliz -

thank you for your prompt support. I Modified the values and everything is fine now.