-
Notifications
You must be signed in to change notification settings - Fork 12
/
experiment.tmpl.js
52 lines (43 loc) · 1.31 KB
/
experiment.tmpl.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
/**
* @title <%= title %>
* @description <%= description %>
* @version 0.1.0
*
* @assets assets/
*/
// You can import stylesheets (.scss or .css).
import "../styles/main.scss";
import FullscreenPlugin from "@jspsych/plugin-fullscreen";
import HtmlKeyboardResponsePlugin from "@jspsych/plugin-html-keyboard-response";
import PreloadPlugin from "@jspsych/plugin-preload";
import { initJsPsych } from "jspsych";
/**
* This function will be executed by jsPsych Builder and is expected to run the jsPsych experiment
*
* @type {import("jspsych-builder").RunFunction}
*/
export async function run({ assetPaths, input = {}, environment, title, version }) {
const jsPsych = initJsPsych();
const timeline = [];
// Preload assets
timeline.push({
type: PreloadPlugin,
images: assetPaths.images,
audio: assetPaths.audio,
video: assetPaths.video,
});
// Welcome screen
timeline.push({
type: HtmlKeyboardResponsePlugin,
stimulus: "<p>Welcome to <%= title %>!<p/>",
});
// Switch to fullscreen
timeline.push({
type: FullscreenPlugin,
fullscreen_mode: true,
});
await jsPsych.run(timeline);
// Return the jsPsych instance so jsPsych Builder can access the experiment results (remove this
// if you handle results yourself, be it here or in `on_finish()`)
return jsPsych;
}