Welcome to the LimeSurvey Community Forum

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

Update answer via API

  • silentMantra
  • silentMantra's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
3 years 2 weeks ago - 3 years 2 weeks ago #227061 by silentMantra
Update answer via API was created by silentMantra
Please help us help you and fill where relevant:
Your LimeSurvey version: Version 3.27.1+210531
Own server or LimeSurvey hosting: own server
==================
Hello, I'm currently experiencing a weird problem when updating a response using remotecontrol. Say for example that I add a response with add_response and the following parameters
{
 "submitdate":null,
 "123456X1234X12345": "Y"
}
then I get as response {"id":1,"result":"1","error":null}. Then I can see on the survey page that there is a response with id 1 that is marked not completed (hat the red cross on the completed column) and has the desired answer Y to the question with ID 12345. However if after that I try to use update_response to add an answer to a different question with these parameters (notice the different question ID)
{
"id" : 1,
 "submitdate":null,
 "123456X1234X99999": "Y"
}
then I get as a response {"id":1,"result":"Error: Survey does not allow edit after completion.","error":null}.
I'm not sure if this is the intended behaviour and the error message is just misleading but I think that if the response is marked as not yet completed, I should be able to update it.

Does anyone have experience with this? Do I have to use something other then update_response to add additional answers to a response?
I tried to google quite a bit but haven't found anything useful, so any help is much appreciated. Thanks!

Edit: also from what I could see on github in the file remotecontrol_handle.php under update_response, it doesn't seem like the completion field of the response is ever checked
Last edit: 3 years 2 weeks ago by silentMantra. Reason: Added hint about remotecontrol file on Github

Please Log in to join the conversation.

  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
3 years 2 weeks ago #227124 by tpartner
Replied by tpartner on topic Update answer via API
Can you attach a sample of your complete code?

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.

Please Log in to join the conversation.

  • silentMantra
  • silentMantra's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
3 years 2 weeks ago #227129 by silentMantra
Replied by silentMantra on topic Update answer via API
Hi, thanks for the question, but I don't think the code is the problem since I can recreate the issue with 2 Post requests on Postman, which are the following:
POST myserver.com/index.php?r=admin/remotecontrol
body:
{
"method" : "add_response",
"params" : [
"mySessionID",
123456,
{
"123456X1234X234567": "Y",
"submitdate":null
}
],
"id": 1
}
to which I get {"id":1,"result":"1","error":null}. Then

POST myserver.com/index.php?r=admin/remotecontrol
body:
{
"method" : "update_response",
"params" : [
"mySessionID",
123456,
{
"id" : 1,
"submitdate":null,
"123456X1234X765432": "N",
}
],
"id" : 1
}
to which I get {"id":1,"result":"Error: Survey does not allow edit after completion.","error":null}

Today I noticed that if I turn on "Allow multiple responses or update responses with one token:" under participant settings, then the update works and I get
{"id":1,"result":true,"error":null}

But still I'm confused as to why I get "Survey does not allow edit after completion." if the response is marked as not completed.

Please Log in to join the conversation.

Moderators: tpartnerholch

Lime-years ahead

Online-surveys for every purse and purpose