Millisecond Forums

How to link Inquisit script and demographic script

By Penny - 2/6/2008

Dear all,

I designed an IAT (Implicit Association Test) script to compare students' response towards two universities. I also designed the demographic scripts for further sub-group analysis (thanks for the wonderful functions of Inquisit 3). Now I do not know how to link these two scripts, and let it run from the IAT to the demographic questions without interruption or transfer.

Here is the beginning of IAT Inquisit:

/ subjects = (1 of 2)
/ preinstructions = (overview1, overview2, overview4, overview5, consent, begin1, begin2)
/ postinstructions = (end)
/ blocks = [1=Target1_practice;

/ subjects = (2 of 2)
/ preinstructions = (overview1, overview2, overview4, overview5, consent, begin1, begin2)
/ postinstructions = (end)
/ blocks = [1=Target2_practice;

Here is part of the demographic script:

<dropdown gender>
/ caption = "Gender"
/ options = ("female", "male")

<textbox age>
/ caption = "Age"
/ mask = positiveinteger
/ range = (7, 110)

<surveypage demographics1>
/ caption = "Please answer the following demographic questions"
/ fontstyle = ("Verdana", -16, true, false, false, false, 5, 0)
/ questions = [1=gender; 2=age; 3=degree; 4=living; 5=alumni; 6=relationship]

Your help is highly appreciated!



By Mia - 2/6/2008

Hi Penny,

You can do that with the batch element. It allows to run a group of Inquisit scripts in a sequence (you will find some details in the Inqusit help). All you have to do is to program two experiments, one for the IAT and another for your demographics, and than put them together in a new batch than might look like this:

/ file = "IAT.exp"
/ file = "demographics.exp"

(Before and after "batch" insert those arrows, they disappear on this page)

When you start the batch, just make sure that all other files (i.e. your IAT.exp and the demographic.exp) are located in the same folder as you new batch.exp. The subject ID will be carried over from one experiment to the other.

Bye, Mia
By Rickardcarlsson - 3/9/2008

I have a related question. I want to do the exact same thing: an IAT-script followed by a demographic survey. However i want to adminstrate it online. Will a similar batch-command work in the web-version? I was under the impression that only registered .exp will record data It would be absurd if it would require multiple licenses to utilize the survey function in this manner. In that case i will stick with old (not so quite so nice) soloutions that worked in inquisit 2 (e.g. likerts in the same script).

By seandr - 3/9/2008

Yes, you can run multiple scripts using the batch element with Inquisit web edition. The script file that you should register is the one containing the <batch> element (not the ones with IAT or survey).


By Rickardcarlsson - 3/31/2008

That's great! But I wonder how I should go about so that I can easily identify and pair up the two .dat-files that are produced.  I will sometimes for ease of admininstration let many people use the same subject number (instead i use subject number to counter-balance to certain conditions). However then it is impossible to tell which demographic data file that goes with which IAT data file.

Often I can be fairly certain because of IP number and minute and seconds it was done. However sometimes 30 people with same external IP will perform the test and be done just about at the same time.

Is there a work around for this? Or is it possible to incorporate survey-pages in the same script as the IAT so to produce a single data file?

By seandr - 4/1/2008

Yes, it's certainly possible to include the demographic survey in the same script as the IAT. I just wrote the article at this link, which explains how to do this:

The article uses the example of combining two IATs, but the same strategy applies to combining an IAT with a survey, or any two measures.

If anything in the article is unclear, let me know.



By Rickardcarlsson - 4/2/2008

Ok, thanks good guide. As of now I have already integrated my survey with my IAT script, simply by adding the elements. It works just fine with one exception. The data I collect from the IAT (the rest of the script) is stored in a .dat file called iat.dat (which is the name of my script) but the data from the survey is stored in a .dat file named surv.dat (which is the name of the survey included in the script). Why is this? Is there some work around? Would using the include strategy solves this problem?

The problem right now is that I will sometimes get 50 .dat files with IAT-data and 50 .dat files with survey data to download from Since they all use one of two subject  IDs (1, 2) I cannot be sure which IAT.dat goes with which surv.dat. Or will they always come up in pairs in the web file manager? If that is the case then there is no big problem.

By seandr - 4/4/2008

By default, survey data is saved in a different file than reaction time data because the kinds of analyses done on these types of data are typically very different.

With surveys, it's usually much more convenient to have 1 row of data per subject, with responses from each survey item in a separate column.

With reaction time data, you are typically computing metrics such as means, medians, Cohen's D, d prime, etc. based on very large sets of trials grouped by various treatment conditions. You may often want to discard particular trials with excessively high or low latencies. These kinds of analyses would be extremely cumbersome (dare I say impossible) if all of the data from each trials (response, latency, treatment conditions) were somehow put into a single enormous row for each subject.

You can record your survey data in the same file as your reaction time data, however. Each <surveypage> is a specialized kind of <trial>, so you can insert survey pages in your /trials list of your <block> elements. When a surveypage is run as a trial in a <block> (as opposed to a page in a <survey>), its data are recorded in the the main data file (i.e., IAT.dat in your case), with each survey item appearing as a separate row.

If you want separate files, and you are recycling the same subject numbers across different subjects, then you'll need to rely on some additional cues to correlate the two data files. Specifically, you should be able to match up most of the files using the subject number, date, and time columns. In the event those values are the same for multiple participants, you could disambiguate them using the ip address, which is saved in the name of the data file.


By Maria - 9/20/2009

Hi Sean,

I've used a batch file to combine an IAT with a survey. However, at the end of the IAT, there appears a page saying "The experiment has ended". Only when you press CTRL + b, you are led to the survey part. Is it possible to avoid the page in between?

I tried to put the survey part into the IAT file, changing "surveypage" into block, "questions" into "trials" and "survey" into "expt". Do I have to change for example the "textbox" into "trial" as well? How does the programme know then what format the question is supposed to have?

Thanks in advance.


By seandr - 9/21/2009

Hi Maria,

To remove the "The experiment has ended." message, just delete the "/endlock=true" command from the <defaults> element.

Sounds like you've otherwise gotten the <batch> option to work. Let me know if you need anything else.


By Maria - 9/21/2009

Hi Sean,

thanks a lot for your quick reply, this works out perfectly. Now the batch file is running without any problem.


By Andrea Deme - 10/2/2014

Dear All,

I have problem that is connected to the batch files and running 2 scripts (IAT and demographic survey) as well.
The probem is that I use a custom launch page and it seems that just because of that all the participants get the same id (the same number basically).

As I use a batch file and I get data in 2 separate dat files, it would be of - so to speak - vital importnace to be able to pair them up unambigously. Cold you help me, how I could make Inquisit to use "sequential id" mode with my custom launch page (attached)?

Or else (if this is not possible) could you please clarify how I could include the survey pages as trials into the IAT to get just one simple output (dat) file? That previous answer was unfortunately too brief for my limited experience with Inquisit.

thanks a lot!!
By Dave - 10/2/2014

Look at your launch page's source code. The subject number is generated / returned by

function GetSubjectNumber()
    return "3";

As it stands, your function simply returns a constant value -- 3. If you wanted sequential IDs, you cannot simply do this in JavaScript -- you'd need a database running in the backend to keep track of which IDs have already been passed out, etc.

What you can do in JavaScript, is return a *random* ID. While it is possible that such a function could return the same ID for two different participants over the course of time, it is exceedingly unlikely (because the sampling space is so huge).

function GetSubjectNumber()
   return (Math.floor(Math.random() * 1000000000));

You can alternatively (or in addition) merge your two scripts. <survey> elements are special types of <block>s and <surveypage> elements are special types of <trial>. You simply integrate those into your IAT script as you would with any other additional block etc. See the "How to Combine Multiple Scripts" topic in the documentation.
By Andrea Deme - 10/2/2014

Thanks for the quick reply!! i am already relieved:)

one more question: would it be possible to simple include the elements of the survey in the IAT without using the inlcude element? (I know it is more complicated in a way, but still... )

I'll do the modification in the script as well.

thanks again! 
By Dave - 10/2/2014

You don't need to use <include>. In fact, putting the elements directly into a single "main" script is probably easier -- all <include> does is paste the contents of one file into another, so it amounts to the same thing anyway.
By Dave - 10/2/2014

One more thing: If you want to end up with all the data in a single file per subject, you must avoid using <survey> elements (those will always generate a separate output file). Instead, run any surveypages via <block> elements.
By Andrea Deme - 10/2/2014

I did include all the blocks and trials in the main script (attached) but the problem is that he options on the survey pages appear in black (on black background) so they are invisible. On which level could/should I change the font color?

The second comment is also great, thanks! But I am afraid that I am not sure what you mean by running surveypages via block elements. Should every surveypage be included/embedded in a block element or should I reconstruct the <surveypage> elemnts to trials and the <survey> to <block> by transforming the synatx of these? 
By Dave - 10/2/2014

Instead of

<survey mysurvey>
/ pages = [1=page1; 2=page2; ...]

you do

<block mysurvey>
/ trials = [1=page1; page2; ...]

In the <block> that runs the <surveypage>s, set the /screencolor attribute to what you want / need.
By Andrea Deme - 10/2/2014

You are great, thanks a lot!!!

And now I faced another problem :)
My script, as it is usual, should give compatible-incompatible and incompatible-compatible block orders for different participants (based on their IDs), but the way I introduced random ID selection in the jawa script keeps giving them even numbers all the time, so I don't have a balanced distribution of the 2 differemt orders above. I run 12 tests and I got incompatible-compatible order all the time (and even numbers as subj ID).
Is there a way I could affect the distribution of odd and even numbers?
By Dave - 10/2/2014

Either the condition assignment in your script is faulty, or you have not properly replaced the GetSubjectNumber() in the launch page's source or you're not refreshing the launch page between runs (which you need to do to get a new id).
By Andrea Deme - 10/2/2014

The puzzling thing is that I do get different numbers as IDs, but all of them just seems to be even numbers (see attached), and I have no idea, why :(
The script must be okay, I think, as if I run it on the PC with odd and even numbers as IDs it changes the block order...
(And I  modified the launch page just as you instructed me to, but according to the huge numbers, it is working properly, i think...)
By Dave - 10/2/2014

Hmm, weird. (1) It is, of course, perfectly possible to receive multiple even ids in a row. Same thing as tossing a coin -- nothing prevents in from landing heads multiple times in a row. Over the long run, though, the expectation is approx. 50% heads and 50% tails, or as here: 50% odd and 50% even numbers. (2) It might be that your browser's JavaScript engine has a bug or bias in its Math.random() or Math.floor() implementation. Would be interesting to know if the same happens across different browsers or if changing the function to e.g.

function GetSubjectNumber()
    return (Math.round(Math.random() * 1000000000));


function GetSubjectNumber()
    return (Math.ceil(Math.random() * 1000000000));

makes any (systematic) difference.

EDITED TO ADD: It is usually not advisable to use Math.round() because it will lead to the resulting distribution being non-uniform.
By Andrea Deme - 10/2/2014

yes, you are absolutely right about the multiple heads and tails, and that I shouldn't worry about this... I tried math.floor implementation again and multiple (5 or 6) odd numbers in a raw also occurred. than i tried ceil and seemed a tiny bit more balanced (but still, it was just 6 or 7 trials that is very impressionistic),
anyway, i'll  stick to that and thank you again for your time and effort! it was a huge help you just gave me!! :)
By Andrea Deme - 10/2/2014

oh, you looked it up! great!!! thanks a lot!! :)
By Dave - 10/2/2014

No problem. Note that I would generally recommend sticking with Math.floor(), which -- in theory -- should get you closest to a uniform odd/even distribution.
By Andrea Deme - 10/13/2014

dear Dave, sorry, itts me again... the very same scripts and html that run perfectly a week ago just went rong and I cannopt find the reason why... I did not modify any important parts in the script. it's probably a typical issue, please see the error messagge and the scripts and html attached. could you help me out again?
By Dave - 10/13/2014

The error message indicates no subject id was passed to the script. In case of the IAT that's fatal as the counterbalancing of conditions (cf. the <variables> element) relies on it.

As to why that is, I cannot tell you based on the materials you provided. I would need the live link to the actual launch page.
By Andrea Deme - 10/13/2014

Oh, okay, it's here:
By Dave - 10/13/2014

Thanks for the link. There is nothing obviously "wrong" with the launch page code. That said, I am able to reproduce the error using the latest Firefox version / the NPAPI plugin, but not using Internet Explorer / ActiveX or ClickOnce.

My guess would thus be that Mozilla changed their plugin handling (again) recently, essentially breaking the way the subject id and other information is passed from the launch page to the plugin via. The only quick "fix" I can think of is to direct your participants to complete the study using Internet Explorer (which is fortunately present on every Windows system by default).

Over the long run, I would recommend at least considering upgrading to Inquisit 4, which provides support for modern platforms and browsers.

P.S.: I'll be looking into this more deeply, but that'll take some time. Oddly enough, the issue does not seem to occur with standard launch pages generated via the Web Script Wizard, which suggests there is some (non-obvious) factor relating to the "custom" launch page you're using involved.
By Andrea Deme - 10/13/2014

Uhh, oh my... I tried explorer as well and it did work... thank you very much, you saved my day again. And yes, I'll put some pressure on the head of department and ask for the upgrade to Inquisit 4. So you say simply changing the html would not solve the problem, right? 
By Andrea Deme - 10/13/2014

Oh, I've just noticed the PS, sorry. It's probably a useful piece of additional info: I use a page created by simply modifying the standard launch page (so that I can format the text and instructions displayed on the first screen and translate some small instructions as well regarding the plugins), so this problem might be due to the fact that normally the standard page is more "flexible" and by simply copying and editing it I made something be fixed that should not be so...
By Dave - 10/13/2014

Did some more quick digging and testing. Try changing the GetSubjectNumber() function in the HTML source to

function GetSubjectNumber()
    return (Math.ceil(Math.random() * 1000000000)).toString();

and let me know if that resolves the issue in Firefox. (I have no idea why the original code suddenly stopped working there.)