Tuesday, January 5, 2016

SurveyGizmo Custom Scripting

One nice feature of SurveyGizmo is their server-side custom scripting functionality (example below). It’s a PHP-like scripting language that allows you to modify the survey contents and operation at runtime. The script runs server-side before the page loads and offers a lot options for customizing a survey.

There are several things I would love to see with this feature:

  1. Syntax validation in the editor. Having to go through several survey pages to test your script and then find out you are missing a semi-colon or have a typo is no fun. A basic eval of the script would catch most of these errors.
  2. Using full PHP instead of PHP-lite. Having programmed a survey system I can understand why Survey Gizmo went with a more controlled subset of the language but when I need to use a function that isn’t there I’m not happy about it.
  3. Adding an option to run a script on page save. Currently, the scripts only run on page load so custom logic, validation and other items need to be on the next page. Sometimes it would be nice to just have them on the same page.

Having said that all in all its still pretty powerful functionality that we use with a lot of surveys at Researchscape.

Example of mapping the state question to another question that tracks the four main US Census regions.

Monday, January 4, 2016

SurveyGizmo Hacks

At Researchscape we’ve been using SurveyGizmo to run most of our surveys. It has a lot of flexibility built in but the customization options make it easy to adapt it for our needs. Going to start posting some quick hacks that I’ve used to customize various surveys.

First one up is a simple table customization. By default the table layout is dynamic but if you have a scale question with some labels (eg Strongly Disagree – 1, 2, 3, 4, Strongly Agree – 5) the column will not be equally sized. However we don’t want to change the whole table to a fixed layout which would squeeze the row heading.

Solution is to add a CSS class to the table question and in the Style section add custom CSS to the survey like follows:

.fixed-columns td:nth-child(n+2) {
    width: 8%;
}