Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 492
  • Last Modified:

how do I post a feedback message on a drupal form

I have a webform where I want to add up the score for the selections made on the form, e.g. the user gets from 1 to 5 points for each answer, and give the user a message based on his score.  I thought about using a markup field on the webform, but it seems that I cannot set the value of a markup field.  

I set up the webform and I know that I can write the code in the 'additional processing' for the form.  

How do I access the field values to add up the score and more importantly,
How can I display the feedback after the user hits submit.  I want to give them their score and a message like 'great job' or 'needs improvement'.
0
d2fox
Asked:
d2fox
  • 5
  • 4
1 Solution
 
Thomas4019Commented:
I've never used webform before, I'm more a fan of CCK myself, http://drupal.org/project/cck.

I know with CCK and Rules you could process a submission and deliver conditional messages.
http://drupal.org/project/rules
0
 
d2foxAuthor Commented:
I don't know how to set up a form in cck.  Are you saying it won't work well in webform?
0
 
Thomas4019Commented:
What exactly are you trying to do, CCK is definitely more powerful that webform, but if you are trying to collect data in a survey like fashion the webform is easier.

Rules could work with webform but not easily, http://drupal.org/node/474644.

Again, if you explain what you are trying to do as a whole, i can tell you what way would be easiest.
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
d2foxAuthor Commented:
I have 10 questions that the user has to answer 'yes / maybe / no'.  For each of the 'yes' answers, they get 1 point.  5 points gets them a 'you are doing ok' result, 8 or more gets them a 'great job', less than 5 gets them a 'you need to work on improving'.


That's it.  I have the form, need to figure out the code.

Thank you.
0
 
Thomas4019Commented:
sounds like either CCK or webform will work great.

If you're going to do any PHP coding in Drupal, you will want the module Devel installed so that you can call the function dpm(). See this guide, http://blog.anselmbradford.com/2009/03/14/2-invaluable-drupal-development-tips-list-all-available-variables-and-backtrace-a-page/.

Once you find out how to access the fields (which the above link should show you how), then you can use drupal_set_message() to show a box on the next page with a configurable message, http://api.drupal.org/api/function/drupal_set_message/6.
0
 
d2foxAuthor Commented:
so I can set the message, but it shows with the normal form submission and doesn't stand out.  It's in a yellow box with the message 'thank you, your sumission has been received' below it.  How can I remove that message and make mine more prominent?
0
 
Thomas4019Commented:
Cool, looking at this,http://api.drupal.org/api/function/drupal_set_message/6, there's an optional second parameter where you can set the type. If you set it to 'warning'  or 'error' it should stand out more.

Also look at this post, http://drupal.org/node/214389.

It looks like calling drupal_get_messages() will clear any messages that have been set.

Good luck,
Thomas Hansen
0
 
d2foxAuthor Commented:
hmmm, can't seem to get rid of the system generated messages.  I still get my message, then

Thank you, your submission has been received.
You have already submitted this form. View your previous submissions.

I put this in the 'additional processing':  

drupal_get_messages();
drupal_set_message('This is my message.','warning');
0
 
Thomas4019Commented:
That must mean Webform is displaying that message after is displaying it's message after your custom PHP code.

Well, a hackish way of solving this might be to use string overrides, http://drupal.org/project/stringoverrides,  to replace that text, "Thank you, your submission has been received." with nothing.

Or if you want to be REALLY hackish delete line 2005 from webform.module in the webform folder. This get's annoyting because you'd have to re-delete that line everytime you upgrade.

It's actually not that hard to make forms with a custom module using the forms api, http://drupal.org/node/751826. You could do that instead of webform which would give you near infinite flexibility.
0
 
TheChemicCommented:
If this were my project...

I would create separate pages/nodes for each message.

Node: Great Job
           You did really good, bla bla bla

Node: You did okay
           Sounds like you're an average person, bla bla bla

Node: You could use some improvement
          Dude, you kinda sucked man, bla bla bla

etc..

Then, I would use rules to forward the user to each individual page/node based on their score.  Since this would be a FULL PAGE, it would not appear tiny and you could customize it's appearance in any way you like.  I often use rules and custom landing pages depending on user actions.  It works great for me.
0

Featured Post

[Webinar On Demand] Database Backup and Recovery

Does your company store data on premises, off site, in the cloud, or a combination of these? If you answered “yes”, you need a data backup recovery plan that fits each and every platform. Watch now as as Percona teaches us how to build agile data backup recovery plan.

  • 5
  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now