Hi,
in my last routine, i have a “finish experiment” button. Upon clicking this, participants should be redirected to prolific with the completionURL. However, the quit screen with the text “thank you for your patience” always shows up, requiring participants to press an additional button (“OK”).
Is there any way to automatically end the quit screen once the data is saved?
Thanks!
I don’t know of one…this period is important because it represents when the data is actually being saved.
I would recommend that you use the normal end rather than quitting in code for participants who have finished.
Thanks!
I don’t want to get rid of it entirely, just to automatically move on when the data is saved. Maybe the ok button can automatically get clicked once the dialog appears?
I know how to automatically click when the experiment is starting but there’s nowhere to add code to click when it has finished.
Could you please share how it works for when the experiment starts? Might be just what I need
Wouldn’t know for the builder but in the JS code, I was thinking right between these lines:
psychoJS.quit({message: message, isCompleted: isCompleted});
return Scheduler.Event.QUIT;
Okay, it seems easy enough knowing this post:
https://discourse.psychopy.org/t/is-there-a-way-to-skip-the-dialog-box-when-running-online/25625/4?u=ctwiehaus
Only: How do I find the elementID for where it says “Thank you for your patience” at the end?
Can you use developer tools when it’s on the screen?
Yes, I just found it there and it works now with the code below. Also works if you add a code component and enter the code in the End Experiment tab. Participants are now automatically redirected to Prolific with the completion URL and all data is saved
Thanks, @wakecarter for your support! The tip about the code for the starting dialog box helped me a lot!
var checkOK = setInterval(function() {
// Wait for the element containing "Thank you for your patience" to exist
var thankYouElement = document.querySelector(".scrollable-container");
if (thankYouElement) {
console.log("Thank you element found.", thankYouElement.innerText);
// If the text includes "Thank you for your patience," click the OK button
if (thankYouElement.innerText.includes("Thank you for your patience")) {
// Get the status of the OK button
var statusOK = document.getElementById("dialogOK").innerHTML;
console.log("Press Ok now...", statusOK);
// Click on the OK button if it's enabled
var okButton = document.getElementById("dialogOK");
if (okButton && !okButton.disabled) {
console.log("Clicking OK button...");
okButton.click();
} else {
console.log("OK button is not enabled.");
}
// Stop the interval
clearInterval(checkOK);
}
}
}, 100); // Check every 100ms
I am happy to assist but not exactly sure what you mean. It sounds like you have an item or something else in your code that is also called okButton?! What is the error message and do you see entries in the console log?
You can edit the var okButton and all its occurences in my code to anthing else.
Some more complex error was initiated trying to fix this, so I cannot track this down after all.