PennController for IBEX › Forums › Support › Automatic credit granting, and group assignment
- This topic has 7 replies, 2 voices, and was last updated 4 years, 4 months ago by
suphasiree.
-
AuthorPosts
-
April 28, 2020 at 2:36 pm #5164
suphasiree
ParticipantHello 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!
April 28, 2020 at 3:37 pm #5165Jeremy
KeymasterHello!
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
April 28, 2020 at 4:55 pm #5166suphasiree
ParticipantThank 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!
April 28, 2020 at 5:03 pm #5167suphasiree
ParticipantJeremy, 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!)
April 28, 2020 at 5:04 pm #5168Jeremy
KeymasterNo difference, I was just trying to make the forum’s syntax-highlighter happy
April 28, 2020 at 5:51 pm #5170suphasiree
ParticipantHi 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 4 years, 4 months ago by
suphasiree.
-
This reply was modified 4 years, 4 months ago by
suphasiree.
April 29, 2020 at 11:36 am #5174Jeremy
KeymasterThat’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
April 29, 2020 at 1:39 pm #5177suphasiree
ParticipantHi Jeremy, now the redirect link works as intended! Thank you again for all your help, I really appreciate it!
-
This reply was modified 4 years, 4 months ago by
-
AuthorPosts
- You must be logged in to reply to this topic.