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

\gradeimport_csv_load_data::check_user_exists() can unreliably fetch another user's ID

    XMLWordPrintable

Details

    • Bug
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • 3.5.4, 3.6.2
    • 3.5.6, 3.6.4
    • Gradebook
    • MOODLE_35_STABLE, MOODLE_36_STABLE
    • MOODLE_35_STABLE, MOODLE_36_STABLE
    • MDL-64958-master
    • Hide
      1. Create students s1 and s2. Give them the same ID number.
      2. Enrol them in a course with some activities (e.g. assignment)
      3. Go to the course homepage.
      4. Navigate to "Grades / Grade administration / Grader report"
      5. Click on the Export tab.
      6. Under the Export tab, click on the Plain text file tab.
      7. Click Download.
      8. Open the downloaded CSV file using a text editor and set a grade for s2's assignment. Save the edited CSV file.
      9. Back on the browser, click on the Import tab.
      10. Drag and drop the CSV file to the File picker.
      11. Click "Upload grades"
      12. Under "Identify user by", set the following:
        Map from ID number
        Map to ID number
      13. Under "Grade item mappings", map the assignment accordingly.
      14. Click Upload grades.
      15. Confirm that you get an error that multiple users were found.
      16. Confirm that the import fails.
      Show
      Create students s1 and s2. Give them the same ID number. Enrol them in a course with some activities (e.g. assignment) Go to the course homepage. Navigate to " Grades / Grade administration / Grader report " Click on the Export tab. Under the Export tab, click on the Plain text file tab. Click Download. Open the downloaded CSV file using a text editor and set a grade for s2's assignment. Save the edited CSV file. Back on the browser, click on the Import tab. Drag and drop the CSV file to the File picker. Click " Upload grades " Under " Identify user by ", set the following: Map from ID number Map to ID number Under " Grade item mappings ", map the assignment accordingly. Click Upload grades. Confirm that you get an error that multiple users were found. Confirm that the import fails.

    Description

      Since email and idnumber are not unique fields, there's a chance that multiple user records will be matched when querying for user data using these fields in \gradeimport_csv_load_data::check_user_exists(). This can lead to a different user's grades being inadvertently modified during grade import.

      In such a case, this function needs to return a null userid instead.

      I was able to reproduce this problem by having 2 users have the same email address (with $CFG->allowaccountssameemail turned on). I uploaded using the email field mapping, and only got one user being updated even when the update should have been for the other user.

      Attachments

        Issue Links

          Activity

            People

              jpataleta Jun Pataleta
              jpataleta Jun Pataleta
              Víctor Déniz Falcón Víctor Déniz Falcón
              Adrian Greeve Adrian Greeve
              Anna Carissa Sadia Anna Carissa Sadia
              Adrian Greeve, Jake Dallimore, Mathew May, Mihail Geshoski, Sujith Haridasan
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:
                13/May/19

                Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0 minutes
                  0m
                  Logged:
                  Time Spent - 2 hours, 50 minutes
                  2h 50m