Birthday block: Birthday field into new count format.

Birthday block: Birthday field into new count format.

by Monico Briseño -
Number of replies: 23
Picture of Testers
Hi, Andy. Yesterday, I was thinking how to make easier to populate the birthday field. Is there a way to include birthday field into the new count format and this field with the status required field?

TIA

Mónico

Average of ratings: -
In reply to Monico Briseño

Re: Birthday block: Birthday field into new count format.

by Anthony Borrow -
Picture of Core developers Picture of Plugin developers Picture of Testers
Mónico - I am not sure I understand what you mean. With user profile fields you can make it a required field and allow the user to edit it (see attached screenshot). I have recommended that the birthday field be a populated field (not required and locked) since currently it assumes the data to be in a valid date format (ISO, USA, or EUR) and all of the birthdays to be in a single format as chosen by the site administrator. Perhaps an enhancement would be to do some validity checking upon data entry and be able to check for any valid date format; however, this would probably be more easily accomplished if we added an actual date field in the mdl_user table. While all of these may be more eloquent and complete solutions, for the time being, I am satisfied with functional and working with the Moodle table structure as it exists. Peace - Anthony
Attachment bd.png
In reply to Anthony Borrow

Re: Birthday block: Birthday field into new count format.

by Monico Briseño -
Picture of Testers
Hi, Anthony. I appreciate your birthday block explanation. From this point of view is OK. I want to explain better: Birthday block is a great tool to motivate our moodle users. For this reason, I want to populate as soon as possible birthday field to offer this kind of service. I see two scenarios to do this:

a) New moodle user type his/her birthday information during the inscription process.
b) Moodle admininistrator has the birthday information of all moodle users in spreadsheet format and he wants to populate birthday block database in batch process.

Potential solutions

a) Include the birthday field into account format for new moodle registrations.
b) I couldn't find the DOB field in the moodle tables. Can you point me out, where I can find it.

Any idea to make this true.


A proposal for next birthday block release

An option to send an email message to the person based on birthday information.


Cheers

Mónico



In reply to Monico Briseño

Re: Birthday block: Birthday field into new count format.

by Anthony Borrow -
Picture of Core developers Picture of Plugin developers Picture of Testers
Monico - For your situation, if you have the data in a spreadsheet I would see if you could use ODBC and export it to a MySQL table. Then I would use a SQL statement to add the information into the Moodle custom user profile table. Currently, there is no DOB field in mdl_users. We would have to request it to be added; however, currently there is nothing in Moodle that would really make use of it. It makes more sense as part of a SIS (like Focus). In any case, if you would like some help getting the data into your Moodle database just let me know and I can help walk you through the process here on the forum. Step one is to get the information from the spreadsheet into a mysql database. Then we can proceed with writing an insert statement based on where the information is. You will want to check mdl_user_info_field and get the id of the custom user field you want to use (or are/have been using for testing). Finally, if you give me the field names of the mysql table you create from the spreadsheet we should be able to write your SQL statement. Let me know if you have any questions. Peace - Anthony
In reply to Monico Briseño

Re: Birthday block: Birthday field into new count format.

by Chad Outten -
thanks Anthony for your work on this. Birthday block works nicely in 1.9

fyi - i successfully bulk uploaded (via .csv file) DOB info for 1500 existing user accounts.

as per install instructions for this block, first, create an additional user profile field.

-go to site admin
-users/accounts/user profile fields
-create a new profile field/text input
etc

when the block is properly installed & the new user profile field created, its essential to get the name right for this new field in the .csv file

i didn't get the 'new profile field' convention from moodle docs. i do recall getting lucky reading some bug tracker notes! ;P

the convention is profile_field_shortname

important: replace 'shortname' with the actual short name used for the new profile field eg. dob

so the field should read something like profile_field_dob

http://docs.moodle.org/en/Upload_users

cheers, Chad



In reply to Chad Outten

Re: Birthday block: Birthday field into new count format.

by Anthony Borrow -
Picture of Core developers Picture of Plugin developers Picture of Testers
Chad - Thanks for sharing your experience and congratulations on being able to upload the 1500 users. I agree that it is not as clear or easy as it could be to make sure that the profile field naming happens as it needs to. From you experience, where could we improve the documentation? Let's see what we can do to keep it from being a matter of luck and make your successful experience that of everyone who uses the birthday block. Peace - Anthony

p.s. - Thanks for confirming that all is working in 1.9. Let me know if you have any suggestions for improvement.
In reply to Anthony Borrow

Re: Birthday block: Birthday field into new count format.

by Chad Outten -
Hi Anthony,

I've added to Moodle Docs @ http://docs.moodle.org/en/User_profile_fields

In terms of suggestions for future improvement for the Birthday Block, that's hard bcs i think 'simplicity is the ultimate sophistication'. This block effectively serves a simple, yet important function.

The ability for the block to auto sendmail a 'Happy Birthday' message to those users celebrating their birthday would be nice. Also, perhaps an option to configure block to display birthdays for the week, month.

Cheers,
Chad
In reply to Chad Outten

Re: Birthday block: Birthday field into new count format.

by Anthony Borrow -
Picture of Core developers Picture of Plugin developers Picture of Testers
Chad - Thanks for your feedback on the birthday block. I personally think that birthday greetings should be personal rather than automatically generated which generally strikes me as spam. What I have seen happen is that students will be reminded that it is a classmates birthday and then can choose to click and send a quick Happy Birthday greeting. So I'm not going to implement that suggestion. However, I did like the option of viewing a week of month of birthdays. A couple of questions about how you think this should work. How do you determine the current week? Today + 7 days or use Moodle's first day of week setting (Monday - Monday). In other words how do we determine when to start and stop searching? Similarly, and I would like it to be consistent with week, the question remains for the month. Do you want from the 1st to the end of the current month? I think we should change the display from Today's Birthdays to This Weeks Birthdays and perhaps put in parentheses the dates that are being displayed or for the month something like March Birthdays. The other issue that comes up is that I think if you are doing more than today's birthdays you should have a way of seeing the date of birth and that the year should be hidden since some folks are more sensitive about their age. Let me know what your thoughts are and then please file a feature request in the tracker detailing how we should lay this out and I will play with it to see if we can make it happen. Peace - Anthony
In reply to Anthony Borrow

Re: Birthday block: Birthday field into new count format.

by Steve Iman -
There are some neat ideas here, and I'd love to have some advanced warning. In the past I've collected birthdates and printed cards etc. in advance. In looking at the module I chose not to install it for fear of having such a short fuse. I could envision myself getting all the way to school before knowing it was somebody's birthday in classwink ANY easy to remember warning would be great, and if that could be a variable in order to deal with display issues in huge implementations, that'd be cool. How about a 3-day warning? That way, Suzie will know to get the cake organized ahead of the class session where Ken gets sung towink
In reply to Steve Iman

Re: Birthday block: Birthday field into new count format.

by Steve Iman -
Woops.. just installed it and found out that the feature I was hoping for was already built in. In the configuration setting, 0 days ahead is the default, but one can specify the advanced warning in as many days as one would like. Perfect!
In reply to Steve Iman

Re: Birthday block: Birthday field into new count format.

by Dan Jeffries -
Just installed this too - really like it! Nice and simple, but effective.

Just a quick question - how do I change the display in the block so it can say 'Upcoming Birthdays' rather than 'Today's birthdays'?

smile
In reply to Dan Jeffries

Re: Birthday block: Birthday field into new count format.

by Anthony Borrow -
Picture of Core developers Picture of Plugin developers Picture of Testers
Dan - Glad you like the Birthday block. If you want to change the language strings you can login as the site administrator and then go to the Administration block, click on Language and Language editing, then click on the edit words or phrases tab, select the birthday block from the bottom of the list of language files to edit, edit away and remember to save the changes. Alternatively, you could also just modify the /blocks/birthday/lang/en_utf8 file and change it there. Peace - Anthony
In reply to Anthony Borrow

Re: Birthday block: Birthday field into new count format.

by Alex Moura -
Hi Anthon.

Thanks for help to others. This topic help me to solve and install block. But, yet I have one ask. I see that field birthday have a format DD.MM.YYYY I need a tip to change this to format DD/MM/YYYY. Can you help me on this too?
I try to change your code this:

case 'EUR':
$period = explode('.',$date);
$month = $period[1];
$day = $period[0];

To this:

case 'EUR':
$period = explode('/',$date);
$month = $period[1];
$day = $period[0];

But it not work sad
So I think that have more code to change.
Thanks for all
Alex Moura


In reply to Alex Moura

Re: Birthday block: Birthday field into new count format.

by Anthony Borrow -
Picture of Core developers Picture of Plugin developers Picture of Testers
Alex - Unfortunately it is not that simple. Is there any reason why you cannot just do something like:

UPDATE mdl_user_info_data
SET data = replace(data,'/','.')
WHERE fieldid = 1;
(presuming your dob field is the only user profile field or the first one).

In other words it may be easier to just change the data in the database. Alternatively, I could work toward adding a separator field and seeing what I could do to make it so that another separator other than the default could be specified. In your case, you would be using the EUR format with a / separator instead of the period (.). I am open to doing this but it seems better to me if we keep the data in a consistent format (i.e. USA, EUR, or ISO). Let me know what you think and how I can be of help. Peace - Anthony
In reply to Anthony Borrow

Re: Birthday block: Birthday field into new count format.

by Alex Moura -
Hi Anthony. Thanks for answer.
In fact, change the database is the most easiest way to made this, but, this will be implicate in manual intervention with some periodicity. So, is very interesting that this can be made automatically.
Well I live in Brazil, so this is our date format dd/mm/yyyy. I know that it´s an mod. I can suggest to modify code to include date on BRA format in field. And, I can translate the language to Portuguese-Brazilian. I made this with translator tool from moodle, but, I don´t know how to include this translation to your code too. If you can help me this too.
Before I forget, this is an simple add-in, but, with great implications on our learning system. This bring learning to most personal level. Adding value to students or website users. I am very appreciate this mod. So, thank you for developing this.
Alex Moura
In reply to Alex Moura

Re: Birthday block: Birthday field into new count format.

by Anthony Borrow -
Picture of Core developers Picture of Plugin developers Picture of Testers
You could have the block perform the change as part of a cron job which would periodically go through and change the records that need to be changed. As for the translation, just go to the blocks/birthday/lang/en_utf8/block_birthday.php file and translate the strings and send the translation to me and I'll add it as one of the translations. Let me know if it might serve as a general portuguese translation. As for providing a Brazilian option, I am not sure how the sql will handle that but I did begin playing with some possibilities. If you could create an feature request issue in the tracker I will follow up on it. Glad the block has been helpful to you. I'd like to clean it up some and make it more flexible for a variety of date formats. Your help in testing some of that functionality will be helpful. Peace - Anthony
In reply to Anthony Borrow

Re: Birthday block: Birthday field

by debbie wombwell -
Do you know how this can be incorporated into a CSV file so the infomation is uploaded automatically when enrolling learners to moodle?
In reply to debbie wombwell

This forum post has been removed

The content of this forum post has been removed and can no longer be accessed.
In reply to Deleted user

Re: Birthday block: Birthday field

by Anthony Borrow -
Picture of Core developers Picture of Plugin developers Picture of Testers
Alan - Yes, updating the birthdays is possible by using the Import Users option in the Site administration block. You can specify the profile field used for the date of birth and either create new accounts with that information or update existing users adding their birthdays to their accounts. If there is a desired feature from my attempt at a birthday block just create a feature request in the tracker and I will happily give it a look. Peace - Anthony
In reply to Monico Briseño

Re: Birthday block: Birthday field into new count format.

by Nacho Aguilar -
Hi,

I'm getting crazy trying to use birthday block, so I need some help. I'm a bit newbie

We have a field in our database call 'nacimiento' (birthday). It's BIGINT type. It's in mdl_user not in mdl_user_info_field as you suggested, It's just because the filed was there before we decided to use birthday block.

So, can I use that field to show birthdays on the block? What must I change in birthday_block.php to work properly for us?

Can I clone our fied into a new one inside mdl_user_info_field?

We are using Moodle 1.9.7+,
Mysql 5.
My moodle site: https://www.lasallefelipebenito.es

Thanks again!
In reply to Nacho Aguilar

Re: Birthday block: Birthday field into new count format.

by Anthony Borrow -
Picture of Core developers Picture of Plugin developers Picture of Testers
Nacho - It would involve some rewriting but would not be insurmountable. The nice thing about using the bigint is that I assume you are storing the dates as unix timestamps. In that respect some of the code may be easier. One of the reasons I initially avoided that was I was afraid of having to deal with timezone issues and if it the date was close to midnight I didn't want people's birthdays shifting.

You could probably get by with some minimal modifications by modifying the get_month_day function. You would not need the cases based on format. You could get rid of all the format stuff (ISO, EUR, USA). You would not have to get the field->id since you would know that the data is already in $user. The $SQL statement could be greatly simplified around line 128.

Please feel free to give it a shot and let me know if you have specific questions. Peace - Anthony
In reply to Anthony Borrow

Re: Birthday block: Birthday block doesnt work as expected for EUR dateformat

by Toni Soto -
Hello Anthony,

I write this post in this thread because I think it is related to what Nacho and others posted before.

I installed Birthday block in moodle 1.9.5 and setup the dateformat for EUR. I posted the birthday date for some different users to test it.

user1 - 19.07.2001
user2 - 20.07.2005
user3 - 19.07.1999
user4 - 20.07.1994

As you can see the date format correspond to EUR.

I also setup block_birthday_days = 0 to show birthdays of the day.

1st Test:
On july, 19 I tested the block and I found something very strange: Only user1 was listed in the birthday block. As you can see above user3 should be listed too, because they share the same day and month but different year.

2nd Test:
I change the block_birthday_days = 1
Then (on july, 19) the birthday block listed two users: user1 and user2. This is right as they are in the interval of one day. But user3 and user4 were not listed as they were expected because they were born in identical day and month but in different year.

The birthday block worked as expected for EUR dateformat only if the year is 2000 or later.

3rd Test:
I change the dateformat to ISO and changed the birthdays of the four users (user1,..user4) to the new format: YYYY-MM-DD.

Right..!!The birthday block worked as expected.

I didn't test USA format.

I read the documentation and the discussion forum for birthday block to see if anyone had detected this issue. I have also had a look to the code in block_birthday.php to see if I could guess what was going wrong. I'm a rookie in PHP so I could not solve it by myself for the time being.

Anyone can test this block to confirm what I found out ...?

Any solution to this issue...?

Thanks in advance,

Toni Soto

In reply to Toni Soto

Re: Birthday block: Birthday block doesnt work as expected for EUR dateformat

by Anthony Borrow -
Picture of Core developers Picture of Plugin developers Picture of Testers
Toni - Many thanks for your testing and reporting this issue. Would you mind creating an issue in the Moodle Tracker? That will get the issue on my official to do list but it does sound like a bug. The details you provided are most helpful and once we identify the problem and can reproduce it (which should be easy now) it is usually not that difficult to fix. Peace - Anthony