PennController for IBEX › Forums › Support › Logging randomly generated IDs for MTurkers
- This topic has 6 replies, 2 voices, and was last updated 2 years, 1 month ago by
JunLyu.
-
AuthorPosts
-
January 31, 2023 at 3:41 pm #9867
JunLyu
ParticipantHi Jeremy,
I am trying to embed an html (named “ID” below) that allows participants online to generate a random ID and copy-paste it both in PC Ibex and Qualtrics. As I tried, the results file do not contain the generated ID (the webpage shows normally). Here is the code I used:
//Generate random IDs newTrial("ID", newHtml("ID", "ID.html") .cssContainer({"width":"720px"}) .center() .print() .log() , newButton("continue", "Click to continue") .center() .print() .wait(getHtml("ID").test.complete() .failure(getHtml("ID").warn()) ) )
Could you please let me know which part of the code is incorrect? In the old Ibex, I simply used something like this
["ID", "Form", {html: {include: "ID.html"}}]
and the IDs are registered automatically.Thank you!
JunFebruary 3, 2023 at 9:29 am #9879Jeremy
KeymasterHi Jun,
What version of PennController are you using? Also, what does your HTML file look like?
Using PennController 2.0 and this HTML code, things work just fine for me:
<script> function newCode() { const randomCode = [...Array(8)].map(()=>Math.round(Math.random()*10)).join(''); document.querySelector("#code").value = randomCode; document.querySelector("#codeDisplay").innerText = randomCode; } </script> <button onclick="newCode()">Generate code</button> <input id='code' type='text' name='code' style='display:none;' class='obligatory' /> <p>Your code is <span id='codeDisplay'></span></p>
Jeremy
February 3, 2023 at 2:25 pm #9886JunLyu
ParticipantHi Jeremy,
The html itself works fine (both my old html that generates the ID and your code). But the ID generated on the html cannot be found in my results file. Here is what my html file (not the script which works) looks like:
“We require you to generate a unique identifier so that we can match your reading experiment answers to the questionnaire.
1. Click on the following button to create your unique identifier.
(A button here says “create unique identifier)2. Copy and paste the identifier above into the box below:
(there is a box here in which participants can copy-paste the ID; I am supposed to see this ID in the results file but I do not)3. Also copy and paste the identifier above into the “Participant ID” box on Qualtrics (the questionnaire that you opened).”
I should be able to see the ID participants generate. But now I cannot. So I wonder whether my code in the “main” script is incorrect:
//Generate random IDs newTrial("ID", newHtml("ID", "ID.html") .cssContainer({"width":"720px"}) .center() .print() .log() , newButton("continue", "Click to continue") .center() .print() .wait(getHtml("ID").test.complete() .failure(getHtml("ID").warn()) ) )
Jun
February 8, 2023 at 11:00 am #9895Jeremy
KeymasterHi Jun,
Do you mind sharing the raw content of your HTML file? You can either post the code or share your experiment’s URL on this thread, or send it at support@pcibex.net if you don’t want to share it publicly
Jeremy
February 8, 2023 at 2:04 pm #9896JunLyu
ParticipantHi Jeremy,
Yes, here is the html code.
<script language="javascript" type="text/javascript"> function randomString() { var chars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz"; var string_length = 8; var randomstring = ''; for (var i=0; i<string_length; i++) { var rnum = Math.floor(Math.random() * chars.length); randomstring += chars.substring(rnum,rnum+1); } document.randform.randomfield.value = randomstring; } </script> <h3> Participant ID: </h3> We require you to generate a unique identifier so that we can match your reading experiment answers to the questionnaire.<br> <br> <table> <tr> <td colspan="1"> <b> 1. Click on the following button to create your unique identifier. </b> </td> </tr> <tr> <td> <form name="randform"> <input type="button" value="Create unique identifier" onClick="randomString();"> <input type="text" name="randomfield" value=""> </form> </td> </tr> <tr> <td> <b>2. Copy and paste the identifier above into the box below: </b> </td> </tr> <tr> <td colspan="1"> <textarea name="identifier" rows="1" cols="8" class="obligatory"></textarea> </td> </tr> </table> <tr> <td> <b>3. Also copy and paste the identifier above into the "Participant ID" box on Qualtrics (the questionnaire that you opened): </b> </td> </tr>
I have copied my project. Here’s the link to the project copy:
https://farm.pcibex.net/r/dmGVab/
Jun
February 8, 2023 at 2:19 pm #9897Jeremy
KeymasterHi Jun,
Your “ID” trial comes after your
SendResults
, so whatever the participant types after that point just won’t be sent as part of the resultsJeremy
February 8, 2023 at 2:54 pm #9900JunLyu
ParticipantThank you Jeremy! Now it works.
-
AuthorPosts
- You must be logged in to reply to this topic.