View Issue Details

This bug affects 1 person(s).
 6
IDProjectCategoryView StatusLast Update
05023Bug reportsImport/Exportpublic2011-04-13 23:58
Reporterpmonstad Assigned ToDenisChenu  
PrioritynormalSeverityminor 
Status closedResolutionfixed 
Product Version1.91RC4 
Fixed in Version1.91RC5 
Summary05023: [GSOC] html tags in statistics Excel export
Description

When exporting to Excel the responses has a html tag left after almost every question (<br />):

Felt-sammendrag for 0002(1)
"Vurder kurset du deltok på:<br />
[Kursholders presentasjon av stoffet]"
Svar Antall Prosent
1 (lavest) (1) 3 37.50%
2 (2) 2 25.00%
3 (3) 1 12.50%
4 (høyest) (4) 0 0.00%
Ubesvart 2 25.00%
Ikke fullført eller ikke vist 0 0.00%

Felt-sammendrag for 0002(3)
"Vurder kurset du deltok på:<br />
[Kursets faglige innhold]"

TagsNo tags attached.
Attached Files
screen.png (28,816 bytes)   
screen.png (28,816 bytes)   
05023-dev.patch (5,144 bytes)   
Index: statistics_function.php
===================================================================
--- statistics_function.php	(revision 9887)
+++ statistics_function.php	(working copy)
@@ -846,15 +846,15 @@
                     4)      Average size of file per respondent
                     5)      Average no. of files
                     5)      Summary/count of file types (ie: 37 jpg, 65 gif, 12 png)
-                    6)      Total size of all files (useful if you�re about to download them all)
-                    7)      You could also add things like �smallest file size�, �largest file size�, �median file size�
+                    6)      Total size of all files (useful if you’re about to download them all)
+                    7)      You could also add things like “smallest file size”, “largest file size”, “median file size”
                     8)      no. of files corresponding to each extension
                     9)      max file size
                     10)     min file size
                  */
 
                 // 1) Total number of files uploaded
-                // 2)      Number of respondents who uploaded at least one file (with the inverse being the number of respondents who didn�t upload any)
+                // 2)      Number of respondents who uploaded at least one file (with the inverse being the number of respondents who didn’t upload any)
                 $fieldname=substr($rt, 1, strlen($rt));
                 $query = "SELECT SUM(".db_quote_id($fieldname.'_filecount').") as sum, AVG(".db_quote_id($fieldname.'_filecount').") as avg FROM ".db_table_name("survey_$surveyid");
                 $result=db_execute_assoc($query) or safe_die("Couldn't fetch the records<br />$query<br />".$connect->ErrorMsg());
@@ -1518,6 +1518,23 @@
                     $qother=$nrow[5];
                 }
                  
+                switch($outputType)
+                {
+                    case 'xls':
+                        $qquestion .= " ";
+                        break;
+                    case 'pdf':
+                        $qquestion .= " ";
+                        break;
+                    case 'html':
+                        //Add linebreak after question. To place list IDs and answer codes on a new line.
+                        $qquestion .= "<br />\n";
+                        break;
+                    default:
+
+                        break;
+                }
+
                 //check question types
                 switch($qtype)
                 {
@@ -1542,7 +1559,7 @@
                         }
 
                         //list IDs and answer codes in brackets
-                        $qquestion .= "<br />\n[".$atext."]";
+                        $qquestion .= "[".$atext."]";
                         $qtitle .= "($qanswer)";
                         break;
 
@@ -1562,7 +1579,7 @@
                             $atext=FlattenText($qrow[1]);
                         }
 
-                        $qquestion .= "<br />\n[".$atext."]";
+                        $qquestion .= "[".$atext."]";
                         $qtitle .= "($qanswer)";
                         break;
 
@@ -1583,7 +1600,7 @@
                             $atext=FlattenText($qrow[1]);
                         }
                         //output
-                        $qquestion .= "<br />\n[".$atext."]";
+                        $qquestion .= "[".$atext."]";
                         $qtitle .= "($qanswer)";
                         break;
 
@@ -1601,7 +1618,7 @@
                             $alist[]=array("D", $statlang->gT("Decrease"));
                             $atext=FlattenText($qrow[1]);
                         }
-                        $qquestion .= "<br />\n[".$atext."]";
+                        $qquestion .= "[".$atext."]";
                         $qtitle .= "($qanswer)";
                         break;
 
@@ -1625,7 +1642,7 @@
                             $atext=FlattenText($qrow[1]);
                         }
 
-                        $qquestion .= "<br />\n[".$atext."] [".$ltext."]";
+                        $qquestion .= "[".$atext."] [".$ltext."]";
                         $qtitle .= "($qanswer)";
                         break;
 
@@ -1666,7 +1683,7 @@
                             $alist[]=array($i, $i);
                         }
 
-                        $qquestion .= "<br />\n[".$fielddata['subquestion1']."] [".$fielddata['subquestion2']."]";
+                        $qquestion .= "[".$fielddata['subquestion1']."] [".$fielddata['subquestion2']."]";
                         list($myans, $mylabel)=explode("_", $qanswer);
                         $qtitle .= "[$myans][$mylabel]";
                         break;
@@ -1694,7 +1711,7 @@
                         }
 
                         //output
-                        $qquestion .= "<br />\n[".$atext."]";
+                        $qquestion .= "[".$atext."]";
                         $qtitle .= "($qanswer)";
                         break;
 
05023-dev.patch (5,144 bytes)   
05023-stable.patch (5,659 bytes)   
Index: statistics_function.php
===================================================================
--- statistics_function.php	(revision 9911)
+++ statistics_function.php	(working copy)
@@ -848,15 +848,15 @@
                     4)      Average size of file per respondent
                     5)      Average no. of files
                     5)      Summary/count of file types (ie: 37 jpg, 65 gif, 12 png)
-                    6)      Total size of all files (useful if you�re about to download them all)
-                    7)      You could also add things like �smallest file size�, �largest file size�, �median file size�
+                    6)      Total size of all files (useful if you�re about to download them all)
+                    7)      You could also add things like �smallest file size�, �largest file size�, �median file size�
                     8)      no. of files corresponding to each extension
                     9)      max file size
                     10)     min file size
                  */
 
                 // 1) Total number of files uploaded
-                // 2)      Number of respondents who uploaded at least one file (with the inverse being the number of respondents who didn�t upload any)
+                // 2)      Number of respondents who uploaded at least one file (with the inverse being the number of respondents who didn�t upload any)
                 $fieldname=substr($rt, 1, strlen($rt));
                 $query = "SELECT SUM(".db_quote_id($fieldname.'_filecount').") as sum, AVG(".db_quote_id($fieldname.'_filecount').") as avg FROM ".db_table_name("survey_$surveyid");
                 $result=db_execute_assoc($query) or safe_die("Couldn't fetch the records<br />$query<br />".$connect->ErrorMsg());
@@ -1519,6 +1519,23 @@
                     $qparentqid=$nrow[4];
                     $qother=$nrow[5];
                 }
+
+                switch($outputType)
+                {
+                    case 'xls':
+                        $linefeed = "\n";
+                        break;
+                    case 'pdf':
+                        $linefeed = "\n";
+                        break;
+                    case 'html':
+                        //Add linebreak after question. To place list IDs and answer codes on a new line.
+                        $linefeed = "<br />\n";
+                        break;
+                    default:
+
+                        break;
+                }
                  
                 //check question types
                 switch($qtype)
@@ -1544,7 +1561,7 @@
                         }
 
                         //list IDs and answer codes in brackets
-                        $qquestion .= "<br />\n[".$atext."]";
+                        $qquestion .= $linefeed."[".$atext."]";
                         $qtitle .= "($qanswer)";
                         break;
 
@@ -1564,7 +1581,7 @@
                             $atext=FlattenText($qrow[1]);
                         }
 
-                        $qquestion .= "<br />\n[".$atext."]";
+                        $qquestion .= $linefeed."[".$atext."]";
                         $qtitle .= "($qanswer)";
                         break;
 
@@ -1585,7 +1602,7 @@
                             $atext=FlattenText($qrow[1]);
                         }
                         //output
-                        $qquestion .= "<br />\n[".$atext."]";
+                        $qquestion .= $linefeed."[".$atext."]";
                         $qtitle .= "($qanswer)";
                         break;
 
@@ -1603,7 +1620,7 @@
                             $alist[]=array("D", $statlang->gT("Decrease"));
                             $atext=FlattenText($qrow[1]);
                         }
-                        $qquestion .= "<br />\n[".$atext."]";
+                        $qquestion .= $linefeed."[".$atext."]";
                         $qtitle .= "($qanswer)";
                         break;
 
@@ -1627,7 +1644,7 @@
                             $atext=FlattenText($qrow[1]);
                         }
 
-                        $qquestion .= "<br />\n[".$atext."] [".$ltext."]";
+                        $qquestion .= $linefeed."[".$atext."] [".$ltext."]";
                         $qtitle .= "($qanswer)";
                         break;
 
@@ -1668,7 +1685,7 @@
                             $alist[]=array($i, $i);
                         }
 
-                        $qquestion .= "<br />\n[".$fielddata['subquestion1']."] [".$fielddata['subquestion2']."]";
+                        $qquestion .= $linefeed."[".$fielddata['subquestion1']."] [".$fielddata['subquestion2']."]";
                         list($myans, $mylabel)=explode("_", $qanswer);
                         $qtitle .= "[$myans][$mylabel]";
                         break;
@@ -1696,7 +1713,7 @@
                         }
 
                         //output
-                        $qquestion .= "<br />\n[".$atext."]";
+                        $qquestion .= $linefeed."[".$atext."]";
                         $qtitle .= "($qanswer)";
                         break;
 
@@ -1857,6 +1874,7 @@
                         $sheet->setCellValueByColumnAndRow(0,$xlsRow,$xlsTitle);
                         ++$xlsRow;
                         $sheet->setCellValueByColumnAndRow(0,$xlsRow,$xlsDesc);
+                        $sheet->getStyleByColumnAndRow(0,$xlsRow)->getAlignment()->setWrapText(true);
 
                         $tableXLS = array();
                         $footXLS = array();
05023-stable.patch (5,659 bytes)   
Bug heat6
Complete LimeSurvey version number (& build)9797
I will donate to the project if issue is resolvedNo
BrowserAll
Database type & versioncentos 5.5
Server OS (if known)centos 5.5
Webserver software & version (if known)centos 5.5
PHP Version5.1.6

Users monitoring this issue

pasmaill

Activities

pasmaill

pasmaill

2011-03-15 21:49

reporter   ~14444

Hey there,

I'm very interested in taking part in Gsoc 2011 for Limesurvey. Here is my first attempt at getting to grips with the Limesurvey source, as well as my first contribution to open source!!! So here goes:

I've submitted 05023-dev.patch as a possible patch. I've never actually made a patch so I'm not too sure if I have done it properly, in particular my text editor seems to be disagreeing with some of the characters in line 849, 850 and 857.

As for the actual patch I removed the offending "<br />\n" from the concatenations that add on the additional text (IDs and answer codes) for questions. Then I added a new "switch case" before the "switch case" that is used to format the additional text for questions. This new "switch case" concatenates "<br />\n" on to $qquestion for the html case and a simple space for the others before the additional text is concatenated.

This rectifies the problem but I am not too sure if the format is correct, i.e. possibly there should be some consistency between the displays of the three formats. For example, the additional text should be on a new line/row for all the formats or they should simply have a space between them and the question.

I realise that I have probably over analysed this issue but first impressions do count so I'm sticking with it:)

Please let me know what you think.

Regards,
Peter

pasmaill

pasmaill

2011-03-15 22:00

reporter   ~14448

No htmlspecialchars...

Hey there,

I'm very interested in taking part in Gsoc 2011 for Limesurvey. Here is my first attempt at getting to grips with the Limesurvey source, as well as my first contribution to open source!!! So here goes:

I've submitted 05023-dev.patch as a possible patch. I've never actually made a patch so I'm not too sure if I have done it properly, in particular my text editor seems to be disagreeing with some of the characters in line 849, 850 and 857.

As for the actual patch I removed the offending "<br />\n" from the concatenations that add on the additional text (IDs and answer codes) for questions. Then I added a new "switch case" before the "switch case" that is used to format the additional text for questions. This new "switch case" concatenates "<br />\n" on to $qquestion for the html case and a simple space for the others before the additional text is concatenated.

This rectifies the problem but I am not too sure if the format is correct, i.e. possibly there should be some consistency between the displays of the three formats. For example, the additional text should be on a new line/row for all the formats or they should simply have a space between them and the question.

I realise that I have probably over analysed this issue but first impressions do count so I'm sticking with it:)

Please let me know what you think.

Regards,
Peter

DenisChenu

DenisChenu

2011-03-27 16:01

developer   ~14556

Last edited: 2011-03-27 16:10

Hello pasmaill,

I think it can be good to add a new variable : $linefeed

And switch for pdf/html/excel :)

I think excel accept \lf

Do you want to do the modifiaction with the last svn version ? I could put it to dev version after.

And please : use an utf8 editor

pasmaill

pasmaill

2011-03-27 17:23

reporter   ~14558

Last edited: 2011-03-27 17:25

Hi Denis,

My editor is set to UTF-8...??

Please find the new patch 05023-stable above.

I introduced the new variable $linefeed. \lf did not work but after some digging I found http://phpexcel.codeplex.com/discussions/32427?ProjectName=phpexcel. Thus see line 1857 for the fix. PDF is not as easy as it uses the tcpdf function "titleintopdf" (See line 1871). Not too sure how to proceed with this.

Peter

DenisChenu

DenisChenu

2011-03-27 17:50

developer   ~14559

Last edited: 2011-03-27 17:53

Great !

I test your patch and send it to svn version !

For utf8 : maybe someone else don't use utf8 ;) : i confirm i have the same problem of you :)

DenisChenu

DenisChenu

2011-03-27 19:36

developer   ~14563

fixed in 9914

Just some littlme adaptation of your patch.

Confirm for bad encoding

Issue History

Date Modified Username Field Change
2011-03-11 14:57 pmonstad New Issue
2011-03-11 14:57 pmonstad File Added: screen.png
2011-03-11 19:15 c_schmitz Summary html tags in Excel export => [GSOC] html tags in statistics Excel export
2011-03-12 13:03 Mazi Assigned To => c_schmitz
2011-03-12 13:03 Mazi Status new => confirmed
2011-03-14 23:18 dionet Issue Monitored: dionet
2011-03-14 23:18 dionet Issue End Monitor: dionet
2011-03-15 21:48 pasmaill File Added: 05023-dev.patch
2011-03-15 21:49 pasmaill Note Added: 14444
2011-03-15 22:00 pasmaill Note Added: 14448
2011-03-27 16:01 DenisChenu Note Added: 14556
2011-03-27 16:01 DenisChenu Assigned To c_schmitz => DenisChenu
2011-03-27 16:01 DenisChenu Status confirmed => assigned
2011-03-27 16:09 DenisChenu Note Edited: 14556
2011-03-27 16:10 DenisChenu Note Edited: 14556
2011-03-27 17:15 pasmaill File Added: 05023-stable.patch
2011-03-27 17:23 pasmaill Note Added: 14558
2011-03-27 17:25 pasmaill Note Edited: 14558
2011-03-27 17:50 DenisChenu Note Added: 14559
2011-03-27 17:53 DenisChenu Note Edited: 14559
2011-03-27 18:30 pasmaill Issue Monitored: pasmaill
2011-03-27 19:36 DenisChenu Note Added: 14563
2011-03-27 19:36 DenisChenu Status assigned => resolved
2011-03-27 19:36 DenisChenu Fixed in Version => 1.91RC5
2011-03-27 19:36 DenisChenu Resolution open => fixed
2011-04-13 23:58 c_schmitz Status resolved => closed
2021-08-03 07:59 guest Bug heat 4 => 6