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

Always use the same method to retrieve list of user profile fields

    XMLWordPrintable

    Details

    • Testing Instructions:
      Hide

      Test 1.

      1. As admin go to Site administration>Users>Accounts>User profile fields
      2. Create and edit categories - make sure the forms are displayed in the modals and everything works
      3. Create and edit fields - make sure the forms are displayed in the modals and everything works
      4. Try to delete and move categories and fields, make sure it works. Please note that there were no changes to this functionality, there are some unusual behaviors there (for example, when you delete category the fields are moved to another category). Before failing the test make sure that there is actual regression comparing to the master branch
      5. Create and edit users, make sure that profile fields appear in the edit form as expected
      6. Go to the Site administration>Users>All users
      7. Try to search users by custom profile fields, make sure the search works

      Test 2.

      1. Enable e-mail self registration
      2. Add some profile fields and select "use in sign up form"
      3. Try to register as a new user, make sure that the sign up profile fields are displayed

      Test 3

      1. Create custom profile fields and users who have some custom profile fields
      2. Enrol one of such users into the course
      3. Backup the course with user data
      4. Delete this user
      5. Restore the course with user data
      6. Make sure the user is created and their profile fields are still there

      Test 4

      1. Create custom profile fields FieldA and FieldB in the same category, name category CatA.
      2. As admin go to Site administration>Badges>Manage badges
      3. Create a badge, navigate to Criteria tab, add Profile completion criteria
      4. In Profile completion criteria settings check that custom field section exists (CatA) and listed under "Profile completion" section.
      5. In Profile completion criteria settings tick-off one standard field, e.g. Country and two custom fields, FieldA and FieldB, save.
      6. In Criteria tab observe "Profile completion" summary that contains 3 fields selected at previous step.
      7. Go to Site administration>Badges>Manage badges, observe badge is listed and criteria column contains 3 fields selected at previous step.
      8. Navigate to Site administration>Users>Accounts>User profile fields, delete FieldB.
      9. Go to Site administration>Badges>Manage badges, observe badge is listed and criteria column contains 3 fields, instead of FieldB the text "Warning: This user profile field is no longer available." is shown.
      10. Edit badge, navigate to Criteria tab.
      11. In Criteria tab observe "Profile completion" summary that contains 3 fields, instead of FieldB the text "Warning: This user profile field is no longer available." is shown.
      12. Edit "Profile completion" criteria, observe the top section is "Current parameters issues" and it contains removed field.
      13. Observe custom field section exists (CatA) and listing FieldA only.
      14. Untick "Warning: This user profile field is no longer available." field and save.
      15. In Criteria tab observe "Profile completion" summary that contains 2 fields, Country and FieldA.
      Show
      Test 1. As admin go to Site administration>Users>Accounts>User profile fields Create and edit categories - make sure the forms are displayed in the modals and everything works Create and edit fields - make sure the forms are displayed in the modals and everything works Try to delete and move categories and fields, make sure it works. Please note that there were no changes to this functionality, there are some unusual behaviors there (for example, when you delete category the fields are moved to another category). Before failing the test make sure that there is actual regression comparing to the master branch Create and edit users, make sure that profile fields appear in the edit form as expected Go to the Site administration>Users>All users Try to search users by custom profile fields, make sure the search works Test 2. Enable e-mail self registration Add some profile fields and select "use in sign up form" Try to register as a new user, make sure that the sign up profile fields are displayed Test 3 Create custom profile fields and users who have some custom profile fields Enrol one of such users into the course Backup the course with user data Delete this user Restore the course with user data Make sure the user is created and their profile fields are still there Test 4 Create custom profile fields FieldA and FieldB in the same category, name category CatA. As admin go to Site administration>Badges>Manage badges Create a badge, navigate to Criteria tab, add Profile completion criteria In Profile completion criteria settings check that custom field section exists (CatA) and listed under "Profile completion" section. In Profile completion criteria settings tick-off one standard field, e.g. Country and two custom fields, FieldA and FieldB, save. In Criteria tab observe "Profile completion" summary that contains 3 fields selected at previous step. Go to Site administration>Badges>Manage badges, observe badge is listed and criteria column contains 3 fields selected at previous step. Navigate to Site administration>Users>Accounts>User profile fields, delete FieldB. Go to Site administration>Badges>Manage badges, observe badge is listed and criteria column contains 3 fields, instead of FieldB the text "Warning: This user profile field is no longer available." is shown. Edit badge, navigate to Criteria tab. In Criteria tab observe "Profile completion" summary that contains 3 fields, instead of FieldB the text "Warning: This user profile field is no longer available." is shown. Edit "Profile completion" criteria, observe the top section is "Current parameters issues" and it contains removed field. Observe custom field section exists (CatA) and listing FieldA only. Untick "Warning: This user profile field is no longer available." field and save. In Criteria tab observe "Profile completion" summary that contains 2 fields, Country and FieldA.
    • Affected Branches:
      MOODLE_311_STABLE
    • Fixed Branches:
      MOODLE_311_STABLE
    • Pull 3.11 Branch:
      MDL-71051-311-2
    • Pull Master Branch:
      MDL-71051-master-2
    • Sprint:
      WP 3.11 SP 1

      Description

      There are a lot of places in code that query user_info_field and user_info_category directly instead of using API

      It is inconsistent, it will cause field name not being displayed properly after MDL-28452 and also it is often inefficient

      I used this issue to also make some UI changes to the management of profile fields

      all the things changed in this issue:

      • do not query directly from the DB, use API methods to work with custom user profile fields
      • change the method profile_get_custom_field_data_by_shortname() (from MDL-45242) to return stdClass and not throw exception - it is not a coding exception that some field shortname does not exist
      • in the unittests use generators for user profile fields (introduced in MDL-45242)
      • use modal forms for editing user profile fields and categories
      • use mustache template to render the admin interface to manage profile fields, move "add new field" control into each category

        Attachments

        1. MDL-71051-Test-1.png
          2.08 MB
          Huong Nguyen
        2. MDL-71051-Test-1-Datetime.png
          101 kB
          Huong Nguyen
        3. MDL-71051-Test-2.png
          116 kB
          Huong Nguyen
        4. MDL-71051-Test-4.png
          1.32 MB
          Huong Nguyen

          Issue Links

            Activity

              People

              Assignee:
              marina Marina Glancy
              Reporter:
              marina Marina Glancy
              Peer reviewer:
              Ruslan Kabalin Ruslan Kabalin
              Integrator:
              Adrian Greeve Adrian Greeve
              Tester:
              Huong Nguyen Huong Nguyen
              Participants:
              Component watchers:
              Amaia Anabitarte, Carlos Escobedo, Ferran Recio, Ilya Tregubov, Sara Arjona (@sarjona)
              Votes:
              0 Vote for this issue
              Watchers:
              9 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:
                Fix Release Date:
                17/May/21

                  Time Tracking

                  Estimated:
                  Original Estimate - 0 minutes
                  0m
                  Remaining:
                  Remaining Estimate - 0 minutes
                  0m
                  Logged:
                  Time Spent - 1 week, 2 days, 2 hours, 35 minutes
                  1w 2d 2h 35m