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

Add custom field types plugin and course custom fields functionality

    XMLWordPrintable

    Details

    • Testing Instructions:
      Hide
      Upgrade
      1. On an existing Moodle instance with courses, upgrade your instance with the patch applied.
      2. Confirm that the upgrade completes successfully.
      Basic functionality
      1. Log in as an admin
      2. Go to Site administration / Plugins / Custom fields / Manage custom field types
      3. Confirm that the following custom field type plugins are installed and enabled:
        • Checkbox
        • Date and time
        • Dropdown menu
        • Text field
        • Text area
      4. Open another browser tab and go to Site administration / Courses / Course custom fields
      5. Click "Add a new category"
      6. Confirm that a new category "Other fields" is added.
      7. Try to rename this category.
      8. Confirm that you can rename the category.
      9. Refresh the page.
      10. Confirm that the category name remains unchanged.
      11. Click "Add a new custom field"
      12. Confirm that you see the enabled custom field type plugins on the dropdown menu.
      13. Add at least two for each custom field type to the category. Set various settings for each custom field.
      14. Create another category and add each custom field types with various settings for each custom field.
      15. Edit one or more courses.
      16. Confirm that the custom categories and fields that you have set up earlier are shown on the course edit form.
      17. Confirm that the input behaviours for each custom field are consistent with their settings. Examples:
        Setting Behaviour
        Required An error will be shown indicating that the field is required when the custom field is left empty.
        Unique data If you have two courses c1 and c2 you cannot use the same value for a custom field that has already been defined on the other course
        Locked If you are a teacher, you won't be able to edit the custom field. If you are a manager/admin, you should be able to.
      1. Go to the site home.
      2. Confirm that the custom fields that have been set are shown for each course listed in the site home according to their visibility settings. For example,
        Visible to Expected
        Everyone Custom field value can be seen by everyone regardless of their role.
        Course editors Only users with the course creator role or above can view the custom field's value.
        Not visible The custom field's value won't be displayed at all
      Backup and restore
      1. Disable one or more custom field types in Site administration / Plugins / Custom fields / Manage custom field types
      2. Backup a course
      3. Restore the backup as a new course.
      4. Go to the site home.
      5. Confirm that the custom field values for the course are shown, except for the field types that have been disabled.
      6. Reenable the disabled custom field types.
      7. Back on the site home, confirm that the custom field values are shown.
      Deleting a custom field.
      1. Go to Site administration / Courses / Course custom fields
      2. Delete one of the defined custom fields.
      3. Go to the site home.
      4. Confirm that the values for the deleted custom field are no longer shown.
      Uninstalling a field type plugin.
      1. Go to Site administration / Plugins / Custom fields / Manage custom field types
      2. Uninstall one of the field types.
      3. Go to the site home.
      4. Confirm that the values for the custom fields from the uninstalled custom field type are no longer shown.
      Search
      1. Enable global search using the simple DB engine.
      2. Index all of the site contents.
      3. Search a word that's in the value of a custom field.
      4. Confirm that the custom field comes up on the search results.
      Privacy
      1. Go to Site administration / Users / Privacy and policies / Plugin privacy registry.
      2. Expand all nodes.
      3. Go to the core_customfield section.
      4. Confirm that it doesn't have any warning shown beside it (e.g. no "Userlist provider missing" message, etc)
      Fresh installation
      1. If you're working on the Moodle instance from the previous section, uninstall it. On MDK:

        mdk uninstall -y
        

      2. Create a fresh install of Moodle with this patch.
      3. Confirm that installation completes successfully.
      Show
      Upgrade On an existing Moodle instance with courses, upgrade your instance with the patch applied. Confirm that the upgrade completes successfully. Basic functionality Log in as an admin Go to Site administration / Plugins / Custom fields / Manage custom field types Confirm that the following custom field type plugins are installed and enabled: Checkbox Date and time Dropdown menu Text field Text area Open another browser tab and go to Site administration / Courses / Course custom fields Click " Add a new category " Confirm that a new category "Other fields" is added. Try to rename this category. Confirm that you can rename the category. Refresh the page. Confirm that the category name remains unchanged. Click " Add a new custom field " Confirm that you see the enabled custom field type plugins on the dropdown menu. Add at least two for each custom field type to the category. Set various settings for each custom field. Create another category and add each custom field types with various settings for each custom field. Edit one or more courses. Confirm that the custom categories and fields that you have set up earlier are shown on the course edit form. Confirm that the input behaviours for each custom field are consistent with their settings. Examples: Setting Behaviour Required An error will be shown indicating that the field is required when the custom field is left empty. Unique data If you have two courses c1 and c2 you cannot use the same value for a custom field that has already been defined on the other course Locked If you are a teacher, you won't be able to edit the custom field. If you are a manager/admin, you should be able to. Go to the site home. Confirm that the custom fields that have been set are shown for each course listed in the site home according to their visibility settings. For example, Visible to Expected Everyone Custom field value can be seen by everyone regardless of their role. Course editors Only users with the course creator role or above can view the custom field's value. Not visible The custom field's value won't be displayed at all Backup and restore Disable one or more custom field types in Site administration / Plugins / Custom fields / Manage custom field types Backup a course Restore the backup as a new course. Go to the site home. Confirm that the custom field values for the course are shown, except for the field types that have been disabled. Reenable the disabled custom field types. Back on the site home, confirm that the custom field values are shown. Deleting a custom field. Go to Site administration / Courses / Course custom fields Delete one of the defined custom fields. Go to the site home. Confirm that the values for the deleted custom field are no longer shown. Uninstalling a field type plugin. Go to Site administration / Plugins / Custom fields / Manage custom field types Uninstall one of the field types. Go to the site home. Confirm that the values for the custom fields from the uninstalled custom field type are no longer shown. Search Enable global search using the simple DB engine. Index all of the site contents. Search a word that's in the value of a custom field. Confirm that the custom field comes up on the search results. Privacy Go to Site administration / Users / Privacy and policies / Plugin privacy registry. Expand all nodes. Go to the core_customfield section. Confirm that it doesn't have any warning shown beside it (e.g. no "Userlist provider missing" message, etc) Fresh installation If you're working on the Moodle instance from the previous section, uninstall it. On MDK: mdk uninstall -y Create a fresh install of Moodle with this patch. Confirm that installation completes successfully.
    • Affected Branches:
      MOODLE_33_STABLE, MOODLE_34_STABLE, MOODLE_35_STABLE, MOODLE_37_STABLE
    • Fixed Branches:
      MOODLE_37_STABLE
    • Pull Master Branch:
      MDL-57898-master

      Description

      Description edited to describe the new feature:

      An admin can specify course custom fields to be displayed with the course description.

      A course custom field may be locked so that only users with the capability to change locked custom fields (by default users with the default role of manager only) will be able to change it in the course settings.

      The visibility of a course custom field may be restricted to teachers only, or it may be hidden from everyone.

      Course custom fields are searchable with the global search.

       


      Original issue description:

      Original project proposal, now adjusted, is here for reference: https://moodleassociation.org/mod/page/view.php?id=238.

      Users of Moodle need to be able to more easily and visibly extend the data that is associated with Moodle courses/categories/groups/etc. (ie. various contexts) to meet their needs. Not every Moodle installation requires the same type of data, and thus a "one set of data fits all" solution will not suffice. It is therefore necessary to provide a system that allows any Moodle installation to define and extend the type of data they wish to associate with their courses/other contexts, and interact with this data from the UI, plugins and external systems. Such a system must be built to work smoothly and efficiently with Moodle.

      Essentially, this encompases applying the same functionality that currently allows extending user profile fields to other moodle contexts, including: site, category, course, user (done), cohorts, groups and groupings. This is to facilitate the storing of additional metadata about a given context (for example: for a course attributes like Campus, Status, Level, Credit Value, etc.).

      This will have a large benefit from both an integration (with other systems like Student Management Systems) and Search perspective - especially if this fits into the new "Global Search" functions in the latest version of moodle.

        Attachments

        1. 3.png
          3.png
          151 kB
        2. 2.png
          2.png
          217 kB
        3. 1.png
          1.png
          105 kB

          Issue Links

            Activity

              People

              • Votes:
                10 Vote for this issue
                Watchers:
                29 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Fix Release Date:
                  20/May/19

                  Time Tracking

                  Estimated:
                  Original Estimate - 0 minutes
                  0m
                  Remaining:
                  Remaining Estimate - 0 minutes
                  0m
                  Logged:
                  Time Spent - 3 hours
                  3h