Moodle
  1. Moodle
  2. MDL-26060

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

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Minor 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.

        Gliffy Diagrams

        1. MDL_feedback_date_sort.patch
          1 kB
          Adam Olley
        2. MDL-26049.patch
          0.5 kB
          Andreas Grabs

          Activity

          Hide
          Andreas Grabs added a comment -

          You can test the issue:
          create a feedback (not anonymous)
          do two or more submits with students
          go to the show entries page
          click in the table-header on "Date" to sort this table.
          Now the error is shown.
          The fix is done by a change of the table definition in show_entries.php

          Show
          Andreas Grabs added a comment - You can test the issue: create a feedback (not anonymous) do two or more submits with students go to the show entries page click in the table-header on "Date" to sort this table. Now the error is shown. The fix is done by a change of the table definition in show_entries.php
          Hide
          Eloy Lafuente (stronk7) added a comment -

          Integrated, thanks, will be tested soon (recommendation, put the testing instructions in the PULL request, it makes life easier to testers)

          Ciao

          Show
          Eloy Lafuente (stronk7) added a comment - Integrated, thanks, will be tested soon (recommendation, put the testing instructions in the PULL request, it makes life easier to testers) Ciao
          Hide
          Helen Foster added a comment -

          Adam, thanks for your report and Andreas, thanks for your fix, which is now available in the latest 2.0.2+ weekly.

          Show
          Helen Foster added a comment - Adam, thanks for your report and Andreas, thanks for your fix, which is now available in the latest 2.0.2+ weekly.

            People

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

              Dates

              • Created:
                Updated:
                Resolved: