Skip to content

Instantly share code, notes, and snippets.

var previousAnswer ="";
Qualtrics.SurveyEngine.addOnload(function() {
var questionId = this.questionId;
this.questionclick = function(event, element) {
if (element.type == 'radio') {
var options = document.querySelectorAll('.q-checked');
for (var i = 0; i < options.length; i++) {
var ansArr = options[i].htmlFor.split('~');
var ansStr = ansArr[2] + '_' + ansArr[3];
Qualtrics.SurveyEngine.addOnReady(function() {
//variables
var draggableClassName = ".chair"; // the class name of elements that should be draggable
var edField = "distance"; // this will be the name of the Embedded Data field with the distance.
jQuery( function() {
jQuery( draggableClassName ).draggable({
stop: function() {
var distance = getDistanceBetweenElements(document.getElementById("Chair1"),
Qualtrics.SurveyEngine.addOnload(function() {
var qid = this.questionId;
document.onkeydown = function(event) {
console.log('keydown',event);
if (event.which == 37) {
event.preventDefault();
Qualtrics.SurveyEngine.registry[qid].setChoiceValue(1, true);
jQuery('#NextButton').click();
} else if (event.which == 39) {
Qualtrics.SurveyEngine.addOnload(function() {
var qid = this.questionId;
document.onkeydown = function(event) {
console.log('keydown',event);
if (event.which == 37) {
event.preventDefault();
Qualtrics.SurveyEngine.registry[qid].setChoiceValue(1, true);
} else if (event.which == 39) {
event.preventDefault();
Qualtrics.SurveyEngine.addOnload(function () {
var that = this;
this.questionclick = function(event,element) {
var choices = that.getSelectedChoices(); // returns an array of all selected options
if (choices.length >= 6) {
// now reveal the question!
jQuery('#QID2').show();
} else {
// or not
jQuery('#QID2').hide();

Setting up Nginx on Your Local System

by Keith Rosenberg

Step 1 - Homebrew

The first thing to do, if you're on a Mac, is to install homebrew from http://mxcl.github.io/homebrew/

The command to type into terminal to install homebrew is:

ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"