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

Html Free Recall plugin #137

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
Open

Html Free Recall plugin #137

wants to merge 9 commits into from

Conversation

atakaragoz
Copy link

Hello,

This plugin is compatible with jsPsych version 7+.

The plugin is supposed to approximate free recall experiments using typed responses as opposed to spoken ones. By removing the word as soon as the participant presses spacebar it removes the participant's ability to edit their previous responses as well as enables the participant to potentially provide repeats of words.

One could also use this plugin to perform free association experiments by having participants enter a single word at a time and not allow for edits.

The basic idea behind the plugin is to record the words a participant inputs and end the trial when a certain button (by default spacebar) is pressed. The best way to use this is within a loop as I've shown in the examples.

Please let me know if you think this plugin is superfluous or if you would prefer changes to documentation or features.

Copy link

changeset-bot bot commented Sep 4, 2024

⚠️ No Changeset found

Latest commit: 6c1114f

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@jodeleeuw
Copy link
Member

Hi @atakaragoz

This is a great contribution. We're a little swamped right now so it might be another week or two before we can help with fixing the failing checks, but we're appreciative of the contribution and will get to it ASAP.

Adding package.json, appears to have been deleted at some point.
@atakaragoz
Copy link
Author

Hello! I believe the issue was that the package.json was missing from my plugin directory. I've gone ahead and added that to see if it fixes things.

Please let me know if there is anything else I can do.

@atakaragoz
Copy link
Author

Hello! Just wanted to see if there was any update on this?

@m-delem
Copy link

m-delem commented Feb 17, 2025

Hello @atakaragoz,

Thank you for the great plugin! I am currently testing it, this might be exactly what I needed to implement an online Deese-Roediger-McDermott paradigm.

There were a couple things I had to tweak here and there to have the examples running smoothly, so I thought I could share them. I have little to no experience of contributing to anyone else's code on GH, so let me know if I can do better than putting my snippets here.

First, this might be a difference between jsPsych 7 and 8, but the plugin type has to be specified differently in your examples:

var free_association_trial = {
  type: "html-written-recall"
}
// Returns an error. It should be:
var free_association_trial = {
  type: htmlWrittenRecall
}

In your examples, you use result data from your plugin called button_pressed as a condition in your loop_function():

var free_association_block = {
  timeline: [free_association_trial],
  loop_function() {
    if (jsPsych.data.get().last(1).values()[0].button_pressed) {
      return false;
    } else {
      return true;
    }
  }
}

However, in the latest version of your plugin you seem to have renamed this data button, so this condition is not working anymore. The working example becomes:

var free_association_block = {
  timeline: [free_association_trial],
  loop_function() {
    if (jsPsych.data.get().last(1).values()[0].button == "pressed") {
      return false;
    } else {
      return true;
    }
  }
}

Finally, warnings from jsPsych advised to add version and data fields to the info of your plugin. I added this to remove the warning on my end:

const info = {
    name: "html-written-recall",
    version: "1.0.0",
    // parameters: {...},
    data: {
      rt: {
        type: jspsych.ParameterType.INT,
      },
      stimulus: {
        type: jspsych.ParameterType.STRING,
      },
      response: {
        type: jspsych.ParameterType.STRING,
      },
      button: {
        type: jspsych.ParameterType.STRING,
      },
    },
}

Thanks again for the cool plugin!

@jadeddelta
Copy link
Collaborator

hey @atakaragoz, i can add this to my workload to get the plugin reviewed, just let me know if you are willing to work on suggestions or if i should make the modifications myself to make it ready to be published!

and thank you @m-delem for the comment! yes, the first one is a result of going from v6 to v7 actually! and good catch for adding the data fields, for v8, especially if we consider releasing this plugin as a v8 plugin rather than a v7 to be compatible with the most recent version of jspsych. as for contributing, since this is someone else's plugin, you'd normally just get permission to add commits onto their branch if they'd like. if you want a general overview on open source contribution, this guide does a fantastic job at giving you a basic idea!

@atakaragoz
Copy link
Author

Hello @jadeddelta! Happy to make any changes that you wish for me to make just let me know what you'd like me to change and I will get right on it.

Also @m-delem, thank you for the improvements and glad it was at least helpful to you in some way. Best of luck in your DRM paradigm 😄!

Copy link
Collaborator

@jadeddelta jadeddelta left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it looks good! i've added a good bit of details to look over for our first pass, and if you'd like to also update this plugin to v8 via adding the version and data fields, feel free to do so- but it's not necessary!

<html>
<head>
<script src="https://unpkg.com/[email protected]"></script>
<script src="../dist/index.browser.js"></script>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

npm run build only builds an index.browser.min.js- but we recommend you change this to simply "../index.js" to use the raw file for development, just so that all error reporting works! (don't forget to do this for the other example file)

}
});
var free_association_trial = {
type: 'html-written-recall',
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

don't forget to change this to htmlWrittenRecall for both examples!

timeline: [free_association_trial],
loop_function() {
// Loop until 10 trials are completed
if (jsPsych.data.get().last(1).values()[0].button_pressed) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remember to change this to jsPsych.data.get().last(1).values()[0].button == "pressed" for both examples


if (trial.button_string !== null) {
new_html +=
'<div><button id="jspsych-html-keyboard-response-button" style="display: none; justify-content:center">' +
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can add the class to the button class="jspsych-btn" to keep the style consistent with other jspsych buttons

</head>
<body></body>
<script>
// Example where a participant gives as many words as possible in time of 10 seconds
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

update comment to match what the trial does

var free_recall_block = {
timeline: [free_recall_trial],
on_start: function() {
begin_block_time = performance.now();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

begin_block_time doesn't exist within the scope for the block_time_start: begin_block_time in the previous trial, it would be best to define begin_block_time beforehand as performance.now() and then use that reference for both the free_recall_trial and the on_start function

var trial_data = {
rt: response.rt,
stimulus: trial.stimulus,
response: textbox.value, // Get the value of the textbox
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i get a weird condition on my testing where it'll keep the space bar in the next trial, maybe it would be good to clear the value of the textbox afterwards? otherwise each response after will be like " dog" instead of "dog"

this becomes especially evident for me if next_word_key is anything but the space bar key

default: null,
},
next_word_key: {
type: jspsych.ParameterType.STRING,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you could specify this to be jspsych.ParameterType.KEY

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

Successfully merging this pull request may close these issues.

4 participants