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

New Plugin: Browser Check #2209

Merged
merged 28 commits into from
Nov 5, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
7bbc243
initial work on browser-check plugin, WIP
jodeleeuw Oct 7, 2021
448c507
basic grabbing of features working
jodeleeuw Oct 8, 2021
3ebf212
add inclusion_function
jodeleeuw Oct 8, 2021
ea3feaa
allow endExperiment to save data to the final trial
jodeleeuw Oct 19, 2021
dbaa11e
implement ending experiment with message and data saving
jodeleeuw Oct 19, 2021
76f2d5a
fix jest errors in package.json
jodeleeuw Oct 19, 2021
b0758a6
remove duplicate test
jodeleeuw Oct 19, 2021
08277ee
implement interactive resize
jodeleeuw Oct 19, 2021
ed2847d
parameterize the messages in interactive resize
jodeleeuw Oct 19, 2021
a76fe72
add testing for vsync_rate
jodeleeuw Oct 19, 2021
01b07fa
removes exclusion example (deprecated)
jodeleeuw Oct 20, 2021
59351a5
start of browser-check docs
jodeleeuw Oct 20, 2021
c7c755e
add deprecation warning
jodeleeuw Oct 20, 2021
192fe02
change default exclusion_message
jodeleeuw Oct 20, 2021
8fb99cc
add example file
jodeleeuw Oct 20, 2021
0c749e8
round frame rate to two decimals
jodeleeuw Oct 20, 2021
1535856
add jsdoc comments
jodeleeuw Oct 20, 2021
82c2716
add documentation and demos
jodeleeuw Oct 20, 2021
5130c3c
fix spaces/tabs errors
jodeleeuw Oct 20, 2021
011f3f5
update docs for endExperiment
jodeleeuw Oct 21, 2021
80a74c6
set version to 0.1.0 so changeset bumps it to 1.0.0
jodeleeuw Oct 21, 2021
45fb3eb
add changesets
jodeleeuw Oct 21, 2021
8eaabdd
add webcam and microphone detection
jodeleeuw Oct 21, 2021
a0337af
Merge remote-tracking branch 'origin/main' into plugin-exclusions
jodeleeuw Oct 21, 2021
a849f51
Merge branch 'main' into plugin-exclusions
jodeleeuw Oct 21, 2021
b8acdc1
docs updates
jodeleeuw Oct 27, 2021
2c795f4
update pl
jodeleeuw Oct 27, 2021
4493864
make exclusion_message a function. respond to other feedback in reviews.
jodeleeuw Oct 28, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/khaki-rice-retire.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@jspsych/plugin-browser-check": major
---

Initial release of the browser-check plugin. The plugin can measure various features and properties of the participant's browser and optionally exclude participants from the study based on these features and properties.
5 changes: 5 additions & 0 deletions .changeset/new-llamas-remember.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"jspsych": minor
---

`jsPsych.endExperiment()` has a new, optional second parameter for saving data. Passing in an object of key-value pairs will store the pairs in the data for the final trial of the experiment.
49 changes: 49 additions & 0 deletions docs/demos/jspsych-browser-check-demo1.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<!DOCTYPE html>
<html>
<head>
<script src="https://unpkg.com/jspsych@7.0.0"></script>
<script src="https://unpkg.com/@jspsych/plugin-browser-check@1.0.0"></script>
<script src="https://unpkg.com/@jspsych/plugin-html-button-response@1.0.0"></script>
<link rel="stylesheet" href="https://unpkg.com/jspsych@7.0.0/css/jspsych.css">
</head>
<body></body>
<script>

var jsPsych = initJsPsych();

var start = {
type: jsPsychHtmlButtonResponse,
stimulus: '',
choices: ['Run demo']
};

var trial = {
type: jsPsychBrowserCheck
};

var show_data = {
type: jsPsychHtmlButtonResponse,
stimulus: function() {
var trial_data = jsPsych.data.getLastTrialData().values();
var trial_json = JSON.stringify(trial_data, null, 2);
return '<p style="margin-bottom:0px;"><strong>Trial data:</strong></p>'+
'<pre style="margin-top:0px;text-align:left;">'+trial_json+'</pre>';
},
choices: ['Repeat demo']
};

var trial_data_loop = {
timeline: [trial, show_data],
loop_function: function() {
return true;
}
};

if (typeof jsPsych !== "undefined") {
jsPsych.run([start, trial_data_loop]);
} else {
document.body.innerHTML = '<div style="text-align:center; margin-top:50%; transform:translate(0,-50%);">You must be online to view the plugin demo.</div>';
}
</script>

</html>
53 changes: 53 additions & 0 deletions docs/demos/jspsych-browser-check-demo2.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
<!DOCTYPE html>
<html>
<head>
<script src="https://unpkg.com/jspsych@7.0.0"></script>
<script src="https://unpkg.com/@jspsych/plugin-browser-check@1.0.0"></script>
<script src="https://unpkg.com/@jspsych/plugin-html-button-response@1.0.0"></script>
<link rel="stylesheet" href="https://unpkg.com/jspsych@7.0.0/css/jspsych.css">
</head>
<body></body>
<script>

var jsPsych = initJsPsych();

var start = {
type: jsPsychHtmlButtonResponse,
stimulus: '',
choices: ['Run demo']
};

var trial = {
type: jsPsychBrowserCheck,
inclusion_function: (data) => {
return ['chrome', 'firefox'].contains(data.browser);
},
exclusion_message: `<p>You must use Chrome or Firefox to complete this experiment.</p>`
};

var show_data = {
type: jsPsychHtmlButtonResponse,
stimulus: function() {
var trial_data = jsPsych.data.getLastTrialData().values();
var trial_json = JSON.stringify(trial_data, null, 2);
return '<p style="margin-bottom:0px;"><strong>Trial data:</strong></p>'+
'<pre style="margin-top:0px;text-align:left;">'+trial_json+'</pre>';
},
choices: ['Repeat demo']
};

var trial_data_loop = {
timeline: [trial, show_data],
loop_function: function() {
return true;
}
};

if (typeof jsPsych !== "undefined") {
jsPsych.run([start, trial_data_loop]);
} else {
document.body.innerHTML = '<div style="text-align:center; margin-top:50%; transform:translate(0,-50%);">You must be online to view the plugin demo.</div>';
}
</script>

</html>
51 changes: 51 additions & 0 deletions docs/demos/jspsych-browser-check-demo3.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
<!DOCTYPE html>
<html>
<head>
<script src="https://unpkg.com/jspsych@7.0.0"></script>
<script src="https://unpkg.com/@jspsych/plugin-browser-check@1.0.0"></script>
<script src="https://unpkg.com/@jspsych/plugin-html-button-response@1.0.0"></script>
<link rel="stylesheet" href="https://unpkg.com/jspsych@7.0.0/css/jspsych.css">
</head>
<body></body>
<script>

var jsPsych = initJsPsych();

var start = {
type: jsPsychHtmlButtonResponse,
stimulus: '<p>If you want to test the interactive resize, make your browser window small before continuing.</p>',
choices: ['Run demo']
};

var trial = {
type: jsPsychBrowserCheck,
minimum_width: 1000,
minimum_height: 600
};

var show_data = {
type: jsPsychHtmlButtonResponse,
stimulus: function() {
var trial_data = jsPsych.data.getLastTrialData().values();
var trial_json = JSON.stringify(trial_data, null, 2);
return '<p style="margin-bottom:0px;"><strong>Trial data:</strong></p>'+
'<pre style="margin-top:0px;text-align:left;">'+trial_json+'</pre>';
},
choices: ['Repeat demo']
};

var trial_data_loop = {
timeline: [trial, show_data],
loop_function: function() {
return true;
}
};

if (typeof jsPsych !== "undefined") {
jsPsych.run([start, trial_data_loop]);
} else {
document.body.innerHTML = '<div style="text-align:center; margin-top:50%; transform:translate(0,-50%);">You must be online to view the plugin demo.</div>';
}
</script>

</html>
59 changes: 59 additions & 0 deletions docs/demos/jspsych-browser-check-demo4.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
<!DOCTYPE html>
<html>
<head>
<script src="https://unpkg.com/jspsych@7.0.0"></script>
<script src="https://unpkg.com/@jspsych/plugin-browser-check@1.0.0"></script>
<script src="https://unpkg.com/@jspsych/plugin-html-button-response@1.0.0"></script>
<link rel="stylesheet" href="https://unpkg.com/jspsych@7.0.0/css/jspsych.css">
</head>
<body></body>
<script>

var jsPsych = initJsPsych();

var start = {
type: jsPsychHtmlButtonResponse,
stimulus: '',
choices: ['Run demo']
};

var trial = {
type: jsPsychBrowserCheck,
inclusion_function: (data) => {
return data.browser == 'chrome' && data.mobile === false
},
exclusion_message: (data) => {
if(data.mobile){
return '<p>You must use a desktop/laptop computer to participate in this experiment.</p>';
} else if(data.browser !== 'chrome'){
return '<p>You must use Chrome as your browser to complete this experiment.</p>'
}
}
};

var show_data = {
type: jsPsychHtmlButtonResponse,
stimulus: function() {
var trial_data = jsPsych.data.getLastTrialData().values();
var trial_json = JSON.stringify(trial_data, null, 2);
return '<p style="margin-bottom:0px;"><strong>Trial data:</strong></p>'+
'<pre style="margin-top:0px;text-align:left;">'+trial_json+'</pre>';
},
choices: ['Repeat demo']
};

var trial_data_loop = {
timeline: [trial, show_data],
loop_function: function() {
return true;
}
};

if (typeof jsPsych !== "undefined") {
jsPsych.run([start, trial_data_loop]);
} else {
document.body.innerHTML = '<div style="text-align:center; margin-top:50%; transform:translate(0,-50%);">You must be online to view the plugin demo.</div>';
}
</script>

</html>
34 changes: 8 additions & 26 deletions docs/overview/exclude-browser.md
Original file line number Diff line number Diff line change
@@ -1,30 +1,12 @@
# Exclude Participants Based on Browser Features
jodeleeuw marked this conversation as resolved.
Show resolved Hide resolved
*Changed in 7.1*

Online subjects will use many different kinds of browsers. Depending on the experiment, it may be important to specify a minimum feature set of the browser. jsPsych makes this straightforward. Simply specify certain exclusion criteria in the `initJsPsych` method call. If a subject's browser doesn't meet the criteria the experiment will not start and the subject will see a message explaining the problem. For size restrictions the subject will see a message that displays the current size of their browser window and the minimum size needed to start the experiment, giving the subject an opportunity to enlarge the browser window to continue.
Online subjects will use many different kinds of browsers.
Depending on the experiment, it may be important to specify a minimum feature set of the browser.

Current exclusion options:
* Minimum browser width & height
* Support for the WebAudio API
As of v7.1 of jsPsych, the recommended way to do this is using the [browser-check plugin](../plugins/browser-check.md).
This plugin can record many features of the subject's browser and exclude subjects who do not meet a defined set of inclusion criteria.
Please see the [browser-check plugin documentation](../plugins/browser-check.md) for more details.

## Examples

#### Exclude browsers that are not at least 800x600 pixels

```javascript
initJsPsych({
exclusions: {
min_width: 800,
min_height: 600
}
});
```

#### Exclude browsers that do not have access to the WebAudio API

```javascript
initJsPsych({
exclusions: {
audio: true
}
});
```
The prior approach of using the `exclusions` parameter in `initJsPsych()` is deprecated and will be removed in `v8.0`.
You can find the documentation for it in the [7.0 docs](https://www.jspsych.org/7.0/overview/exclude-browser).