Uploaded image for project: 'Plugins'
  1. Plugins
  2. CONTRIB-2797

View all responses for questionnaire configured for visible groups causes SQL errors

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Critical Critical
    • 2.0, 2.1
    • 2.0.2
    • Module: Questionnaire
    • None
    • PostgreSQL
    • MOODLE_20_STABLE
    • MOODLE_20_STABLE, MOODLE_21_STABLE

      I set up a demo questionnaire with "visible groups", and a course that had a couple of users in different groups. Each user completed the questionnaire and then went to view the results clicking on the "all responses" link.

      Error reading from database
      More information about this error
      Debug info: ERROR: operator does not exist: character varying = bigint
      LINE 7: R.username=GM.userid
      ^
      HINT: No operator matches the given name and argument type(s). You might need to add explicit type casts.
      SELECT R.id, R.survey_id, R.submitted, R.username
      FROM mdl_questionnaire_response R,
      mdl_groups_members GM
      WHERE R.survey_id=2 AND
      R.complete='y' AND
      GM.groupid>0 AND
      R.username=GM.userid
      ORDER BY R.id
      [array (
      )]
      Stack trace:
      • line 391 of /lib/dml/moodle_database.php: dml_read_exception thrown
      • line 232 of /lib/dml/pgsql_native_moodle_database.php: call to moodle_database->query_end()
      • line 672 of /lib/dml/pgsql_native_moodle_database.php: call to pgsql_native_moodle_database->query_end()
      • line 163 of /mod/questionnaire/report.php: call to pgsql_native_moodle_database->get_records_sql()

      This is caused because R.username is a character not integer field. The SQL needs to be (cast (R.username as int))=GM.userid.

      Once fixed at line 163,176,199 the same error is revealed at lines and in choose_group_form.php at line 61 and in locallib.php at line 2271.

      There may be other places that use a similar query which I haven't uncovered yet!

            mchurch Mike Churchward
            jenny-gray Jenny Gray (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:

                Error rendering 'clockify-timesheets-time-tracking-reports:timer-sidebar'. Please contact your Jira administrators.