Hi everyone,
I'm new on this forum.
I'm here because i try to record the number of time a participant press a key when a text is displayed on the screen. So i try to adapt a script i fund here to build this function (my only training in programmation is a 20 hours tuto on openclassroom...). I add the script in the question (in fact in the descriptive text). Here is my attempt :
Qualtrics.SurveyEngine.addOnReady(function() {
let questionId = "NumberOfPushG" ;
document.onkeydown = function(event) {
let i = 0
if (event.which == 71){
event.preventDefault();
i += 1
Qualtrics.SurveyEngine.registryquestionId].setChoiceValue(i);
}
}
});
Of course it doesn't work i would not be here otherwise...
What am i doing wrong ?
Thank you in advance to everyone.
You have a number of logic and syntax errors. For starters, NumberofPushG isn't a valid questionId. Also, you can't set a value for a Descriptive Text question.
Try:
Qualtrics.SurveyEngine.addOnReady(function() {
var i = 0;
document.onkeydown = function(event) {
if(event.which == 71){
event.preventDefault();
i++;
Qualtrics.SurveyEngine.setEmbeddedData("count",i);
}
}
});
Thank you for your answer ! If i can't set a value for a Descriptive Text, i have to put this in a question under the text ? what kind ? (sorry if it's a dumb question ...).
I tried it in a descriptive text, it does not actually work. But I tried in a multiple choice question and a text input question, it doesn't work either.
https://www.qualtrics.com/community/discussion/comment/26753#Comment_26753I changed it to setEmbeddedData so it would work with a Descriptive Text question. Be sure the define "count" in the survey flow so it gets saved in your response data.
https://www.qualtrics.com/community/discussion/comment/26755#Comment_26755I'm trying to do it, i'll be back with a victory.
Hum, ok i need more help, the "survey flow" is that the thing ?
So, i try to add an embedded data, i suppose it's a block " Embedded data" but where can i find how to define " count "
Is it here ?
Ok, it does work ! Thank you so much !
Leave a Reply
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.