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

Form: Test using any of supported option in duration element.

    XMLWordPrintable

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Minor
    • Resolution: Won't Fix
    • Affects Version/s: 3.8
    • Fix Version/s: None
    • Component/s: Forms Library
    • Labels:
      None
    • Testing Instructions:
      Hide

      It is pretty much covered in unittest (you can same test without patch and it will show the error).

      But if you eager to check it is all fine in the interface, then do the following (with debugging enabled):

      1. Navigate to any course, open "Enrolment methods" and click edit icon on "Manual enrolment".
      2. Set "Notify before enrolment expires" to "Enroller only", this will enable "Notification threshold", save changes and get back to "Manual enrolment" editing interface.
      3. Modify enrol/manual/lib.php as follows:

        diff --git a/enrol/manual/lib.php b/enrol/manual/lib.php
        index a346a08a8b5..a4754f1a328 100644
        --- a/enrol/manual/lib.php
        +++ b/enrol/manual/lib.php
        @@ -594,7 +594,7 @@ class enrol_manual_plugin extends enrol_plugin {
                 $mform->addElement('select', 'expirynotify', get_string('expirynotify', 'core_enrol'), $options);
                 $mform->addHelpButton('expirynotify', 'expirynotify', 'core_enrol');
         
        -        $options = array('optional' => false, 'defaultunit' => 86400);
        +        $options = array('defaultunit' => 86400);
                 $mform->addElement('duration', 'expirythreshold', get_string('expirythreshold', 'core_enrol'), $options);
                 $mform->addHelpButton('expirythreshold', 'expirythreshold', 'core_enrol');
                 $mform->disabledIf('expirythreshold', 'expirynotify', 'eq', 0);
        

      4. Get back to "Manual enrolment" editing page, refresh and observe that there is no notice shown.
      Show
      It is pretty much covered in unittest (you can same test without patch and it will show the error). But if you eager to check it is all fine in the interface, then do the following (with debugging enabled): Navigate to any course, open "Enrolment methods" and click edit icon on "Manual enrolment". Set "Notify before enrolment expires" to "Enroller only", this will enable "Notification threshold", save changes and get back to "Manual enrolment" editing interface. Modify enrol/manual/lib.php as follows: diff --git a/enrol/manual/lib.php b/enrol/manual/lib.php index a346a08a8b5..a4754f1a328 100644 --- a/enrol/manual/lib.php +++ b/enrol/manual/lib.php @@ -594,7 +594,7 @@ class enrol_manual_plugin extends enrol_plugin { $mform->addElement('select', 'expirynotify', get_string('expirynotify', 'core_enrol'), $options); $mform->addHelpButton('expirynotify', 'expirynotify', 'core_enrol'); - $options = array('optional' => false, 'defaultunit' => 86400); + $options = array('defaultunit' => 86400); $mform->addElement('duration', 'expirythreshold', get_string('expirythreshold', 'core_enrol'), $options); $mform->addHelpButton('expirythreshold', 'expirythreshold', 'core_enrol'); $mform->disabledIf('expirythreshold', 'expirynotify', 'eq', 0); Get back to "Manual enrolment" editing page, refresh and observe that there is no notice shown.
    • Affected Branches:
      MOODLE_38_STABLE
    • Pull Master Branch:
      MDL-66185-master

      Description

      "Duration" element constructor is allowing to specify options:

          * @param array $options Options to control the element's display. Recognised values are
          *              'optional' => true/false - whether to display an 'enabled' checkbox next to the element.
          *              'defaultunit' => 1|60|3600|86400|604800 - the default unit to display when the time is blank.
          *              If not specified, minutes is used.
      

      Currently optional flag presence in options list seems compulsory, i.e. not providing optional (value does not matter) results in "key does not exist" notice.

      This fix is making possible to not to specify it at every duration element instance (it defaults to false in that case).

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              kabalin Ruslan Kabalin
              Reporter:
              kabalin Ruslan Kabalin
              Participants:
              Component watchers:
              Adrian Greeve, Jake Dallimore, Mathew May, Mihail Geshoski, Peter Dias
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:

                  Time Tracking

                  Estimated:
                  Original Estimate - 0 minutes
                  0m
                  Remaining:
                  Remaining Estimate - 0 minutes
                  0m
                  Logged:
                  Time Spent - 1 hour, 5 minutes
                  1h 5m