1) Is the HTML ID the intID I can find in the internal code on the Compose questionnaire-page?
No, the HTML ID is something that you write actively in your HTML code:
Media Files in Questionnaires (watch out for id=
)
2) Does the .attachCheck ensure the timestamp stops when the "next" button is pressed? And does the below look OK?
Not yet. You will have to (a) write the new timestamp into an internal variable, and you will have to return true
in the function to allow the respondent to continue.
I would also recommend to use a different (!) internal variable for this than for any other events, because one may complete answering the question and will then click "next". Just in case, there is another trigger you are using.
3) Do I have to save both times into internal variables, or can I just save the difference (the total response time from start of audio to click on "next") as in the last block of code?
Both is possible. But storing both will simplyfy things if you have strange behavior. For example if one does not play the video, but only clicks on "next". If you have separate timestamps, you will easier understand the -16999922200 in that case :)
And is the use of "input" here correct, in order to save the data?
input
is just a variable here. You could as well write:
document.getElementById("IV01_02").value = diffInSeconds;
I wonder why you ask in English here, but cire German manual pages? You are aware, we're sitting in Munich, right?
4) I have many, many pages to post this code to. Do I have to save the data differently or change anything else (other than the HTML ID for the audio)?
Depends on what is changing on the pages. I would strongly (!) recommend to save it once as a text in the list of questions, and use placeholders to add the HTML IDs, using show(). On the page, it could look like this then:
text('JS01', [
'%videoID%' => 'stimulus1.mp4',
'%internalA%' => 'IV01_01',
'%internalB%' => 'IV01_02'
]);
Just keep on testing, keep an eye on the developer console of your browser, and try to use console.log()
to see what you JavaScript does and what it does not yet do.