Basically, I want something similar to sgapiGetQuestionResponseCount, but instead of counting responses, listing out responses based on the answer to a question on the current survey.
I have a survey that serves as an assessment. Each group of participants has a territory were they assess a number of locations. I currently use the following script to count how many total assessments were done in the territory of the person who just submitted the assessment (the first part determines which territory was just assessed, and the second counts the other time that territory was assessed.
This does work, however, what I really want is to show the actual locations that were assessed for that territory, rather than just the counts.
For example, if question ID 91 is where participants selected the location number, I would want to have the list of all the answers for question ID 91, given the current answer for Question ID 87. This way they could quickly see what locations they have evaluated already.
Currently, my work around is I give them a link to a shared report that has the responses for all locations. However, this is rather clunky, and since there are a lot of people doing the assessments, it is a lot of work on their part.
My script for counting by territory.
%%DIV = sgapiGetQuestionOptionSelected(87);
%%DIVname = sgapiGetValueLabel (87);
%%output .= “Total complete assessments for %%DIVname DIV: “;
%%output .= sgapiGetQuestionResponseCount(87, “%%DIV”);
%%output .= “<br />”;
Thanks for the response. The original question is actually a cascading drop down. However, because cascading drop downs are very difficult to work with from a reporting side, I pull the various levels into other question types. The name I have played with using either a regular drop down or radio button question type (hidden from participants). I have survey gizmo put the lower level location number into an individual text box.
For example if each person has to assess each of their locations, I wanted to the custom script to pull from the submitted results
- How did you answer the “your name” question on the current survey. While this was originally a cascading drop down, I can push it into any other hidden value, or hidden question type. There are around 100 people, but since it is automated, I can have it put into anything.
- Given you answer “your name” what is the list of locations (another question in the cascading drop down, this one realistically needs to be fed into a regular hidden value or text box question type due to the large number of options) that you have previously done.
Though based on what you have said, it just doesn’t look possible with a custom script. When I saw the ability to count other responses, it made me hope that I could do more than just count. I agree that google sheets would be much better. In fact, at the end of the assessment, I download the data and use excel to do exactly this to make sure everyone did what they were supposed to. Unfortunately, I’d never be allowed to store my data in google.
I really thought using the reports to break out the responses would be the golden ticket, but many of the participants don’t want to bother clicking on the link to go to the report. If it is not on the main thank you page, some will just email me to look it up for them, or wait until I look everything up at the end and email them what locations they are missing.
Hi, Steve. It is unclear from your description what kind of question (or questions) you use to determine locations and what is “assessment”. If both (QID 87 and 91) are, let say. radios, and you just want to get crossed counts then there are a few ways how you can accomplish this:
- In report, just use “Crosstab”
- You can add Complex quotas and track progress on the quotas page.
- If you want to do it with custom script, you can introduce a hidden value for each crossed point that will accumulate required numbers. I don’t think that you would able to get crossed values as is just straight in custom script because you really want to re-iterate all accumulated results. That thing is not possible with script. In other words, quotas are not accessible via either scripts or API, you have to add your own counters.
- I also find that the most convenient way to calculate complex crossing and dependencies is posting to Google Sheet and make all calculations there. It’s reliable, fast (in contrast to reports), real time (again, in contrast to reports), and much much simpler to construct (compare to scripts or SG reports). Just post your QID 87 and 91 to Google upon every survey completion and do whatever you wish with numbers easily.