SurveyGizmo's CustomScript Action now supports the LUA programming language.
Legacy Custom Scripting Language Deprecation Plans
New accounts (created after October 29, 2018) will only have the option to use Lua in scripts.
As of October 29, 2018 Custom Scripting Actions will default to Lua as the scripting type in the Custom Scripting Action for accounts created before this date. You will be able to switch to the Legacy Custom Scripting; though we highly encourage using Lua.
In the long term, Legacy Custom Scripting Actions will be switched to read-only. Read-only scripts will continue to function; you will just be prevented from editing. The exact date on this is to be determined; we will send notifications well ahead of time.
While SurveyGizmo is one of the most flexible survey tools around, we get requests for customizations that are not available out of the box. This is where JavaScript and Custom Scripting can save the day. If you have scripting chops you can use the JavaScript action or the Custom Scripting action to achieve the survey of your dreams.
Both our Drag & Drop Ranking question and our Ranking Grid will report and export on the row headers for each question. The report data of an aggregated score and a corresponding rank for each row header/option. Some users are more interested in focusing on the rank and how often each row header or option is selected for each rank. This script will transform the data into a hidden Radio Button Grid to accomplish the rank aggregation for each row header/option.
Start by building your Drag & Drop Ranking or Ranking Grid question.
On a later page, build a Radio Button Grid question with the row headers from your Drag & Drop Ranking or Ranking Grid question as column headers and the ranking score – 1 through however many answer column headers you added – as row headers.
On the same page but preceding the Radio Button Grid question, add a Custom Script action and paste the below code.
ranking_qID = 2 --qustion ID of the drag and drop/ranking grid
recode_qID = 3 --question ID of the radio button grid into which we are recoding, column reporting values should be exactly the same as ranking question row headers, row titles numeric sequential
next_pageID = 2 --ID of the next page to jump to so respondents do not see the page with the radio button grid
source_options = getquestionoptions(ranking_qid, 'Reporting')
source_answers = getvalue(ranking_qid)
source_by_rankings = {}
for key,value in pairs (source_answers) do
source_by_rankings[value] = source_options[key]
end
target_question = array_flip(gettablequestiontitles(recode_qid))
--row title => qid
for rank,option in pairs (source_by_rankings) do
rank = tonumber(rank)
setvalue(target_question[rank], option)
end
jumptopage(next_pageid)
Required Customizations
In the script above you will need to customize variables highlighted in yellow in order to make the script work in your survey. Not sure how to find these? Check out our How to Find IDs Tutorial to learn how!
ranking_qID - The question ID of your original Drag & Drop Ranking or Ranking Grid question.
recode_qID - question ID of the radio button grid into which we are recoding, column reporting values should be exactly the same as ranking question row headers, row titles numeric sequential
next_pageID - The page ID for the next page to jump to so that respondents do not see the page with the Radio Button Grid.
Test and run a report and an export
You'll need to manually record several test responses as Custom Script actions are not triggered by the test data generator.
Start by checking out your Individual Responses under Results > Individual Responses. Confirm that the data from your Ranking question and your Radio Button Grid Question corresponds.
Next, run a Standard Report to confirm that your data is in the format you require.
Finally, if you plan to use the raw data exports. You'll want to confirm that this data is also formatted they way that you need it to be.