record('letter',letter);
InsertRecord('letter',letter);
setValue('decisions', 'playerNr=' + playerNr + ' and period=' + period, 'letter', letter);
var PID= getInt("PID");
var Cond= getInt("Cond");
if (Cond>8) {
if (PID ===1) {letter="A";}
else if (PID ===2) {letter="B";}
else if (PID ===3) {letter="C";}
else if (PID ===4) {letter="D";}
else if (PID ===5) {letter="E";}
else if (PID ===6) {letter="F";}
else if (PID ===7) {letter="G";}
else if (PID ===8) {letter="H";}
}
//assign University IDs
if (Cond<9) {
if (PID ===1) {letter="USC-A";}
else if (PID ===2) {letter="USC-B";}
else if (PID ===3) {letter="USC-C";}
else if (PID ===4) {letter="USC-D";}
else if (PID ===5) {letter="OSU-E";}
else if (PID ===6) {letter="OSU-F";}
else if (PID ===7) {letter="OSU-G";}
else if (PID ===8) {letter="OSU-H";}
}
//set endowments
//HeteroUSC HeteroOSU
if (Cond===3 || Cond===7 ||Cond===10) {
if (PID===1) {endowment=20;}
else if (PID===2) {endowment=10;}
else if (PID===3) {endowment=20;}
else if (PID===4) {endowment=10;}
else if (PID===5) {endowment=20;}
else if (PID===6) {endowment=10;}
else if (PID===7) {endowment=20;}
else if (PID===8) {endowment=10;}
}
// RichUsc poorOSU
if (Cond===1 || Cond===5 || Cond===9) {
if (PID===1) {endowment=20;}
else if (PID===2) {endowment=20;}
else if (PID===3) {endowment=20;}
else if (PID===4) {endowment=20;}
else if (PID===5) {endowment=10;}
else if (PID===6) {endowment=10;}
else if (PID===7) {endowment=10;}
else if (PID===8) {endowment=10;}
}
//poor USC rich OSU
if (Cond===2 || Cond===6) {
if (PID===1) {endowment=10;}
else if (PID===2) {endowment=10;}
else if (PID===3) {endowment=10;}
else if (PID===4) {endowment=10;}
else if (PID===5) {endowment=20;}
else if (PID===6) {endowment=20;}
else if (PID===7) {endowment=20;}
else if (PID===8) {endowment=20;}
}
//med all
if (Cond===4 || Cond===8 ||Cond===11) {
if (PID===1) {endowment=15;}
else if (PID===2) {endowment=15;}
else if (PID===3) {endowment=15;}
else if (PID===4) {endowment=15;}
else if (PID===5) {endowment=15;}
else if (PID===6) {endowment=15;}
else if (PID===7) {endowment=15;}
else if (PID===8) {endowment=15;}
}//GROUP FORMATION//ID segregatedif (Cond<4 || Cond>8) { if (PID<5) subgroup=1; else subgroup=2;}//ID mixedif (Cond>4 & Cond<9) { if (PID<3) subgroup=1; else if (PID>6) subgroup=1; else subgroup=2;}if (Cond<4) { if (PID<5) {subgroup=1; } else {subgroup=2;}}//ID mixedif (Cond>4 & Cond<9) { if (PID<3) {subgroup=1; } else if (PID>6) {subgroup=1; } else {subgroup=2;}}record ('subgroup',subgroup);record ('endowment',endowment);record ('letter',letter);Hi Thomas,JavaScript (JS) functions that take multiple parameters have those parameters separated by commas. Using commas to separate thousands (as in your example) will not work, as the three zeroes at the end will be interpreted as an additional parameter of the function.From the experiment on the repository, stage 9, I can see that you have wrapped all your record() functions in an 'if' statement. This will lead to errors. See the warning box here: https://lioness-doc.readthedocs.io/en/latest/040_reference_manual.html#writing-to-the-database . In your case I would record all of these custom variables in a previous stage (e.g. stage 1) and use setValue from there on out. The setValue() function will work as normal inside if statements.Furthermore, the record() function is to write to the database. It does not define the value of a JS variable in a stage. In your script (stage 9), for example, you cannot use 'cash_start' in a text element by only writing:record('cash_start', 50000);This will merely write the value 50000 to the column 'cash_start' for this participant. If you want the value to be available in text elements you should write:cash_start = 50000 /* this defines a JS variable and assigns a value to it */record('cash_start', cash_start); /*this writes that value to the decisions table */Cheers,
Lucas
Hi Thomas,
Thank you for your question. I noticed the LIONESS documentation could have been clearer on this.The function record() will create a variable in the decisions table with the name of the first argument and the value of the second argument. By contrast, the function setValue() will update the value of an existing variable in the database, which may be created with a standard input element, or with the record() function.This information can also be found in this (now updated) part of the documentation: https://lioness-doc.readthedocs.io/en/latest/040_reference_manual.html#writing-to-the-databaseLucas
Hi Liliana,
In stage 7 your JS element should be placed above the text element where it is used. Hopefully that solves it.
Besides, in stage 6 you are using the record() function inside another function. This might not work stably. Probably it’s safer to write record(‘quizScore’,0) before the function and then use setValue() within a function.
Cheers, Lucas
--
You received this message because you are subscribed to the Google Groups "LIONESS Lab help and discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to lioness-lab...@googlegroups.com.
To view this discussion, visit https://groups.google.com/d/msgid/lioness-lab/50536dc7-cb6e-4d8f-806e-0ba6f64258e5n%40googlegroups.com.