A few months ago I used the excellent advice over here to create a survey in Qualtrics with some javascript code that saved people\'s responses (given by moving a slider) as emb
I haven't tried T. Gibbon's Q_JFE=0
suggestion above, and the suggestion to hide the Next button didn't work for me (though it's possible this was just because I did it wrong - perhaps someone could comment if it worked for them).
When I mailed Qualtrics, their suggestion was to add an event listener as follows, and then remove it before applying another.
document.getElementById('NextButton').addEventListener(function (event) {
doStuff();
});
However, since I'm just a psychologist who wants to get data quickly rather than a javascript programmer, I wasn't sure just how to go about 'removing an event listener', and decided to try what I thought was a simpler solution, in that it doesn't rely on having some functions run when the 'next' button is clicked.
For each question that contains a slider whose data I want to save (I had just one such question per page), I included the following, to save the ID for that particular question as embedded data. Each question's ID is saved with a unique tag ('q1ID' in the following). I had one such question per page.
Qualtrics.SurveyEngine.setEmbeddedData('q1ID', this.getQuestionInfo().QuestionID);
Then once all the slider-type questions had been presented, on the following page I included this code:
Qualtrics.SurveyEngine.addOnload(function()
{
var tags = ['q1','q2', 'q3'];
var pipedStrings = {'QID356':'${q://QID356/TotalSum}',
'QID357':'${q://QID357/TotalSum}',
'QID358':'${q://QID358/TotalSum}'};
tags.forEach(function(tag) {
var qID = Qualtrics.SurveyEngine.getEmbeddedData(tag + 'ID');
var response = pipedStrings[qID];
Qualtrics.SurveyEngine.setEmbeddedData(tag, response);
});
});
Initially, I'd tried what I thought was more sensible:
tags.forEach(function(tag) {
var qID = Qualtrics.SurveyEngine.getEmbeddedData(tag + 'ID');
var response = '${q://' + qID + '/TotalSum}';
Qualtrics.SurveyEngine.setEmbeddedData(tag, response);
});
But as pointed out here, Qualtrics won't allow you to fetch data by concatenating a variable into a string like this. Consequently, even though it seems a ridiculously roundabout what to do it, I created the pipedStrings
object that has a list of all the question IDs I needed (which I found by exporting the survey to a text file and searching for my question tags).
This allowed me to save the responses to slider questions as embedded data, with the keys listed in tags
. If anyone has a simpler approach, avoiding have to create the dictionary of pre-formatted strings, please do comment.