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

Quiz can't be created on some mysql configurations

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Minor Minor
    • None
    • 1.6.1
    • Quiz
    • None
    • All
    • MySQL
    • MOODLE_16_STABLE

      I don't know if anyone else has found this (several bug tracker searches came up empty) but we've recently encountered a problem trying to create quizzes in Moodle 1.6.1 using MySQL 5.0.22 - adding a quiz fails with the error Could not add a new instance of quiz.

      The error is caused by insert_record in quiz_add_instance failing with the sql error: Field 'questions' doesn't have a default value

      This error seems reasonable enough, 'questions' doesn't have a default value (and since it is a text type it can't have a default value) and there is no value supplied for the questions field in the insert query.

      A possible fix could be to use

      $quiz->questions = '';

      in quiz_add_instance?

      Interestingly it looks like the query only fails with certain settings of the sql_mode [1] server variable. On the server where the error happens sql_mode has the value

      STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION

      it's the STRICT_TRANS_TABLES setting that triggers the error. I'm guessing this is the default value (new in MySQL 5?) since it's unlikely our IT guys would've done any configuration work on MySQL beyond a simply installing it

      [1] http://dev.mysql.com/doc/refman/5.0/en/server-sql-mode.html

            timhunt Tim Hunt
            imported Imported (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.