View Issue Details

This bug affects 1 person(s).
 4
IDProjectCategoryView StatusLast Update
05439Bug reportsSurvey takingpublic2011-09-07 09:16
Reporterronvdburg Assigned Toc_schmitz  
PriorityhighSeveritypartial_block 
Status closedResolutionfixed 
Product Version1.91+ 
Fixed in Version1.91+ 
Summary05439: {TOKEN:ATTRIBUTE_1} is not replaced everywhere
Description

I used {TOKEN:ATTRIBUTE_1} in the question text.
This works properly when taking a survey.
This works properly when printing (printanswers.php).

However, the token attribute replacement is NOT done in exporting the answers to pdf (PDF Export).

Steps To Reproduce

Make sure you have a survey with at least 1 (user defined) attribute.
Change a question text containing {TOKEN:ATTRIBUTE_1}.
Make the survey active & closed.
Create a token entry and add a proper text to the Token's attribute 1.
Take the survey and see:
= The question text properly replaces {TOKEN:ATTRIBUTE_1} with the proper text.
Now finish the survey and press submit.
Do print the survey and verify:
= The (html version) of the printable survey replaces properly.
= The PDF version shows {TOKEN:ATTRIBUTE_1} in stead of replacing it.

Additional Information

Could you please have repaired this today, my customer wants to send out the survey tomorrow.

If not possible, can you give me a hint to fix it myself (and uploading the patch)?

I see there exists a tokenReplace function in replacements.php.

TagsNo tags attached.
Attached Files
printanswers.php.svn-diff.txt (1,453 bytes)   
Index: printanswers.php
===================================================================
--- printanswers.php	(revision 10920)
+++ printanswers.php	(working copy)
@@ -224,7 +224,7 @@
     {
         if(isset($_POST['printableexport']))
         {
-            $pdf->intopdf(FlattenText($fname[0].$fname[1],true).": ".$fname[2]);
+            $pdf->intopdf(FlattenText(tokenReplace($fname[0].$fname[1]),true).": ".$fname[2]);
             $pdf->ln(2);
         }
         else
Index: admin/printablesurvey.php
===================================================================
--- admin/printablesurvey.php	(revision 10920)
+++ admin/printablesurvey.php	(working copy)
@@ -779,7 +779,7 @@
             $question = array(
 					 'QUESTION_NUMBER' => $total_questions	// content of the question code field
             ,'QUESTION_CODE' => $deqrow['title']
-            ,'QUESTION_TEXT' => preg_replace('/(?:<br ?\/?>|<\/(?:p|h[1-6])>)$/is' , '' , $deqrow['question'])	// content of the question field
+            ,'QUESTION_TEXT' => preg_replace('/(?:<br ?\/?>|<\/(?:p|h[1-6])>)$/is' , '' , tokenReplace($deqrow['question']))	// content of the question field
             ,'QUESTION_SCENARIO' => $explanation	// if there are conditions on a question, list the conditions.
             ,'QUESTION_MANDATORY' => ''		// translated 'mandatory' identifier
             ,'QUESTION_ID' => $deqrow['qid']    // id to be added to wrapping question div
printanswers.php.svn-diff.txt (1,453 bytes)   
Bug heat4
Complete LimeSurvey version number (& build)10746
I will donate to the project if issue is resolvedNo
Browser
Database type & versionmysql 14.12
Server OS (if known)Centos 2.2.3 (Linux version 2.6.18-194.3.1.el5)
Webserver software & version (if known)Apache/2.2.3 (CentOS)
PHP Version5.1.6

Users monitoring this issue

There are no users monitoring this issue.

Activities

c_schmitz

c_schmitz

2011-09-01 18:51

administrator   ~16188

Hi ronvdburg

are you a donator?

ronvdburg

ronvdburg

2011-09-01 19:29

reporter   ~16191

No, not with money, but I donate all the patches that I need (and are paid) by my customer.

c_schmitz

c_schmitz

2011-09-01 21:22

administrator   ~16192

ok, will have a look

ronvdburg

ronvdburg

2011-09-02 14:01

reporter   ~16208

Hi Carsten,

I found the issue and repaired it for my survey.
The patch is uploaded. Indeed it was so easy that I am ashamed that it took me so long.

The patch only does a tokenReplace in the question text; if you would like to also replace token fields elsewhere (e.g. the Group text), please let me know and I will send a new patch / svn-diff.

Regards,

Ron

c_schmitz

c_schmitz

2011-09-02 17:27

administrator   ~16215

Thank you. No further patch is needed for that because the replacement functions will be completel rewritten in the next version.

c_schmitz

c_schmitz

2011-09-07 09:16

administrator   ~16242

New version released

Issue History

Date Modified Username Field Change
2011-09-01 16:11 ronvdburg New Issue
2011-09-01 18:51 c_schmitz Note Added: 16188
2011-09-01 18:51 c_schmitz Assigned To => c_schmitz
2011-09-01 18:51 c_schmitz Status new => feedback
2011-09-01 19:29 ronvdburg Note Added: 16191
2011-09-01 19:29 ronvdburg Status feedback => assigned
2011-09-01 21:22 c_schmitz Note Added: 16192
2011-09-02 13:57 ronvdburg File Added: printanswers.php.svn-diff.txt
2011-09-02 14:01 ronvdburg Note Added: 16208
2011-09-02 17:27 c_schmitz Note Added: 16215
2011-09-02 17:27 c_schmitz Status assigned => resolved
2011-09-02 17:27 c_schmitz Fixed in Version => 1.91+
2011-09-02 17:27 c_schmitz Resolution open => fixed
2011-09-07 09:16 c_schmitz Note Added: 16242
2011-09-07 09:16 c_schmitz Status resolved => closed