FMCorz/moodle-block_xp

Rules page not working when plugin set for the whole site

Closed this issue · 4 comments

Hi, I tried to setup the plugin on the course level and the rules work fine, but when I set it for the whole site it gives a blank page with the following error:
Fatal error: Call to undefined function course_get_format() in [MYMOODLEPATH]\blocks\xp\classes\rule_cm.php on line 89
I tried uninstalling and installing to remove all db entries on course-relevant rules but the issue still remains.

Using the latest version of the plugin and Moodle 3.2.2

Whoops. Well spotted!

I'm guessing a good workaround was to:

  • Revert to "One per course"
  • Remove the rules attached to specific activities
  • Change to "For the whole site" again

The problem is that the plugin is trying to get the course format of the front page, which does not exist. At least that's what I'm thinking.

As you've removed everything from the block_xp tables, I suggest you simply purge your caches, that should then go just fine.

Thanks for your report!

Canx commented

I'm ignorant so I'll ask: why would you want to have a site "level up" block? In which context would be interesting check progress outside courses?

That request came from other people who do not "track progress", it's more rewarding for what you're doing. So, rather than the teacher using the block, you can see that as the platform offering some sort of XP level, just like some other MOOCs.

My analysis was incorrect. The file containing course_get_format is not loaded when debugging is turned off, and the course does not have sections, and maybe other edge cases. I'm not sure how many are affected by this, whether it's new or not, but the patch should fix it.