• Resolved coachdrd

    (@coachdrd)


    I’m a running coach and I want to be able to create pace calculators on my WP website.

    Where a subscriber enters a recent race time (in hours, minutes & seconds), selects a race distance (e.g. 5k, 10k, half-mara. mara) and then my formula calculate estimates of potential finishing times for different race distances – after completing one of my training plans.

    The output would need to be in hours, minutes and seconds as well.

    I’d also like to be able to calculate training paces. Which would be output in minutes/mile or minutes/km.

    Is this sort of thing possible with your Forminator plugin?

    I can only find time as in time of day PM or AM for inputting into the calaculation fields. As per ‘Timepicker’ field.

Viewing 8 replies - 1 through 8 (of 8 total)
  • Plugin Support Dmytro – WPMU DEV Support

    (@wpmudevsupport16)

    Hi there @coachdrd

    Yes, that type of calculation can be done in a Forminator form. But you’d want to use Number fields instead of Timepicker fields (timepicker isn’t designed for this type of calculation).

    As an example, you could add a Number field for Hours, another for Minutes, and a 3rd for Seconds. Then add a Select box with the distance options you want.

    In the Calculations field, you can then manipulate the values of the Hours, Minutes, Seconds & Distance fields however you need.

    For example, this basic formula would calculate the number of seconds per km:
    (({number-1}*3600)+({number-2}*60)+{number-3})/{select-1}

    I set up a quick & dirty example of the above on one of my test sites here so you can see it in action ??
    https://newcoolsite.ml/new-form-test/

    Thread Starter coachdrd

    (@coachdrd)

    Hi Patrick,

    Thanks. That look promising. Is there any way to select the units you want to display the results in. e.g minutes/mile or minutes/km. Seconds/km is not something that runners work with.

    Regards,

    D

    Plugin Support Dmytro – WPMU DEV Support

    (@wpmudevsupport16)

    @coachdrd

    Sure, you can write up a formula to get results exactly how you want them.

    For example, to get the results in my form to display minutes/km instead, I adjusted the formula to divide the whole thing by 60, like so:

    ((({number-1}*3600)+({number-2}*60)+{number-3})/{select-1})/60

    I added a 2nd Calculations field to the example form on my page so you can see it working.

    Thread Starter coachdrd

    (@coachdrd)

    Hi Patrick,

    Closer still.

    But that gives a decimal of minutes.

    What I really want is Minutes and Seconds. So, for example it would be displayed as 7:30 (mm:ss format) rather than 7.5

    Hope that makes sense?

    • This reply was modified 4 years, 1 month ago by coachdrd.
    Plugin Support Dmytro – WPMU DEV Support

    (@wpmudevsupport16)

    Hi again @coachdrd

    Hmm, I’ve tried to get the result to display as you want, but haven’t managed to figure out the needed combination of calculations, even using hidden calculation fields to work it out in “steps”.

    I’ve put in a request for more help with this idea from our support team to see if there’s a true math wiz in the bunch. ??

    We’ll post again here with an update when available. In the meantime though, if you’d like to have a go at it, here’s the demo form I set up on my site that you can import into Forminator on your site:
    https://www.dropbox.com/s/vxifnhdksq94f0f/forminator-marathon-form-export.txt?dl=0

    Instructions for import here:
    https://premium.wpmudev.org/docs/wpmu-dev-plugins/forminator/#import-export

    Cheers!
    Patrick

    Thread Starter coachdrd

    (@coachdrd)

    Thanks Patrick,

    Your assistance is much appreciated. I’m sure it must be possible to convert a decimal figure to mins & seconds. My idea would be to separate off the whole number for minutes. Then multiply the remainder by 60 to get the seconds. Then join them back together. I just don’t have a clue how to do that in forminator ??

    • This reply was modified 4 years, 1 month ago by coachdrd.
    Plugin Support Dmytro – WPMU DEV Support

    (@wpmudevsupport16)

    @coachdrd

    I got a reply from one of our 2nd-level support wizkids.

    But unfortunately, this type of calculation can’t be done directly in Forminator, as the Calculations field only accepts numerical values.

    So it would need some custom js to make it work. And the challenge would be to get the change state of a Calculation field (probably would need a MutationObserver).

    So I’m afraid you may need to hire a developer for this customization, and maybe point him/her to our Forminator API docs here: https://premium.wpmudev.org/docs/api-plugin-development/forminator-api-docs/

    I believe the get_form_field() and update_form_field() methods may be of particular interest.

    Cheers!
    Patrick

    Plugin Support Amin – WPMU DEV Support

    (@wpmudev-support2)

    Hello @coachdrd ,

    We haven’t heard from you for a few days now, so it looks like you don’t have more questions for us.

    Please feel free to re-open this ticket if needed.

    kind regards,
    Kasia

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘Pace and time calculations’ is closed to new replies.