Moodle
  1. Moodle
  2. MDL-40471

Badges 'manage' node in navigation needs to consider more capabilities

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: 2.5
    • Fix Version/s: 2.5.3
    • Component/s: Badges
    • Labels:
    • Testing Instructions:
      Hide

      You need a course and course badges enabled on web site.

      Create a user and enroll this user to the course as a student (or any other role, but easier to test with students as they have very limited capabilities).

      1. Login as a student. Go to the course. Make sure that you can't see "Badges" in course administration.

      2. As an admin allow student role to create a badge in this course (badges:createbadge). As a student, go to the course. Now, you should be able to see "Badges > Manage Badges" and "Badges > Add a new Badge" in course administration.

      3. As a student, try creating a badge. When done, you should be redirected to Badge overview page. No other tabs (except "Overview") should be shown.

      4. As an admin, now allow student role to configure criteria of badges in this course (badges:configurecriteria capability). As a student, create another badge. When done, you should be redirected to Badge criteria page. You should be able to see "Overview" and "Criteria" tabs.

      5. As an admin, remove "create badge" and "configure criteria" capabilities of a student role in this course. Students should no longer be able to perform any of the previous actions. Navigation elements should be removed (I am not quite sure if users should log out and log in for this to happen as navigation tree might be cached per user session).

      6. As an admin, enable "award badge" capability for a student role in this course. As and admin, create a course badge (or edit existing one created earlier). Add "Manual award" criteria and select "Student" among roles in criteria settings. Save criteria and enable badge. As a student, go to the manage bagdes page and try to award a badge. You should be able to award a badge to anyone in this course with capability "earn badge" (students by default), but no other actions.

      Show
      You need a course and course badges enabled on web site. Create a user and enroll this user to the course as a student (or any other role, but easier to test with students as they have very limited capabilities). 1. Login as a student. Go to the course. Make sure that you can't see "Badges" in course administration. 2. As an admin allow student role to create a badge in this course (badges:createbadge). As a student, go to the course. Now, you should be able to see "Badges > Manage Badges" and "Badges > Add a new Badge" in course administration. 3. As a student, try creating a badge. When done, you should be redirected to Badge overview page. No other tabs (except "Overview") should be shown. 4. As an admin, now allow student role to configure criteria of badges in this course (badges:configurecriteria capability). As a student, create another badge. When done, you should be redirected to Badge criteria page. You should be able to see "Overview" and "Criteria" tabs. 5. As an admin, remove "create badge" and "configure criteria" capabilities of a student role in this course. Students should no longer be able to perform any of the previous actions. Navigation elements should be removed (I am not quite sure if users should log out and log in for this to happen as navigation tree might be cached per user session). 6. As an admin, enable "award badge" capability for a student role in this course. As and admin, create a course badge (or edit existing one created earlier). Add "Manual award" criteria and select "Student" among roles in criteria settings. Save criteria and enable badge. As a student, go to the manage bagdes page and try to award a badge. You should be able to award a badge to anyone in this course with capability "earn badge" (students by default), but no other actions.
    • Affected Branches:
      MOODLE_25_STABLE
    • Fixed Branches:
      MOODLE_25_STABLE
    • Pull from Repository:
    • Pull Master Branch:
      MDL-40471_master

      Description

      Upon testing MDL-39986 I noticed there are a number of capabilities which seem like they need to add the 'manage badges' menu to be able to get to the page to manage them if you only have that single capability. It probably means converting the navigation item capability check to a has_any_capability() call

      We also should check through a role with each of these capabilities and ensure that you can do the action with only that:

      moodle/badges:awardbadge
      moodle/badges:configurecriteria
      moodle/badges:configuredetails
      moodle/badges:configuremessages
      moodle/badges:createbadge
      moodle/badges:deletebadge
      moodle/badges:earnbadge
      moodle/badges:viewawarded
      moodle/badges:viewbadges

        Gliffy Diagrams

          Issue Links

            Activity

            Hide
            Yuliya Bozhko added a comment - - edited

            Hmmm... I looked through this one and found that there were quite a few things going on not quite right.

            I rewrote navigation part and account for has_any_capability() similar to admin settings page. Also added more checks around editing badges to make sure that users with only some permissions are not redirected to the pages they don't access to and get locked out.

            Also added missing "badges:configurecriteria" capability to admin settings page.

            Show
            Yuliya Bozhko added a comment - - edited Hmmm... I looked through this one and found that there were quite a few things going on not quite right. I rewrote navigation part and account for has_any_capability() similar to admin settings page. Also added more checks around editing badges to make sure that users with only some permissions are not redirected to the pages they don't access to and get locked out. Also added missing "badges:configurecriteria" capability to admin settings page.
            Hide
            Yuliya Bozhko added a comment -

            I think this one will also solve problem reported in MDL-39983 where users with correct capabilities cannot award badges.

            Show
            Yuliya Bozhko added a comment - I think this one will also solve problem reported in MDL-39983 where users with correct capabilities cannot award badges.
            Hide
            Dan Poltawski added a comment -

            Hi Yuliya,

            This looks good to me, the proof will be in the testing instructions.

            Show
            Dan Poltawski added a comment - Hi Yuliya, This looks good to me, the proof will be in the testing instructions.
            Hide
            Yuliya Bozhko added a comment -

            Thanks! I even read through the instructions once again to make sure they are correct

            Show
            Yuliya Bozhko added a comment - Thanks! I even read through the instructions once again to make sure they are correct
            Hide
            Sam Hemelryk added a comment -

            Thanks Yuliya this has been integrated now, master + 25

            Show
            Sam Hemelryk added a comment - Thanks Yuliya this has been integrated now, master + 25
            Hide
            Mark Nelson added a comment -

            Hi Yuliya,

            Works as expected, thanks.

            Just a quick note - I noticed the 'Name' field under 'Issuer details' is populated in master with the name of the site, but is not in 2.5. Is this expected?

            Show
            Mark Nelson added a comment - Hi Yuliya, Works as expected, thanks. Just a quick note - I noticed the 'Name' field under 'Issuer details' is populated in master with the name of the site, but is not in 2.5. Is this expected?
            Hide
            Yuliya Bozhko added a comment -

            Thanks Mark!

            Default Issuer name is the name of the web site, unless a different issuer name is specified when creating a badge. It might be the case why they differ in different badges.

            Yuliya

            Show
            Yuliya Bozhko added a comment - Thanks Mark! Default Issuer name is the name of the web site, unless a different issuer name is specified when creating a badge. It might be the case why they differ in different badges. Yuliya
            Hide
            Mark Nelson added a comment -

            Ok, so I looked at the code to find out why when creating a badge in integration 2.5 the issuer name was left empty, where as in integration master it was populated with the site name and found -

            if (isset($CFG->badges_defaultissuername)) {
                $mform->setDefault('issuername', $CFG->badges_defaultissuername);
            }
            

            I then searched for this setting and found that it was set to empty on my integration 2.5 site, which is why this was happening. I do not recall deleting the default value in this field so I am not sure how this came to be.

            Show
            Mark Nelson added a comment - Ok, so I looked at the code to find out why when creating a badge in integration 2.5 the issuer name was left empty, where as in integration master it was populated with the site name and found - if (isset($CFG->badges_defaultissuername)) { $mform->setDefault('issuername', $CFG->badges_defaultissuername); } I then searched for this setting and found that it was set to empty on my integration 2.5 site, which is why this was happening. I do not recall deleting the default value in this field so I am not sure how this came to be.
            Hide
            Damyon Wiese added a comment -

            This issue along with 77 of it's friends has been sent upstream and released to the world.

            Thankyou for your contribution.

            Show
            Damyon Wiese added a comment - This issue along with 77 of it's friends has been sent upstream and released to the world. Thankyou for your contribution.

              People

              • Votes:
                0 Vote for this issue
                Watchers:
                5 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: