How to implement unique codes/ids to allow for remote participants?

I am currently working on a website that researchers at universities can use to set up and run participant-based studies. The current MVP is out, however I have noticed a big flaw in how the website is set up, and I am unsure how to solve it to fit my users’ needs.

Currently the website is set up as follows:

  1. Someone who wants to do a research study can make an account and setup a study. Their study’s information is stored in the MySQL database tied to their research project id and that project id is associated with their account id.

  2. When the researcher is ready to do their study, they can sign into the website (this grabs their study information) and go to the “start splash screen” which is meant for participants. Then, they can bring in participants into their lab/classroom/etc. and sit them down at the computer. The participant goes through the study that the researcher sets up.

  3. When they are done and click submit, the participant’s information is stored on the database yet again tied to the research project id. The backend knows what the research project id is because the browser is logged in to the researcher’s account.

This method works great for those doing in-person, in-lab studies where they can control the laptop the participant uses, etc. However, I’ve gotten feedback about how researchers want to be able to send out links to participants so that they can complete the study on their own. Due to the way the backend is set up, I am not sure how to modify the website to allow this.

Ideally, I would have a separate webpage for participants to be directed to and they would put in some sort of unique ID/code that would link them to the correct study. That special code would have to pull the correct study information from the database for the participant to see, and then submit the participant’s answers to the database under the correct research project.

My question is how would you go about this change? How would you generate unique ids that would allow specific study information to be pulled from the database while also keeping in mind security? I think it would be best to have a one-time use code so random people cannot get ahold of a code and use it multiple times.

I might also be thinking of this completely wrong. Any advice, technologies, or solutions you may have would be amazing. Please let me know if I need to provide any more context! Thank you!

P.S I am using vanilla HTML, CSS, JS (Knockout) for frontend. Node/Express js, MySQL for backend.