FMCorz / moodle-block_xp

A gamification plugin for Moodle allowing students to gain experience points and level up.
https://levelup.plus/?ref=github
150 stars 41 forks source link

Anonymous leaderboard cannot be displayed when guest user is not found #94

Closed gushagelberg2 closed 5 years ago

gushagelberg2 commented 5 years ago

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

FMCorz commented 5 years ago

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.

gushagelberg2 commented 5 years ago

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?

FMCorz commented 5 years ago

@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

gushagelberg2 commented 5 years ago

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

FMCorz commented 5 years ago

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.

FMCorz commented 2 years ago

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

Upgrading to Moodle 3.9 should fix the issue.