Logging randomly generated IDs for MTurkers

PennController for IBEX Forums Support Logging randomly generated IDs for MTurkers

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #9867
    JunLyu
    Participant

    Hi 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!
    Jun

    #9879
    Jeremy
    Keymaster

    Hi 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

    #9886
    JunLyu
    Participant

    Hi 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

    #9895
    Jeremy
    Keymaster

    Hi 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

    #9896
    JunLyu
    Participant

    Hi 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();">&nbsp;
    <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

    #9897
    Jeremy
    Keymaster

    Hi 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 results

    Jeremy

    #9900
    JunLyu
    Participant

    Thank you Jeremy! Now it works.

Viewing 7 posts - 1 through 7 (of 7 total)
  • You must be logged in to reply to this topic.