Uploaded image for project: 'Moodle'
  1. Moodle
  2. MDL-47600

mod_assign tries to insert null value into table assign_grades

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: Minor Minor
    • None
    • 2.6.3, 2.7.2
    • Assignment
    • None
    • MOODLE_26_STABLE, MOODLE_27_STABLE

      We've just had the following error message on our production system which runs on Moodle $release = '2.6.2 (Build: 20140310).
      ------------
      Debug info: Column 'attemptnumber' cannot be null
      INSERT INTO moassign_grades (assignment,userid,timecreated,timemodified,grade,grader,attemptnumber) VALUES(?,?,?,?,?,?,?)
      [array (
      0 => '45066',
      1 => '143186',
      2 => 1412843794,
      3 => 1412843794,
      4 => -1,
      5 => '22',
      6 => NULL,
      )]
      Error code: dmlwriteexception

      Stack trace:

      line 446 of /lib/dml/moodle_database.php: dml_write_exception thrown
      line 1080 of /lib/dml/mysqli_native_moodle_database.php: call to moodle_database->query_end()
      line 1122 of /lib/dml/mysqli_native_moodle_database.php: call to mysqli_native_moodle_database->insert_record_raw()
      line 2684 of /mod/assign/locallib.php: call to mysqli_native_moodle_database->insert_record()
      line 588 of /mod/assign/feedback/editpdf/classes/document_services.php: call to assign_base->get_user_grade()
      line 66 of /mod/assign/feedback/editpdf/locallib.php: call to assignfeedback_editpdf\document_services::get_feedback_document()
      line 225 of /mod/assign/feedback/editpdf/locallib.php: call to assign_feedback_editpdf->get_widget()
      line 205 of /mod/assign/feedback/editpdf/locallib.php: call to assign_feedback_editpdf->view()
      line 1097 of /mod/assign/gradingtable.php: call to assign_feedback_editpdf->view_summary()
      line 1206 of /mod/assign/gradingtable.php: call to assign_grading_table->format_plugin_summary_with_link()
      line 729 of /lib/tablelib.php: call to assign_grading_table->other_cols()
      line 433 of /mod/assign/gradingtable.php: call to flexible_table->format_row()
      line 1330 of /lib/tablelib.php: call to assign_grading_table->format_row()
      line 1442 of /lib/tablelib.php: call to table_sql->build_table()
      line 1185 of /mod/assign/renderer.php: call to table_sql->out()
      line 981 of /mod/assign/renderer.php: call to mod_assign_renderer->flexible_table()
      line 221 of /lib/outputrenderers.php: call to mod_assign_renderer->render_assign_grading_table()
      line 302 of /local/printpreview/assign.class.php: call to plugin_renderer_base->render()
      line 112 of /local/printpreview/assign.class.php: call to assign->view_grading_table()
      line 90 of /local/printpreview/assign.class.php: call to assign->view_grading_tab()
      line 507 of /mod/assign/locallib.php: call to assign->view_grading_page()
      line 53 of /mod/assign/view.php: call to assign_base->view()
      ---------------
      I believe the culprit ist the following code in mod/assign/locallib.php lines 2748 and following:
      -------------
      if ($create) {
      $grade = new stdClass();
      $grade->assignment = $this->get_instance()->id;
      $grade->userid = $userid;
      $grade->timecreated = time();
      $grade->timemodified = $grade->timecreated;
      $grade->grade = -1;
      $grade->grader = $USER->id;
      if ($attemptnumber >= 0)

      { $grade->attemptnumber = $attemptnumber; }

      $gid = $DB->insert_record('assign_grades', $grade);
      ------------
      If the attemptnumber is negative then $grade->attemptnumber is not set. Compare to line 2643 where this is done correctly.

      I see this bug also in Moodle 2.7.2+ (Build: 20140911). So this might not have been fixed.

            Unassigned Unassigned
            jzimmer Juergen Zimmer
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved:

                Error rendering 'clockify-timesheets-time-tracking-reports:timer-sidebar'. Please contact your Jira administrators.