Get LimeSurvey not selected multiple choice answers with "N" using API Remote Control - api

Is it possible to get not selected answers in multiple choice question type marked with "N" when consuming Lime Survey API?
The API method export_responses gives all the question/subquestions/answers codes of user responses in bulk.
But the multiple choice question type signalizes only the selected answers with an "Y". I'd like responses bring the answers not selected with an "N" written. LimeSurvey can do that?
Example:
listTpFisioAt is the question code; text, in listTpFisioAt[text], is an option. When I consume the API to get responses I get something like this:
lisTpFisioAt[Fototerapia]
lisTpFisioAt[Termoterapia]
lisTpFisioAt[Cinesioterapia] Y
lisTpFisioAt[Eletroterapia]
lisTpFisioAt[Hidroterapia] Y
In this case user selected Cinesioterapia and Hidroterapia in Lime Survey interface.
I'd like to get:
lisTpFisioAt[Fototerapia] N
lisTpFisioAt[Termoterapia] N
lisTpFisioAt[Cinesioterapia] Y
lisTpFisioAt[Eletroterapia] N
lisTpFisioAt[Hidroterapia] Y

No, is not possible. Limesurvey fills checked options only. The other ones are left empty. You will need to fill the empty ones yourself by processing the output.
Hope it helps.
Thanks

Related

Using an API to Extract All Comments from a Reddit Post

I am using the Reddit API (Pushshift) : https://github.com/pushshift/api
Using the documentation, I understand how I can use this to extract every comment containing the word "covid" that was left in a certain time period:
https://api.pushshift.io/reddit/search/comment?q=covid&after=3h&before=2h&size=1
The output looks something like this:
{"data":[{"subreddit_id":"t5_2qh6p","author_is_blocked":false,"comment_type":null,"edited":false,"author_flair_type":"richtext","total_awards_received":0,"subreddit":"Conservative","author_flair_template_id":null,"id":"j98zf27","gilded":0,"archived":false,"collapsed_reason_code":null,"no_follow":false,"author":"VamboRoolOkay","send_replies":true,"parent_id":41917615743,"score":1,"author_fullname":"t2_7uxkru5f","all_awardings":[],"body":"I will never believe that election fraud wasn't a significant factor. Go ahead - call it a conspiracy theory. But I also maintained that Covid was lab-created. Truth is the Daughter of Time.","top_awarded_type":null,"author_flair_css_class":null,"author_patreon_flair":false,"collapsed":false,"author_flair_richtext":[{"e":"text","t":"Conservative"}],"is_submitter":false,"gildings":{},"collapsed_reason":null,"associated_award":null,"stickied":false,"author_premium":false,"can_gild":true,"link_id":"t3_116l7ct","unrepliable_reason":null,"author_flair_text_color":"dark","score_hidden":true,"permalink":"/r/Conservative/comments/116l7ct/kamala_harris_plans_on_running_with_biden_in_2024/j98zf27/","subreddit_type":"public","locked":false,"author_flair_text":"Conservative","treatment_tags":[],"created_utc":1676866031,"subreddit_name_prefixed":"r/Conservative","controversiality":0,"author_flair_background_color":"","collapsed_because_crowd_control":null,"distinguished":null,"retrieved_utc":1676866047,"updated_utc":1676866048,"body_sha1":"328df3784d15f77b98a84418c4ce720822227cfe","utc_datetime_str":"2023-02-20 04:07:11"}],"error":null,"metadata":{"es":{"took":98,"timed_out":false,"_shards":{"total":828,"successful":828,"skipped":824,"failed":0},"hits":{"total":{"value":573,"relation":"eq"},"max_score":null}},"es_query":{"size":1,"query":{"bool":{"must":[{"bool":{"must":[{"simple_query_string":{"fields":["body"],"query":"covid","default_operator":"and"}},{"range":{"created_utc":{"gte":1676862433000}}},{"range":{"created_utc":{"lt":1676866033000}}}]}}]}},"aggs":{},"sort":{"created_utc":"desc"}},"es_query2":"{\"size\":1,\"query\":{\"bool\":{\"must\":[{\"bool\":{\"must\":[{\"simple_query_string\":{\"fields\":[\"body\"],\"query\":\"covid\",\"default_operator\":\"and\"}},{\"range\":{\"created_utc\":{\"gte\":1676862433000}}},{\"range\":{\"created_utc\":{\"lt\":1676866033000}}}]}}]}},\"aggs\":{},\"sort\":{\"created_utc\":\"desc\"}}","api_launch_time":1673017478.254743,"api_request_start":1676873233.6143198,"api_request_end":1676873233.7406816,"api_total_time":0.12636184692382812}}
My Question: Suppose I identify a post that contains the word "covid" - now, I want to retrieve every comment on this post : Is this possible to do?
For instance, based on the output of these results, I see that :
link_id: t3_116l7ct
parent_id:41917615743
Can I somehow use this information to write an API query to retrieve all comments from this post?
I tried the following query but got an empty result: https://api.pushshift.io/reddit/comment/search/?link_id=t3_116cjib
Thanks!

Watson Assistant retaining the value that is a recognised entity

I am capturing a user response in my assistant, after which I want following questions to repsond based in the response that has been previously captured into an entity i have created
For example I will respond to a question with
Banana this is captured as an entity
I then want the watson assistant to then respond to subsequent question based on the entity captured. For example I want to ask
What colour ? and for the assistant to know that Im asking the question in relation to the banana, as I know that some people interacting with the assistant won't ask the question "what colour is a banana ?"
What you are asking is one of the reasons (as #data_henrik mentioned) we have context variables. These once set will remain through out the conversation. You can set a context variable using either the context editor ( see three dot menu of a dialog node ) or in the json response packet i.e.
"context": {
"my_saved_entity" : #entity_defined
}
In your case #entity_defined = banana so "my_saved_entity" becomes banana.
You can then use this context variable in your response;
The colour of a $my_saved_entity is Yellow
And you can text for a setting of $my_saved_entity in the dialog condition i.e.
(if) $my_saved_entity = "banana" or the short hand version $my_saved_entity:banana
I would suggest you read the following documentation, and have a play
https://cloud.ibm.com/docs/services/assistant?topic=assistant-dialog-runtime#dialog-runtime-context-variables

How do I make a stack column chart with two events organized by services?

Basically I need to make a column chart with the different endpoints along the x axis (services such as log in, etc.) with each endpoint having a unique column stacked with two colors, red for service error events and green for service events.
I can get something with a search string like this:
my search EVENT="[SERVICES]" OR EVENT="[SERVICE_ERROR]" | chart count by EVENT, ENDPOINT
though its event on the x axis (but showing both services and service error like I need) with the endpoints being different colored stacked in the chart.
Yet reversing this causes ONLY SERVICE EVENTS to show up, which is beyond my reasoning since service errors appear in the first search.
Above is just something I tried. I also tried:
my search | fields ENDPOINT "[SERVICE]" "[SERVICE_ERROR]"
according to the splunk documentation on stacking charts here:
https://docs.splunk.com/Documentation/Splunk/7.1.1/Viz/ColumnBarCharts
(last example at bottom of page).
I wanted to make sure I was thorough with my explanation but in short...
My goal is to have the all the endpoints displayed on the x axis with the count of the different service events and service error events as the actual graph data as one column split into two colors for both events.
Thank you for any help!!
I found the answer and wanted to share in case anyone else might find this helpful:
First, I made a unique field for error using the field extractor. "[SERVICE_ERROR]" wanted to link to all other events similar to it so I had to use "error_message" to extract my errors.
Next I added this to my search string:
....... | stats count(eval(match(EVENT,"[SERVICE]"))) AS service count(error) AS error BY endservice
This calculates a table that finds the count of both the event "[SERVICE]" and the field "error" and renames them using "AS/as". The field "endservice" is a field extraction I use to get more accurate endpoints.
Finally I go to my chart's format option (near the magnifying glass and three dots in the upper right hand corner, it looks like a paint brush) and click on it. After that I selected "stacked column" (the middle one).
The voila! I have my stacked graph of two different data types! I hope this helps someone else someday.

Obtain Deviantart Deviation ID / UUID from page URL

I was looking at the Deviantart API to see what you can do with it .
A lot of requests require you to provide a deviation id to work with.
Take for instance adding a deviation to favorites ( in Collections -> Add deviation to favorites above, I cannot post more than 2 links... )
Now I looked through the API to figure out how to obtain that id, but I did not find out how to do so.
If I only have the deviation URL, for instance http://kennyklent.deviantart.com/art/Pinkie-Pie-Dancing-296143815 , how can I tell its deviation-id?
It is not the number at the end 296143815, I would've thought so, but it's not.
If it helps, here's one example from the api's /browse/dailydeviations endpoint
"deviationid": "27FD366A-30CB-FC3E-DE54-9621E90FCE60",
"printid": "E984FC87-8B57-239C-FE7C-E2674A0DDFC4",
"url": "http://mudimba.deviantart.com/art/SF-Botanical-Gardens-57879397",
So this deviation SF-Botanical-Gardens-57879397 has the id 27FD366A-30CB-FC3E-DE54-9621E90FCE60 - but how would I find out if it wasn't listed in the examples?
Update 06/2017:
For anyone stumbling across this 2 years later, the answer below still works but there is now another way to get the UUID. Every Deviation now has a meta property da:appurl showing the UUID value on the deviation page itself.
To stay with the SF-Botanical-Gardens-57879397 example from above, looking at the page source at http://mudimba.deviantart.com/art/SF-Botanical-Gardens-57879397 reveals:
<meta property="da:appurl" content="DeviantArt://deviation/27FD366A-30CB-FC3E-DE54-9621E90FCE60">
Which contains exactly the UUID value 27FD366A-30CB-FC3E-DE54-9621E90FCE60
Original answer
I got an answer from a Deviantart dev directly, http://comments.deviantart.com/1/492518964/3755610860
You cannot convert integer IDs into UUID format, you have to query the api to find the correct uuid. So for your example, you would query the /gallery/folders endpoint and then the gallery/{folderid} endpoint to get the list of deviations in that folder.
There's no easier way to obtain the UUID for a given URL for now.

Use custom function to populate gSpreadsheet cell based on a XML/JSON response

Ok, this one has become a little tricky for me and I really need some assistance to work through it.
Problem
I have a GSpreadsheet which has a list of data, in this case Twitter usernames. Using the API of a service provider (in this case the Klout API), I would like to retrieve information about that user to populate a cell within a spreadsheet.
Based on what I can work out so far, I would need to write a custom function to do this but I have no idea where to start, how I might construct it, or if there are any examples of doing this.
Scenario
The Klout API can return either an XML or JSON response (see http://developer.klout.com/docs/read/api/API), based on the string passed. For example, the URL:
http://api.klout.com/1/users/show.xml?key=SECRET&users=thewinchesterau
would return the following XML response:
<users>
<user>
<twitter_id>17439480</twitter_id>
<twitter_screen_name>thewinchesterau</twitter_screen_name>
<score>
<kscore>56.63</kscore>
<slope>0</slope>
<description>creates content that is spread throughout their network and drives discussions.</description>
<kclass_id>10</kclass_id>
<kclass>Socializer</kclass>
<kclass_description>You are the hub of social scenes and people count on you to find out what's happening. You are quick to connect people and readily share your social savvy. Your followers appreciate your network and generosity.</kclass_description>
<kscore_description>thewinchesterau has a low level ofinfluence.</kscore_description>
<network_score>58.06</network_score>
<amplification_score>29.16</amplification_score>
<true_reach>90</true_reach>
<delta_1day>0.3</delta_1day>
<delta_5day>0.5</delta_5day>
</score>
</user>
</users>
Based on this response, I would like to be able to populate different cells with the values returned within the XML (or JSON if easier) packet.
So, for example, I would have a spreadsheet like the following which would have custom functions to go out and retrieve the value of the relevant XML element response to populate the cell:
Cell A B C D E
1 Username kscore Network score Amplification score True reach
2 thewinchester =kscore(A2) =nscore(A2) =ascore(A2) =tscore(A2)
Questions
Are there any gSpreadsheet examples you know of that use an API to pull data in from an external source?
How would one write a custom function to fetch the result from the API and populate a cell with a result of a specific element?
Any information, examples or helpers you have are greatly appreciated.
You want the importXML function, documented here. The formula you want will look something like this:
=importXML("http://api.klout.com/1/users/show.xml?key=SECRET&users=" + A1, "//users/user/score/kscore")
You could write a custom script with Google AppScript, but there's a simple solution to this similar to what Nick Johnson posted. I've tested this against the score function, but it could be easily adapted to the show endpoint with different XPath.
=importXML("http://api.klout.com/1/klout.xml?users="&A1&"&key=YOUR_API_KEY", "//users/user/kscore")
This presumes your Twitter IDs are in the A column.
Note, Google Docs limits the number of such importXML functions to 50 per spreadsheet. You could concatenate groups of 5 userids for each importXML call, effectively putting your limit to 250 a sheet.
This could also be adapted to a similar call in Excel that doesn't have that limit. Keep in mind the Klout ToS, though, using proper attribution and rate limits.