BIM2 and disable_form_change_checker

As a developer, you have to love it when someone using your code diagnoses and identifies their own problem with your code. Especially if they give you a clear and concise explanation you can use. That’s what happened with the BIM2 problem I blogged about recently. It appears I was using Moodle 2.3.4 the problem was found on Moodle 2.3.2+ and there was a change in the Moodle code in-between. The following describes the bug and hopefully the fix/change I’ve made to the BIM code.

The problem

The problem arises in bim/marker/allocation_form.php with this
[source code=”php”]
// turn off the checking

disable_form_change_checker is described here and it was added in Moodle 2.3.3.

So the question is how to handle this neatly so that BIM gracefully degrades with older versions of Moodle?

The solution?

One approach is to simply require the more recent version of Moodle, but given this is one function call in one section of the code. There has to be a more fine grain solution, doesn’t there?

Perhaps just removing the call? But I remember it getting quite annoying without it. So, for now, it stays.

Of course, method_exists. I need to code more.

[source code=”php”]
if ( method_exists( $mform, "disable_form_change_checker" ) ) {

No problem with 2.4. What about older versions?

Yes, Moodle 2.2 crashes with this problem in BIM. And method_exists fixes it. Time to commit the code and we’re done.

0 thoughts on “BIM2 and disable_form_change_checker

Leave a Reply

Your email address will not be published. Required fields are marked *