Replies: 2 comments
-
@jspsych/core would love to get some thoughts on this! |
Beta Was this translation helpful? Give feedback.
0 replies
-
Another option that we could pursue would be to allow var switch_node = {
timeline: function(){
var data = jsPsych.data.get().last(1).values()[0];
switch (jsPsych.pluginAPI.compareKeys(data.response)){
case criminal:
return criminal_timeline;
case healthcare:
return healthcare_timeline;
case education:
return education_timeline;
case vaccine:
return vaccine_timeline;
default:
return 'else'; // skip? or no default
}
} |
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
-
Building upon previous discussion, to address the issues of conditional branching but maintaining syntax close to existing if-statements for simplicity, I would like to propose the syntax below:
This format maintains the same syntax as normal conditional branching, except the main difference is a dictionary to organize responses and string return values. Compared to normal conditional branching where the return values 'true' or 'false' map to whether the timeline happens, having flexible return values of string keys allows us to account for more than two branches. Having these string keys map to different timelines defined by representing timeline_variables as an object allows this to be clear and efficient in use and implementation.
Beta Was this translation helpful? Give feedback.
All reactions