
Solved
Key Press Response Issue
Hello! I'm trying to add java script to descriptive text questions so that participants can press one of two keys (1 or 0) and the survey will automatically progress to the next question and the key that they pressed (1 or 0) is reported in the exported data file.
With my current script (image attached) I have found that pressing 1 or 0 does move the participant to the next question (yay!) However, I'm having trouble with the exported data. Originally, the questions that I added script to (Q3 and Q6) were both descriptive text questions. In this data file, there was no column for Q3 or Q6. Then, I tried changing Q3 to a multiple choice question and retaking the survey. In this data file, there was still no column for Q6, but there was a column for Q3. However, there was only Q3 data recorded for the 3 previous attempts (in which Q3 was a descriptive text question) and there was no Q3 data for the most recent attempt (in which Q3 was a multiple choice question). (I have attached these 2 data files-- note: I've deleted the name, location, IP address etc.)
So it seems that, when java script is added to descriptive text questions, the data is being recorded, but it is not being reported in the exported data file. Does anyone know how to set it up so that the key (1 or 0) that is pressed in response to a descriptive text question is recorded and reported?
I based my script off to a response on this thread. Community user @mattyb513 posted their code here and I got the event.which numbers and event.code for 1 and 0 here.
!

Best answer by mattyb513
It's probably easiest to leave it as a descriptive text and then just record the response with embedded data.
You can replace the `Qualtrics.SurveyEngine.registry[qid]...` lines with `Qualtrics.SurveyEngine.setEmbeddedData('MyEmbeddedDataName','0');` and `Qualtrics.SurveyEngine.setEmbeddedData('MyEmbeddedDataName','1');`
Of course, replace `MyEmbeddedDataName` with whatever you want the Embedded Data to be named.
Then in your survey flow, anywhere in it, add an EmbeddedData block and name it the same thing. Don't set a value. This will force it to show in your export.
View originalLeave a Reply
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.