Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Specify exact time for selected elements / Automatic (form) input save while 'timeout' in effect #216

Open
ghost opened this issue Oct 28, 2023 · 0 comments

Comments

@ghost
Copy link

ghost commented Oct 28, 2023

What would you like or expect to see?

An option that saves inputs (eg. of forms) if the participant goes past the 'timeout'.

Or an object/sth else the I could wrap other around, with which I could select the exact time the user has to be on that screen, even if he clicks "next"/"send"/"save".

When 'timeout' runs out, the input are saved, even if the participant didn't press "next" or whichever button.

What is currently happening?

No input from the form gets saved on timeout.

The elements I have:

  • instructions
  • form
  • Flanker task1
  • Flanker task2

Please describe the steps needed to reproduce this phenomenon

The elements I have:
-instructions, which I want to run - for example - for (example) exactly 90 seconds,
-form, which I want to run - for (example) exactly 90 seconds,

  • Flanker task, which I want to run - for (example) exactly 90 seconds
  • Flanker task, which I want to run - for (example) exactly 90 seconds

I am trying to see the differences in the first 15 minutes of doing the task vs next 15-30 minutes in responses, which is why I'm trying to set a specific time to each component.
I thought I can do with 'Timeout' in 'Behaviour', but then I noticed that with the form: if I wait until the timeout, the entries do not get saved; and if I press the "next" button when the timeout did not yet take affect, the entries are saved, but I cannot force the participant to have the same time for each part, meaning I cannot make the participants wait for the exact time.

I tried using this script (I also changed the footer style="display:none") which would do the at the specified second from the start (before the timeout), which saves the data, I think it works, but am not sure:

// Set the delay in milliseconds
var delay = 9000;  // 9 seconds

// Use setTimeout to submit the form after the delay
setTimeout(function() {
    // Get the submit button element
    var submitButton = document.querySelector('button[form="demography"]');
    
    // Trigger a click event on the submit button
    if (submitButton) {
        submitButton.click();
    }
}, delay);

ALSO!

when I put in code for an additional timer, so that participants can see how much time they have left/to wait until the next window, the code for the delay has to be in front of the code for the timer, I don't know why, as the js code doesn't work even if the scripts are separated in the windows.


//FIRST PART
// Set the delay in milliseconds
var delay = 9000;  // 9 seconds

// Use setTimeout to submit the form after the delay
setTimeout(function() {
    // Get the submit button element
    var submitButton = document.querySelector('button[form="demography"]');
   
    // Trigger a click event on the submit button
    if (submitButton) {
        submitButton.click();
    }
}, delay);

//SECOND PART
// Set the countdown time in milliseconds
var countdownTime = 60000; // 1 minute

// Initialize previous minutes and seconds
var prevMinutes = -1;
var prevSeconds = -1;

// Update the countdown every 1 second
var countdown = setInterval(function() {
    countdownTime -= 1000;
    var minutes = Math.floor((countdownTime % (1000 * 60 * 60)) / (1000 * 60));
    var seconds = Math.floor((countdownTime % (1000 * 60)) / 1000);

    // Pad the minutes and seconds with leading zeros if they are less than 10.
    minutes = String(minutes).padStart(2, '0');
    seconds = String(seconds).padStart(2, '0');

    // Only update the display if the minutes or seconds have changed
    if (minutes !== prevMinutes || seconds !== prevSeconds) {
        document.getElementById("timer-form").innerHTML = minutes + ":" + seconds;
        prevMinutes = minutes;
        prevSeconds = seconds;
    }

    // If the countdown is finished, stop the timer
    if (countdownTime <= 0) {
        clearInterval(countdown);
        document.getElementById("timer-form").innerHTML = "TIME'S UP";
    }
}, 1000);

Finally, please tell us which browser you're using (and the version thereof)

Latest Chrome

@ghost ghost changed the title Automatic (form) input save while 'timeout' in effect Specify exact time for selected elements / Automatic (form) input save while 'timeout' in effect Oct 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

0 participants