Moodle
  1. Moodle
  2. MDL-30137

error/moodle/dmlreadexception when grade weight is changed

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: 2.1.2, 2.2
    • Fix Version/s: 2.1.3
    • Component/s: Quiz
    • Labels:
    • Environment:
      Microsoft Windows 2008 R2, MS SQL 2005, PHP 5.3.6, IIS 7
    • Database:
      Microsoft SQL
    • Testing Instructions:
      Hide

      1. Create a quiz one essay question.
      2. Attempt the quiz twice as a student.
      3. As teacher, grade the first attempt, but not the second attempt.
      4. Try switching the grading method from first attempt to second attempt, and back.
      5. Verify that the student's overall best grade (in the gradebook, and on the quiz view page when logged in as the student) toggles between NULL and the grade you assigned when manually grading.

      Show
      1. Create a quiz one essay question. 2. Attempt the quiz twice as a student. 3. As teacher, grade the first attempt, but not the second attempt. 4. Try switching the grading method from first attempt to second attempt, and back. 5. Verify that the student's overall best grade (in the gradebook, and on the quiz view page when logged in as the student) toggles between NULL and the grade you assigned when manually grading.
    • Affected Branches:
      MOODLE_21_STABLE, MOODLE_22_STABLE
    • Fixed Branches:
      MOODLE_21_STABLE
    • Pull from Repository:
    • Pull Master Branch:
    • Rank:
      24799

      Description

      When editing a simple quiz to change the grade weight I get the error "error/moodle/dmlreadexception" when saving. The new grade is saved.
      Debugging produces:

      Debug info: SQLState: 42000<br>
      Error Code: 102<br>
      Message: [Microsoft][SQL Server Native Client 10.0][SQL Server]Incorrect syntax near '<'.<br>

      SELECT users.userid, qg.id, qg.grade, newgrades.newgrade

      FROM (
      SELECT userid
      FROM mdl_quiz_grades qg
      WHERE quiz = '376'
      UNION
      SELECT DISTINCT userid
      FROM mdl_quiz_attempts quiza2
      WHERE
      quiza2.timefinish <> 0 AND
      quiza2.preview = 0 AND
      quiza2.quiz = '376'
      ) users

      LEFT JOIN mdl_quiz_grades qg ON qg.userid = users.userid AND qg.quiz = '376'

      LEFT JOIN (

      SELECT quiza.userid, MAX(quiza.sumgrades) * 1.1111111111111 AS newgrade
      FROM mdl_quiz_attempts quiza

      WHERE

      quiza.timefinish <> 0 AND
      quiza.preview = 0 AND
      quiza.quiz = '376'
      GROUP BY quiza.userid
      ) newgrades ON newgrades.userid = users.userid

      WHERE
      ABS(newgrades.newgrade - qg.grade) > 0.000005 OR
      (newgrades.newgrade IS NULL) <> (qg.grade IS NULL)
      [array (
      0 => '376',
      1 => '376',
      2 => '376',
      3 => '376',
      )]

      Stack trace: •line 394 of \lib\dml\moodle_database.php: dml_read_exception thrown
      •line 252 of \lib\dml\sqlsrv_native_moodle_database.php: call to moodle_database->query_end()
      •line 368 of \lib\dml\sqlsrv_native_moodle_database.php: call to sqlsrv_native_moodle_database->query_end()
      •line 773 of \lib\dml\sqlsrv_native_moodle_database.php: call to sqlsrv_native_moodle_database->do_query()
      •line 807 of \lib\dml\sqlsrv_native_moodle_database.php: call to sqlsrv_native_moodle_database->get_recordset_sql()
      •line 697 of \mod\quiz\locallib.php: call to sqlsrv_native_moodle_database->get_records_sql()
      •line 380 of \mod\quiz\edit.php: call to quiz_update_all_final_grades()

        Issue Links

          Activity

          Hide
          Tim Hunt added a comment -

          Can anyone test this proposed change on our full range of supported DBs?

          Show
          Tim Hunt added a comment - Can anyone test this proposed change on our full range of supported DBs?
          Hide
          Tim Hunt added a comment -

          Adding a possible 'anyone'.

          Show
          Tim Hunt added a comment - Adding a possible 'anyone'.
          Hide
          Eloy Lafuente (stronk7) added a comment -

          I've put the query between set_debug(true/false) and then I've tried changing the weight of 1 question under the 4 DBs (mysql, pg, mssql and oracle - not sqlsrv here but should be the same than mssql).

          I saw the query being executed in the 4 DBs without error. Ciao

          Show
          Eloy Lafuente (stronk7) added a comment - I've put the query between set_debug(true/false) and then I've tried changing the weight of 1 question under the 4 DBs (mysql, pg, mssql and oracle - not sqlsrv here but should be the same than mssql). I saw the query being executed in the 4 DBs without error. Ciao
          Hide
          Tim Hunt added a comment -

          Thanks ELoy. Submitting for integration.

          Show
          Tim Hunt added a comment - Thanks ELoy. Submitting for integration.
          Hide
          Aparup Banerjee added a comment -

          Thanks, this has been integrated, up for DB testing. (although already tested once by Eloy)

          Show
          Aparup Banerjee added a comment - Thanks, this has been integrated, up for DB testing. (although already tested once by Eloy)
          Hide
          Adrian Greeve added a comment -

          Realized that I need to test this on windows. I don't currently have that configuration.

          Show
          Adrian Greeve added a comment - Realized that I need to test this on windows. I don't currently have that configuration.
          Hide
          Jason Fowler added a comment -

          Hi Tim, This doesn't seem to work on the gradebook for me at all. I might be missing something.

          It shows the correct values on the student's review page, but for their grades page, and the admin's gradebook, it always shows the graded result, rather than null. Could this be because I gave a value of 100% for the first attempt?

          Show
          Jason Fowler added a comment - Hi Tim, This doesn't seem to work on the gradebook for me at all. I might be missing something. It shows the correct values on the student's review page, but for their grades page, and the admin's gradebook, it always shows the graded result, rather than null. Could this be because I gave a value of 100% for the first attempt?
          Hide
          Tim Hunt added a comment -

          At step 3. How did you do the manual grading? You should have been using mod/quiz/report.php?mode=grading&id=...

          Show
          Tim Hunt added a comment - At step 3. How did you do the manual grading? You should have been using mod/quiz/report.php?mode=grading&id=...
          Hide
          Jason Fowler added a comment -

          I did it that way, yes. Does that mean this patch can be bypassed if you grade a quiz a different way?

          Show
          Jason Fowler added a comment - I did it that way, yes. Does that mean this patch can be bypassed if you grade a quiz a different way?
          Hide
          Tim Hunt added a comment -

          Well, it is also possible to edit grades in the gradebook.

          This may be an issue with the gradebook (not being able to remove a grade that was previously assigned) or with how the quiz communicates wiht the gradebook (not telling it to remove the grade in this scenario).

          It is not really relevant to testing this issue. This issue was a DB error when updating the quiz_grades table from the quiz_attempts table. That now seems to work, so I think we should pass this, and file a separate bug about updating the gradebook when the student's quiz grade changes from something to null.

          Show
          Tim Hunt added a comment - Well, it is also possible to edit grades in the gradebook. This may be an issue with the gradebook (not being able to remove a grade that was previously assigned) or with how the quiz communicates wiht the gradebook (not telling it to remove the grade in this scenario). It is not really relevant to testing this issue. This issue was a DB error when updating the quiz_grades table from the quiz_attempts table. That now seems to work, so I think we should pass this, and file a separate bug about updating the gradebook when the student's quiz grade changes from something to null.
          Hide
          Jason Fowler added a comment -

          error has been handled/prevented

          Show
          Jason Fowler added a comment - error has been handled/prevented
          Hide
          Aparup Banerjee added a comment -

          \o/ , Jason please open up the follow on issue and link these up for reference.

          Show
          Aparup Banerjee added a comment - \o/ , Jason please open up the follow on issue and link these up for reference.
          Hide
          Eloy Lafuente (stronk7) added a comment -

          Yes, you got this finally upstream, just in time for Moodle 2.2beta. Congrats and thanks!

          Ciao

          Show
          Eloy Lafuente (stronk7) added a comment - Yes, you got this finally upstream, just in time for Moodle 2.2beta. Congrats and thanks! Ciao
          Hide
          Iñigo Zendegi added a comment -

          Hello,

          This bug also affects Oracle database, and the patch works fine in Oracle too.

          Regards.

          Show
          Iñigo Zendegi added a comment - Hello, This bug also affects Oracle database, and the patch works fine in Oracle too. Regards.

            People

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

              Dates

              • Created:
                Updated:
                Resolved: