Details

1. Add a non-editing teacher to the course (this role can award and view recipients by default).
2. Login as this non-editing teacher.
3. Go to the course.
4. Badges navigation should appear under course administration.
5. If there are any badges, only one action should be available in manage badge table - award a badge.
5a. If there are no badges, add new badge button should not appear. User should see just a message that there are no badges.
6. Try to award a badge.
7a. If the role is not among criteria, you should get a message that it is not possible.
7b. If the role among criteria, you should be able to award badge.

1. Add a non-editing teacher to the course (this role can award and view recipients by default).
2. Login as this non-editing teacher.
3. Go to the course.
4. Badges navigation should appear under course administration.
5. If there are any badges, only one action should be available in manage badge table - award a badge.
5a. If there are no badges, add new badge button should not appear. User should see just a message that there are no badges.
6. Try to award a badge.
7a. If the role is not among criteria, you should get a message that it is not possible.
7b. If the role among criteria, you should be able to award badge.

Hi Nneko,
I'm not a programmer, so am just checking my understanding here. This change seems to check if the permission "award badge" is set to "allow", and if so, display the Badges node in the Administration menu, and if not, don't. If this is correct, then it has my +! for integration as soon as possible!

Lindy Klein
added a comment - 02/Jun/13 9:33 PM Hi Nneko,
I'm not a programmer, so am just checking my understanding here. This change seems to check if the permission "award badge" is set to "allow", and if so, display the Badges node in the Administration menu, and if not, don't. If this is correct, then it has my +! for integration as soon as possible!
Thanks for the speedy response!
Lindy

Yes, Lindy your interpretation is correct. The original badgeslib only added the managebadges link if the user had configure badges privilege which meant a user would have to be able to add,create, and edit badges to view the badges/index.php page.

Given, that this was the only place that presented the award badges button it meant that regular users with the award privilege but not the add, edit, delete badges privileges had no way to navigate to the award badges page and would have to enter the URL directly. This corrects that anomaly and as the badges index page verifies privileges before showing UI elements it should be safe.

However, I am not an expert on Moodle code and only recently started so there maybe more elegant or better ways to achieve this but currently the attached patch to badgeslib does solve the problem.

Nneko Branche
added a comment - 02/Jun/13 10:45 PM - edited Yes, Lindy your interpretation is correct. The original badgeslib only added the managebadges link if the user had configure badges privilege which meant a user would have to be able to add,create, and edit badges to view the badges/index.php page.
Given, that this was the only place that presented the award badges button it meant that regular users with the award privilege but not the add, edit, delete badges privileges had no way to navigate to the award badges page and would have to enter the URL directly. This corrects that anomaly and as the badges index page verifies privileges before showing UI elements it should be safe.
However, I am not an expert on Moodle code and only recently started so there maybe more elegant or better ways to achieve this but currently the attached patch to badgeslib does solve the problem.
Nneko.

Dan Poltawski
added a comment - 03/Jul/13 4:34 AM Hi Yuliya,
I was going to try and get this one integrated and tested, but there seem to be a few problems, so sending it back to you:
As a user without the capability to add a new badge (actually just non-editing teacher was how I discovered it, the 'add new badge' button was displayed:
When there were no badges at all
When there was a badge that I had the permission to award
So I think there are a few places which need fixing up

Yuliya Bozhko
added a comment - 03/Jul/13 4:43 AM Good catch! Not really a bug as users without permissions can't create a badge anyway, but I agree that it would look better if we prevent people from trying
Fixed on index page and in renderer, couldn't find anywhere else where users can be adding a new badge.

Dan Poltawski
added a comment - 03/Jul/13 5:21 AM I've integrated and tested this now. Thanks Yuliya.
I think we might need to consider the navigation adding a bit more, but rather than hold up this issue, i'm adding a new issue.