Modifying XML properties after it is loaded by a participant

Ask questions and discuss programming issues around Tatool Java.
Locked
StoneJ
Posts: 50
Joined: Thu Aug 29, 2013 10:39 am
Institution: University of Lancaster, UK

Modifying XML properties after it is loaded by a participant

Post by StoneJ » Sat Mar 29, 2014 2:59 pm

Hi,

In one of my currently ongoing studies I have a group of participants doing a certain training task. The XML file they download is set for them to run 4 blocks of 8 trials in each block which was chosen as it takes the average person 15 minutes to do that amount of trials and the participants only get paid for 15 mins of work per session they run.

Now, some of the participants are 5/6/7 sessions in and a few are saying the sessions are taking much longer than 15 mins for them, so I need to lower the number of executions.

I am guessing I know the answer, but is there some simple way to edit the properties of an XML once it is already loaded?

I am going to alter the actual executable and redefine the number of executions within that, repackage it, and send that out to the ones who need to do less. I am merely curious if there is a cleaner way?


Cheers,


James

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

Re: Modifying XML properties after it is loaded by a partici

Post by alocher » Sun Mar 30, 2014 4:46 am

Hi James,

I feel your pain. In one of the first studies where Tatool has been used, we encountered the same problem and had to do similiar workarounds. I remember writing a small application which participants could run to update the module xml file within the database that allowed us to keep all the old data. I unfortunately can't find the code anymore ...

For the next time the following feature will come in handy for you though:

1. The TimerListSelector allows you to set a timeout for how long the selector should iterate through child elements. The iterator accepts two properties, the normal numIterations property to set the maximum number of iterations allowed, and the timeout property to stop iterations after a specific timeout in miliseconds. It is important to understand that this will stop execution in the middle of a trial.

Usage

Set the TimerListSelector in your module xml file the same way you'd set any other element selector handler.

Code: Select all

<!-- TASK ITERATOR -->
<bean id="taskIterator" class="ch.tatool.core.element.TimerListSelector">
	<property name="timeout" value="10000" />
	<property name="numIterations" value="3" />
</bean>
Within your executable you'll have to trigger the start of the timer within your startExecutionAWT() method. The following method should do just that as it will search for a handler in the moduleHierarchy of the type ExecutionStartHandler and call the method startExecution of that handler. Don't worry if you're afraid that calling the startExecution method for every trial will reset the timer. Only the first time when the method is called the timer is started, otherwise nothing happens.

Code: Select all

private void triggerStartExecution(ExecutionContext context) {
        handler = (ExecutionStartHandler) ElementUtils.findHandlerInStackByType(context, ExecutionStartHandler.class);
        if (handler != null) {
            handler.startExecution(context);
        }
}
Hope that helps.

StoneJ
Posts: 50
Joined: Thu Aug 29, 2013 10:39 am
Institution: University of Lancaster, UK

Re: Modifying XML properties after it is loaded by a partici

Post by StoneJ » Sun Mar 30, 2014 6:27 am

Thanks for the detailed reply as always. Maintaining operation from the same module is my primary concern so that participants will continue from their current level.

Ok, I avoided the use of a timer to account for this possibility because I didn't want huge variations in the amount of trials one person does compared to another. I have experimented with the timer handlers on some of my other tasks, because of the lack of documentation it took me awhile to work out how to get them to work and even then I could only get TemporalListSelector to work, not TimerListSelector. Also getting them to work in conjunction with the visual timeouthandler to display the image in the status bar I think I needed to add a method or two to the source code to get it to work (whereas I am sure I needed to do something along the lines of the method you have posted above).

I have an upcoming experiment taking place in schools where time pressures will be much more strict so I will experiment with this code to achieve this function for that experiment.

Thanks,


James

Locked

Who is online

Users browsing this forum: No registered users and 1 guest