Skip to content

Commit

Permalink
use evaluateTimelineVariable
Browse files Browse the repository at this point in the history
  • Loading branch information
cherriechang committed Aug 8, 2024
1 parent 1dc7e46 commit bf650a0
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 16 deletions.
1 change: 1 addition & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

32 changes: 16 additions & 16 deletions packages/spatial-cueing-task/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,8 @@ function makeEndogenousCue(jsPsych: JsPsych, cue_period: number) {
const endogenous_cue = {
type: jsPsychHtmlKeyboardResponse,
stimulus: () => {
const validity = jsPsych.timelineVariable("validity");
const stimulus_direction = jsPsych.timelineVariable("stimulus_direction");
const validity = jsPsych.evaluateTimelineVariable("validity");
const stimulus_direction = jsPsych.evaluateTimelineVariable("stimulus_direction");
const cue_direction = cueDirectionMapper(validity, stimulus_direction);

var stimulus = `<div class="jspsych-spatial-cueing-container">` + StimulusBox.Default;
Expand Down Expand Up @@ -157,8 +157,8 @@ function makeExogenousCue(jsPsych: JsPsych, cue_period: number) {
const exogenous_cue = {
type: jsPsychHtmlKeyboardResponse,
stimulus: () => {
const validity = jsPsych.timelineVariable("validity");
const stimulus_direction = jsPsych.timelineVariable("stimulus_direction");
const validity = jsPsych.evaluateTimelineVariable("validity");
const stimulus_direction = jsPsych.evaluateTimelineVariable("stimulus_direction");
const cue_direction = cueDirectionMapper(validity, stimulus_direction);

var stimulus = `<div class="jspsych-spatial-cueing-container">`
Expand Down Expand Up @@ -186,15 +186,15 @@ function makeExogenousStimulus(jsPsych: JsPsych) {
const exogenous_stimulus = {
type: jsPsychHtmlKeyboardResponse,
stimulus: () => {
const validity = jsPsych.timelineVariable("validity");
const stimulus_direction = jsPsych.timelineVariable("stimulus_direction");
const validity = jsPsych.evaluateTimelineVariable("validity");
const stimulus_direction = jsPsych.evaluateTimelineVariable("stimulus_direction");
const cue_direction = cueDirectionMapper(validity, stimulus_direction);

var stimulus = `<div class="jspsych-spatial-cueing-container">`;
if (cue_direction == Direction.Left || cue_direction == Direction.Bi) {
stimulus += jsPsych.timelineVariable("stimulus_direction") == Direction.Left ? StimulusBox.WithStimulusHighlighted : StimulusBox.Highlighted;
stimulus += jsPsych.evaluateTimelineVariable("stimulus_direction") == Direction.Left ? StimulusBox.WithStimulusHighlighted : StimulusBox.Highlighted;
}
else if (jsPsych.timelineVariable("stimulus_direction") == Direction.Left) {
else if (jsPsych.evaluateTimelineVariable("stimulus_direction") == Direction.Left) {
stimulus += StimulusBox.WithStimulus;
}
else {
Expand All @@ -204,9 +204,9 @@ function makeExogenousStimulus(jsPsych: JsPsych) {
stimulus += FixationBox.NoCue;

if (cue_direction == Direction.Right || cue_direction == Direction.Bi) {
stimulus += jsPsych.timelineVariable("stimulus_direction") == Direction.Right ? StimulusBox.WithStimulusHighlighted : StimulusBox.Highlighted;
stimulus += jsPsych.evaluateTimelineVariable("stimulus_direction") == Direction.Right ? StimulusBox.WithStimulusHighlighted : StimulusBox.Highlighted;
}
else if (jsPsych.timelineVariable("stimulus_direction") == Direction.Right) {
else if (jsPsych.evaluateTimelineVariable("stimulus_direction") == Direction.Right) {
stimulus += StimulusBox.WithStimulus;
}
else {
Expand All @@ -222,7 +222,7 @@ function makeExogenousStimulus(jsPsych: JsPsych) {
task: "stimulus",
cue_type: "exogenous",
correct_response: () => {
return jsPsych.timelineVariable("stimulus_direction") == Direction.Left ? 'f' : 'j';
return jsPsych.evaluateTimelineVariable("stimulus_direction") == Direction.Left ? 'f' : 'j';
}
},
on_finish: function (data: any) {
Expand All @@ -241,11 +241,11 @@ function makeEndogenousStimulus(jsPsych: JsPsych) {
const endogenous_stimulus = {
type: jsPsychHtmlKeyboardResponse,
stimulus: () => {
const validity = jsPsych.timelineVariable("validity");
const stimulus_direction = jsPsych.timelineVariable("stimulus_direction");
const validity = jsPsych.evaluateTimelineVariable("validity");
const stimulus_direction = jsPsych.evaluateTimelineVariable("stimulus_direction");
const cue_direction = cueDirectionMapper(validity, stimulus_direction);

var stimulus = `<div class="jspsych-spatial-cueing-container">` + (jsPsych.timelineVariable("stimulus_direction") == Direction.Left ? StimulusBox.WithStimulus : StimulusBox.Default);
var stimulus = `<div class="jspsych-spatial-cueing-container">` + (jsPsych.evaluateTimelineVariable("stimulus_direction") == Direction.Left ? StimulusBox.WithStimulus : StimulusBox.Default);
switch (cue_direction) {
case Direction.Left:
stimulus += FixationBox.LeftCue;
Expand All @@ -261,7 +261,7 @@ function makeEndogenousStimulus(jsPsych: JsPsych) {
break;
};

stimulus += (jsPsych.timelineVariable("stimulus_direction") == Direction.Right ? StimulusBox.WithStimulus : StimulusBox.Default) + `</div>`;
stimulus += (jsPsych.evaluateTimelineVariable("stimulus_direction") == Direction.Right ? StimulusBox.WithStimulus : StimulusBox.Default) + `</div>`;

return stimulus;
},
Expand All @@ -270,7 +270,7 @@ function makeEndogenousStimulus(jsPsych: JsPsych) {
task: "stimulus",
cue_type: "endogenous",
correct_response: () => {
return jsPsych.timelineVariable("stimulus_direction") == Direction.Left ? 'f' : 'j';
return jsPsych.evaluateTimelineVariable("stimulus_direction") == Direction.Left ? 'f' : 'j';
}
},
on_finish: function (data: any) {
Expand Down

0 comments on commit bf650a0

Please sign in to comment.