OU blog: Error writing to database in Moodle 2.2
Please turn on debugging and post back the error stack trace. Perhaps a database table was not created when you upgraded the module from a previous version. The stack trace will tells us that.
Thanks Rob. I should have turn on the debugging in the first place. This is what I got:
Debug info: Out of range value adjusted for column 'grade' at row 1
INSERT INTO mdl_oublog (name,summary,allowcomments,individual,maxvisibility,maxbytes,maxattachments,grade,course,completionposts,completioncomments,accesstoken) VALUES(?,?,?,?,?,?,?,?,?,?,?,?)
0 => 'test',
1 => '<p>dasjklsdafjkl;</p>',
2 => '1',
3 => '0',
4 => '100',
5 => '52428800',
6 => '9',
7 => '-15',
8 => '389',
9 => 0,
10 => 0,
11 => '106ead6bc3d37e425ccd5c1509191bda',
- line 397 of /lib/dml/moodle_database.php: dml_write_exception thrown
- line 893 of /lib/dml/mysqli_native_moodle_database.php: call to moodle_database->query_end()
- line 935 of /lib/dml/mysqli_native_moodle_database.php: call to mysqli_native_moodle_database->insert_record_raw()
- line 31 of /mod/oublog/lib.php: call to mysqli_native_moodle_database->insert_record()
- line 443 of /course/modedit.php: call to oublog_add_instance()
It was a scale value: Pass, refer. I did try a number grade and that worked. As you can see from the error message, the value is for 'grade' is '-4' (I am guessing this is its position in relation to 'no grade'). Since the number grades (located below, not above 'no grade') produce a positive number in the grade field, perhaps it is using the wrong integer type?
I should add: have no way of checking at the moment.
I too saw the negative value, but did not quite understand how it got there. It looks like that has triggered the out of range part of the stack trace.
I am able to set grades using a custom scale in my production Moodle (2.3.3+). In the database, the grade value is "-5." Do you know if you are using the most recent release of OUblog?
SUCCESS! I queried the grade field in mdl_oublog and, sure enough, it was 'unsigned'. So it would not take negative numbers.
The fact it was unsigned is strange. In my other 2.2 installation, the field was not designated as signed or unsigned.
In any case, I changed it to signed
alter table mdl_oublog modify grade int signed;
and now it works!
Thanks, Rob, for talking me though this!