Skip to main content

Class StroopTestDataHandler

Accumulates per-stimulus response records during a Stroop Test session and transmits them to the backend at the end of the scenario.

public class StroopTestDataHandler : MonoBehaviour

Inheritance​

Examples​

Feed a response from the Stroop generator when a participant presses a button:

// Inside StroopTestGenerator, on button press:
var record = new StroopTestDataHandler.StroopTestRecord(
actionName, currentStimulus,
DateTimeOffset.Now.ToUnixTimeMilliseconds(), elapsedTime);
_dataHandler.CacheInputRecord(record);

To trigger transmission manually (e.g. from a debug button) rather than waiting for the game mode event:

_dataHandler.SendToServer(() => Debug.Log("Stroop data sent."));

Remarks​

Add this component to the same GameObject as StroopTestGenerator. During the test, StroopTestGenerator calls StroopTestRecord) on each participant button press, building up the in-memory log. When the scenario ends, Action) serialises the log to JSON and enqueues it with IDataSendService. A guard prevents double-submission if the game mode fires the send event more than once.

Methods​

CacheInputRecord(StroopTestRecord)​

Caches a single Stroop Test input record.

public void CacheInputRecord(StroopTestDataHandler.StroopTestRecord loggingData)

Parameters​

NameTypeDescription
loggingDataStroopTestDataHandler.StroopTestRecordThe data to cache.

SendToServer(Action)​

Sends the cached Stroop Test data to the server.

public void SendToServer(Action callback)

Parameters​

NameTypeDescription
callbackActionCallback to invoke after sending completes.

Examples​

Example usage with an inline lambda:

stroopDataHandler.SendToServer(() => {
Debug.Log("Stroop data successfully sent to the server.");
});

Example usage with a named method:

stroopDataHandler.SendToServer(OnStroopDataSent);

void OnStroopDataSent()
{
Debug.Log("Callback: Data sent.");
}