I would like to know how to create a counter after a grid component so as to have a score for theses questions. For example, for each "X" in the array, the counter will be the same if the "X" is in the first column, +1 if it's in the second column...

My problem is principally i don't know how to find the number of the colum with the "X".

Thanks for you help

CommentFileSizeAuthor
#3 Doc2.pdf46.2 KBvenezia

Comments

jimbullington’s picture

Status: Active » Postponed (maintainer needs more info)

Sorry, I'm not following you. Perhaps you could attach some screen shots to illustrate your problem further.

roderik’s picture

I just tested a grid element, for another patch.
I had 5 questions (rows) defined, and the 4 columns (possible answers) have keys 'gridkey1' to 'gridkey4'.
I checked 2 answers and left the rest empty.
Here's an extract of the element's data from my {webform_submitted_data} table:

nid     sid     cid     no      data
1842	1881	11	gridq1	
1842	1881	11	gridq2	gridkey2
1842	1881	11	gridq3	
1842	1881	11	gridq4	
1842	1881	11	gridq5	gridkey4

Answers are in the 'data' field, the questions are in the 'no' field. Also those without an answer.

This tells me that an SQL statement to do what you want, would be something like
SELECT [...], COUNT(d.no) FROM webform_submitted_data d WHERE [... AND] d.cid={cid for your grid element} GROUP BY [...], d.data

I don't know if that helps you...
This doesn't have much to do with the Webform Report module. This module lacks any proper support for 'grid elements' until now.

venezia’s picture

StatusFileSize
new46.2 KB

I'm sure that I will need to use this kind of SQL Statement.

I have a grid in which each column is a value and I want a new line that just display the total. (see picture, in this case I would like to display "total: 5")

Where should I had the code?

Thank you

roderik’s picture

Oh, you want to sum all different column values? Then don't group it, just get one number with

SELECT [...], SUM(CAST(d.data AS DECIMAL)) FROM webform_submitted_data d WHERE [... AND] d.cid={cid for your grid element} AND d.nid={your webform node}

I don't know where you should "had" the code. This seems too specific to put into the module, so you'll probably just want to get your own data & build your own HTML fragment to output, for this specific node.

...which you can do in nook_nodeapi('view') in a custom module (stick things in $node->content)
... or somewhere in a node-*.tpl.php / preprocess function in your theme. Most site builders probably prefer this. (There may also be other ways...)