Moodle
  1. Moodle
  2. MDL-41967

grade book download shows error when using custom profile fields.

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Minor 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 2.4 Branch:
      wip-MDL-41967-24
    • Pull 2.5 Branch:
      wip-MDL-41967-25
    • Pull Master Branch:
      wip-MDL-41967-master
    • Rank:
      53150

      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

        Issue Links

          Activity

          Hide
          Ankit Agarwal added a comment -

          Looks good Adrian.
          Thanks

          Show
          Ankit Agarwal added a comment - Looks good Adrian. Thanks
          Hide
          Dan Poltawski added a comment -

          The main moodle.git repository has just been updated with latest weekly modifications. You may wish to rebase your PULL branches to simplify history and avoid any possible merge conflicts. This would also make integrator's life easier next week.

          TIA and ciao

          Show
          Dan Poltawski added a comment - The main moodle.git repository has just been updated with latest weekly modifications. You may wish to rebase your PULL branches to simplify history and avoid any possible merge conflicts. This would also make integrator's life easier next week. TIA and ciao
          Hide
          Damyon Wiese added a comment -

          Had a play and it seems a PIA to add unit tests for the exporters because they dont use normal echo or the call exit directly after exporting the report.

          Show
          Damyon Wiese added a comment - Had a play and it seems a PIA to add unit tests for the exporters because they dont use normal echo or the call exit directly after exporting the report.
          Hide
          Damyon Wiese added a comment -

          Thanks Adrian,

          This has been integrated to 24, 25 and master.

          It would be really nice to have some unit tests for the exporters (hint hint) even if it's just on master.

          Show
          Damyon Wiese added a comment - Thanks Adrian, This has been integrated to 24, 25 and master. It would be really nice to have some unit tests for the exporters (hint hint) even if it's just on master.
          Hide
          Jason Fowler added a comment -

          Passes on MySQL and PostgreSQL will see if someone can help me with Oracle and MSSQL

          Show
          Jason Fowler added a comment - Passes on MySQL and PostgreSQL will see if someone can help me with Oracle and MSSQL
          Hide
          Damyon Wiese added a comment -

          Passed on oracle.

          Show
          Damyon Wiese added a comment - Passed on oracle.
          Hide
          Dan Poltawski added a comment -

          looking at mssql.

          Show
          Dan Poltawski added a comment - looking at mssql.
          Hide
          Dan Poltawski added a comment -

          Seems like there could be some better error validation..
          ( ! ) Notice: Undefined property: stdClass::$customfield_Checkbox1 in /Users/danp/git/integration/grade/lib.php on line 2728
          Call Stack

          1. Time Memory Function Location
            1 0.0004 280392 {main}

            ( ) ../index.php:0
            2 0.8718 13783080 grade_export->display_preview( ) ../index.php:61
            3 0.9448 14062456 grade_helper::get_user_field_value( ) ../lib.php:282

          Show
          Dan Poltawski added a comment - Seems like there could be some better error validation.. ( ! ) Notice: Undefined property: stdClass::$customfield_Checkbox1 in /Users/danp/git/integration/grade/lib.php on line 2728 Call Stack Time Memory Function Location 1 0.0004 280392 {main} ( ) ../index.php:0 2 0.8718 13783080 grade_export->display_preview( ) ../index.php:61 3 0.9448 14062456 grade_helper::get_user_field_value( ) ../lib.php:282
          Hide
          Dan Poltawski added a comment -

          Created MDL-42291 for the capitalisation issue I discovered causing that warning.

          Show
          Dan Poltawski added a comment - Created MDL-42291 for the capitalisation issue I discovered causing that warning.
          Hide
          Damyon Wiese added a comment -

          - my fields were just "one" and "two" so I didn't notice that one.

          Show
          Damyon Wiese added a comment - - my fields were just "one" and "two" so I didn't notice that one.
          Hide
          Dan Poltawski added a comment -

          All good on mssql

          Show
          Dan Poltawski added a comment - All good on mssql
          Hide
          Jason Fowler added a comment -

          Thanks Dan, thanks Damyon.

          Show
          Jason Fowler added a comment - Thanks Dan, thanks Damyon.
          Hide
          Eloy Lafuente (stronk7) added a comment -

          Yes, it's happening (somewhere in the French Polynesia, right now). And you did it, raising Moodle to new excellency levels.

          Or, if you prefer, yes, you fixed that boring issue.

          Thanks anyway! Ciao

          Show
          Eloy Lafuente (stronk7) added a comment - Yes, it's happening (somewhere in the French Polynesia, right now). And you did it, raising Moodle to new excellency levels. Or, if you prefer, yes, you fixed that boring issue. Thanks anyway! Ciao

            People

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

              Dates

              • Created:
                Updated:
                Resolved: