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

sql error in survey_print_recent_activity

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Duplicate
    • Affects Version/s: 1.9
    • Fix Version/s: 1.9.1
    • Component/s: Survey
    • Labels:
      None
    • Database:
      Microsoft SQL
    • Affected Branches:
      MOODLE_19_STABLE
    • Fixed Branches:
      MOODLE_19_STABLE

      Description

      == Problem ==

      The SQL query in line line 162 of mod/survey/lib.php is incorrect. Here is the error message that the database gives along with a traceback:

      Column 'mdl_survey_answers.time' is invalid in the select list because it is not contained in either an aggregate function or the GROUP BY clause.

      SELECT sa.userid, sa.survey, sa.time, u.firstname, u.lastname, u.email, u.picture FROM mdl_survey_answers sa JOIN mdl_user u ON u.id = sa.userid WHERE sa.survey IN (14,15,16) AND sa.time > 1209578400 GROUP BY sa.userid, sa.survey ORDER BY sa.id ASC

      • line 686 of lib/dmllib.php: call to debugging()
      • line 162 of mod/survey/lib.php: call to get_recordset_sql()
      • line 942 of course/lib.php: call to survey_print_recent_activity()
      • line 27 of blocks/recent_activity/block_recent_activity.php: call to print_recent_activity()
      • line 317 of blocks/moodleblock.class.php: call to block_recent_activity->get_content()
      • line 341 of blocks/moodleblock.class.php: call to block_base->is_empty()
      • line 338 of lib/blocklib.php: call to block_base->_print_block()
      • line 369 of course/format/twu/format.php: call to blocks_print_group()
      • line 226 of course/view.php: call to require()

      == Solution ==

      Adding the extra columns to the GROUP BY clause will remove the error message (although I'm not certain that the code is doing what it was meant to do).

      To do this, change line 161 to:

      "GROUP BY sa.userid, sa.survey, sa.time, u.firstname, u.lastname, u.email, u.picture, sa.id"

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                stronk7 Eloy Lafuente (stronk7)
                Reporter:
                trick Alan Trick
                Participants:
                Component watchers:
                Amaia Anabitarte, Bas Brands, Carlos Escobedo, Sara Arjona (@sarjona), Víctor Déniz Falcón
              • Votes:
                0 Vote for this issue
                Watchers:
                1 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Fix Release Date:
                  15/May/08