drachels / moodle-mod_mootyper

4 stars 18 forks source link

Error reading database #34

Closed daemonsdontrest closed 4 years ago

daemonsdontrest commented 7 years ago

I have installed Mootyper for the first time and somehow got this error after clicking setup. Is this a bug? I can't configure anything since this error is persistent.

screen shot 2017-01-20 at 3 29 57 pm

Moodle version: 3.1.1 (Build: 20160711) MooTyper version: 3.1.3 (Build: 2016101101)

################################################################## Debug info: ERROR: argument of OR must be type boolean, not type integer LINE 6: (1)) ^ SELECT id, lessonname FROM mdl_mootyper_lessons WHERE ((visible = 2 AND authorid = 2) OR (visible = 1 AND editable <= 2 AND courseid = 48) OR (visible = 0) OR (1)) ORDER BY id [array ( )] Error code: dmlreadexception ×Stack trace: line 474 of /lib/dml/moodle_database.php: dml_read_exception thrown line 244 of /lib/dml/pgsql_native_moodle_database.php: call to moodle_database->query_end() line 794 of /lib/dml/pgsql_native_moodle_database.php: call to pgsql_native_moodle_database->query_end() line 134 of /mod/mootyper/locallib.php: call to pgsql_native_moodle_database->get_records_sql() line 125 of /mod/mootyper/mod_setup.php: call to get_mootyperlessons()

#######################################################################

drachels commented 7 years ago

Sorry to take so long to answer. I have been very ill for the past four days and still don't feel well. Since I did not have a server with postgresql, I had to set one up to be able to make sure the fix is going to work. You can wait until I issue a new version, which might take a couple of days, or you can fix the version you have by changing the following: In the localib.php file for version MooTyper 3.1.3 replace the $sql, lines 120 through 126 with the following:

$sql = "SELECT id, lessonname
          FROM ".$CFG->prefix."mootyper_lessons
          WHERE ((visible = 2 AND authorid = ".$u.") OR
                (visible = 1 AND ".is_user_enrolled($u, $c)." = 1) OR
                (visible = 0 AND ".is_user_enrolled($u, $c)." = 1) OR
                (".can_view_edit_all($u, $c)." = 1))
          ORDER BY id";

Let me know if it works, or if you have problems.

daemonsdontrest commented 7 years ago

Hi drachels!

Thank you for your time in solving this issue. Sorry I wasn't aware about your illness, I should have posted it after some time. :( I will not let your effort go to waste! I'll give it a shot now. Thanks and get well soon!

daemonsdontrest commented 7 years ago

Hi,

I changed the lines from 120 to 126 to your modified query, and now it works :)

screen shot 2017-01-23 at 9 24 13 pm

screen shot 2017-01-23 at 9 23 27 pm

Thanks for your help!

drachels commented 4 years ago

While testing MooTyper 3.8.0+, I discovered that I had closed this without ever adding the modifications to the master branch at the time. Must have been sicker than I thought. Anyway, the fix is in the current master branch with version of 3.8.1. Will do some more "just to be sure it is right" testing tomorrow. If all goes well, I will do another, new release.