Problem with gradebookplus_v2

Problem with gradebookplus_v2

by Chris Lamb -
Number of replies: 1

I've just replaced the standard Gradebook on a Moodle 1.7 installation with Gradebook Plus v2.  Every time I go into the Gradebook I have the word "Error" repeated twice at the top of the page.

I've done some testing, and the problem seems to be in grade\lib.php in the following block of code:

// add extra grade tables if necessary
$sql = 'SELECT 1,1 FROM '.$CFG->prefix.'grade_events LIMIT 1';
if (!get_records_sql($sql)) {
    if ($CFG->dbtype=='postgres7') {
        require_once('db/postgres7.php');
    }
    elseif($CFG->dbtype == 'mysql') { 
        require_once('db/mysql.php');
    }
    else {
        print "DB not supported.<br />";
    }
    create_tables();
}

The problem appears to be that the create_tables call (which is drawn from db/mysql.php) is executed every time you go to the Gradebook, instead of just the first time if the tables grade_events and grade_events_grades don't already exist.  This results in Moodle attempting to create tables which already exist, causing an error message for each table.  If I drop those two tables from the database and go to the Gradebook again I get 'Success' in green twice instead, but then the next time I go to it I get 'Error' in red again.  I suspect that the line $sql = 'SELECT 1,1 FROM '.$CFG->prefix.'grade_events LIMIT 1'; is faulty in some way.

Having created the tables I could bodge the code so that create_tables isn't called again, but that seems rather inelegant.  I'd prefer the code to work properly, if possible, and if there is a correction necessary to the code then it would help others in the future if it could be made available from the Moodle downloads section in place of this one.

Any advice would be welcome!

In reply to Chris Lamb

Re: Problem with gradebookplus_v2

by Anthony Borrow -
Picture of Core developers Picture of Plugin developers Picture of Testers
Chris - As you probably know, I serve as the official maintainer of the GBPv2 patch which is written for Moodle 1.8. I am doing my best to make the code obsolete. I would not recommend installing it. I think you would be much better served upgrading first to 1.8 and then to Moodle 1.9 which will provide you with the same functionality that GBPv2 has. Let me know if you have any questions. Peace - Anthony