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

test_restore_course_with_same_stamp_questions fails for questions storing answers in a custom table instead of question_answers

    • MOODLE_405_STABLE, MOODLE_500_STABLE
    • MDL-85350_405
    • MDL-85350_500
    • MDL-85350_main
    • Hide

      Test 1: Pre-patch on clean Moodle

      1. Set up a Moodle instance with no 3rd party question plugins.
      2. Run ./vendor/bin/phpunit mod/quiz/tests/backup/repeated_restore_test.php --filter 'test_restore_course_with_same_stamp_questions'
      3. Verify that all tests pass with 7 (on Moodle 4.5) or 8 (on Moodle 5.0+) skipped tests.

      Test 2: Pre-patch on Moodle with 3rd party plugins

      1. Unzip the attached qbehaviour_adaptivemultipart.zip into question/behaviour/adaptivemultipart and qtype_formulas.zip into question/type/formulas and re-initialise phpunit.
      2. Run ./vendor/bin/phpunit mod/quiz/tests/backup/repeated_restore_test.php --filter 'test_restore_course_with_same_stamp_questions'
      3. Verify that the test fails for the Formulas question type.

      Test 3: Post-patch on Moodle with 3rd party plugins

      1. Run ./vendor/bin/phpunit mod/quiz/tests/backup/repeated_restore_test.php --filter 'test_restore_course_with_same_stamp_questions'
      2. Verify that all tests do either pass or are skipped. The number of skipped tests must be 1 more than in the first test, i. e. 8 on Moodle 4.5 and 9 on Moodle 5.0 and newer.
      Show
      Test 1: Pre-patch on clean Moodle Set up a Moodle instance with no 3rd party question plugins. Run ./vendor/bin/phpunit mod/quiz/tests/backup/repeated_restore_test.php --filter 'test_restore_course_with_same_stamp_questions' Verify that all tests pass with 7 (on Moodle 4.5) or 8 (on Moodle 5.0+) skipped tests. Test 2: Pre-patch on Moodle with 3rd party plugins Unzip the attached qbehaviour_adaptivemultipart.zip into question/behaviour/adaptivemultipart and qtype_formulas.zip into question/type/formulas and re-initialise phpunit. Run ./vendor/bin/phpunit mod/quiz/tests/backup/repeated_restore_test.php --filter 'test_restore_course_with_same_stamp_questions' Verify that the test fails for the Formulas question type. Test 3: Post-patch on Moodle with 3rd party plugins Run ./vendor/bin/phpunit mod/quiz/tests/backup/repeated_restore_test.php --filter 'test_restore_course_with_same_stamp_questions' Verify that all tests do either pass or are skipped. The number of skipped tests must be 1 more than in the first test, i. e. 8 on Moodle 4.5 and 9 on Moodle 5.0 and newer.
    • Hide

      Code verified against automated checks.

      Checked MDL-85350 using repository: https://github.com/PhilippImhof/moodle.git

      More information about this report

      Built on: Fri Jun 6 14:18:36 UTC 2025

      Show
      Code verified against automated checks. Checked MDL-85350 using repository: https://github.com/PhilippImhof/moodle.git MOODLE_405_STABLE (0 errors / 0 warnings) [branch: MDL-85350_405 | CI Job ] MOODLE_500_STABLE (0 errors / 0 warnings) [branch: MDL-85350_500 | CI Job ] main (0 errors / 0 warnings) [branch: MDL-85350_main | CI Job ] More information about this report Built on: Fri Jun 6 14:18:36 UTC 2025

      The unit test test_restore_course_with_same_stamp_questions was introduced with MDL-83541. It tests all available question types that support automatic testing and checks whether the question has $questiondata->options->answers set. If this is the case, it assumes that the question will automatically have its answer data in the question_answers table, as that is what all classic question types included in core and many third party qtype plugins do.

      However, some question types have custom tables, e. g. qtype_formulas_answers for the Formulas question type. It is, of course, debatable whether that was a good choice. But the consequence is that the test will fail for third party questions of that kind.

      I suggest doing an additional check in the unit test in order to skip testing question types that mimic core question behaviour but use custom tables.

            philippimhof Philipp Imhof
            philippimhof Philipp Imhof
            Votes:
            0 Vote for this issue
            Watchers:
            7 Start watching this issue

              Created:
              Updated:

                Error rendering 'clockify-timesheets-time-tracking-reports:timer-sidebar'. Please contact your Jira administrators.