- Posts: 5
- Thank you received: 0
Welcome to the LimeSurvey Community Forum
Ask the community, share ideas, and connect with other LimeSurvey users!
Access variables inserted using RemoteControl 2 API in relevance equation
- zuercher8353
-
Topic Author
- Offline
- New Member
-
Less
More
1 year 11 months ago #214602
by zuercher8353
Access variables inserted using RemoteControl 2 API in relevance equation was created by zuercher8353
Hi there
I`m using the RemoteControl 2 API to insert values into hidden question. These values are based on the response a survey participant gave to a chatbot which is integrated into the survey using an Iframe. In more detail the actions are:
Q1 : User interacts with Chatbot integarted into Q1 (iframe)
Chatbot Backend: Inserts value into Q2 (hidden yes/no question) based on survey participants answer to Q1.
Q3: Uses the value of Q2 in a relevance equation (goal it should only be visible if Q2 was set to yes).
The problem is that Q3 doesn't use the value stored in the database to evaluate the relevance equation. I tested that the relevance equation is correct by unhidding Q2 and answering it directly in the survey. Also, I can see in the response tab the inserting of the result of Q2 worked fine.
Is there a way to achieve such a behavior? Such that the relevance equation considers the response saved in the database? For me, it would be the best if I don’t have to change the source code.
Would appreciate it if someone could help me. I'm also willing to donate.
Best regards, Jonas
I`m using the RemoteControl 2 API to insert values into hidden question. These values are based on the response a survey participant gave to a chatbot which is integrated into the survey using an Iframe. In more detail the actions are:
Q1 : User interacts with Chatbot integarted into Q1 (iframe)
Chatbot Backend: Inserts value into Q2 (hidden yes/no question) based on survey participants answer to Q1.
Q3: Uses the value of Q2 in a relevance equation (goal it should only be visible if Q2 was set to yes).
The problem is that Q3 doesn't use the value stored in the database to evaluate the relevance equation. I tested that the relevance equation is correct by unhidding Q2 and answering it directly in the survey. Also, I can see in the response tab the inserting of the result of Q2 worked fine.
Is there a way to achieve such a behavior? Such that the relevance equation considers the response saved in the database? For me, it would be the best if I don’t have to change the source code.
Would appreciate it if someone could help me. I'm also willing to donate.
Best regards, Jonas
The topic has been locked.
1 year 11 months ago - 1 year 11 months ago #214609
by jelo
How is Q2 hidden? Via CSS Class? Or do you use the LimeSurvey option to hide the question? Dependng on how you hide a question, the question is no longer available to save data via Javascript. If you use the RemoteControl 2 API, you normally would't use that approach. But perhaps I didn't get it right.
If the data is correctly available while being hidden, it is available in the response data set. If that is the case, my second idea would be that Q3 cannot access the data, if it is in the same group/page as Q2. Place Q3 in a different group and check again.
The meaning of the word "stable" for users
www.limesurvey.org/forum/development/117...ord-stable-for-users
Replied by jelo on topic Access variables inserted using RemoteControl 2 API in relevance equation
Can you provide a LSS export of these three questions and attach it here? It's a lot easier to understand what you are doing and spot issues.The problem is that Q3 doesn't use the value stored in the database to evaluate the relevance equation. I tested that the relevance equation is correct by unhidding Q2 and answering it directly in the survey. Also, I can see in the response tab the inserting of the result of Q2 worked fine.
How is Q2 hidden? Via CSS Class? Or do you use the LimeSurvey option to hide the question? Dependng on how you hide a question, the question is no longer available to save data via Javascript. If you use the RemoteControl 2 API, you normally would't use that approach. But perhaps I didn't get it right.
If the data is correctly available while being hidden, it is available in the response data set. If that is the case, my second idea would be that Q3 cannot access the data, if it is in the same group/page as Q2. Place Q3 in a different group and check again.
The meaning of the word "stable" for users
www.limesurvey.org/forum/development/117...ord-stable-for-users
Last edit: 1 year 11 months ago by jelo.
The following user(s) said Thank You: zuercher8353
The topic has been locked.
1 year 11 months ago #214620
by tpartner
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Replied by tpartner on topic Access variables inserted using RemoteControl 2 API in relevance equation
You need to fire the ExpressionScript checkconditions() function after loading the question.
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The topic has been locked.
1 year 11 months ago #214622
by jelo
The meaning of the word "stable" for users
www.limesurvey.org/forum/development/117...ord-stable-for-users
Replied by jelo on topic Access variables inserted using RemoteControl 2 API in relevance equation
Tony, do you use the approach the threadstarter described with LS3?
The meaning of the word "stable" for users
www.limesurvey.org/forum/development/117...ord-stable-for-users
The topic has been locked.
1 year 11 months ago #214623
by tpartner
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Replied by tpartner on topic Access variables inserted using RemoteControl 2 API in relevance equation
That's hard to answer because I see no indication of how they are inserting the Q2 value. (script details?)
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: DenisChenu, zuercher8353
The topic has been locked.
- zuercher8353
-
Topic Author
- Offline
- New Member
-
Less
More
- Posts: 5
- Thank you received: 0
1 year 11 months ago - 1 year 11 months ago #214630
by zuercher8353
Replied by zuercher8353 on topic Access variables inserted using RemoteControl 2 API in relevance equation
Hey there thank you for your replies. I try to answer in more detail and I also attached a screenshot of the Infrastructure as well as a demo survey that I created. I'm using LimeSurvey
Version 3.25.20
.
Question Group1:
Q1: Chatbot. This question is a Text Display Question, in the source of Q1 I integrated a Chatbot using an Iframe. I pass the Limesurvey-userToken to the chatbot, so I know which user is interacting with the chatbot. When the conversation is finished the chatbot decides whether Q2 should be answered with yes or no. To communicate this decision I use the Limesurvey 2 API in Python. In more detail I use the API method: update_response(string $sSessionKey,integer $iSurveyID,array $aResponseData): string|boolean. In order that to update the correct data I use the question-identifier and the Limesurvey-userToken. To check whether the update_response call worked I go to the Responses-Tab in the Limesurvey Menu, where I can see that Q2 is now answered.
Q2: Decision is a Yes/No question. This question is hidden by entering 0 into the relevance equation of the question. I use it as a "dummy" question that is used to communicated from the chatbot to the LimeSurvey.
Question Group2:
Q3: OptionalQuestion. This question should only be displayed if Q2 is set to yes, this should be achieved by the following relevance equation: ((Decision.NAOK == "Y")).
However, here comes the problem:The relevance equation is evaluated as false and the question is not displayed, even if the result of Q2 is set to "Y" in the database (verified by looking at the Responses Tab in the LimeSurvey).
I think the problem is that the relevance equation doesn't use the value of Q2 that is saved in the database.
Is this correct does the relevance equation use some kind of "cached" values?
If so is there a workaround such that this relevance equation uses the value that is stored in the database?
If not is there another way to achieve such a behavior: Display certain questions based on an external Program?
Thanks a lot for your help
Jonas
Question Group1:
Q1: Chatbot. This question is a Text Display Question, in the source of Q1 I integrated a Chatbot using an Iframe. I pass the Limesurvey-userToken to the chatbot, so I know which user is interacting with the chatbot. When the conversation is finished the chatbot decides whether Q2 should be answered with yes or no. To communicate this decision I use the Limesurvey 2 API in Python. In more detail I use the API method: update_response(string $sSessionKey,integer $iSurveyID,array $aResponseData): string|boolean. In order that to update the correct data I use the question-identifier and the Limesurvey-userToken. To check whether the update_response call worked I go to the Responses-Tab in the Limesurvey Menu, where I can see that Q2 is now answered.
Q2: Decision is a Yes/No question. This question is hidden by entering 0 into the relevance equation of the question. I use it as a "dummy" question that is used to communicated from the chatbot to the LimeSurvey.
Question Group2:
Q3: OptionalQuestion. This question should only be displayed if Q2 is set to yes, this should be achieved by the following relevance equation: ((Decision.NAOK == "Y")).
However, here comes the problem:The relevance equation is evaluated as false and the question is not displayed, even if the result of Q2 is set to "Y" in the database (verified by looking at the Responses Tab in the LimeSurvey).
I think the problem is that the relevance equation doesn't use the value of Q2 that is saved in the database.
Is this correct does the relevance equation use some kind of "cached" values?
If so is there a workaround such that this relevance equation uses the value that is stored in the database?
If not is there another way to achieve such a behavior: Display certain questions based on an external Program?
Thanks a lot for your help
Jonas
Attachments:
Last edit: 1 year 11 months ago by zuercher8353.
The topic has been locked.