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

moodle mdl_assign_user_mapping fills with millions of useless records

XMLWordPrintable

    • MOODLE_25_STABLE, MOODLE_26_STABLE, MOODLE_27_STABLE
    • MOODLE_25_STABLE, MOODLE_26_STABLE, MOODLE_27_STABLE
    • MDL-42526-master
    • Hide
      1. in a course of 1000 students,
      2. create an assignment with blind marking and offline grading worksheet enabled
      3. Login as a teacher
      4. Now download a grading worksheet
      5. Check the database for records in mdl_assign_user_mapping with assignid = 0 (there should be none)
      Show
      in a course of 1000 students, create an assignment with blind marking and offline grading worksheet enabled Login as a teacher Now download a grading worksheet Check the database for records in mdl_assign_user_mapping with assignid = 0 (there should be none)

      Our mdl_assign_user_mapping table has millions of records
      with id, userid and assignment set to 0. I explain the location of
      the bug, and easy fix, and document the use case on how this happens to us.

      the mdl_assign_user_mapping table holds 3 fields, (id, assignment, user). the id gets used for uploading/mapping feedback. In mod/assign/locallib.php around 5945 function allocate_unique_ids, there is an insert statement which doesn't include the assignment id.

      In that file, there are 2 locations of an insert_record for that table. the other function get_uniqueid_for_user_static, does it correctly.
      5976 $record = new stdClass();
      5977 $record->assignment = $assignid;
      5978 $record->userid = $userid;
      5979
      5980 return $DB->insert_record('assign_user_mapping', $record);

      to fix in the first function,
      if (!$record)

      { $record = new stdClass(); $record->userid = $user->id; ** ADD THIS $record->assignment = $assignid; $DB->insert_record('assign_user_mapping', $record); }

      Here is the use case and scenario to re-create -
      we have a class of 1000 students,
      we are using the assignment module as a dropbox for files from the instructor to the student.
      create an assignment with no submission items selection, but grading worksheet and feedback files by the instructor.
      Now download a grading sheet. (this triggers the bug that creates 1000,s of incorrect entries in that table).

      Its kind of crazy what it does, for 1000 students in the course, it adds 1 valid record (id, assignment, userid), then 999 (id, 0, userid), then it does
      another record correctly, then 998 with (id,0, userid)

      Easy fix, if one clicks the grade in the assignment, that triggers the other function to set the values properly. but in our scenario it exploits the bug. For us to fix, we'll be deleting all entries where assignment=0 then optimize the 3,000,0000 + record table.

            jamiesensei Jamie Pratt (Inactive)
            smileyatic Steven Miley
            Damyon Wiese Damyon Wiese
            Sam Hemelryk Sam Hemelryk
            Andrew Lyons Andrew Lyons
            Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated:
              Resolved:

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