2

I want to build a very simple linear survey with multiple choice questions.

Each answer will be assigned a numeric value and I was hoping to pass that value via segment variables.

So at the end of the survey I could do something like:

segment_1 plus segment_2 plus segment_3

= (value)

e.g mysite.com/template/01/08/09

would give a numeric value of 18

And then use that value to conditionally display another template.

Is this possible, advisable or just plain crazy?

Thanks.

3

Theoretically it is possible.

  • IF you are on EE 2.9+ you can use Mathematical Operators in your conditionals. (Thanks Derek for reminding me about that!)
  • If you are using a version below EE2.9 you would need to use something like MX Calc to calculate the totals and then use that to call an embed to get around parse order issues.

Having said that is probably not the best approach because EE only allows you to have 10 segments so your test could only have 10 questions (more likely 8 if you have a template_group/template structure already in place).

You would be better off either doing the calculation when the user submits the form and appending the total value to the url or better yet determine the template you want to display and change the redirect value to that based upon the total.

Another option would be submitting the form and then using something like Mo Variables to grab the POST data on the next page.

2
  • FYI, Mathematical operations are supported in conditionals. – Derek Jones Feb 2 '15 at 21:29
  • Ahh I forgot about that being added in 2.9 and have updated my answer to reflect – Justin Long Feb 2 '15 at 21:31
1

Yes. The rest of this answer is to meet the minimum 30 character requirement. ;)

2
  • Derek, hi! Instead of add useful info on another answer, please edit Justin's one and improve it. I'm sure he doesn't mind. – Sobral Feb 2 '15 at 22:30
  • Justin, Derek, Thank you very much for your help. I was able to get the required functionality using MX Calc -for some reason I couldn't get it to work using normal math operations even though I'm using EE 2.9.2. As regards having limited segments to work with, I've got around that by using the last segment variable which just keeps a tally of the "score" allowing me to pull the final value from the last segment and use it within a conditional. It's a actually a very simple but powerful solution that I can see having lots of possibilities. Thanks again. – Frequency Feb 3 '15 at 18:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.