Hello everyone!
I'd like to ask users to tap a button while listening to music and store the time interval between those tappings to later calculate their average tapping speed.
Previously I had asked for help here to create two buttons (start and stop) so that users could enter a time interval with them. They pressed start, counted some time, and then pressed stop. That created 2 date events stored as short text and the difference between them, in milliseconds, was calculated and stored as an equation in another question. This worked fine with this code, for the buttons
<p>How long do you think the music lasted for? Please use the start and stop buttons to recriate the time interval you think the music lasted for. </p>
<button class="btn btn-success" id="button1" onclick="dateevent1()" type="button">start</button><button class="btn btn-danger" id="button2" onclick="dateevent2()" type="button">stop</button><script type="text/javascript" charset="utf-8">
$(document).ready(function(){
// Verstecke den „Weiter“-Button
//$('#button2').hide();
});
function dateevent1(){
var thisQuestion = $('#question{QID}');
var date1 = Date.now();
$('input[type=text]:eq(0)', thisQuestion).val(date1);
$('#button1').hide();
$('#button2').show();
}
function dateevent2(){
var thisQuestion = $('#question{QID}');
var date2 = Date.now();
$('input[type=text]:eq(1)', thisQuestion).val(date2);
$('#ls-button-submit').trigger('click');
}
</script>
<style type="text/css">#question{QID} .answer-container {
display: none;
}
</style>
and this code for storing the difference in another equation question. The time was: {(reprodretrosptempo_SQ002-reprodretrosptempo_SQ001)} milliseconds.
Now, I tried to edit the first piece of code to create a new date event for each tapping. I don't need the system to calculate the average tapping speed, just store a new short answer for each tapping with the date. Is this possible? I assumed a variable N that would increase one point after recording each tapping, but does not seem to work. Can anyone help me with this? Here is the code I've edited for the tapping feature
<p>While you are listening tap on the 'TAP' button, to the pulse you feel that most naturally fits the music.</p>
<br />
<button id="tapbutton" onclick="tapping()" type="button">TAP</button>
<script type="text/javascript" charset="utf-8">
$(document).ready(function(){
// Verstecke den „Weiter“-Button
//$('#button2').hide();
});
function tapping(){
var thisQuestion = $('#question{QID}');
var date = Date.now();
var n = 0;
$('input[type=text]:eq(n)', thisQuestion).val(date);
n++;
</script>
Thank you
Lígia
Please help us help you and fill where relevant:
Your LimeSurvey version:
LimeSurvey Community Edition
Version 3.28.49+230215
Own server or LimeSurvey hosting:
Survey theme/template:
==================
(Write here your question/remark)