Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Slider response doesnt being recorded #3415

Open
chen-goren opened this issue Oct 12, 2024 · 2 comments
Open

Slider response doesnt being recorded #3415

chen-goren opened this issue Oct 12, 2024 · 2 comments

Comments

@chen-goren
Copy link

chen-goren commented Oct 12, 2024

Hi,

According to the "image-slider-response" (ver. 2.0.0.) documentation, I should get the user's choice for the slider's position in my data file. Yet, I don't get any values besides "slider_start". Therefore, I tried to manually add that value to my data file using:
"on_finish: function(data) { data.slider = data.response; } but i only get "null" values...
I would appreciate any help...

This is my code so far:

var imageDisplayTrial = {
type: jsPsychImageSliderResponse,
stimulus: function () {
var img = getRandomImage();
return img;
},
trial_duration: 5000,
post_trial_gap: 500,
stimulus_height: 400,
stimulus_width: 400,
labels: ['+', '-'],
prompt: "

Emotion

",
require_movement: false,
response_ends_trial: false,
min: 0,
max: 100,
slider_start: 50,
button_label: 'Continue', // This will be hidden via jQuery
on_load: function() {
$('.jspsych-btn').hide(); // Use jQuery to hide the button when the trial starts
},
data: {
task: 'image_display',
group: selectedGroup
},
on_finish: function(data) {
data.slider = data.response;
}
};

Thanks!

@Shaobin-Jiang
Copy link
Contributor

This is expected behavior of the image-slider-response plugin, as the participant ought to submit their response via a button click and the absence of that button click indicates no response. In your case, you just have to make some tweaks from within on_load and on_finish.

In on_load, add this:

document.querySelector('#jspsych-image-slider-response-response').addEventListener('input', (event) => {
    window.slider_value = event.target.value;
});

Then in on_finish, do this:

data.slider = window.slider_value ?? data.slider_start;

@chen-goren
Copy link
Author

Thank you very much Shaobin-Jiang, it worked!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants