Closed hgeorgsch closed 4 years ago
The error is triggered because of missing grading configurations. The error displayed is:
ERROR: null value in column "gradepass" violates not-null constraint
The standard way of setting grade configurations is in the settings page. There are several standard Moodle core methods which are invoked when we specify that we support grading. However, we have deviated from this practice and manually placed these configs in a tab in the activity. See: https://github.com/KQMATH/moodle-mod_capquiz/blob/c0f8b10eb1e15ac15777ff8d1f9d9519f1ce9a7d/mod_form.php#L44
The problem arises because that the gradepass value isn't loaded properly when accessing the settings page. The stars_to_pass is undefined when accessing the settings page: https://github.com/KQMATH/moodle-mod_capquiz/blob/c0f8b10eb1e15ac15777ff8d1f9d9519f1ce9a7d/lib.php#L151
See PR #127 which implemented grading.
This problem is still present as of today. FYI.
New test. Error still persistent.
Make and publish a CAPQuiz instance. Open the instance as teacher. Open the gear menu (upper right corner), choose edit settigns. Add a sentence to the description. Push save and display. I get the following debug messages.
Debug info: ERROR: null value in column "gradepass" violates not-null constraint DETAIL: Failing row contains (5, 3, 2, Undeployed CAP, mod, capquiz, 3, 0, null, 6, null, 1, 5.00000, 0.00000, null, null, null, 1.00000, 0.00000, 0.00000, 0.00000, 2, 0, null, 0, 0, 0, 1, 0, 1589359806, 1597229838). UPDATE mdl_grade_items SET courseid = $1,categoryid = $2,itemname = $3,itemtype = $4,itemmodule = $5,iteminstance = $6,itemnumber = $7,iteminfo = $8,idnumber = $9,calculation = $10,gradetype = $11,grademax = $12,grademin = $13,scaleid = $14,outcomeid = $15,gradepass = $16,multfactor = $17,plusfactor = $18,aggregationcoef = $19,aggregationcoef2 = $20,sortorder = $21,display = $22,decimals = $23,locked = $24,locktime = $25,needsupdate = $26,weightoverride = $27,timecreated = $28,timemodified = $29,hidden = $30 WHERE id=$31 [array ( 'courseid' => '3', 'categoryid' => '2', 'itemname' => 'Undeployed CAP', 'itemtype' => 'mod', 'itemmodule' => 'capquiz', 'iteminstance' => '3', 'itemnumber' => '0', 'iteminfo' => NULL, 'idnumber' => '6', 'calculation' => NULL, 'gradetype' => '1', 'grademax' => 5.0, 'grademin' => 0.0, 'scaleid' => NULL, 'outcomeid' => NULL, 'gradepass' => NULL, 'multfactor' => 1.0, 'plusfactor' => 0.0, 'aggregationcoef' => 0.0, 'aggregationcoef2' => 0.0, 'sortorder' => '2', 'display' => '0', 'decimals' => NULL, 'locked' => '0', 'locktime' => '0', 'needsupdate' => '1', 'weightoverride' => '0', 'timecreated' => '1589359806', 'timemodified' => 1597229838, 'hidden' => '0', 0 => '5', )] Error code: dmlwriteexception ×Stack trace: line 489 of /lib/dml/moodle_database.php: dml_write_exception thrown line 329 of /lib/dml/pgsql_native_moodle_database.php: call to moodle_database->query_end() line 1234 of /lib/dml/pgsql_native_moodle_database.php: call to pgsql_native_moodle_database->query_end() line 1267 of /lib/dml/pgsql_native_moodle_database.php: call to pgsql_native_moodle_database->update_record_raw() line 253 of /lib/grade/grade_object.php: call to pgsql_native_moodle_database->update_record() line 307 of /lib/grade/grade_item.php: call to grade_object->update() line 152 of /mod/capquiz/lib.php: call to grade_item->update() line 164 of /mod/capquiz/lib.php: call to capquiz_grade_item_update() line 45 of /mod/capquiz/lib.php: call to capquiz_update_grades() line 612 of /course/modlib.php: call to capquiz_update_instance() line 152 of /course/modedit.php: call to update_moduleinfo()
This should now be fixed in release v0.4.2.
When I change the settings of a CAPQuiz activity (edit settings in the gear menu, none of the tabs), I get a write error on the database. AFAICT all the changes are successfully stored, but I get the error nevertheless.