Hi, I have a select field (multiple selection/listbox). The report works fine but when I download the csv file, the values are not correct. Please look at the images, let me know if this is something that can be fixed. thanks.

CommentFileSizeAuthor
#1 945398.patch1.84 KBjimbullington
data-csv.jpg38.69 KBluthien
data-report.jpg49.61 KBluthien

Comments

jimbullington’s picture

StatusFileSize
new1.84 KB

Please try the attached patch - this should process multi-selects correctly.

jimbullington’s picture

Status: Active » Needs review
luthien’s picture

Hi Jim, I think I was wrong. The csv file was displaying the values correctly (6.x-2.0-beta5 + patch)

Example:

12687,"17976,11706,11485,10963,16784,10964","16789,7373,16784,20811"
16789,"2372,11706,21213,10963,10568,16784","17976,11485,11798,10553,10964,22609"
10553,"2372,11706,10964,16703,11459,11798,4924,10963,16789,21204,21162","16703,11798,10963,21162"

The error was when I opened the csv file using MS Excel, the keys were all wrong like the images from my initial post. Could you please look at it using the example above? any other reports opens correctly in excel, only multi-select fields are failing. thanks.

By the way, if I specify "display value" for the format and option fields, no values are displayed. The table only displays results is I use "display key" instead. My selects were all dynamically generated but I don't think that is the problem as your results displays the values correctly with the key.

jimbullington’s picture

I don't think it was working before BETA5 + patch.

The best way to import "tricky" CSV files into Excel is to use Get External Data:

  1. Open a blank spreadsheet
  2. Click Data, Get External Data, Import Text File
  3. Pick your csv file - you'll probably have to change "Files of Type:" to (*.* All Files)
  4. The Text Import Wizard should start - choose delimited for the file format
  5. Next, choose comma as a delimiter
  6. Next, you have to tell it what format the columns are - for the multi-select columns, choose Text, otherwise it will import them as a long number. Click on each column to specify.

Using the above, I was able to import your example as a three column spreadsheet.

I hope this helps.

jimbullington’s picture

Sorry, forgot to respond to the second part - what do you mean by My selects were all dynamically generated ?

Also, what version of Webform are you using? There may have been some changes in select handling between webform versions.

luthien’s picture

I'm using the "Load a pre-built option list" to display the multi-select list, with options that were dynamically generated using PHP.

beta5 + patch generated the right csv.

For Excel, I was using the "general" format, changing columns to "text" was the solution, thanks.

You can update the issue to fixed as the patch solved the problem.

jimbullington’s picture

Version: 6.x-2.0-beta4 » 6.x-2.0-beta5

Thank you for the feedback.

However, I am still concerned about the other issue you raised:

By the way, if I specify "display value" for the format and option
fields, no values are displayed. The table only displays results is I
use "display key" instead. My selects were all dynamically generated but
I don't think that is the problem as your results displays the values
correctly with the key.

Is this still a problem? Can you provide more information? What version of Webform are you using?

luthien’s picture

oh yes, that is still an issue for me. I'm using the following:

Webform 6.x-3.4
webform report 6.x-2.0-beta5

I'm looking at the webform-results/table and I'm noticing that sometimes the key is displayed and others the value. Maybe that is causing the problem with the display of the values for webform report. If I select "values" for another form, it either displays nothing or displays the key. For this post's example, it displays just commas, empty fields. Maybe my form is so unique that I'm introducing some new scenarios that were not planned when the modules were created.
For example, one of the dynamic select was created based on dates queries. Once the date is out of specified range, those previous values won't be part of the select options; although any submissions using those values should be saved. Please send me an email and I will show you an example if you need to look at this particular web form.

jimbullington’s picture

Looks like select handling in webform 3.x has changed. Can you try the following in webform_report.inc? It should be at line 230.

        // Get mapping for select lists (Start)
        if ($col['type'] == 'select') {
          // get component info
          $result = db_query("SELECT c.extra FROM {webform_component} c WHERE c.nid = %d AND c.cid = %d", $node->wnid, $col['cid']);
          $r = db_fetch_object($result);
          $extra = unserialize($r->extra);
          // load the webform select component handler
          module_load_include('inc', 'webform', 'components/select');
          // detect webforms 3.x and handle 
          if (function_exists('_webform_select_options_callback')) {
            // make a webform "component"
            $wfcomp['extra'] = $extra;
            // get select options
            $columns[$index]['pairs'] = _webform_select_options($wfcomp);
          }
          // get options from webforms 2.x
          else {
            if (strpos($extra['items'],'|')){
              $columns[$index]['pairs'] = array();
              foreach (explode("\n",$extra['items']) as $pair){
                list ($k,$v) = explode ('|',$pair);
                $columns[$index]['pairs'][$k] = $v;
              }
            }
          }
        }
        // Get mapping for select lists (End)
luthien’s picture

Thanks a lot for the prompt replies and solutions to the problems. The code from #9 fixed the problem partially. The values are now correctly displayed for one of the selects but the other one only works with the keys. If I select values for all, I get the "There are no submissions that match the criteria for the selected webform. ", maybe there is a conflict with the patch for the search filter?

Note: Your module is generating the reports perfectly fine, while I'm getting errors using the webform-results/table functionality from the webform module itself (http://drupal.org/node/975000).

If you add chart capabilities plus other minor features to the module that will be extremely useful for all. Thanks again!

jimbullington’s picture

I would like to revisit this when you have time:

... The code from #9 fixed the problem partially. The values are now correctly displayed for one of the selects but the other one only works with the keys. If I select values for all, I get the "There are no submissions that match the criteria for the selected webform. ", maybe there is a conflict with the patch for the search filter?

There should not be a conflict with the search filter.

Can you clarify or post some examples of: "but, the other one only works with the keys" and "If I select values for all, I get..."

Thank you for your continued feedback.

luthien’s picture

Hi, I just tested and it works fine, you might close the issue. Thanks!

*out of topic but something to think about it: it will be great to be able to filter reports and to assign permissions per role to see certain part of the report, kind of granularity support for the search results. Instead of creating several reports, one for each user, where the search term is a specific key; imagine creating a single report and by passing the key via url to be able to obtain results for that particular user. One user sees only part of the report, the one related to his key; while another user can only access his part of the report.

an example I just made up:

Report #1: List all people that belongs to a club and order by country.
Report #2: List only those who are from US
Report #3: List only those who are from Mexico
Report #4: List only those who are from UK
etc...

instead of creating many reports, one for each country for example, and assigning permission to users to see only the report for their respective country; what about using report #1 for everybody and somehow filtering the key to display the report to that particular user or role? user1 can not see report for user2 or user3, only his assigned report. This feature is good for sensitive info that only certain users can see. Having reporting tool that reduces maintenance time by designing a single report instead of more than x number of reports, to achieve the same goal, will be nice to have. I will think about it but perhaps you have already considered this possibility.

jimbullington’s picture

Status: Needs review » Fixed

Thank you for the review.

As far as the other request, you might look here - we have been working on token support for module.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.