Skip to content

Commit

Permalink
adding countdown to Prolific redirect after trial completion if Proli…
Browse files Browse the repository at this point in the history
…fic completion code is populated as env var (#45)
  • Loading branch information
varun646 authored Aug 26, 2024
2 parents 6cf49dc + 1d25cbf commit 8b6f0ee
Showing 1 changed file with 22 additions and 5 deletions.
27 changes: 22 additions & 5 deletions template/experiment-ui/pages.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,30 @@
* This is the end page that is shown after the experiment
*/
function endPage() {
let link = ''
if (process.env.REACT_APP_redirect !== '') {
link = `<a href="${process.env.REACT_APP_redirect}">Back to prolific</a>`
let link = '';
let atag = '';
let interval;
// the value compared below is hardcoded in the .env file produced by Copier
// if you modify the value in the .env file or your env vars to a completion code provided by Prolific
// a link will be presented to users that redirects to Prolific with the completion code populating
// a query string parameter
if (process.env.NODE_APP_completionCode !== 'ABCD1234') {
link = 'https://app.prolific.com/submission/complete?cc=${process.env.NODE_APP_completionCode}';
let countdown = 5;
atag = `<a href=>Click here to redirect to Prolific.</a> You will be redirected automatically in <span id="countdown">${countdown}</span> seconds...`;
interval = setInterval(() => {
countdown -= 1;
document.getElementById('countdown').innerText = countdown;
}, 1000);

setTimeout(() => {
clearInterval(interval);
window.location.href = link;
}, 5000);
}
let html = `<div class="msg">Thank you for participating in our experiment.<br/>${link}</div>`
let html = `<div class="msg">Thank you for participating in our experiment.<br/>${atag}</div>`;

document.body.innerHTML = html
document.body.innerHTML = html;
}

function waitPage() {
Expand Down

0 comments on commit 8b6f0ee

Please sign in to comment.