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

Grade scale test fails with Oracle




      The test introduced, with the introduction of single point grade items, in MDL-16474 fails because, when the newly created grade item is instantiated, there is an access to the database to find a pre-existing grade item with the same provided values and a fetch to fill in the values that were not provided. Although this fetch is not needed in this case, it would normally not be a problem, except that in Oracle where there are some string comparisons that take place.

      The real problem (and perhaps we should consider solving that separately) is that the grade item code blindly combines the provided values into a query, without considering the types of each value. The result is a query that compares strings to CLOBs in Oracle.

      The simple fix in this case is to avoid the fetch when the grade item is instantiated, and this can be done by adding a parameter to the instantiation call.

      lib/grade/tests/grade_scale_test.php, line 164

              $grade_item = new grade_item($grade_item, false);

      For reference, here is the unit test output that sparked this search.

      2) core_grade_scale_testcase::test_grade_scale
      dml_read_exception: Error reading from database (ORA-00932: inconsistent datatypes: expected - got CLOB
      SELECT * FROM p_grade_items WHERE  courseid = :o_param1 AND categoryid = :o_param2 AND itemname = :o_param3 AND itemtype = :o_param4 AND itemnumber = :o_param5 AND needsupdate = :o_param6 AND gradetype = :o_param7 AND scaleid = :o_param8 AND iteminfo = :o_param9 AND timecreated = :o_paran0 AND timemodified = :o_paran1 
      [array (
        'o_param1' => '459000',
        'o_param2' => 401001,
        'o_param3' => 'manual grade_item scale_1',
        'o_param4' => 'manual',
        'o_param5' => 0,
        'o_param6' => 0,
        'o_param7' => 2,
        'o_param8' => '272006',
        'o_param9' => 'Manual grade item used for unit testing',
        'o_paran0' => 1406725958,
        'o_paran1' => 1406725958,
      To re-run:
       vendor/bin/phpunit core_grade_scale_testcase lib/grade/tests/grade_scale_test.php


        Issue Links



              fred Frédéric Massart
              salvetore Michael de Raadt
              Adrian Greeve Adrian Greeve
              Dan Poltawski Dan Poltawski
              Dan Poltawski Dan Poltawski
              Adrian Greeve, Ilya Tregubov, Kevin Percy, Mathew May, Mihail Geshoski, Shamim Rezaie
              0 Vote for this issue
              2 Start watching this issue