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

Sorting by date on user list for responses list throws an error

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 2.0.1
    • Fix Version/s: 2.0.3
    • Component/s: Feedback
    • Labels:
    • Affected Branches:
      MOODLE_20_STABLE
    • Fixed Branches:
      MOODLE_20_STABLE

      Description

      Action:
      Viewing a list of responses in a feedback module, you click the date heading

      Expected Response:
      Page reloads with the list of responses sorted by date

      Actual Response:
      Page returns an error (when debugging is on) as follows:

      Debug info: ERROR: column reference "timemodified" is ambiguous at character 226
      SELECT DISTINCT u.id,u.picture,u.firstname,u.lastname,u.imagealt,u.email FROM mdl_user u, mdl_feedback_completed c
      WHERE anonymous_response = $1 AND u.id = c.userid AND c.feedback = $2
      ORDER BY timemodified ASC, lastname DESC LIMIT 20 OFFSET 0
      [array (
      0 => 2,
      1 => '13',
      )]
      Stack trace:
      • line 391 of /lib/dml/moodle_database.php: dml_read_exception thrown
      • line 229 of /lib/dml/pgsql_native_moodle_database.php: call to moodle_database->query_end()
      • line 669 of /lib/dml/pgsql_native_moodle_database.php: call to pgsql_native_moodle_database->query_end()
      • line 875 of /mod/feedback/lib.php: call to pgsql_native_moodle_database->get_records_sql()
      • line 167 of /mod/feedback/show_entries.php: call to feedback_get_complete_users()

      Diagnosis:
      Error is caused by timemodified being ambiguous (exists in both user and feedback_completed table), the field also needs to be in the select statement so it can be sorted on.

      Fix:
      I've attached a patch that fixes this issue. Tested successfully.

        Attachments

          Activity

            People

            Assignee:
            grabs Andreas Grabs
            Reporter:
            aolley Adam Olley
            Tester:
            Helen Foster
            Participants:
            Component watchers:
            Amaia Anabitarte, Carlos Escobedo, Ferran Recio, Sara Arjona (@sarjona)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:
              Fix Release Date:
              5/May/11