Custom Script: List answer values for one question (from all participants) based on current question answer.

0

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 />”;

 

 

Nikolay Ryazantsev answered
    0

    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:

    1. In report, just use “Crosstab”
    2. You can add Complex quotas and track progress on the quotas page.
    3. 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.
    4. 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.
    Nikolay Ryazantsev answered
      ×

      Login

      Question stats

      • Active
      • Views97 times
      • Answers1 answer
      • Followers1 follower