FMCorz/moodle-block_xp

Anonymous leaderboard cannot be displayed when guest user is not found

gushagelberg2 opened this issue · 6 comments

When I click on "Ladder" in the plugin settings area, the following error appears (see attachment)
Exception - Argument 1 passed to block_xp\local\xp\user_state::__construct() must be an instance of stdClass, boolean given, called in [dirroot]/blocks/xp/classes/local/leaderboard/anonymised_leaderboard.php on line 83

screen shot 2019-03-04 at 10 50 01

Plugin Version: 2019020303
Moodle Version: Moodle 3.5.4+ (Build: 20190118)
Browser: Firefox 65.0.1

Thanks for the report @gushagelberg2. It seems that your Moodle site is in a state where the guest user does not exist. This should not happen as the guest user is created during site installation. Please double check whether you have overridden the config value $CFG->siteguest which should contain the ID of the guest user.

Hi,
I have the guest user turned off on purpose. For data security reasons. Is the error then not avoidable if I don't allow guest users?

@gushagelberg2 You don't have to allow guest users, but you must have the guest user present in the database. Note that we raised this issue with Moodle too: https://tracker.moodle.org/browse/MDL-64991

2019-03-13 11_28_27-Ladder
I added a user with the username "guest_user" but the error still appears.
Could the problem have to do with groups? I noticed in another course that the error did not appear and I can not choose a group. In the course where the error appears, the error doesn't appear if I choose another group.
2019-03-13 11_22_28-Ladder

The guest user is used when anonymising the leaderboard, so it's likely that another group's leaderboard didn't need to be anonymised. I will close this issue as it really seems to be caused by a missing guest user.

Please ask your administrator to confirm that the value of the admin config siteguest points to the right guest user. Usually the guest user is identified by ID 1, but that may change depending on the system.

This issue appears related to a GDPR bug that would have been fixed in https://tracker.moodle.org/browse/MDL-69079 (moodle/moodle@d6ec2d3).

Upgrading to Moodle 3.9 should fix the issue.