Welcome to the LimeSurvey Community Forum

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

Get latest response with export_responses_by_token() API function

  • SybrenR
  • SybrenR's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
7 years 5 months ago #144938 by SybrenR
As a new feature for our existing survey, we want some users to be able to fill in a survey again.
To do this, we set 'completed' back to 'N' and 'uses left' to 1, so the user can use the same token again to fill out the survey.

This results in 2 complete responses to the survey.

When using the API to retrieve the answers, the only data that comes in is the first reponse, even though we are only interested in the newer answers. This can be bypassed by setting the first reponse to completed='NO', but I think there should be a better way to allways download the most recent response for a token.

Does anybody know how I can achieve this? Thanks in advance!
The topic has been locked.
  • DenisChenu
  • DenisChenu's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
7 years 4 months ago - 7 years 4 months ago #145100 by DenisChenu
Just a question, why not set uses left to 10000 directly ?

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.
Last edit: 7 years 4 months ago by DenisChenu. Reason: typo
The topic has been locked.
  • SybrenR
  • SybrenR's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
7 years 4 months ago #145169 by SybrenR
In general we only want users to fill in the survey twice. They have to fill in details about their energy meter, solar panels etc, so we don't want them to fill it in again unless we want to have the information updated.

The problem remains: Unless I manually set the first response to 'incomplete', only the first set of answers will be returned and not the most recent.
The topic has been locked.
  • DenisChenu
  • DenisChenu's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
7 years 4 months ago #145248 by DenisChenu
OK, got it.

Seems to be OK in code : github.com/LimeSurvey/LimeSurvey/blob/ma...rol_handle.php#L2523

When you browse response : there are one or two answers ?
Because if you 'Enable token-based response persistence' i think you have only one answer in response table.

Denis

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 topic has been locked.

Lime-years ahead

Online-surveys for every purse and purpose