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

Add hooks (instead of callbacks) to extend course edit form

XMLWordPrintable

    • MOODLE_401_STABLE
    • MOODLE_404_STABLE
    • MDL-73483-master
    • Hide
      1. Install helper plugin https://github.com/dmitriim/moodle-local_helper (git clone https://github.com/dmitriim/moodle-local_helper.git local/helper)
      2. Navigate to /admin/hooks.php and confirm you see new hooks in the list (core_course\hook\after_form_definition, core_course\hook\after_form_definition_after_data, core_course\hook\after_form_submission and core_course\hook\after_form_validation)
      3. Confirm each of the hooks has associated callbacks from local_helper.
      4. Navigate to /course/management.php and click Create a new course button.
      5. Confirm you can see "New course is being created" info banner as well as  "Save to Course ID number" text field.
      6.  Populate course full name, course short name, category, but leave "Save to Course ID number" empty and try to submit the form.
      7. Confirm you see an error "This value can not be empty" related to "Save to Course ID number"  text field.
      8. Populate the field with "Test value" and save and display the form.  Confirm it went past validation.
      9. Click on Settings and bring up the course form again. Confirm you see "A course is being updated" info banner.
      10. Confirm "Test value" saved to "Course ID number" field.
      11. Remove a value of "Save to Course ID number"  field and try to submit the form.  Confirm you see an error "This value can not be empty" related to the actual "Course ID number"  text field.
      12. Populate "Save to Course ID number"  with "New test value". Click Save and display and then back to course settings.
      13. Confirm "New test value" saved to  "Course ID number".
      Show
      Install helper plugin https://github.com/dmitriim/moodle-local_helper (git clone https://github.com/dmitriim/moodle-local_helper.git local/helper) Navigate to /admin/hooks.php and confirm you see new hooks in the list (core_course\hook\after_form_definition, core_course\hook\after_form_definition_after_data, core_course\hook\after_form_submission and core_course\hook\after_form_validation) Confirm each of the hooks has associated callbacks from local_helper. Navigate to /course/management.php and click Create a new course button. Confirm you can see "New course is being created" info banner as well as  "Save to Course ID number" text field.  Populate course full name, course short name, category, but leave "Save to Course ID number" empty and try to submit the form. Confirm you see an error "This value can not be empty" related to "Save to Course ID number"  text field. Populate the field with "Test value" and save and display the form.  Confirm it went past validation. Click on Settings and bring up the course form again. Confirm you see "A course is being updated" info banner. Confirm "Test value" saved to "Course ID number" field. Remove a value of "Save to Course ID number"  field and try to submit the form.  Confirm you see an error "This value can not be empty" related to the actual "Course ID number"  text field. Populate "Save to Course ID number"  with "New test value". Click Save and display and then back to course settings. Confirm "New test value" saved to  "Course ID number".

      There're already callbacks (coursemodule_edit_post_actions, coursemodule_standard_elements and coursemodule_validation) that enables us to extend the form for modules. It would be great to have additional PSR hooks to extend the course and course category edit forms.

            dmitriim Dmitrii Metelkin
            mstimvol Tim Volckmann
            Brendan Heywood Brendan Heywood
            Jun Pataleta Jun Pataleta
            Kim Jared Lucas Kim Jared Lucas
            Votes:
            4 Vote for this issue
            Watchers:
            26 Start watching this issue

              Created:
              Updated:
              Resolved:

                Estimated:
                Original Estimate - 0 minutes
                0m
                Remaining:
                Remaining Estimate - 0 minutes
                0m
                Logged:
                Time Spent - 6 hours, 10 minutes
                6h 10m

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