Presenting a task depending on the counterbalancing condition within a XML file

Ask questions and discuss programming issues around Tatool Java.
Locked
a.rey-mermet
Posts: 39
Joined: Fri Mar 07, 2014 6:21 am
Institution: University of Zurich

Presenting a task depending on the counterbalancing condition within a XML file

Post by a.rey-mermet » Tue Jan 20, 2015 4:00 am

Hi!

I want that a control task occurs, depending on my counterbalancing condition. To this end, I created a java-file "CounterbalancingBatteryExecutable" similarly to "CodeExecutable" so that after the code of the participant is given, the experimenter has to enter the counterbalancing condition (1 for the first counterbalancing, 2 for the second counterbalancing) and a variable "counterbalancing_battery" is created with the code either 1 or 2.
Now, I want that my control task is performed only in the first counterbalancing. To do this, I have to put my variable "counterbalancing_battery" within the XML file in an if-loop (e.g., if counterbalancing == 1, then do the control task)
How can I do this?

Here is the XML file:
timerRating.xml
Thanks in advance for your help!
Alodie
You do not have the required permissions to view the files attached to this post.

alocher
Posts: 259
Joined: Tue Apr 24, 2012 12:56 pm
Institution: Tatool

Re: Presenting a task depending on the counterbalancing condition within a XML file

Post by alocher » Thu Jan 22, 2015 9:24 pm

You can't add an if clause to your XML as that won't help in your case. The XML is read into memory at startup which means it won't know anything about your counterbalancing condition yet. A way to achieve what you're looking for is by creating your own Selector. Within your Counterbalancing executable you can save a module property which you can then access in your selector and decide whether you'd want to execute any of the children within that ListElement (e.g. your control task).

Take a look at the SessionListSelector. This Selector does a similar check. It gets the current session number and checks whether the session number is part of a list of sessions, and only executes its child elements if the session number is present in the list (method canCreateIterator() on line 90). In your case you'd have to read the module property of your Counterbalancing executable and decide whether to run (yes iterator can be created) or not run (no don't create iterator and stop executing this ListElement) the child elements.

a.rey-mermet
Posts: 39
Joined: Fri Mar 07, 2014 6:21 am
Institution: University of Zurich

Re: Presenting a task depending on the counterbalancing condition within a XML file

Post by a.rey-mermet » Mon Jan 26, 2015 7:40 am

I think, I understand the idea, but at the moment, I don't know how to implement it. So, if I understand you correctly, I first have to create a module property in the Counterbalancing executable, such as:

Code: Select all

context.getExecutionData().getModule().getModuleProperties().put("Ausbalancierung", counterbalancing);
context.getExecutionData().getModuleSession().putValue(this.getId(), "Ausbalancierung", counterbalancing);
Then, I have to copy in my control task Executable the following code:

Code: Select all

 protected boolean canCreateIterator(ExecutionContext context) {
        long sessionNr = context.getDataService().getSessionCount(
                context.getExecutionData().getModule(), includeUnfinished);
        return (sessionList.contains((int) (sessionNr + 1)))
                && ((executedIterations < numIterations) || (numIterations < 0));
    }
Now, I have to change it so that it runs or not the the control task. But what do I have to change?
And don't I need to change anything in the XML file?

cheers,
Alodie

cvonbastian
Posts: 185
Joined: Tue Apr 24, 2012 8:22 am
Institution: Bournemouth University

Re: Presenting a task depending on the counterbalancing condition within a XML file

Post by cvonbastian » Mon Jan 26, 2015 8:55 am

Hi Alodie,

just a quick question in-between: is it really necessary to have the balancing fully automatized? I usually just use two different module files (e.g., forms A and B) and then 'manually' counterbalance participants (half gets A, half gets B). So if you're doing the experiment in the lab, I'd recommend that solution. Also if you'd conduct the experiment online, you could solve the counterbalancing via two module files by assigning half of the participants' codes to 'group A' and half of them to 'group B', with each group being associated with a different module file (if that's what you need, I could explain it to you in more detail).

Concerning the above code, what it does is to count the number of sessions and returns a boolean whether or not the result is part of the sessionList. In your case, you don't want to associate the execution with a specific sessionNr, but a variable that you get from some user input (similar to the CodeExecutable I guess). So the part that you want to change is what you extract from the ExecutionContext (i.e., .getSessionCount(context.getExecutionData().getModule(), includeUnfinished)).

a.rey-mermet
Posts: 39
Joined: Fri Mar 07, 2014 6:21 am
Institution: University of Zurich

Re: Presenting a task depending on the counterbalancing condition within a XML file

Post by a.rey-mermet » Mon Jan 26, 2015 12:54 pm

Hi Claudia,

In our project, we have 2 counterbalancing conditions about task orders across two sessions and 3 counterbalancing conditions about Stroop stimuli. Thus, we already have 6 module files. Now, for the second pilot, we want to introduce a control task at the beginning of session 2. Thus, it would make 12 module files. I was searching a way to reduce the number of module files in order to be simple as possible when handling the experiment files in the group lab. But at the moment, I don't understand how to do it.

cvonbastian
Posts: 185
Joined: Tue Apr 24, 2012 8:22 am
Institution: Bournemouth University

Re: Presenting a task depending on the counterbalancing condition within a XML file

Post by cvonbastian » Mon Jan 26, 2015 7:59 pm

Okay, as I understand it, as long as you're not having exactly the same executables in session 2, you'll need different module files for session 2 anyway, but I see why you may want to solve the Stroop stimuli situation differently (assuming that they all use the same Stroop executable). :)
So, what I think you need is a task such as the CodeExecutable that takes the counterbalancing version as input (let's say a value between 1 and 3 for the 3 conditions). This value has to be saved as a Module Property. You then have to access this value analogous to how the SessionNr is accessed in the above example. For this purpose, you have to access the module from the context. This is completely solved within your executables, you only have to add the counterbalancing task to your module file (e.g., put it right after the CodeExecutable).

This has to go into the executable that takes the version number as input:

Code: Select all

// create a property for the version value (1 to 3)
private static IntegerProperty versionProperty = new IntegerProperty("version");

// save keyboard input in variable
int value = (Integer) actionValue;

// set the value as property (i.e., save on the module level)
versionProperty.setValue(context.getExecutionData().getModule(), this, version);
You then have to access that value in the Stroop executable:

Code: Select all

// create a property for the version value (1 to 3)
private static IntegerProperty versionProperty = new IntegerProperty("version");

// get the version property value from the module
int stimuliFileVersion = versionProperty.getValue(context.getExecutionData().getModule(), this, 1);
After that, you can use the stimuliFileVersion to create some logic which stimuliFile to use.

Locked

Who is online

Users browsing this forum: No registered users and 1 guest