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

Make criteria a sub-plugin to allow easier sharing of new types

    Details

    • Type: Improvement
    • Status: Reopened
    • Priority: Major
    • Resolution: Unresolved
    • Affects Version/s: 2.5
    • Fix Version/s: None
    • Component/s: Badges
    • Testing Instructions:
      Hide

      Review existing functionality

      To ensure this refactor hasn't broken anything. I would do the following:

      • Install a fresh 2.6dev site (last week's weekly or before)
      • Creating a site badge, using all available criteria types
      • Create a course badge, using all available criteria types
      • Award the badges to some users
      • Upgrade the site to include this patch
      • View "Manage badges" page, badge "Overview", badge "Criteria" pages for site and course badges and make sure everything looks ok
      • View the awarded badge page
      • Create some new badges, using all available criteria types and repeat steps above.

      Removing an existing plugin

      This simulates the case where someone removes a plugin that is still being used or imports some badges from a site with a plugin that doesn't exist on the new site.

      • Create a site badge using the 'profile' criterion.
      • Delete or move the badge/criteria/profile/ folder, then immediately purge all caches.
      • You will get various warnings that the criteria is missing but nothing should be badly broken.
      • You shouldn't be able to enable a badge that is based on the criteria that has been removed
      • If the overall aggregation is "all" you shouldn't be able to award a badge with invalid criteria
      • If the overall aggregation is "any" you should be able to award the badge if they meet one of the other criteria

      Adding a new plugin

      • Review the criteria options on a badge criteria tab.
      • Unzip the attached file into your webroot and make sure it creates a folder badges/criteria/example/
      • Immediately after adding the code, make sure you purge all caches
      • You should see a new criteria option 'Example badge criteria' which you should be able to select and save as a new criteria.
      • The new criteria doesn't do anything except automatically award the criterion.

      Backup and restore

      • Backup and restore a course with criteria. Make sure the badges are restored properly.
      • Backup a course with badges on Moodle without this patch or a Moodle 2.5 site. Then restore on a site with this patch. The badges and their criteria should still be restored correctly.

      Unit tests

      All badge tests should pass including the new ones added by this patch.

      Show
      Review existing functionality To ensure this refactor hasn't broken anything. I would do the following: Install a fresh 2.6dev site (last week's weekly or before) Creating a site badge, using all available criteria types Create a course badge, using all available criteria types Award the badges to some users Upgrade the site to include this patch View "Manage badges" page, badge "Overview", badge "Criteria" pages for site and course badges and make sure everything looks ok View the awarded badge page Create some new badges, using all available criteria types and repeat steps above. Removing an existing plugin This simulates the case where someone removes a plugin that is still being used or imports some badges from a site with a plugin that doesn't exist on the new site. Create a site badge using the 'profile' criterion. Delete or move the badge/criteria/profile/ folder, then immediately purge all caches . You will get various warnings that the criteria is missing but nothing should be badly broken. You shouldn't be able to enable a badge that is based on the criteria that has been removed If the overall aggregation is "all" you shouldn't be able to award a badge with invalid criteria If the overall aggregation is "any" you should be able to award the badge if they meet one of the other criteria Adding a new plugin Review the criteria options on a badge criteria tab. Unzip the attached file into your webroot and make sure it creates a folder badges/criteria/example/ Immediately after adding the code, make sure you purge all caches You should see a new criteria option 'Example badge criteria' which you should be able to select and save as a new criteria. The new criteria doesn't do anything except automatically award the criterion. Backup and restore Backup and restore a course with criteria. Make sure the badges are restored properly. Backup a course with badges on Moodle without this patch or a Moodle 2.5 site. Then restore on a site with this patch. The badges and their criteria should still be restored correctly. Unit tests All badge tests should pass including the new ones added by this patch.
    • Affected Branches:
      MOODLE_25_STABLE
    • Pull Master Branch:
      MDL-39864_master

      Description

      At the moment there appears to be no easy process to add custom criteria to Moodle. Ideally adding new criteria would be as easy as adding a new question type or filter.

      As far as I can tell, although only one file is required to contain the criteria itself changes need to be made to multiple core files for that criteria to be available.

        Gliffy Diagrams

          Attachments

            Issue Links

              Activity

                People

                • Votes:
                  17 Vote for this issue
                  Watchers:
                  19 Start watching this issue

                  Dates

                  • Created:
                    Updated: