PennController for IBEX › Forums › Requests › Prevent participants from continuing if resources weren't downloaded
Tagged: CheckPreload, zip
- This topic has 2 replies, 2 voices, and was last updated 2 years, 9 months ago by irenecg.
-
AuthorPosts
-
February 24, 2022 at 6:30 pm #7808irenecgParticipant
Hi Jeremy,
I am running an online oddball (demonstration link here: https://farm.pcibex.net/r/fkspSF/) with MTurk, which means lots of people start the experiment at the same time. I have my resources (a bunch of videos) inside a zip file (5.1 MB) that gets downloaded when the study starts. What happens is that sometimes, for some of the participants, that downloading fails. So after waiting the two or three minutes that my CheckPreloaded phase allows, the study starts anyway and they just face a green screen.
I once asked about whether there was any way to, if the preloading of the zip file failed, to try it again, and I think the answer was that it wasn’t possible. My question is now slightly different: could there be a way in which if the preloading failed, the study gets frozen? I was thinking about adding a new CheckPreloaded with a 10-20 minutes duration, but then I’d need to modify the text so it says something different than the first CheckPreload phase (the one which is useful to actively download the zip file).Thanks!
IreneFebruary 24, 2022 at 7:57 pm #7809JeremyKeymasterHi Irene,
If you experience issues with preloading zip files, I suggest you try using PennController 2.1 beta, on which I am still currently working, where I revise the way zip files are downloaded
Then if you still need to detect failure to download the zip file, you could add a file named AA.js to your Modules folder (you want the filename to come before PennController.js in an alphanumeric order) with a content like this:
const zipError = ()=>{ const pe = document.querySelector(".PennController-PennController"); const parent = pe.parentElement; pe.remove(); const warning = document.createElement("P"); warning.innerHTML = "There was a problem loading resources for this experiment. Please reload this page to try again."; parent.append(warning); }; const oldFetch = window.fetch; window.fetch = function(...args){ const r = oldFetch.apply(this, args); if (typeof(args[0])=="string" && args[0].match(/\.zip$/i)) r.catch(zipError); return r; }
And to fully capture all the errors in the download process, also add this at the top of your project’s main.js script:
PennController._AddElementType("dummyelementname", function(PennEngine) { const olderror = PennEngine.debug.error; PennEngine.debug.error = function(...args) { if (typeof(args[0])=="string" && args[0].match(/Error downloading .+zip/)) zipError(); return olderror.apply(this, args); } })
Let me know if you have questions
Jeremy
February 25, 2022 at 4:02 am #7810irenecgParticipantGreat! Thank you! I’ll have a look at it!
-
AuthorPosts
- You must be logged in to reply to this topic.