|
| 1 | +import { JsPsychPlugin, ParameterType, JsPsych, TrialType } from 'jspsych__8.x'; |
| 2 | + |
| 3 | +declare const info: { |
| 4 | + readonly name: 'instructions'; |
| 5 | + readonly version: string; |
| 6 | + readonly parameters: { |
| 7 | + /** Each element of the array is the content for a single page. Each page should be an HTML-formatted string. */ |
| 8 | + readonly pages: { |
| 9 | + readonly type: ParameterType.HTML_STRING; |
| 10 | + readonly default: any; |
| 11 | + readonly array: true; |
| 12 | + }; |
| 13 | + /** This is the key that the participant can press in order to advance to the next page. This key should be |
| 14 | + * specified as a string (e.g., `'a'`, `'ArrowLeft'`, `' '`, `'Enter'`). */ |
| 15 | + readonly key_forward: { |
| 16 | + readonly type: ParameterType.KEY; |
| 17 | + readonly default: 'ArrowRight'; |
| 18 | + }; |
| 19 | + /** This is the key that the participant can press to return to the previous page. This key should be specified as a |
| 20 | + * string (e.g., `'a'`, `'ArrowLeft'`, `' '`, `'Enter'`). */ |
| 21 | + readonly key_backward: { |
| 22 | + readonly type: ParameterType.KEY; |
| 23 | + readonly default: 'ArrowLeft'; |
| 24 | + }; |
| 25 | + /** If true, the participant can return to previous pages of the instructions. If false, they may only advace to the next page. */ |
| 26 | + readonly allow_backward: { |
| 27 | + readonly type: ParameterType.BOOL; |
| 28 | + readonly default: true; |
| 29 | + }; |
| 30 | + /** If `true`, the participant can use keyboard keys to navigate the pages. If `false`, they may not. */ |
| 31 | + readonly allow_keys: { |
| 32 | + readonly type: ParameterType.BOOL; |
| 33 | + readonly default: true; |
| 34 | + }; |
| 35 | + /** If true, then a `Previous` and `Next` button will be displayed beneath the instructions. Participants can |
| 36 | + * click the buttons to navigate. */ |
| 37 | + readonly show_clickable_nav: { |
| 38 | + readonly type: ParameterType.BOOL; |
| 39 | + readonly default: false; |
| 40 | + }; |
| 41 | + /** If true, and clickable navigation is enabled, then Page x/y will be shown between the nav buttons. */ |
| 42 | + readonly show_page_number: { |
| 43 | + readonly type: ParameterType.BOOL; |
| 44 | + readonly default: false; |
| 45 | + }; |
| 46 | + /** The text that appears before x/y pages displayed when show_page_number is true.*/ |
| 47 | + readonly page_label: { |
| 48 | + readonly type: ParameterType.STRING; |
| 49 | + readonly default: 'Page'; |
| 50 | + }; |
| 51 | + /** The text that appears on the button to go backwards. */ |
| 52 | + readonly button_label_previous: { |
| 53 | + readonly type: ParameterType.STRING; |
| 54 | + readonly default: 'Previous'; |
| 55 | + }; |
| 56 | + /** The text that appears on the button to go forwards. */ |
| 57 | + readonly button_label_next: { |
| 58 | + readonly type: ParameterType.STRING; |
| 59 | + readonly default: 'Next'; |
| 60 | + }; |
| 61 | + /** The callback function when page changes */ |
| 62 | + readonly on_page_change: { |
| 63 | + readonly type: ParameterType.FUNCTION; |
| 64 | + readonly pretty_name: 'Page change callback'; |
| 65 | + readonly default: (current_page: number) => void; |
| 66 | + }; |
| 67 | + }; |
| 68 | + readonly data: { |
| 69 | + /** An array containing the order of pages the participant viewed (including when the participant returned to previous pages) |
| 70 | + * and the time spent viewing each page. Each object in the array represents a single page view, |
| 71 | + * and contains keys called `page_index` (the page number, starting with 0) and `viewing_time` |
| 72 | + * (duration of the page view). This will be encoded as a JSON string when data is saved using the `.json()` or `.csv()` |
| 73 | + * functions. |
| 74 | + */ |
| 75 | + readonly view_history: { |
| 76 | + readonly type: ParameterType.COMPLEX; |
| 77 | + readonly array: true; |
| 78 | + readonly parameters: { |
| 79 | + readonly page_index: { |
| 80 | + readonly type: ParameterType.INT; |
| 81 | + }; |
| 82 | + readonly viewing_time: { |
| 83 | + readonly type: ParameterType.INT; |
| 84 | + }; |
| 85 | + }; |
| 86 | + }; |
| 87 | + /** The response time in milliseconds for the participant to view all of the pages. */ |
| 88 | + readonly rt: { |
| 89 | + readonly type: ParameterType.INT; |
| 90 | + }; |
| 91 | + }; |
| 92 | +}; |
| 93 | +type Info = typeof info; |
| 94 | +/** |
| 95 | + * This plugin is for showing instructions to the participant. It allows participants to navigate through multiple pages |
| 96 | + * of instructions at their own pace, recording how long the participant spends on each page. Navigation can be done using |
| 97 | + * the mouse or keyboard. participants can be allowed to navigate forwards and backwards through pages, if desired. |
| 98 | + * |
| 99 | + * @author Josh de Leeuw |
| 100 | + * @see {@link https://www.jspsych.org/latest/plugins/instructions/ instructions plugin documentation on jspsych.org} |
| 101 | + */ |
| 102 | +declare class InstructionsPlugin implements JsPsychPlugin<Info> { |
| 103 | + private jsPsych; |
| 104 | + static info: { |
| 105 | + readonly name: 'instructions'; |
| 106 | + readonly version: string; |
| 107 | + readonly parameters: { |
| 108 | + /** Each element of the array is the content for a single page. Each page should be an HTML-formatted string. */ |
| 109 | + readonly pages: { |
| 110 | + readonly type: ParameterType.HTML_STRING; |
| 111 | + readonly default: any; |
| 112 | + readonly array: true; |
| 113 | + }; |
| 114 | + /** This is the key that the participant can press in order to advance to the next page. This key should be |
| 115 | + * specified as a string (e.g., `'a'`, `'ArrowLeft'`, `' '`, `'Enter'`). */ |
| 116 | + readonly key_forward: { |
| 117 | + readonly type: ParameterType.KEY; |
| 118 | + readonly default: 'ArrowRight'; |
| 119 | + }; |
| 120 | + /** This is the key that the participant can press to return to the previous page. This key should be specified as a |
| 121 | + * string (e.g., `'a'`, `'ArrowLeft'`, `' '`, `'Enter'`). */ |
| 122 | + readonly key_backward: { |
| 123 | + readonly type: ParameterType.KEY; |
| 124 | + readonly default: 'ArrowLeft'; |
| 125 | + }; |
| 126 | + /** If true, the participant can return to previous pages of the instructions. If false, they may only advace to the next page. */ |
| 127 | + readonly allow_backward: { |
| 128 | + readonly type: ParameterType.BOOL; |
| 129 | + readonly default: true; |
| 130 | + }; |
| 131 | + /** If `true`, the participant can use keyboard keys to navigate the pages. If `false`, they may not. */ |
| 132 | + readonly allow_keys: { |
| 133 | + readonly type: ParameterType.BOOL; |
| 134 | + readonly default: true; |
| 135 | + }; |
| 136 | + /** If true, then a `Previous` and `Next` button will be displayed beneath the instructions. Participants can |
| 137 | + * click the buttons to navigate. */ |
| 138 | + readonly show_clickable_nav: { |
| 139 | + readonly type: ParameterType.BOOL; |
| 140 | + readonly default: false; |
| 141 | + }; |
| 142 | + /** If true, and clickable navigation is enabled, then Page x/y will be shown between the nav buttons. */ |
| 143 | + readonly show_page_number: { |
| 144 | + readonly type: ParameterType.BOOL; |
| 145 | + readonly default: false; |
| 146 | + }; |
| 147 | + /** The text that appears before x/y pages displayed when show_page_number is true.*/ |
| 148 | + readonly page_label: { |
| 149 | + readonly type: ParameterType.STRING; |
| 150 | + readonly default: 'Page'; |
| 151 | + }; |
| 152 | + /** The text that appears on the button to go backwards. */ |
| 153 | + readonly button_label_previous: { |
| 154 | + readonly type: ParameterType.STRING; |
| 155 | + readonly default: 'Previous'; |
| 156 | + }; |
| 157 | + /** The text that appears on the button to go forwards. */ |
| 158 | + readonly button_label_next: { |
| 159 | + readonly type: ParameterType.STRING; |
| 160 | + readonly default: 'Next'; |
| 161 | + }; |
| 162 | + /** The callback function when page changes */ |
| 163 | + readonly on_page_change: { |
| 164 | + readonly type: ParameterType.FUNCTION; |
| 165 | + readonly pretty_name: 'Page change callback'; |
| 166 | + readonly default: (current_page: number) => void; |
| 167 | + }; |
| 168 | + }; |
| 169 | + readonly data: { |
| 170 | + /** An array containing the order of pages the participant viewed (including when the participant returned to previous pages) |
| 171 | + * and the time spent viewing each page. Each object in the array represents a single page view, |
| 172 | + * and contains keys called `page_index` (the page number, starting with 0) and `viewing_time` |
| 173 | + * (duration of the page view). This will be encoded as a JSON string when data is saved using the `.json()` or `.csv()` |
| 174 | + * functions. |
| 175 | + */ |
| 176 | + readonly view_history: { |
| 177 | + readonly type: ParameterType.COMPLEX; |
| 178 | + readonly array: true; |
| 179 | + readonly parameters: { |
| 180 | + readonly page_index: { |
| 181 | + readonly type: ParameterType.INT; |
| 182 | + }; |
| 183 | + readonly viewing_time: { |
| 184 | + readonly type: ParameterType.INT; |
| 185 | + }; |
| 186 | + }; |
| 187 | + }; |
| 188 | + /** The response time in milliseconds for the participant to view all of the pages. */ |
| 189 | + readonly rt: { |
| 190 | + readonly type: ParameterType.INT; |
| 191 | + }; |
| 192 | + }; |
| 193 | + }; |
| 194 | + constructor(jsPsych: JsPsych); |
| 195 | + trial(display_element: HTMLElement, trial: TrialType<Info>): void; |
| 196 | + simulate(trial: TrialType<Info>, simulation_mode: any, simulation_options: any, load_callback: () => void): void; |
| 197 | + private create_simulation_data; |
| 198 | + private simulate_data_only; |
| 199 | + private simulate_visual; |
| 200 | +} |
| 201 | + |
| 202 | +export { InstructionsPlugin as default }; |
0 commit comments