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

Allow minimum datetime validation for user profile fields

    XMLWordPrintable

    Details

    • Type: Improvement
    • Status: Waiting for peer review
    • Priority: Minor
    • Resolution: Unresolved
    • Affects Version/s: 3.9.6, 3.10.3
    • Fix Version/s: None
    • Component/s: User management
    • Labels:
    • Testing Instructions:
      Hide

      1. For PHPUnit testing run the new test

      user/profile/field/datetime/tests/form_test.php

      2. For manual testing.
      2.1. Add a new user profile field of type 'datetime' with these parameters:

      user/profile/index.php?id=0&action=editfield&datatype=datetime

      shortname: 'minimumdate'
      name: 'Date of birth'
      datatype: 'datetime'
      descriptionformat: FORMAT_HTML
      categoryid: '1'
      required: '1'
      locked: '0'
      visible: '1'
      forceunique: '0'
      signup: '1'
      defaultdata: 0
      defaultdataformat: FORMAT_MOODLE
      startyear: ''
      endyear: ''
      param1: '1900'
      param2: '2020'
      param3: ''
      param4: 'minimumdatetime=18 years;minimumdatetimeerror=Date of birth must be greater than 18'
      param5: ''

      2.2. Test the creation of a new account via the login screen.

      if you enter a 'Date of birth' which is less than 18 years the 'Date of birth' error should be displayed.
      if you enter a 'Date of birth' which is 18 years or greater the 'Date of birth' error should not be displayed.

      Show
      1. For PHPUnit testing run the new test user/profile/field/datetime/tests/form_test.php 2. For manual testing. 2.1. Add a new user profile field of type 'datetime' with these parameters: user/profile/index.php?id=0&action=editfield&datatype=datetime shortname: 'minimumdate' name: 'Date of birth' datatype: 'datetime' descriptionformat: FORMAT_HTML categoryid: '1' required: '1' locked: '0' visible: '1' forceunique: '0' signup: '1' defaultdata: 0 defaultdataformat: FORMAT_MOODLE startyear: '' endyear: '' param1: '1900' param2: '2020' param3: '' param4: 'minimumdatetime=18 years;minimumdatetimeerror=Date of birth must be greater than 18' param5: '' 2.2. Test the creation of a new account via the login screen. if you enter a 'Date of birth' which is less than 18 years the 'Date of birth' error should be displayed. if you enter a 'Date of birth' which is 18 years or greater the 'Date of birth' error should not be displayed.
    • Affected Branches:
      MOODLE_310_STABLE, MOODLE_39_STABLE
    • Pull Master Branch:

      Description

      The proposed amendment provides validation for a minimum datetime value for the profile form fields. The solution is generic and allows specifying custom validation parameters via the param4 field of the user_info_field table.

      Here is an example usage for parameters via the param4 field which validates the date is at least 18 years:

      param4 = 'minimumdatetime=18 years;minimumdatetimeerror=Minimum test date required'

      Additional change implemented to the UI to include a new field called "Data validation parameters" which allows configuring the param4 field manually.

        Attachments

          Activity

            People

            Assignee:
            Unassigned Unassigned
            Reporter:
            emanoylov Emanoil Manoylov
            Participants:
            Component watchers:
            Amaia Anabitarte, Carlos Escobedo, Ferran Recio, Ilya Tregubov, Sara Arjona (@sarjona)
            Votes:
            1 Vote for this issue
            Watchers:
            3 Start watching this issue

              Dates

              Created:
              Updated:

                Time Tracking

                Estimated:
                Original Estimate - 0 minutes
                0m
                Remaining:
                Remaining Estimate - 0 minutes
                0m
                Logged:
                Time Spent - 1 minute
                1m