0 votes
in SoSci Survey (English) by s150884 (110 points)

Hello everyone,
I would like to record timestamps from the moment participants press play on a recording until they answer a selection question.

I have searched for an answer in the forum, and I have found some related topics, but none of them shows exactly what I want to do. I am not sure it is even possible.

Despite not knowing any JS, I have managed to record the timestamp at the moment of pressing the play button. Also, if I add an HTML button, I can calculate the time from pressing play on the recording until pressing the HTML button.

What I can't do is recording the timestamp at the moment participants answer the selection question.

I thought of using a selection sequence question, but I can't since after each selection question I have included a Likert scale.

Here is the code I have. Could someone help, please? Thank you!

var startTime, endTime;


function start() {
  startTime = new Date();
};


var audio = document.getElementById("speaker43");
audio.onplay = start();

    
function end() {
  endTime = new Date();

var question = document.getElementById("ID43");
question.onclick = end();

var input = document.getElementById("RT01_01");
input.value = endTime - startTime;
}
  

1 Answer

0 votes
by SoSci Survey (327k points)

Quite well, but you still fell for a little nastiness from JavaScript. And that is in these lines:

audio.onplay = start();
question.onclick = end();

What happens here? The function start() is called and the result is stored in onplay. But the result does nothing, is is simply undefined. Actually, you want the function itself to be stored in onplay. For that, you omit the parentheses:

audio.onplay = start;
question.onclick = end;

Or in a more contemporary notation:

audio.addEventListener("play", start);
question.addEventListener("click", end);

Please also note, that there is possibly no "click" event in the question, depending on what question type that is. Your code will only work for a dropdown selection

And also keep in mind, that clicking the question another time will change the response time that you have recorded.

Willkommen im Online-Support von SoSci Survey.

Hier bekommen Sie schnelle und fundierte Antworten von anderen Projektleitern und direkt von SoSci Survey.

→ Eine Frage stellen


Welcome to the SoSci Survey online support.

Simply ask a question to quickly get answers from other professionals, and directly from SoSci Survey.

→ Ask a Question

...