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

Error reading from database when viewing question bank

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Duplicate
    • Affects Version/s: 2.2.2
    • Fix Version/s: None
    • Component/s: Quiz
    • Labels:
    • Affected Branches:
      MOODLE_22_STABLE

      Description

      When you click the "Question bank" link in the course setting, you will see the "Error reading from database error message". Obviously, I see two "q.id" within the SELECT clause.

      Default exception handler: Error reading from database Debug: ORA-00918: column ambiguously defined\nSELECT \n FROM (SELECT q.hidden, q.category, q.id, q.qtype, q.name, q.id, q.createdby, uc.firstname AS creatorfirstname, uc.lastname AS creatorlastname, um.firstname AS modifierfirstname, um.lastname AS modifierlastname FROM m_question q LEFT JOIN m_user uc ON uc.id = q.createdby LEFT JOIN m_user um ON um.id = q.modifiedby WHERE q.parent = 0 AND q.hidden = 0 AND q.category = :o_cat21 ORDER BY q.qtype ASC, q.name ASC)\n WHERE rownum <= :o_oracle_num_rows\n[array (\n 'o_cat21' => '8799',\n 'o_oracle_num_rows' => 20,\n)]\n line 394 of /lib/dml/moodle_database.php: dml_read_exception thrown\n* line 268 of /lib/dml/oci_native_moodle_database.php: call to moodle_database->query_end()\n* line 1062 of /lib/dml/oci_native_moodle_database.php: call to oci_native_moodle_database->query_end()\n* line 1141 of /question/editlib.php: call to oci_native_moodle_database->get_recordset_sql()\n* line 1336 of /question/editlib.php: call to question_bank_view->load_page_questions()\n* line 1204 of /question/editlib.php: call to question_bank_view->display_question_list()\n* line 70 of /question/edit.php: call to question_bank_view->display()\n, referer: https://*.*.*.edu/course/view.php?id=2623

      When I use "print_object($fields)", I got the following:
      Array
      (
      [0] => q.hidden
      [1] => q.category
      [2] => q.id
      [3] => q.qtype
      [5] => q.name
      [6] => q.id, q.createdby
      [11] => uc.firstname AS creatorfirstname
      [12] => uc.lastname AS creatorlastname
      [13] => um.firstname AS modifierfirstname
      [14] => um.lastname AS modifierlastname
      )
      So, fields[6] is "q.id, q.createdby", which is the reason why "array_unique($fields)" doesn't work here. There is a very temporary solution, I just put
      unset($fields[2]); after the array_unique, but a permanent solution is required.

      We are using Oracle, Moodle 2.2.2+

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                timhunt Tim Hunt
                Reporter:
                longfeiyu Longfei Yu
                Participants:
                Component watchers:
                Tim Hunt, Andrew Nicols, Mathew May, Michael Hawkins, Shamim Rezaie, Simey Lameze
              • Votes:
                0 Vote for this issue
                Watchers:
                0 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: