Please Note: We are no longer using forums to facilitate standard support. All support issues will be handled via email using our support ticket system. For more detailed information on this change, please see this blog post.

Simple Calculations

  1. Following-up after Chris Hajer's suggestion to create a unique post. Ultimately, what I'm trying to do, and what I believe is a starting point for the solution is documented in the link/thread below that I copied and included below:

    I know some time has elapsed since you last responded to this post, but I was hoping to get your thoughts on something of an extension of this example. I have a pretty basic quiz (30-questions) with each item on the quiz having a possible value between 1 and 10. What I'd like to do is to use a required numeric (number field) to capture the totals.

    Currently I have the quiz paginated (10 questions per section) but it doesn't have to be that way. My goal would be to provide a section score (if I can use pagination) and an aggregate score (upon submission of the form).

    The end-user could then (manually) compare against a range to see how they stack up (e.g. you scored 250, see the chart below to see what this means) or ideally I'd do that programmatically as well (you scored 250 that means you are awesome) - and it looks like your logic would get me most of the way, but with a possible scoring range between 30 and 300, it could be a pretty daunting/messy task to write the case logic, at least the way you have it in your code.

    Here is the link to the work-in-progress:

    And here is the original link to what I think is the solution and my first post, suggesting that I post here:

    Any thoughts or ideas?

    Posted 4 years ago on Tuesday September 13, 2011 | Permalink
  2. Chris, Carl, anyone?

    I'm just posting on this to keep it close to the top so it doesn't get sunk. I was really hopeful that one of the admins can point me in the right direction. Based on the great support and previous answers ( I thought this may be comparatively easy. Not looking for a perfectly baked solution, just a few ideas / code chunks to get me moving in the right direction.


    Posted 4 years ago on Tuesday September 13, 2011 | Permalink
  3. Dave, I will work on this customization today and see how complex it's going to be. Forum support requests take priority over customizations and custom applications such as this, so I appreciate your patience. Thanks.

    Posted 4 years ago on Wednesday September 14, 2011 | Permalink
  4. With a possible score between 30 and 300, what are the ranges of awesomeness? It is something like

    30-59: you're terrible
    60-89: room for improvement
    90-119: getting warm
    120-149: you have some value
    150-179: we might consider hiring you
    180-209: we'd like to talk to you
    210-239: can you come in today?
    240-279: would you like my job?
    280-300 you're the best

    Are there 10 possible ranges maybe? If so, then it's just 10 cases in the final page.

    If you want to do something per section, you multiply the amount of work by the number of sections (so, 10 sections is 10x the work of just doing the summary score.) And in addition to the section score (you scored 18 on the previous section. That means "this") would you want a running total on each section? (that also complicates things quite a bit. - so it would be something like a running total number of point, AND the previous section total.)

    I will post a solution for you to get the total after form submission. Let me know how many ranges their are and what the point ranges are.

    Please also export your form and email it to me at so I have something relevant to start with. Thank you.

    Posted 4 years ago on Wednesday September 14, 2011 | Permalink
  5. Chris,

    First and foremost, you rock! Thanks for taking time to help me out on this. I suspect others will ultimately benefit as well...

    Let me answer the scoring question first. 4 possible cases with ranges as defined below

    226 - 300 points: If you have more than about 240 points, please call us, because we want to feature you on the blog as an example of a courageous organization. Nice job.

    151 - 225 points: Your organization is well on the way to being courageous! You can freely concentrate on the areas that scored lower than others.

    76- 150 points: Not a bad start. Pay close attention to which of the three areas (or particular questions) scored highest and lowest. Can you do more of the bright spots? Can you scrap some things that are completely not courageous?

    0 - 75 points: This score assumes that you probably have “lack of courage” issues in all three areas of culture, process, and behavior. You’ll need to pick your battles and figure out where you can concentrate your efforts at first.

    Ideally I'd like to display the section score (at the bottom of each section - and possibly available as a variable for emailing and confirmation page display) and then the aggregate score at the end / via email (I hope that makes sense).

    Ultimately I think everything else should be relatively straight-forward.

    Look for an email with the form export attached it will be coming from desabol at gmail dot com

    Thanks again,

    Posted 4 years ago on Wednesday September 14, 2011 | Permalink
  6. I received your email and will take a look a that later today. You only have 4 ranges there which should be pretty easy. Displaying the aggregate score and individual section score, throughout the form, would require more customization. I'll start with the easy stuff first.

    Posted 4 years ago on Wednesday September 14, 2011 | Permalink
  7. auinteractive

    Crazy. This is exactly what I am trying to help a friend out with. Looking forward to a solution too. :D Could we make this learning lesson for everyone?

    Posted 4 years ago on Wednesday September 14, 2011 | Permalink
  8. I'll do my best; tonight :-)

    Posted 4 years ago on Wednesday September 14, 2011 | Permalink
  9. auinteractive

    Chris - You are the man.

    I need to mod whatever code you are going to put out to spit out 3 different values for 3 different categories.

    Shouldn't be too difficult.

    Posted 4 years ago on Wednesday September 14, 2011 | Permalink
  10. Chris...I said it before and I'll say it again. You rock!

    Nick...while I had a personal need for a project that I'm working, I'm really psyched that you might benefit as well. That was a secondary, but very important, reason for asking.

    I can't wait! Even an 50% solution is a huge win. I can probably take it the rest of the way, but I suspect that Chris will get us a whole lot further!

    GravityForms has to be one of the best, if not THE best WP plugin. Combined with the support I'm betting on the fact that the team here could be one of my favorite companies that I work with. Truly top-notch!

    Posted 4 years ago on Thursday September 15, 2011 | Permalink
  11. Here's some code:

    I took your XML form, and added 4 hidden fields:

    • Courage subtotal
    • Process subtotal
    • Behavior subtotal
    • Overall total

    I added them to the end of the form, so they're fields 38, 39, 40 and 41. I added these to the form so we can store the values there and possibly use them later.

    The confirmation message in the form builder is not being used. It's all set in functions.php. Please note there are two functions here, one for gform_pre_submission (to calculate and store the subtotals) and one for gform_confirmation (to change the confirmation message.)

    Please post if you have any questions or need further explanation. All the field IDs should match your form. The form ID will need to be changed on two lines, line 3 and line 44. You could change it in line 48 as well, for accuracy.

    This can certainly be extended to use these values in other places. Hopefully this will be a good start for you.

    Posted 4 years ago on Thursday September 15, 2011 | Permalink
  12. Chris,

    This is better than a good start! It's a great start and exactly what I suspect was possible. You've given me exactly enough of a head-start that extending the functionality will be a breeze. I can't say thanks to you and the entire team enough.

    You all rock!

    Posted 4 years ago on Thursday September 15, 2011 | Permalink
  13. Glad that helps. If you need any additional assistance, please let us know.

    Posted 4 years ago on Friday September 16, 2011 | Permalink

This topic has been resolved and has been closed to new replies.

Support Tickets

Open A New Support Ticket
 Open A New Priority Support Ticket *

* Developer license holders only