Automatic credit granting, and group assignment

PennController for IBEX Forums Support Automatic credit granting, and group assignment

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #5164
    suphasiree
    Participant

    Hello Jeremy,

    I am configuring the experiment so that participants from SONA will automatically receive credit after they finish taking the experiment. I am planning to set up 4 separate studies on SONA for each of my group/list, and giving the respective links to the list I want the participants to see (e.g., for List 1: https://expt.pcibex.net/ibexexps/MYACCOUNT/MYEXPERIMENT/server.py?withsquare=0&id=%SURVEY_CODE%, etc). This is so I can control how many subjects are run in each group/list.

    For automatic credit granting, I have included this code at the beginning to collect the ParticipantID from SONA:

    Header(
        newVar("id")
            .global()
    )
    .log( "ParticipantID" , getVar("id"), PennController.GetURLParameter("id") );

    And at the end, I included this code to redirect participants to automatically receive credit from SONA (blahblahblah and XXXX used as placeholders for now):

    newTrial( "exit" ,
        newText("<p>Your results have been saved, but you need to validate your participation below. This is a necessary step to grant you credits!</p>")
            .print()
        ,
        newText("<p><a href='https://ucdavis.sona-systems.com/blahblahblah&credit_token=XXXXX&survey_code="+PennController.GetURLParameter("id")+"'>Click here to confirm my submission on SONA</a>.</p>")
            .print()
        ,
        newButton("void")
            .wait()
    );

    These are my questions:

    1. Since I can’t fully test the credit granting, do the codes and URLs above seem correct to you? Did I do it right?

    2. Given that I want to grant credit automatically and also have control over group assignment, does that mean I have to create 4 separate PC Ibex experiments? (all identical, except for the last part where the unique link for credit granting will be different?)

    Thank you so much for your help!

    #5165
    Jeremy
    Keymaster

    Hello!

    1. Everything looks OK as far as I can tell, but I think you should be able to test SONA’s credit granting if you can create a dummy account. At least this is what I did in the past, and I setup my SONA projects to only accept my dummy account as a participant (maybe I also password-protected them?) and I was able to do a proper testrun

    2. Do you mean that the credit token will be different for different SONA experiments? I forget. If so, you could check the value of withsquare from the URL at the top of your script and set a variable accordingly that you use to generate your link:

    credittoken = "";
    
    switch (GetURLParameter("withsquare")) {
      case 0:
        credittoken = "hellothere";
        break;
      case 1:
        credittoken = "byenow";
        break;
      case 2:
        credittoken = "salutsalut";
        break;
      case 3:
        credittoken = "bonbahaplus";
        break;
    }
    
    // ...
    
        newText('Click here to confirm my submission on SONA.')

    Jeremy

    #5166
    suphasiree
    Participant

    Thank you so much, that helps a lot! I will use that example code to set separate values for the Experiment ID and the Credit token for each experiment/list!

    #5167
    suphasiree
    Participant

    Jeremy, is there a difference in how the double quote (“) and single quote (‘) should be used in that last part of your code?

    (I want to make sure I edit the code correctly!)

    #5168
    Jeremy
    Keymaster

    No difference, I was just trying to make the forum’s syntax-highlighter happy

    #5170
    suphasiree
    Participant

    Hi Jeremy, I just tested it out as a fake participant and the Participant ID part of the redirect URL works.

    However, the redirect link did not contain the set variables for experiment_id and credit_token, for some reason. They were just blank. I am not sure why the variables were not populated in the redirect link?

    Example of the generated redirect link (with missing experiment ID and credit token value): https://ucdavis.sona-systems.com/webstudy_credit.aspx?experiment_id=&credit_token=&survey_code=12345

    Is there a particular place where I should paste the check value / set variable code ? I had pasted it right after PennController.ResetPrefix(null);

    This is the code I am working on (using real values for experimentID and credittoken):

    PennController.ResetPrefix(null);
    
    experimentID = "";
    switch (GetURLParameter("withsquare")) {
      case 0:
        experimentID = "blah1";
        break;
      case 1:
        experimentID = "blah2";
        break;
      case 2:
        experimentID = "blah3";
        break;
      case 3:
        experimentID = "blah4";
        break;
    }
    
    credittoken = "";
    switch (GetURLParameter("withsquare")) {
      case 0:
        credittoken = "hellothere";
        break;
      case 1:
        credittoken = "byenow";
        break;
      case 2:
        credittoken = "salutsalut";
        break;
      case 3:
        credittoken = "bonbahaplus";
        break;
    }
    
    // ...
    
    newText('<p><a href="https://ucdavis.sona-systems.com/webstudy_credit.aspx?experiment_id='+experimentID+'&credit_token='+credittoken+'&survey_code='+PennController.GetURLParameter('id')+'">Click here to confirm my submission on SONA</a>.</p>')
    • This reply was modified 3 years, 12 months ago by suphasiree.
    • This reply was modified 3 years, 12 months ago by suphasiree.
    #5174
    Jeremy
    Keymaster

    That’s because the counter value from the URL is interpreted as a string but the switch statement tests for numbers. Use Number(GetURLParameter("withsquare")) to make sure the counter value from the URL is interpreted as a number.

    Jeremy

    #5177
    suphasiree
    Participant

    Hi Jeremy, now the redirect link works as intended! Thank you again for all your help, I really appreciate it!

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