Uploaded image for project: 'Moodle'
  1. Moodle
  2. MDL-39189

"Roles can assign badges" feature does not work with multiple roles

    Details

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

      1. Create a course badge with criteria "Manual issue by a role". Set up criteria options with several roles (e.g. teacher and course creator). Enable the badge.
      2. Create a user account and give it more than one role in this course.
      3. Login as this new user.
      4. Go to award badge link from "Badge management" or click "Award badge" from Recipients tab.
      5. If the user has more than one role that they can use to award the badge, they should have a drop down to select the role they would like to use.
      6. Award the badge, make sure that nothing breaks.

      Show
      1. Create a course badge with criteria "Manual issue by a role". Set up criteria options with several roles (e.g. teacher and course creator). Enable the badge. 2. Create a user account and give it more than one role in this course. 3. Login as this new user. 4. Go to award badge link from "Badge management" or click "Award badge" from Recipients tab. 5. If the user has more than one role that they can use to award the badge, they should have a drop down to select the role they would like to use. 6. Award the badge, make sure that nothing breaks.
    • Affected Branches:
      MOODLE_25_STABLE
    • Fixed Branches:
      MOODLE_25_STABLE
    • Pull Master Branch:
      MDL-39189_master

      Description

      Roles can assign badges feature does not work with multiple roles.

      Comment from MDL-39049:

      Hi Yuliya,

      While the patch fixes this specific issue - I spotted a logic error.
      A user can have multiple roles in a course and you are only checking the first one returned from "get_user_roles" - you need to loop through that list and only print an error if none of the user roles are in the accepted roles list.
      How to reproduce: Create a badge that can be awarded by the Teacher role. Give a user teacher + course creator roles in a course. Attempt to award the badge as that teacher (should be allowed).

        Gliffy Diagrams

          Attachments

            Issue Links

              Activity

                People

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

                  Dates

                  • Created:
                    Updated:
                    Resolved:
                    Fix Release Date:
                    14/May/13