Difference between revisions of "Radcloud Datahandler script"
Wiki-admin (talk | contribs) |
m |
||
| (One intermediate revision by the same user not shown) | |||
| Line 9: | Line 9: | ||
=== Resources === | === Resources === | ||
| − | The Data handler code is available in SocSci GitLab: | + | The Data handler code is available in SocSci GitLab: {{Gitlab|tsg/radcloud-datahandler|Data handler in GitLab}} |
| − | Packaged versions of the script can be downloaded with tag 'Generic' from the | + | Packaged versions of the script can be downloaded with tag 'Generic' from the {{Gitlab|tsg/radcloud-datahandler/-/packages/|datahandler GitLab package registry}}. |
=== Implementation Examples === | === Implementation Examples === | ||
Example projects that show how you can integrate the data handler into your project: | Example projects that show how you can integrate the data handler into your project: | ||
| − | * | + | * {{Gitlab|tsg/jspsych-radcloud-simple-example|JsPsych radcloud example: I want the simplest possible setup}} |
| − | * | + | * {{Gitlab|tsg/jspsych-radcloud-esmodule|JsPsych radcloud example: I want to use modern JavaScript tooling}} |
== Choose Your Own Setup == | == Choose Your Own Setup == | ||
| Line 26: | Line 26: | ||
You do not need to install anything to start using the datahandler. For most experiments, this approach will be sufficient. | You do not need to install anything to start using the datahandler. For most experiments, this approach will be sufficient. | ||
| − | # Go to the following page: | + | # Go to the following page: {{Gitlab|/tsg/radcloud-datahandler}} |
# Copy the link of the version you want (latest or another pinned version). | # Copy the link of the version you want (latest or another pinned version). | ||
# Include the following line in your <code>index.html</code> file pointing to the socsci hosted URL. | # Include the following line in your <code>index.html</code> file pointing to the socsci hosted URL. | ||
| Line 36: | Line 36: | ||
datahandler.saveData(radcloudApiKey, ppn, mydata); | datahandler.saveData(radcloudApiKey, ppn, mydata); | ||
</pre> | </pre> | ||
| − | '''Note:''' Example project: | + | '''Note:''' Example project: {{Gitlab|/tsg/jspsych-radcloud-simple-example|JsPsych radcloud example: I want the simplest possible setup}} |
=== I Want to Download the Script and Host It with My Experiment === | === I Want to Download the Script and Host It with My Experiment === | ||
This approach involves using scripts that you can download from Socsci GitLab. | This approach involves using scripts that you can download from Socsci GitLab. | ||
| − | # Login to GitLab and go to: | + | # Login to GitLab and go to: {{Gitlab|tsg/radcloud-datahandler/-/packages}} |
# Get the latest version of the datahandler by downloading the file under 'datahandler - Generic'. | # Get the latest version of the datahandler by downloading the file under 'datahandler - Generic'. | ||
# Add the script to your JavaScript project. | # Add the script to your JavaScript project. | ||
| Line 52: | Line 52: | ||
datahandler.saveData(radcloudApiKey, ppn, mydata); | datahandler.saveData(radcloudApiKey, ppn, mydata); | ||
</pre> | </pre> | ||
| − | '''Note:''' Example project: | + | '''Note:''' Example project: {{Gitlab|tsg/jspsych-radcloud-example|JsPsych radcloud example}} |
=== I Want to Use Modern JavaScript Tooling === | === I Want to Use Modern JavaScript Tooling === | ||
| Line 67: | Line 67: | ||
saveData(radcloudApiKey, ppn, mydata); | saveData(radcloudApiKey, ppn, mydata); | ||
</pre> | </pre> | ||
| − | '''Note:''' Example project: | + | '''Note:''' Example project: {{Gitlab|tsg/jspsych-radcloud-esmodule|JsPsych radcloud example: I want to use modern JavaScript tooling}} |
== Save Data Parameters == | == Save Data Parameters == | ||
| Line 107: | Line 107: | ||
== JsPsych Radcloud Example == | == JsPsych Radcloud Example == | ||
| − | Git checkout project: | + | Git checkout project: {{Gitlab|tsg/jspsych-radcloud-example|JsPsych radcloud example}} |
== Migrating from Radcloud-mini == | == Migrating from Radcloud-mini == | ||
Latest revision as of 14:01, 5 August 2026
Datahandler Script
Introduction
The data handler script is designed to facilitate the upload of data to the Radcloud upload API endpoint. This script streamlines the process of transferring data from local systems to the remote server, ensuring that the data is accurately and efficiently uploaded to the intended API endpoint.
This page demonstrates the data handler script usage with an example.
Resources
The Data handler code is available in SocSci GitLab:
Data handler in GitLab
Packaged versions of the script can be downloaded with tag 'Generic' from the
datahandler GitLab package registry.
Implementation Examples
Example projects that show how you can integrate the data handler into your project:
JsPsych radcloud example: I want the simplest possible setup
JsPsych radcloud example: I want to use modern JavaScript tooling
Choose Your Own Setup
Download the datahandler script and make it part of your project. There are three different ways that you can add the Datahandler to your project. Which approach you choose will depend on what your goals are.
I Want the Simplest Possible Setup
You do not need to install anything to start using the datahandler. For most experiments, this approach will be sufficient.
- Go to the following page:
/tsg/radcloud-datahandler - Copy the link of the version you want (latest or another pinned version).
- Include the following line in your
index.htmlfile pointing to the socsci hosted URL.
<script src="https://www.socsci.ru.nl/tsg/radcloud-datahandler/1.5.7/datahandler.1.5.7.js"></script>
Call the function from JavaScript:
datahandler.saveData(radcloudApiKey, ppn, mydata);
Note: Example project:
JsPsych radcloud example: I want the simplest possible setup
I Want to Download the Script and Host It with My Experiment
This approach involves using scripts that you can download from Socsci GitLab.
- Login to GitLab and go to:
tsg/radcloud-datahandler/-/packages - Get the latest version of the datahandler by downloading the file under 'datahandler - Generic'.
- Add the script to your JavaScript project.
- Include the following line in your
index.htmlfile pointing to the file:
<script src="datahandler.1.5.7.js"></script>
Call the function from JavaScript:
datahandler.saveData(radcloudApiKey, ppn, mydata);
Note: Example project:
JsPsych radcloud example
I Want to Use Modern JavaScript Tooling
Tooling like npm and import statements. You can install the datahandler from Socsci GitLab package registry. This approach allows you to integrate the datahandler into your favorite JavaScript frameworks.
echo @tsg:registry=https://gitlab.socsci.ru.nl/api/v4/projects/2989/packages/npm/ >> .npmrc npm i @tsg/datahandler
Which installs the latest version of the datahandler. Follow up by adding the following import to your ES code:
import {saveData} from '@tsg/datahandler';
saveData(radcloudApiKey, ppn, mydata);
Note: Example project:
JsPsych radcloud example: I want to use modern JavaScript tooling
Save Data Parameters
The datahandler script accepts three parameters.
datahandler.saveData(radcloudApiKey, ppn, mydata);
- api_key: String containing the API key from your Radcloud experiment.
- ppn: The participant number as a string. If not supplied, the save will continue, and data will be added to your experiment under participant 0.
- data: The JavaScript object containing the data.
Example JSON object:
let mydata = {
"data": {
"id": "801744",
"experiment_id": "1176",
"number": 2,
"responseTime": null,
"buttonResponse": null,
"buttonPressed": 2,
"stimulus": "stimuli/image/unlock.jpg"
}
};
Response
A successful call to the upload endpoint will return the following response. It means your task is scheduled and will be processed soon.
Handling the Response in Your Code
datahandler.saveData(radcloudApiKey, mydata.ppn, mydata)
.then(response => {
if (!response.ok) {
message = `Warning: failed saving data (${response.message})`;
}
});
JsPsych Radcloud Example
Git checkout project:
JsPsych radcloud example
Migrating from Radcloud-mini
- Create a new experiment in Radcloud.
- Copy the new experiment API key into your script.
- Add the latest datahandler script to your experiment codebase.
- Modify the calls from
saveData(intodatahandler.saveData(. - Check the response handling and ensure proper error checking.
Warning: Data migration from radcloud-mini to radcloud is not supported.
Support
If you have any questions, suggestions, or feedback, please feel free to reach out to us via email at tsg@ru.nl. We'd love to hear from you and are always open to improving this project based on your input.