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

Questionnaire: add screen displays duplicate records found warning

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 2.3.1
    • Fix Version/s: 2.3.2
    • Component/s: Module: Questionnaire
    • Labels:
      None
    • Affected Branches:
      MOODLE_23_STABLE
    • Fixed Branches:
      MOODLE_23_STABLE

      Description

      Did you remember to make the first column something unique in your call to get_records? Duplicate value '7' found in column 'id'.

      line 746 of /lib/dml/pgsql_native_moodle_database.php: call to debugging()
      line 730 of /mod/questionnaire/lib.php: call to pgsql_native_moodle_database->get_records_sql()
      line 749 of /mod/questionnaire/lib.php: call to questionnaire_get_survey_list()
      line 113 of /mod/questionnaire/mod_form.php: call to questionnaire_get_survey_select()
      line 173 of /lib/formslib.php: call to mod_questionnaire_mod_form->definition()
      line 71 of /course/moodleform_mod.php: call to moodleform->moodleform()
      line 266 of /course/modedit.php: call to moodleform_mod->moodleform_mod()

      In order to reproduce this you'll need quite a few questionnaire instances set up across multiple courses, where some are public and some are template surveys. I think the deciding factor in triggering this warning is the re-use of a public survey in a second course.

      The offending code is in questionnaire_get_survey_list() creating the list of template & public questionnaires for you to choose from on the "add questionnaire" screen - which I think works fine despite this error, but I'm not sure.

      The SQL generated is

      SELECT s.id,s.name,s.owner,s.realm,s.status,q.id as qid
      FROM

      {questionnaire}

      q
      INNER JOIN

      {questionnaire_survey}

      s ON s.id = q.sid
      WHERE status != ? AND owner = ?
      ORDER BY realm,name

      and because the same public survey is used in two different questionnaires, the survey table row is returned twice.

        Attachments

          Activity

            People

            Assignee:
            jenny-gray Jenny Gray
            Reporter:
            jenny-gray Jenny Gray
            Participants:
            Component watchers:
            Mike Churchward
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:
              Fix Release Date:
              10/Sep/12