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

Error when upgrading from 1.9.15 to 2.2 with mssql_n or sqlsrv db connection

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 2.1.3, 2.2, 2.3
    • Fix Version/s: 2.1.4, 2.2.1
    • Component/s: Questions
    • Labels:
    • Environment:
      IIS 7.0, PHP 5.3.8 using fastcgi on WIndows server 2008 R2, Microsoft SQL server 2008
    • Database:
      Microsoft SQL
    • Testing Instructions:
      Hide

      We need to do this in all supported databases:

      1) In a Moodle 1.9 or 2.0 site, create a course with a quiz and four questions in its question bank.

      • question a) A numerical question with no units.
      • question b) A numerical question with some units.
      • question c) A calculated question with no units.
      • question d) A calculated question with some units.

      2) Upgrade the site to Moodle 2.1 or 2.2. Make sure the upgrade completes with no errors.

      3) Verify that:

      • question a) is set to Unit handling: "Units are not used at all. Only the numerical value is graded."
      • question b) is set to Unit handling: "Units are optional. If a unit is entered, it is used to convert the reponse to Unit 1 before grading."
      • similarly for c) and d)
      Show
      We need to do this in all supported databases: 1) In a Moodle 1.9 or 2.0 site, create a course with a quiz and four questions in its question bank. question a) A numerical question with no units. question b) A numerical question with some units. question c) A calculated question with no units. question d) A calculated question with some units. 2) Upgrade the site to Moodle 2.1 or 2.2. Make sure the upgrade completes with no errors. 3) Verify that: question a) is set to Unit handling: "Units are not used at all. Only the numerical value is graded." question b) is set to Unit handling: "Units are optional. If a unit is entered, it is used to convert the reponse to Unit 1 before grading." similarly for c) and d)
    • Workaround:
      Hide

      This patch fixes it

      --- question/type/numerical/db/upgrade.php      2011-12-14 09:06:41.661913300 -0600
      +++ question/type/numerical/db/upgrade-patched.php      2011-12-14 09:10:27.543499200 -0600
      @@ -70,8 +70,9 @@
       
               // Set a better default for questions without units.
               $DB->execute('
      -                UPDATE {question_numerical_options} qno
      -                   SET showunits = 3
      +                UPDATE qno
      +                   SET qno.showunits = 3
      +                   FROM {question_numerical_options} qno
                        WHERE NOT EXISTS (
                                SELECT 1
                                  FROM {question_numerical_units} qnu
      
      Show
      This patch fixes it --- question/type/numerical/db/upgrade.php 2011-12-14 09:06:41.661913300 -0600 +++ question/type/numerical/db/upgrade-patched.php 2011-12-14 09:10:27.543499200 -0600 @@ -70,8 +70,9 @@ // Set a better default for questions without units. $DB->execute(' - UPDATE {question_numerical_options} qno - SET showunits = 3 + UPDATE qno + SET qno.showunits = 3 + FROM {question_numerical_options} qno WHERE NOT EXISTS ( SELECT 1 FROM {question_numerical_units} qnu
    • Affected Branches:
      MOODLE_21_STABLE, MOODLE_22_STABLE, MOODLE_23_STABLE
    • Fixed Branches:
      MOODLE_21_STABLE, MOODLE_22_STABLE
    • Pull from Repository:
    • Pull Master Branch:

      Description

      received the following error
      /admin/index.php?confirmupgrade=1&confirmrelease=1&confirmplugincheck=1

      Default exception handler: Error writing to database Debug: Incorrect syntax near 'qno'.
      
                      UPDATE mdl_question_numerical_options qno
                         SET showunits = 3
                       WHERE NOT EXISTS (
                               SELECT 1
                                 FROM mdl_question_numerical_units qnu
                                WHERE qnu.question = qno.question)
      [array (
      )]
      * line 397 of \lib\dml\moodle_database.php: dml_write_exception thrown
      * line 255 of \lib\dml\mssql_native_moodle_database.php: call to moodle_database->query_end()
      * line 668 of \lib\dml\mssql_native_moodle_database.php: call to mssql_native_moodle_database->query_end()
      * line 78 of \question\type\numerical\db\upgrade.php: call to mssql_native_moodle_database->execute()
      * line 385 of \lib\upgradelib.php: call to xmldb_qtype_numerical_upgrade()
      * line 1466 of \lib\upgradelib.php: call to upgrade_plugins()
      * line 317 of \admin\index.php: call to upgrade_noncore()
      

        Gliffy Diagrams

          Attachments

            Issue Links

              Activity

                People

                • Votes:
                  0 Vote for this issue
                  Watchers:
                  1 Start watching this issue

                  Dates

                  • Created:
                    Updated:
                    Resolved:
                    Fix Release Date:
                    9/Jan/12