PennController for IBEX › Forums › Support › Trying to set a unique participant ID/code for Amazon Mechanical Turk payment › Reply To: Trying to set a unique participant ID/code for Amazon Mechanical Turk payment
Blocks of trial commands are actually arguments passed to the newTrial function (PennController has been deprecated for a few versions now) and, as such, they are evaluated at the very beginning of the experiment. Which means that the string you pass to your newText command is also evaluated before any trial has effectively run, ie. before your "ParticipantID" Var element has been instantiated.
const participant_id = b64_md5((Date.now() + Math.random()).toString());
Then you can do things like newText("code", "<p>Your unique identifying code is: "+participant_id+"</p>")) and .log("Participant id", participant_id) on the closing parenthesis of newTrial (PennController)
Let me know if you have questions