Welcome to the LimeSurvey Community Forum

Ask the community, share ideas, and connect with other LimeSurvey users!

Add a clock / chronometer to survey

  • kgordon
  • kgordon's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
1 year 10 months ago #241950 by kgordon
Add a clock / chronometer to survey was created by kgordon
Please help us help you and fill where relevant: 
Your LimeSurvey version: 5.6.9+230306
Own server or LimeSurvey hosting: own
Survey theme/template:
==================

Hi,

I'm wondering if it's possible to include a clock / chronometer that runs continuously from Question Group 2 through to Question Group 9 (out of 10 question groups), so that participants can see how long they are taking as they go through those questions.

Thanks very much, 
Kyle
 

Please Log in to join the conversation.

  • Joffm
  • Joffm's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
1 year 10 months ago #241955 by Joffm
Replied by Joffm on topic Add a clock / chronometer to survey
Here is a similar request.
[url] forums.limesurvey.org/index.php/forum/pl...s-up-per-user#241379 [/url]

Capture the time at the beginning of the survey
In a question of type "short text" (starttime) enter this.
Hide the question by css class "hidden"
Code:
<script charset="utf-8" type="text/javascript">
  $(document).ready(function() {
       var thisQuestion = $('#question{QID}');
       var now = Date.now();
       $('input[type=text]', thisQuestion).val(now);
  });
</script>


In each page (e.g. group description or somewhere else in the question text)insert the script to show the elapsed time
Like this
Code:
<script>
const start = {starttime};
 
var x = setInterval(function() {
  var distance = Date.now() - start;
 // Time calculations for hours, minutes and seconds
  var hours = Math.floor((distance % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60));
  var minutes = Math.floor((distance % (1000 * 60 * 60)) / (1000 * 60));
  var seconds = Math.floor((distance % (1000 * 60)) / 1000);
 
  // Display the result in the element with id="demo"
  document.getElementById("demo").innerHTML = hours + "h " + minutes + "m " + seconds + "s ";
 
}, 1000);
</script>

Layout is up to you.
 
Joffm
 

Volunteers are not paid.
Not because they are worthless, but because they are priceless

Please Log in to join the conversation.

Moderators: tpartnerholch

Lime-years ahead

Online-surveys for every purse and purpose