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

Replace uses of Array.from() for Qualtrics compatibility #3368

Merged
merged 6 commits into from
Aug 8, 2024

Conversation

Max-Lovell
Copy link
Contributor

Qualtrics have overwritten/incorrectly polyfilled Array.from() such that it doesn't work, and so neither does jsPsych when run directly in Qualtrics. This PR then replaces uses of Array.from() in jsPsych with equivalent functions. So far, a wrapped spread operator [...array] is used in the KeyboardResponseAPI, and Array.prototype.slice.call() in the maxdiff and free-sort plugins.

There's also a single Array.from() call in packages/plugin-sketchpad/src/index.ts, although I can't get this to run on my own fork even in the original version outside of Qualtrics. It also features heavily in the webgazer examples and demos.

Probably worth considering this doesn't do much for any extension, anything in contrib, or Survey-js etc, so Qualtrics compatibility isn't guaranteed, but atleast the core library can be used without dealing with an extra hosting site.

Follows from #3347.

Copy link

changeset-bot bot commented Aug 6, 2024

🦋 Changeset detected

Latest commit: 4b080ca

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 4 packages
Name Type
@jspsych/plugin-sketchpad Patch
jspsych Patch
@jspsych/plugin-free-sort Patch
@jspsych/plugin-maxdiff Patch

Not sure what this means? Click here to learn what changesets are.

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

@Max-Lovell Max-Lovell changed the title Replace usees of Array.from() for Qualtrics compatibility Replace uses of Array.from() for Qualtrics compatibility Aug 6, 2024
@jodeleeuw
Copy link
Member

Thanks @Max-Lovell !

The sketchpad bug is weird, but definitely there. I'm not sure why that broke. I'd like to fix that and include the change to Array.from in this PR. Hopefully tomorrow.

@Max-Lovell
Copy link
Contributor Author

Sounds good @jodeleeuw, thanks!

@jodeleeuw jodeleeuw merged commit 1776f1f into jspsych:main Aug 8, 2024
2 checks passed
@github-actions github-actions bot mentioned this pull request Aug 8, 2024
@jodeleeuw
Copy link
Member

All set! Hopefully 8.0.2 works on Qualtrics now

@jodeleeuw
Copy link
Member

BTW @Max-Lovell if you are interested in contributing a documentation page that briefly covered Qualtrics integration that would be most welcome 😁

@Max-Lovell
Copy link
Contributor Author

Thanks Josh!! switched header to:

    <script src="https://unpkg.com/jspsych@8.0.2"></script>
    <script src="https://unpkg.com/@jspsych/plugin-html-keyboard-response@2.0.0"></script>
    <script src="https://unpkg.com/@jspsych/plugin-free-sort@2.0.1"></script>
    <script src="https://unpkg.com/@jspsych/plugin-maxdiff@2.0.1"></script>
    <script src="https://unpkg.com/@jspsych/plugin-sketchpad@2.0.1"></script>
    <link href="https://unpkg.com/jspsych@8.0.2/css/jspsych.css" rel="stylesheet" type="text/css" />

and all is working: https://universityofsussex.eu.qualtrics.com/jfe/form/SV_9LkywyYb3mtbtgq.

Great to get that finally working, thanks for the help. Will write up some documentation when I'm back from AL in 2 weeks!

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.

2 participants