Moodle
  1. Moodle
  2. MDL-26338

Quiz report - ORA-00932: inconsistent datatypes: expected NUMBER got CHAR

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Critical Critical
    • Resolution: Fixed
    • Affects Version/s: 2.0.1
    • Fix Version/s: 2.0.2
    • Component/s: Quiz
    • Labels:
    • Environment:
    • Rank:
      16457

      Description

      The quiz review (and reports) are returning the following error (moodle in debug mode):
      Error reading from database

      More information about this error

      Debug info: ORA-00932: inconsistent datatypes: expected NUMBER got CHAR
      SELECT u.id || '#' || COALESCE(qa.attempt, '0') AS uniqueid, qa.uniqueid AS attemptuniqueid, qa.id AS attempt, u.id AS userid, u.idnumber, u.firstname, u.lastname, u.picture, u.imagealt, u.email, qa.sumgrades, qa.timefinish, qa.timestart, qa.timefinish - qa.timestart AS duration , COALESCE((SELECT MAX(qqr.regraded) FROM m_quiz_question_regrade qqr WHERE qqr.attemptid = qa.uniqueid),-1) AS regraded FROM m_user u LEFT JOIN m_quiz_attempts qa ON qa.userid = u.id AND qa.quiz = :quizid WHERE qa.id IS NOT NULL AND qa.preview = 0 ORDER BY uniqueid ASC
      [array (
      'quizid' => '155',
      'oracle_num_rows' => 100,
      )]
      Stack trace:
      line 391 of /lib/dml/moodle_database.php: dml_read_exception thrown
      line 268 of /lib/dml/oci_native_moodle_database.php: call to moodle_database->query_end()
      line 1042 of /lib/dml/oci_native_moodle_database.php: call to oci_native_moodle_database->query_end()
      line 1354 of /lib/tablelib.php: call to oci_native_moodle_database->get_records_sql()
      line 321 of /mod/quiz/report/overview/overview_table.php: call to table_sql->query_db()
      line 1375 of /lib/tablelib.php: call to quiz_report_overview_table->query_db()
      line 391 of /mod/quiz/report/overview/report.php: call to table_sql->out()
      line 90 of /mod/quiz/report.php: call to quiz_overview_report->display()

      I have fixed the error (for Oracle is OK, but it should be tested for the other databases too) updating the following files:

      /var/www/moodle20/mod/quiz/report/responses/report.php

      188c188
      < $fields = $DB->sql_concat('u.id', '\'#\'', 'COALESCE(qa.attempt, \'0\')').' AS concattedid, ';

      > $fields = $DB->sql_concat('u.id', '\'#\'', 'COALESCE(qa.attempt, 0)').' AS concattedid, ';

      /var/www/moodle20/mod/quiz/report/overview/report.php

      < $fields = $DB->sql_concat('u.id', '\'#\'', 'COALESCE(qa.attempt, \'0\')').' AS uniqueid, ';

      > $fields = $DB->sql_concat('u.id', '\'#\'', 'COALESCE(qa.attempt, 0)').' AS uniqueid, ';

        Activity

        Hide
        Tim Hunt added a comment -

        This looks like a correct fix to me.

        Just a small comment, I would rather read unified diffs. That is, created with diff -u.

        Show
        Tim Hunt added a comment - This looks like a correct fix to me. Just a small comment, I would rather read unified diffs. That is, created with diff -u.
        Hide
        Tim Hunt added a comment -

        Pull request issued, so this should be in next week's weekly build. Thanks for finding and fixing this.

        Show
        Tim Hunt added a comment - Pull request issued, so this should be in next week's weekly build. Thanks for finding and fixing this.

          People

          • Assignee:
            Tim Hunt
            Reporter:
            Radu Florescu
            Tester:
            Eloy Lafuente (stronk7)
            Participants:
          • Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: