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

qtype_multichoice 'suppresschoicefeedback' hack/hook is not compatible with PHP 8.2

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Minor Minor
    • 4.2.7, 4.3.4
    • 4.2.7, 4.3.4
    • Questions
    • MOODLE_402_STABLE, MOODLE_403_STABLE
    • MOODLE_402_STABLE, MOODLE_403_STABLE
    • Hide

      To test this you need to be able to install plugins from github and you should run PHP 8.2.

      0. CI will run the qtype_multichoice unit tests, which will verify no regressions in core.

      1. Now install commit 8e98d813344d5763aabca79758ce889b2c31a039 of https://github.com/moodleou/moodle-qtype_oumultiresponse/ into your Moodle:

        git clone https://github.com/moodleou/moodle-qtype_oumultiresponse/ question/type/oumultiresponse
        cd question/type/oumultiresponse
        git checkout 8e98d813344d5763aabca79758ce889b2c31a039
        cd ../../../
        

      2. Run the automated PHPUnit tests (or otherwise test the plugin), specifically question/type/oumultiresponse/tests/walkthrough_test.php:

        ./vendor/bin/phpunit question/type/oumultiresponse/tests/walkthrough_test.php
        

        1. Verify that the only problems reported are the debugging message starting "$options->suppresschoicefeedback should no longer be used. ..." or "Deprecated: Creation of dynamic property question_display_options::$suppresschoicefeedback is deprecated in …/question/type/oumultiresponse/questiontype.php on line 408" if run in PHPUnit command line interface.
      3. Now check out the latest main branch of qtype_oumultiresponse:

        cd question/type/oumultiresponse
        git fetch origin
        git checkout main
        

      4. Run the automated PHPUnit tests (or otherwise test the plugin), specifically question/type/oumultiresponse/tests/walkthrough_test.php:

        ./vendor/bin/phpunit question/type/oumultiresponse/tests/walkthrough_test.php
        

        1. Verify that all the automated tests pass cleanly
      Show
      To test this you need to be able to install plugins from github and you should run PHP 8.2. 0. CI will run the qtype_multichoice unit tests, which will verify no regressions in core. Now install commit 8e98d813344d5763aabca79758ce889b2c31a039 of https://github.com/moodleou/moodle-qtype_oumultiresponse/ into your Moodle: git clone https://github.com/moodleou/moodle-qtype_oumultiresponse/ question/type/oumultiresponse cd question/type/oumultiresponse git checkout 8e98d813344d5763aabca79758ce889b2c31a039 cd ../../../ Run the automated PHPUnit tests (or otherwise test the plugin), specifically question/type/oumultiresponse/tests/walkthrough_test.php: ./vendor/bin/phpunit question/type/oumultiresponse/tests/walkthrough_test.php Verify that the only problems reported are the debugging message starting "$options->suppresschoicefeedback should no longer be used. ..." or "Deprecated: Creation of dynamic property question_display_options::$suppresschoicefeedback is deprecated in …/question/type/oumultiresponse/questiontype.php on line 408" if run in PHPUnit command line interface. Now check out the latest main branch of qtype_oumultiresponse: cd question/type/oumultiresponse git fetch origin git checkout main Run the automated PHPUnit tests (or otherwise test the plugin), specifically question/type/oumultiresponse/tests/walkthrough_test.php: ./vendor/bin/phpunit question/type/oumultiresponse/tests/walkthrough_test.php Verify that all the automated tests pass cleanly

      This is not something that is used by core qtype_multichoice itself, but it was a hook that was added to enable derivative question types (initially qtype_oumultiresponse, but more recently qtype_answersselect) more nuanced control of what feedback is visible.

      The general way this sort of thing is controlled in the question system is through a class called question_display_options (which is often stored in a variable called $options is related code), which helps glue the various parts of the system (quiz or whatever, core_question, qbehaviour_, qtype_) together.

      The specific problem we have here is that $options->feedback is not fine-grained enough on its own. ->feedback in general controlls "Specific feedback - that is feedback that depends on the particular answer the student gave." The problem is that qtype_multichoice has two sorts of feedback that fits in this category, and some derived qtypes want to control them independently (for good educational reasons).

      For over 10 years this has worked by setting an un-declared property ->suppresschoicefeedback - but in PHP 8.2 that causes "Deprecated: Creation of dynamic property question_display_options::$suppresschoicefeedback is deprecated in ...".

      I now realise that a better variant of this hack is to instead have a special value of $options->feedback that is neither question_display_options::HIDDEN nor question_display_options::VISIBLE (1). qtype_multichoice can have qtype_multichoice::COMBINED_BUT_NOT_CHOICE_FEEDBACK. (And, this hack would then be similar to the special values like qbehaviour_interactive::TRY_AGAIN_VISIBLE which that question behaviour users to do subtle things.

      Can this be implemented in a backards-compatible way? I will find out..

            timhunt Tim Hunt
            timhunt Tim Hunt
            Luca Bösch Luca Bösch
            Andrew Lyons Andrew Lyons
            Kim Jared Lucas Kim Jared Lucas
            Votes:
            1 Vote for this issue
            Watchers:
            8 Start watching this issue

              Created:
              Updated:
              Resolved:

                Estimated:
                Original Estimate - Not Specified
                Not Specified
                Remaining:
                Remaining Estimate - 0 minutes
                0m
                Logged:
                Time Spent - 4 hours, 7 minutes
                4h 7m

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