Replies: 1 comment
-
Problem solved, here is my new updated code which works `jsPsych.plugins['html-slider-response'] = (function() { var plugin = {}; plugin.trial = function(display_element, trial) {
jsPsych.finishTrial(trialdata); }; return plugin; |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hello, I need a slider plugin that I want to add for a replication of an experiment the problem is that the experiment was created using jspsych 5.0.3 so there was no slider plugin at this time.. I tried everything, to migrate the experiment to jspsych 7, to translate the code of the plugin htlm slider response for it to work on jspsych 5 or even to create a custom plugin. I spent more than 100 hours on it for nothing so now I come to seek your help I am desperate.
PS: I am very bad in programming I start just few weeks ago
here is the custom plugin I created :
`jsPsych.plugins['html-slider-response'] = (function() {
var plugin = {};
plugin.trial = function(display_element, trial) {
console.log(display_element); // add this line
html += '<button id="jspsych-html-slider-response-next" class="jspsych-btn" '+ (trial.require_movement ? "disabled" : "") + '>'+trial.button_label+'';
// wrap the html string in a jQuery object to use jQuery methods$html = $ ("
var
// append the html to the display element
display_element.append($html);
// define what should happen when the button is clicked
display_element.find('#jspsych-html-slider-response-next').on('click', function() {
// get the response value from the slider input element
response.response = display_element.find('#jspsych-html-slider-response-response').val();
if(trial.response_ends_trial){
// end the trial if response ends trial
end_trial();
display_element.find('#jspsych-html-slider-response-next').prop('disabled', true);
}
});
// function to end the trial
function end_trial(){
// clear all timeouts
jsPsych.pluginAPI.clearAllTimeouts();
// save the trial data
var trialdata = {
stimulus: trial.stimulus,
slider_start: trial.slider_start,
response: response.response
};
// clear the display element
display_element.empty();
// move on to the next trial
jsPsych.finishTrial(trialdata);
}
};
return plugin;
})();
`
I tried to base my work on the official plugin
Beta Was this translation helpful? Give feedback.
All reactions