Number of years in date selection forms

Number of years in date selection forms

by Malcolm Abel -
Number of replies: 4
As a Moodle support person I've been a bit concerned about the number of years that now appear in the pop-up menu when someone needs to set a date for something. The default is from 1900 to 2050, which puts 150 options in the list.

In most cases dates are set in the future, and as Moodle is used for teaching they are not set very far in the future. I'd suggest that in most cases no more than 5 years are needed in that list.

Currently it seems that changing the default years involves changing the 'code' in .../moodle/calendar/type/gregorian/classes/structure.php, lines 81 to 97.

Are there cases where such a large range of years is needed?

Is there an easy way to change the default years, for those who can't access the code on their server?

If not, I'd like to propose adding the default dates to the config file, which I have tested out on a local Moodle server.

Thanks

Mal.





Average of ratings: -
In reply to Malcolm Abel

Re: Number of years in date selection forms

by Just H -

Depends where that code is called (can't say I've looked into it). 

For example, what about peoples date of birth or history questions or date started at a company etc.

In reply to Just H

Re: Number of years in date selection forms

by Tim Hunt -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

These days, it is controlled by get_min_year and get_max_year in calendar/type/gregorian/classes/structure.php.

Not sure what else would be affected if you changed that.

Since it defaults to the current year, normally you don't have to scroll far to find the year you want in the menu, but you can still pick dates a long way in the past or future.

In reply to Tim Hunt

Re: Number of years in date selection forms

by Malcolm Abel -
Thanks Tim,

It is a minor issue but the huge list is cumbersome, it shouldn't be if it's not necessary.

I can see this particular date selection form in several settings pages for Assignments, Quizzes etc. In all those places only a small number of years is needed.

Know of any other places?

In the Admin pages, we can add a date field to the user profile. In that case the min and max years can be selected from a list (drawn from the default min_year and max_year). So we can assume the date form function can respond to local variables as well as the default ones.

So seems to be variuos possibilities for setting these years?

Mal.
In reply to Just H

Re: Number of years in date selection forms

by Malcolm Abel -
Thanks Just H.

Can you point to some exact pages in Moodle with examples?

Thanks

Mal.