drachels / moodle-mod_mootyper

4 stars 18 forks source link

Database error when editing activity name on course page #52

Closed heather-williams closed 6 years ago

heather-williams commented 6 years ago

When trying to edit the activity name for a mootyper activity on the course page, using the pencil icon, when you hit enter to save the new name, you get the following database error:

Column 'grademax' cannot be nullINSERT INTO mdl_grade_items (courseid,categoryid,itemname,itemtype,itemmodule,iteminstance,itemnumber,iteminfo,idnumber,calculation,gradetype,grademax,grademin,scaleid,outcomeid,gradepass,multfactor,plusfactor,aggregationcoef,aggregationcoef2,sortorder,display,decimals,locked,locktime,needsupdate,weightoverride,timecreated,timemodified,hidden) VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)[array ( 0 => '1709', 1 => '20370', 2 => 'Mistyped Spaces Lesson', 3 => 'mod', 4 => 'mootyper', 5 => '3', 6 => 0, 7 => NULL, 8 => NULL, 9 => NULL, 10 => 1, 11 => NULL, 12 => 0, 13 => NULL, 14 => NULL, 15 => 0, 16 => 1.0, 17 => 0, 18 => 0, 19 => 0, 20 => 295, 21 => 0, 22 => NULL, 23 => 0, 24 => 0, 25 => 1, 26 => 0, 27 => 1510617032, 28 => 1510617032, 29 => 0,)]Error code: dmlwriteexception* line 482 of /lib/dml/moodle_database.php: dml_write_exception thrown* line 1259 of /lib/dml/mysqli_native_moodle_database.php: call to moodle_database->query_end()* line 1305 of /lib/dml/mysqli_native_moodle_database.php: call to mysqli_native_moodle_database->insert_record_raw()* line 343 of /lib/grade/grade_object.php: call to mysqli_native_moodle_database->insert_record()* line 472 of /lib/grade/grade_item.php: call to grade_object->insert()* line 128 of /lib/gradelib.php: call to grade_item->insert()* line 757 of /mod/mootyper/lib.php: call to grade_update()* line 1378 of /lib/gradelib.php: call to mootyper_grade_item_update()* line 1680 of /course/lib.php: call to grade_update_mod_grades()* line 94 of /course/classes/output/course_module_name.php: call to set_coursemodule_name()* line 3972 of /course/lib.php: call to core_course\output\course_module_name::update()* line 7505 of /lib/moodlelib.php: call to core_course_inplace_editable()* line 385 of /lib/external/externallib.php: call to component_callback()* line 229 of /lib/externallib.php: call to core_external::update_inplace_editable()* line 64 of /lib/ajax/service.php: call to external_api::call_external_function()

I do not see a grade item record for this activity in the grade_item table and even if there was one, you would not be able to set grademax to NULL because that column does not allow NULL values.

drachels commented 6 years ago

It would help to know details of your setup so I can try to duplicate what happened. What operating system, database, and PHP does your server use? Also, which version of Moodle and which version of MooTyper are you having the problem with?

jstilwell commented 6 years ago

MooTyper: $plugin->release = '3.4.0 (Build: 2017110700)'; OS: CentOS Linux release 7.4.1708 (Core) Moodle: 3.1.6 DB: mysql Ver 15.1 Distrib 5.5.56-MariaDB, for Linux (x86_64) using readline 5.1 PHP: 7.0.25

drachels commented 6 years ago

One thing I forgot to ask...was it a fresh install or was it an upgrade?

jstilwell commented 6 years ago

This was a fresh install of the plugin but installed on a version of Moodle that had been previously upgraded.

drachels commented 6 years ago

Thanks for all the info. I will have to check archived files tomorrow on another computer at another location to be certain, but the line of code causing the problem should not be there as MooTyper never has supported grades in the Moodle gradebook. It was there as an example for future development. It appears that for MooTyper 3.4.0 the line, 757, in lib.php just needs to be commented out to fix the problem.

jstilwell commented 6 years ago

Will you be fixing this code in your community version? That's generally what we use when adding plugin code to our repository.

drachels commented 6 years ago

Yes, it will be fixed in the next release, but that will be a few days yet as I have some fairly major changes that will be included also, and I still have some work and testing to do on them. Meanwhile, until the release comes out, there are two options. One is to comment out line 757 in lib.php, or two make sure you use 'Edit' instead of the pencil, if you want to change the activity name. The biggest upcoming change is to make MooTyper's look smaller onscreen. ;) By that I mean, more compact on screen with relocated statistics and links to grades, plus more compact keyboard layouts.

drachels commented 6 years ago

Fix included in MooTyper 3.4.1.

jstilwell commented 6 years ago

@drachels thank you very much!