General plugins

OU blog: Error writing to database in Moodle 2.2

 
 
Picture of Leonard Houx
OU blog: Error writing to database in Moodle 2.2
 

When I create an ou blog module it fails, reading "Error writing to database". It only does this when I set it up as a graded assignment. If I set it up to not be graded, it works fine.

I have been able to get the plugin to work in other 2.2 builds, so I am totally at a loss here.

 
Average of ratings: -
Picture of Rob Johnson
Re: OU blog: Error writing to database in Moodle 2.2
Group Particularly helpful Moodlers

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.

 
Average of ratings: -
Picture of Leonard Houx
Re: OU blog: Error writing to database in Moodle 2.2
 

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(?,?,?,?,?,?,?,?,?,?,?,?)
[array (
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',
)]

Stack trace:

  • 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()
 
Average of ratings: -
Picture of Rob Johnson
Re: OU blog: Error writing to database in Moodle 2.2
Group Particularly helpful Moodlers

What is the grade value you are setting? 

 
Average of ratings:Useful (1)
Picture of Leonard Houx
Re: OU blog: Error writing to database in Moodle 2.2
 

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?

 

 

 
Average of ratings: -
Picture of Leonard Houx
Re: OU blog: Error writing to database in Moodle 2.2
 

I should add: have no way of checking at the moment.

 
Average of ratings: -
Picture of Rob Johnson
Re: OU blog: Error writing to database in Moodle 2.2
Group Particularly helpful Moodlers

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?

 
Average of ratings: -
Picture of Leonard Houx
Re: OU blog: Error writing to database in Moodle 2.2
 

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!

 
Average of ratings: -
Picture of Dolly Miglani
Re: OU blog: Error writing to database in Moodle 2.2
 

NOT able to get the certificate on quiz restriction to get minimum grades

 
Average of ratings: -