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

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

XMLWordPrintable

    • MOODLE_400_STABLE
    • MOODLE_400_STABLE
    • 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

      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.

            pholden Paul Holden
            robegb Rober GB
            Amaia Anabitarte Amaia Anabitarte
            Jun Pataleta Jun Pataleta
            Gladys Basiana Gladys Basiana
            Votes:
            0 Vote for this issue
            Watchers:
            7 Start watching this issue

              Created:
              Updated:
              Resolved:

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

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