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

grade book download shows error when using custom profile fields.

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 2.4.6, 2.5
    • Fix Version/s: 2.4.7, 2.5.3
    • Component/s: Gradebook
    • Labels:
    • Testing Instructions:
      Hide

      Create some custom profile fields

      1. Go to [Administration ► Site administration ► Users ► Accounts ► User profile fields].
      2. Create one or two user profile fields making note of the short name of each field (to be used later).

      Enable profile fields in grade settings

      1. Go to [Administration ► Site administration ► Grades ► General settings].
      2. in 'grade_export_customprofilefields' put in the short names of the custom fields separated by commas.

      Download gradebook (There should be no errors)

      1. Go to a course with some activities that have been graded.
      2. Go to [Administration ► Grade administration ► Export ► Plain text file] and export the gradebook.

      Important

      • This needs to be tested on all databases.
      Show
      Create some custom profile fields Go to [Administration ► Site administration ► Users ► Accounts ► User profile fields] . Create one or two user profile fields making note of the short name of each field (to be used later). Enable profile fields in grade settings Go to [Administration ► Site administration ► Grades ► General settings] . in 'grade_export_customprofilefields' put in the short names of the custom fields separated by commas. Download gradebook (There should be no errors) Go to a course with some activities that have been graded. Go to [Administration ► Grade administration ► Export ► Plain text file] and export the gradebook. Important This needs to be tested on all databases.
    • Affected Branches:
      MOODLE_24_STABLE, MOODLE_25_STABLE
    • Fixed Branches:
      MOODLE_24_STABLE, MOODLE_25_STABLE
    • Pull from Repository:
    • Pull Master Branch:
      wip-MDL-41967-master

      Description

      When custom profile fields have been created and then enabled in the gradebook general settings, the download of the gradebook fails with the following problem:

      Debug info: ERROR: syntax error at or near "'customfield_firstdate'"
      LINE 1: SELECT u.*, cf0.data AS 'customfield_firstdate' , u.lastname...
      ^
      SELECT u.*, cf0.data AS 'customfield_firstdate' , u.lastname AS usrt1, u.firstname AS usrt2, u.id AS usrt
      FROM mdl_user u
      JOIN (SELECT DISTINCT eu1_u.id
      FROM mdl_user eu1_u
      JOIN mdl_user_enrolments eu1_ue ON eu1_ue.userid = eu1_u.id
      JOIN mdl_enrol eu1_e ON (eu1_e.id = eu1_ue.enrolid AND eu1_e.courseid = $1)
      WHERE eu1_u.deleted = 0 AND eu1_u.id <> $2 AND eu1_ue.status = $3 AND eu1_e.status = $4 AND eu1_ue.timestart < $5 AND (eu1_ue.timeend = 0 OR eu1_ue.timeend > $6)) je ON je.id = u.id
       
      LEFT JOIN (SELECT * FROM mdl_user_info_data
      WHERE fieldid = $7) cf0
      ON u.id = cf0.userid
      JOIN (
      SELECT DISTINCT ra.userid
      FROM mdl_role_assignments ra
      WHERE ra.roleid = $8
      AND ra.contextid IN ($9,$10,$11)
      ) rainner ON rainner.userid = u.id
      WHERE u.deleted = 0
       
      ORDER BY usrt1 ASC, usrt2 ASC, usrt ASC
      [array (
      0 => '2',
      1 => '1',
      2 => 0,
      3 => 0,
      4 => 1380092900,
      5 => 1380092900,
      6 => '1',
      7 => '5',
      8 => '41',
      9 => '3',
      10 => '1',
      )]
      Error code: dmlreadexception
      Stack trace:
       
          line 436 of /lib/dml/moodle_database.php: dml_read_exception thrown
          line 239 of /lib/dml/pgsql_native_moodle_database.php: call to moodle_database->query_end()
          line 702 of /lib/dml/pgsql_native_moodle_database.php: call to pgsql_native_moodle_database->query_end()
          line 214 of /grade/lib.php: call to pgsql_native_moodle_database->get_recordset_sql()
          line 244 of /grade/export/lib.php: call to graded_users_iterator->init()
          line 62 of /grade/export/txt/index.php: call to grade_export->display_preview()
      

      This isn't a problem when using mysql, but is present in postgres

        Gliffy Diagrams

          Attachments

            Issue Links

              Activity

                People

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

                  Dates

                  • Created:
                    Updated:
                    Resolved:
                    Fix Release Date:
                    11/Nov/13