Moodle
  1. Moodle
  2. MDL-28120

Workshop upgrade from 1.9 to 2.1 breaks due to duplicate grade entries (patch attached)

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Critical Critical
    • Resolution: Won't Fix
    • Affects Version/s: 2.1
    • Fix Version/s: None
    • Component/s: Workshop
    • Labels:
    • Database:
      MySQL
    • Testing Instructions:
      Hide

      Occurs on our specific Moodle DB only. To reproduce independently:

      • Install Moodle 1.9.
      • Create a workshop (with grades), and manually duplicate some rows in the workshop_grades table.
      • Install Moodle 2.1 and rund the upgrade routine.
      • Proceed until the upgrade of mod/workshop .
      Show
      Occurs on our specific Moodle DB only. To reproduce independently: Install Moodle 1.9. Create a workshop (with grades), and manually duplicate some rows in the workshop_grades table. Install Moodle 2.1 and rund the upgrade routine. Proceed until the upgrade of mod/workshop .
    • Workaround:
      Hide

      Manually delete duplicate rows from mdl_workshop_grades before upgrade. To identify duplicate rows, run the following query:

      SELECT count as dupcnt,id,workshopid,assessmentid,elementno FROM mdl_workshop_grades
      group by workshopid,assessmentid,elementno
      having dupcnt>1

      Show
      Manually delete duplicate rows from mdl_workshop_grades before upgrade. To identify duplicate rows, run the following query: SELECT count as dupcnt,id,workshopid,assessmentid,elementno FROM mdl_workshop_grades group by workshopid,assessmentid,elementno having dupcnt>1
    • Affected Branches:
      MOODLE_21_STABLE
    • Pull from Repository:
    • Pull Master Branch:
    • Rank:
      17740

      Description

      While running the upgrade routine to Moodle 2.1 on (a copy of) our Moodle 1.9 database, the upgrade of mod/workshop terminates with error message: "Error writing to database."

      It turns out that this error occurs at the following line of mod/workshop/accumulative/db/upgradelib.php, within workshopform_accumulative_upgrade_legacy():

      $newid = $DB->insert_record('workshop_grades', $new);

      On further investigation, this is caused by duplicate entries in the (old) mdl_workshop_grades table. The upgrade routine assumes that the key (workshopid, assessmentid, elementno) is unique. However, in out database, this is not the case - among approx. 68.000 rows, there are 14 duplicates. These 14 pairs of rows are identical in every field (except "id"), not only in the three mentioned fields.

      This is likely caused by a bug in previous versions of the workshop module. (Our Moodle installation is quite old, and while currently running on Moodle 1.9, it has been upgraded several times before.) Nevertheless, it would be good if the upgrade would behave gracefully when encountering these duplicate rows.

      An easy way to fix this is to add a GROUP BY clause to the SQL statement that retrieves the data from mdl_workshop_grades_old. See patch attached. Of course, one might as well consider more sophisticated solutions for this problem.

        Activity

          People

          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: