Welcome to the LimeSurvey Community Forum

Ask the community, share ideas, and connect with other LimeSurvey users!

To participate in this restricted survey, you need a valid token...

  • rickanderson
  • rickanderson's Avatar Topic Author
  • Offline
  • Junior Member
  • Junior Member
More
5 years 4 months ago #177603 by rickanderson
Hi...

I have added a javascript button on the end page of my survey which uses the 'html2pdf' script to print the results shown on the end page. This works fine in preview mode but on a live survey it refreshes to a page which states: "To participate in this restricted survey, you need a valid token".

Live survey participants are invited to the survey via a single token (with restricted number of uses and expiry date).

Can anyone suggest a way to avoid this? Ideally the end page would just remain on screen.

I am using LimeSurvey v3.15.5.

Cheers...Rick.
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
5 years 4 months ago #177605 by tpartner
What is the code for your button?

To avoid submitting the #limesurvey form, it should have a type="button" attribute.

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The following user(s) said Thank You: rickanderson
The topic has been locked.
  • DenisChenu
  • DenisChenu's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
5 years 4 months ago #177612 by DenisChenu
Else if you don't want use javascript : you can use gitlab.com/SondagesPro/ExportAndStats/pdfReport
It can replace Print Survey default link to Download your report (where you do reportb with Expression)

Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand , plugin development .
I don't answer to private message.
The following user(s) said Thank You: rickanderson
The topic has been locked.
  • rickanderson
  • rickanderson's Avatar Topic Author
  • Offline
  • Junior Member
  • Junior Member
More
5 years 4 months ago #177645 by rickanderson
Thanks Tony...

The code for the button is:
Code:
<button id="btn">SAVE YOUR REPORT</button>

and the javacsript:
Code:
<script>
var element = document.getElementById('finalScores');
var opt = { 
  margin:       5,
  filename:     'drive.pdf',
  image:        { type: 'jpeg', quality: 0.98 },
  html2canvas:  { scale: 2 },
  jsPDF:        { unit: 'mm', format: 'a4', orientation: 'landscape' }
};
var btn = document.getElementById("btn");
 
btn.addEventListener('click',function(){
  html2pdf().set(opt).from(element).save();
});
</script>

I'll try with type="button" to see if that helps.

Cheers

...Rick
The topic has been locked.
  • rickanderson
  • rickanderson's Avatar Topic Author
  • Offline
  • Junior Member
  • Junior Member
More
5 years 4 months ago #177646 by rickanderson
Thanks Denis...

I'll have a look at pdfReport if I am unable to sort out the current javascript method.

Cheers

...Rick.
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
5 years 4 months ago - 5 years 4 months ago #177647 by tpartner
Try this:

Code:
<button type="button" id="btn">SAVE YOUR REPORT</button>

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Last edit: 5 years 4 months ago by tpartner.
The following user(s) said Thank You: rickanderson
The topic has been locked.
  • rickanderson
  • rickanderson's Avatar Topic Author
  • Offline
  • Junior Member
  • Junior Member
More
5 years 4 months ago #177652 by rickanderson
That seems to have done the job...thanks again Tony.

Thanks both Tony and Denis for your responses, much appreciated .

Cheers

...Rick.
The topic has been locked.
  • DenisChenu
  • DenisChenu's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
5 years 4 months ago #177653 by DenisChenu

rickanderson wrote: I'll have a look at pdfReport if I am unable to sort out the current javascript method.

No javascript methos .

gitlab.com/SondagesPro/ExportAndStats/pdfReport#documentation

PDF is done in PHP and saved as 'file upload' in your survey. This file upload question type can be hidden, and you can replace default way to 'Print your survey' to directly download the generated PDF.

Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand , plugin development .
I don't answer to private message.
The following user(s) said Thank You: rickanderson
The topic has been locked.
  • rickanderson
  • rickanderson's Avatar Topic Author
  • Offline
  • Junior Member
  • Junior Member
More
5 years 4 months ago #177658 by rickanderson
Thanks Denis...will probably look into this method for next version of our survey.

Cheers

...Rick.
The topic has been locked.

Lime-years ahead

Online-surveys for every purse and purpose