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

Add option for automatically populated values for the 'number' custom field

XMLWordPrintable

    • MOODLE_405_STABLE
    • MOODLE_405_STABLE
    • MDL-82715-main-rebased
    • Hide

      Covered by automatic tests.

      Manual tests:

      1. install plugin https://github.com/ilyatregubov/moodle-tool_customprovider
      2. As admin go to course/customfield.php
      3. Click "Add a new custom field" and select CF type "Number"
      4. Add your field a name and a short name
      5. In Field type select "Custom provider" and save
      6. Go to any course page and navigate to settings
      7. In "Other field section" click "Update" next to you field name
      8. Observe field is updated with "123"
      Show
      Covered by automatic tests. Manual tests: install plugin https://github.com/ilyatregubov/moodle-tool_customprovider As admin go to course/customfield.php Click "Add a new custom field" and select CF type "Number" Add your field a name and a short name In Field type select "Custom provider" and save Go to any course page and navigate to settings In "Other field section" click "Update" next to you field name Observe field is updated with "123"
    • 1
    • WP Sprint 2024-I3.3 (Espresso)

      Following on from MDL-80858 and MDL-82571

      Summary of changes
      When configuring a number custom field allow administrator to choose whether they want to input the values manually for each course or calculate automatically. For course custom fields offer an option to calculate the "Number of activities in the course". For other custom field areas this option will not be available and the "Field type" selector should not be displayed. Add a hook to allow other plugins to add more options for automatically calculated fields.

      When configuring a custom field
      When the selector "Field type" is changed, all settings for the manual input disappear (using 'hideIf') and instead the settings for the selected field type appear.

      In case of the "Number of activities in the course" the setting will be an autoselect allowing to choose activities of which types to count. Typical use case will be to display the number of assignments or quizzes (or similar assessment type activities).

      Base class
      All automatic types should inherit the base class. This base class should provide functions for:

      • is_available() - type is available for the given field (i.e. it may only be available in specific areas, such as only courses or only cohorts)
      • recalculate(?int $instanceid) - recalculates the values for all entities or only for a particular instance

      The following functions will be called from the respective functions of the field_controller classes:

      • config_form_definition()
      • config_form_validation()
      • get_default_value()
      • prepare_field_for_display() - this has to be called from the function added in MDL-82571, see last item in the requirements there

      Scheduled task
      There has to be a scheduled task that recalculates the values of all automatic fields.

      When creating the course
      When creating the course (or another entity that uses custom fields, i.e. a cohort), the field should be displayed with the empty value

      When editing the course
      When editing the course the field should be displayed in the correct position with the current value (formatted) and the button to update the value (it calls a WS).

      The "Update" link and the web service are optional if we have enough time.

        1. (1) 8 Passed -- (Main)MDL-82715.png
          (1) 8 Passed -- (Main)MDL-82715.png
          89 kB
        2. courseedit.png
          courseedit.png
          18 kB
        3. error-500.png
          error-500.png
          87 kB
        4. image-2024-09-19-09-54-04-655.png
          image-2024-09-19-09-54-04-655.png
          87 kB
        5. MDL-82715_shortname.png
          MDL-82715_shortname.png
          52 kB
        6. numberfeldoptions.png
          numberfeldoptions.png
          21 kB
        7. numberfieldautomatic.png
          numberfieldautomatic.png
          12 kB
        8. numberfieldsettings.png
          numberfieldsettings.png
          29 kB

            ilyatregubov Ilya Tregubov
            marina Marina Glancy
            David Carrillo David Carrillo
            Paul Holden Paul Holden
            Kim Jared Lucas Kim Jared Lucas
            Votes:
            0 Vote for this issue
            Watchers:
            10 Start watching this issue

              Created:
              Updated:
              Resolved:

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

                  Error rendering 'clockify-timesheets-time-tracking-reports:timer-sidebar'. Please contact your Jira administrators.