View Issue Details

This bug affects 1 person(s).
 10
IDProjectCategoryView StatusLast Update
20114Bug reportsExpression Managerpublic2025-09-19 10:14
ReporterMazi Assigned Toadamzammit  
PrioritynoneSeverityblock 
Status assignedResolutionopen 
Product Version6.6.x 
Summary20114: queXML export doesn't replace EM placeholders
Description

When enabling the "Print answers" feature at a survey, there is a "Export to queXML PDF" button shown. When exporting the given data set to queXML, EM placeholders do not get replaced and the export looks weird - actually you can not really use it, see attached screenshot.

Steps To Reproduce

Steps to reproduce

Import and activate the attached survey.
Run the survey.
Click "Print answers" link at the thank you page.
Use queXML PDF export.

Expected result

Replace EM placeholders for given data set.

Actual result

Unreadable EM syntax is still shown

TagsNo tags attached.
Attached Files
image.png (42,910 bytes)   
image.png (42,910 bytes)   
limesurvey_survey_654535.lss (1,410,168 bytes)
Bug heat10
Complete LimeSurvey version number (& build)6.13.3
I will donate to the project if issue is resolvedNo
Browser
Database type & versionMariaDB 10.1.48
Server OS (if known)
Webserver software & version (if known)
PHP Version8.2

Relationships

related to 20139 closedadamzammit Export as QueXML with debug 2 and 8.3.22 : throw error 

Users monitoring this issue

There are no users monitoring this issue.

Activities

Mazi

Mazi

2025-05-20 10:36

updater   ~82713

@adamzammit, not sure if you usually deal with such queXML stuff?!

adamzammit

adamzammit

2025-05-21 04:16

developer   ~82727

thanks @Mazi. Yes queXML is my area.

If the user wants the queXML PDF export at the "print answers" functionality just for seeing their web responses on a form, it does make sense to execute/replace all the EM code.

But if the user is using it to produce a semi-filled form to later use queXF to process the paper form, then processing the EM will likely break the form's compatibility with queXF as the variable nature will change the layout of the pages.

I'm happy to make a change to execute the EM code, but my preference would be for it to be a configuration option that isn't the default. Would that suit you?

Adam

Mazi

Mazi

2025-05-21 10:01

updater   ~82728

@adamzammit, I fully agree. This adjustment only makes sense for writing a single data set as PDF. We should be able to differentiate this from the other use cases so it would be great if you could look into this.

Mazi

Mazi

2025-06-11 12:15

updater   ~82863

@adamzammit, is there any news regarding a fix for this issue? The user is asking because they want to run a large study at the end of the month.

adamzammit

adamzammit

2025-06-12 05:19

developer   ~82866

thanks for checking in @Mazi.

I've run into a bit of a roadblock. Processing EM for a response currently relies on the survey session being set.

I can get it to process the EM for things like this {rand(0,100)} but for prefills response data I'm not sure if this can be done without messing around with session data

Mazi

Mazi

2025-06-12 09:29

updater   ~82867

@adamzammit, I think there is no other way then generating the session data for the given data set ID. But maybe @DenisChenu has some ideas on how to deal with this?

DenisChenu

DenisChenu

2025-06-12 11:13

developer   ~82868

Last edited: 2025-06-12 11:13

I've run into a bit of a roadblock. Processing EM for a response currently relies on the survey session being set.

It's the case when you came for Print answers after survey done. Maybe check if session is set, if yes : use Expresssion manager.
If not : do not use it.

https://github.com/LimeSurvey/LimeSurvey/blob/edc725d17768264e547d17c4ddd32c9306e37d67/application/controllers/PrintanswersController.php#L51

I think there is no other way then generating the session data for the given data set ID. But maybe @DenisChenu has some ideas on how to deal with this?

https://gitlab.com/SondagesPro/RemoteControl/RemoteManageResponse/-/blob/main/RemoteControlHandler.php?ref_type=heads#L193
and the older one
https://gitlab.com/SondagesPro/coreAndTools/reloadAnyResponse/-/blob/master/reloadResponse.php?ref_type=heads#L55

adamzammit

adamzammit

2025-06-18 07:00

developer   ~82893

hi @Mazi can you give this change a test and see what you think.

https://github.com/LimeSurvey/LimeSurvey/compare/master...adamzammit:LimeSurvey:fix-20114

adamzammit

adamzammit

2025-06-19 07:58

developer   ~82907

@DenisChenu - please reset the queXMLPDF export settings to default. This is unusual and I do not think it is related to this bug.

DenisChenu

DenisChenu

2025-06-19 08:58

developer   ~82908

@adamzammit : where i reset it ?

adamzammit

adamzammit

2025-06-24 05:07

developer   ~82935

Hi @DenisChenu: please go to the main export menu, choose queXML PDF export, then at the bottom of that page press the red "Reset Now" button.

DenisChenu

DenisChenu

2025-06-24 08:20

developer   ~82937

@adamzammit via discord :(

Mazi

Mazi

2025-06-30 10:24

updater   ~83012

@DenisChenu, have you been able to test the fix?

Mazi

Mazi

2025-07-03 15:24

updater   ~83017

@adamzammit, we replaced the two edited files at a 6.13 version but at our initial testing the placeholders have NOT been replaced. We may have done something wrong though... any hints on what else we should consider?
Which survey and LS version should we best test with?

DenisChenu

DenisChenu

2025-07-03 15:46

developer   ~83018

  1. It work only for question : maybe add it for subquestions and answers (see survey attached)

But : the worst part : a big issue

  1. Do the survey and enter "current" in question
  2. Print as QueXML : OK
  3. Go to browse response
  4. Click on 1st tool line, export as QueXML

Wait : Not update text OR updated with 1st response
Have : text updated by last response.

My opinion LimeExpressionManager::ProcessStepString must be done only for particpânt print, not for admin print.

Maybe create a Feature Request to have a integrated way to start a survey by LimeSurvey core API after and use it here.

589315-4-queXML.pdf (4,507,712 bytes)
Mazi

Mazi

2025-07-03 15:53

updater   ~83019

@DenisChenu, "add it for subquestions and answers" is exactly what we were missing. At our example, sub-questions were using placeholders as can be seen at the screenshot we had added. So this still doesn't work.

bismark

bismark

2025-07-03 16:00

reporter   ~83020

Here is a minimum survey that shows the problem in concrete terms. It takes me almost 2 minutes to generate the PDF. I have applied Adam's commit as a patch, but I get the same result as before

https://github.com/LimeSurvey/LimeSurvey/commit/f2d90f065573a6141ed81d509d328541e1e20fbf.patch

237912-1-queXML-2.pdf (5,182,860 bytes)
DenisChenu

DenisChenu

2025-07-03 16:07

developer   ~83021

The lsa i upload is a 3 question for demonstration .

With replacement on question, subquestion and answer text

Mazi

Mazi

2025-07-08 21:38

updater   ~83043

@adamzammit, the fix for question texts looks promising. But we need the same for sub-questions and answer texts as well. These also contain placeholders quite often.
Can you give it a try?

Mazi

Mazi

2025-07-20 05:59

updater   ~83112

@adamzammit, any chance to look into this?

Mazi

Mazi

2025-08-18 18:25

updater   ~83240

@tibor.pacalat, what should we do with this half-baked solution? Maybe @DenisChenu can finish this task?

adamzammit

adamzammit

2025-08-19 05:01

developer   ~83241

Apologies @Mazi this fell off my radar. I will be able to spend some more time on this in the coming week. Can you confirm that the main use case you are looking at is ensuring the replacements happen at the "Print answers" stage (i.e on completion of the web survey). This should be more straightforward to implement in the first instance.

Mazi

Mazi

2025-08-19 10:20

updater   ~83242

@adamzammit, thanks for getting back. You are right, when enabling the "Print answers" feature at a survey, there is a "Export to queXML PDF" button. For that feature we also need to add replacing placeholders for subquestions and answers based on the current session data for this data set.

Mazi

Mazi

2025-08-28 20:59

updater   ~83338

@adamzammit, is there anything we can contribute to help implementing this? A customer will start a new project with placeholders soon and needs this fix.

Mazi

Mazi

2025-08-28 21:00

updater   ~83339

We could also manually backport a new fix to their system for further testing with their survey draft if this helps.

adamzammit

adamzammit

2025-09-02 04:26

developer   ~83349

I have updated the branch to support only processing EM when using the print answer function, and also supporting more replacement targets. Please let me know how you go with this patch:

https://github.com/LimeSurvey/LimeSurvey/compare/master...adamzammit:LimeSurvey:fix-20114

Adam

bismark

bismark

2025-09-04 14:11

reporter   ~83365

I locally installed https://github.com/adamzammit/LimeSurvey/tree/fix-20114
I imported my relevant survey.
I had to switch to php 8.0, because of a CURL error.
I had to reduce the amout of questions (timeout)
I exported the survey to queXML-PDF, the form appears -> submit
The result is same as before - no LimeExpressionManager-replacements

bismark

bismark

2025-09-04 14:17

reporter   ~83366

I executed the survey.
I downloaded the queXML-PDF
same result -> no LimeExpressionManager-replacements

adamzammit

adamzammit

2025-09-05 02:23

developer   ~83369

Hi @bismark - I don't have any of the timeout errors that you are having. The form generation is very fast. Do you know how much memory is allocated to PHP?

I am also able to generate both the regular queXML PDF export (attached as a ZIP file here) and also after completing the survey, the fields are processed as expected (see attached testumfrage-237912-queXML.pdf)

quexmlpdf_237912_de.zip (4,829,439 bytes)
Mazi

Mazi

2025-09-05 10:13

updater   ~83370

@adamzammit, thanks for the feedback. Looks like something went wrong at our testing.

@tibor.pacalat, can you doulbe check if needed so we can then add the fix to one of the next releases?

DenisChenu

DenisChenu

2025-09-05 10:23

developer   ~83371

I exported the survey to queXML-PDF, the form appears -> submit
The result is same as before - no LimeExpressionManager-replacements

Expression Manager can happen only for live survey, not for export !
You can not export {TOKEN:ATTRIBUTE_1} or {Q00.shown} using admin GUI.

I don't see a solution to replace {date("Y")} but not {if(Q00.NAOK,date("Y")}

Then : you must test using "Print answers as QueXML"

Mazi

Mazi

2025-09-05 11:26

updater   ~83372

@DenisChenu, that totally makes sense! Does the fix work for you when calling the printable version at the end of the survey?

DenisChenu

DenisChenu

2025-09-05 11:47

developer   ~83373

No real time to test :)

Mazi

Mazi

2025-09-06 19:29

updater   ~83377

@tibor.pacalat, could you please provide a helping hand and double check if this works for you? I owe you some beers afterwards :-)
Thanks!

tibor.pacalat

tibor.pacalat

2025-09-09 18:35

administrator   ~83385

I have tested this locally (added the changes from here https://github.com/adamzammit/LimeSurvey/commit/b45fda49134e47d881d722c625638dd942580274) and I still see the issue described in the ticket.

In the screenshot: left - before fix, right - after fix.

I have left all the questions unanswered, if this makes any difference or help with debugging.

Mazi

Mazi

2025-09-09 20:22

updater   ~83387

Thanks @tibor.pacalat. Beer is on my when I am visiting Hamburg next time :-)

@adamzammit, any clue what we may be missing or doing wrong during testing?
Is another fix or different LS version needed?

tibor.pacalat

tibor.pacalat

2025-09-10 11:42

administrator   ~83389

@adamzammit, it would be great if you can create a PR to Limesurvey with your proposed fix.

DenisChenu

DenisChenu

2025-09-10 11:58

developer   ~83390

Current :

  1. questions are replaced
  2. sub questions are replaced
  3. answers are not replaced

Tested : Print answers as QueXML using survey_archive_589315.lsa

Export as QueXML is OK : no replacement done.

DenisChenu

DenisChenu

2025-09-10 11:59

developer   ~83391

DenisChenu

DenisChenu

2025-09-10 12:02

developer   ~83392

There is an issue with export quexmlPDF: B1 question text is empty

In master or this comit.

In export B1 question text must be {Q00_QUES.shown} no ?

quexmlpdf_589315_en.zip (4,206,414 bytes)
DenisChenu

DenisChenu

2025-09-10 12:10

developer   ~83393

Biggest issue

  1. Import survey_archive_589315.lsa
  2. Launch survey and enter in question text : "A new questoion, just answered not submitted"
  3. Go to beowse response
  4. View the 1st response as QueXML

##Expected result##

PDF show {Q00_QUES.shown} or "1st answer" for B1 question

##Actual result##

PDF shown A new questoion, just answered not submitted for B1 question (usage of current).

##Potential solution##

To have {Q00_QUES.shown} : just do not replace when export via admin
To have "1st answer" : need to reconstruct whole replacement before : using SESSION ? Sample : https://gitlab.com/SondagesPro/RemoteControl/RemoteManageResponse/-/blob/main/RemoteControlHandler.php?ref_type=heads#L193
REALLY MORE COMPLEX

Did I report this issue separatly ?

Mazi

Mazi

2025-09-19 10:14

updater   ~83449

@adamzammit, looks like we nearly got there. Only answers are not replaced yet, see https://bugs.limesurvey.org/view.php?id=20114#c83390. Can you double check?

Issue History

Date Modified Username Field Change
2025-05-20 10:35 Mazi New Issue
2025-05-20 10:35 Mazi File Added: image.png
2025-05-20 10:35 Mazi File Added: limesurvey_survey_654535.lss
2025-05-20 10:36 Mazi Note Added: 82713
2025-05-20 10:36 Mazi Bug heat 6 => 8
2025-05-21 04:16 adamzammit Note Added: 82727
2025-05-21 04:16 adamzammit Bug heat 8 => 10
2025-05-21 10:01 Mazi Note Added: 82728
2025-05-28 10:05 tibor.pacalat Assigned To => adamzammit
2025-05-28 10:05 tibor.pacalat Status new => assigned
2025-06-11 12:15 Mazi Note Added: 82863
2025-06-12 05:19 adamzammit Note Added: 82866
2025-06-12 09:29 Mazi Note Added: 82867
2025-06-12 11:13 DenisChenu Note Added: 82868
2025-06-12 11:13 DenisChenu Bug heat 10 => 12
2025-06-12 11:13 DenisChenu Note Edited: 82868
2025-06-13 09:47 Mazi View Status private => public
2025-06-13 09:47 Mazi Bug heat 12 => 6
2025-06-18 07:00 adamzammit Note Added: 82893
2025-06-18 10:10 DenisChenu Relationship added related to 20139
2025-06-19 07:58 adamzammit Note Added: 82907
2025-06-19 08:58 DenisChenu Note Added: 82908
2025-06-24 05:07 adamzammit Note Added: 82935
2025-06-24 08:20 DenisChenu Note Added: 82937
2025-06-30 10:24 Mazi Note Added: 83012
2025-07-03 15:24 Mazi Note Added: 83017
2025-07-03 15:46 DenisChenu Note Added: 83018
2025-07-03 15:46 DenisChenu File Added: 589315-4-queXML.pdf
2025-07-03 15:46 DenisChenu File Added: survey_archive_589315.lsa
2025-07-03 15:53 Mazi Note Added: 83019
2025-07-03 16:00 bismark Note Added: 83020
2025-07-03 16:00 bismark File Added: survey_archive_237912.lsa
2025-07-03 16:00 bismark File Added: 237912-1-queXML-2.pdf
2025-07-03 16:00 bismark Bug heat 6 => 8
2025-07-03 16:07 DenisChenu Note Added: 83021
2025-07-08 21:38 Mazi Note Added: 83043
2025-07-20 05:59 Mazi Note Added: 83112
2025-08-18 18:25 Mazi Note Added: 83240
2025-08-19 05:01 adamzammit Note Added: 83241
2025-08-19 10:20 Mazi Note Added: 83242
2025-08-28 20:59 Mazi Note Added: 83338
2025-08-28 21:00 Mazi Note Added: 83339
2025-09-02 04:26 adamzammit Note Added: 83349
2025-09-04 14:11 bismark Note Added: 83365
2025-09-04 14:17 bismark Note Added: 83366
2025-09-05 02:23 adamzammit Note Added: 83369
2025-09-05 02:23 adamzammit File Added: testumfrage-237912-queXML.pdf
2025-09-05 02:23 adamzammit File Added: quexmlpdf_237912_de.zip
2025-09-05 10:13 Mazi Note Added: 83370
2025-09-05 10:23 DenisChenu Note Added: 83371
2025-09-05 11:26 Mazi Note Added: 83372
2025-09-05 11:47 DenisChenu Note Added: 83373
2025-09-06 19:29 Mazi Note Added: 83377
2025-09-09 18:35 tibor.pacalat Note Added: 83385
2025-09-09 18:35 tibor.pacalat File Added: Screenshot 2025-09-09 at 18.32.16.png
2025-09-09 18:35 tibor.pacalat Bug heat 8 => 10
2025-09-09 20:22 Mazi Note Added: 83387
2025-09-10 11:42 tibor.pacalat Note Added: 83389
2025-09-10 11:58 DenisChenu Note Added: 83390
2025-09-10 11:58 DenisChenu File Added: simple-quexcml-test-589315-queXML.pdf
2025-09-10 11:59 DenisChenu Note Added: 83391
2025-09-10 11:59 DenisChenu File Added: Capture d’écran du 2025-09-10 11-58-54.png
2025-09-10 12:02 DenisChenu Note Added: 83392
2025-09-10 12:02 DenisChenu File Added: quexmlpdf_589315_en.zip
2025-09-10 12:02 DenisChenu File Added: Capture d’écran du 2025-09-10 11-59-36.png
2025-09-10 12:10 DenisChenu Note Added: 83393
2025-09-19 10:14 Mazi Note Added: 83449