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

Error reading from database while downloading participants table data. Extra comma in code

    XMLWordPrintable

Details

    • Bug
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • 4.0.1
    • 4.0.2
    • User management
    • MOODLE_400_STABLE
    • MOODLE_400_STABLE
    • MDL-74871-400
    • Hide

      Setup

      1. Login as admin
      2. Navigate to Users > Accounts > User profile fields in site administration
      3. Create a new Text input profile field:
        • Short name: food
        • Name: Food
        • Character limit: 128
      4. Create a new user
        • Food: Potato
      5. Create a course
      6. Enrol user as a student in the course

      With identity fields

      1. Navigate to Users > Permissions > User policies in site administration
      2. Set Show user identity to
        • Email address
        • Food
      3. Save changes
      4. Go to the course and navigate to course participants
      5. Select all participants
      6. Press With selected users... Download table data as .pdf
      7. Confirm file is downloaded, Email address and Food columns are present

      Without identity fields

      1. Navigate to Users > Permissions > User policies in site administration
      2. Clear Show user identity value (so nothing is checked)
      3. Save changes
      4. Go to the course and navigate to course participants
      5. Select all participants
      6. Press With selected users... Download table data as .pdf
      7. Confirm file is downloaded, no identity field columns are present
      Show
      Setup Login as admin Navigate to Users > Accounts > User profile fields in site administration Create a new Text input profile field: Short name: food Name: Food Character limit: 128 Create a new user Food: Potato Create a course Enrol user as a student in the course With identity fields Navigate to Users > Permissions > User policies in site administration Set Show user identity to Email address Food Save changes Go to the course and navigate to course participants Select all participants Press With selected users... Download table data as .pdf Confirm file is downloaded, Email address and Food columns are present Without identity fields Navigate to Users > Permissions > User policies in site administration Clear Show user identity value (so nothing is checked) Save changes Go to the course and navigate to course participants Select all participants Press With selected users... Download table data as .pdf Confirm file is downloaded, no identity field columns are present

    Description

      When trying to download a course participants list as a csv file, for example, the system returns a MySQL error:

      You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near ' gcn.groupnames
      FROM mdl_user u
      ...' at line 1
      SELECT u.firstname, u.lastname, , gcn.groupnames
      FROM mdl_user u
      ...
      -- line 153 of /user/action_redir.php: call to mysqli_native_moodle_database->get_recordset_sql()

      There are two commas after u.lastname.

      The problem can be temporarily solved by removing that comma from /user/action_redir.php, line 144, since each element on the array $userfields->selects has a prepended comma:

       

      $sql = "SELECT u.firstname, u.lastname, {$userfields->selects}
      to
      $sql = "SELECT u.firstname, u.lastname {$userfields->selects}
      

      I guess this problem affects other functionalities.

      In case it is relevant: this error appeared after upgrading to Moodle 4. Not a fresh installation.

      Attachments

        Issue Links

          Activity

            People

              pholden Paul Holden
              robegb Rober GB
              Amaia Anabitarte Amaia Anabitarte
              Jun Pataleta Jun Pataleta
              Gladys Basiana Gladys Basiana
              David Woloszyn, Huong Nguyen, Jake Dallimore, Meirza, Michael Hawkins, Raquel Ortega, Safat Shahin, Stevani Andolo
              Votes:
              0 Vote for this issue
              Watchers:
              7 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:
                11/Jul/22

                Time Tracking

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