documentation for #232

closes #232
This commit is contained in:
Josh de Leeuw 2016-05-22 12:35:35 -04:00
parent 9d4d294bad
commit fb31532071
2 changed files with 73 additions and 3 deletions

View File

@ -22,8 +22,6 @@ Adds the timeline to the end of the experiment.
### Example
#### End the experiment if a particular response is given
```javascript
var trial = {
type: 'text',
@ -350,6 +348,41 @@ var settings = jsPsych.initSettings();
console.log(JSON.stringify(settings.timeline));
```
---
## jsPsych.pauseExperiment
```
jsPsych.pauseExperiment()
```
### Parameters
None.
### Return value
None.
### Description
Pauses the experiment. The experiment will finish the current trial, but will not execute any additional trials until `jsPsych.resumeExperiment()` is called.
### Example
```javascript
var trial = {
type: 'single-stim',
stimulus: 'Press p to take a 30 second break. Otherwise, press c to continue immediately.',
is_html: true,
choices: ['p','c'],
on_finish: function(data){
if(data.key_press == 80) { // 80 = p
jsPsych.pauseExperiment();
setTimeout(jsPsych.resumeExperiment, 30000);
}
}
}
```
---
## jsPsych.progress
@ -385,6 +418,41 @@ var progress = jsPsych.progress();
alert('You have completed approximately '+progress.percent_complete+'% of the experiment');
```
---
## jsPsych.resumeExperiment
```
jsPsych.resumeExperiment()
```
### Parameters
None.
### Return value
None.
### Description
Resumes the experiment after a call to `jsPsych.pauseExperiment()`. If the post trial delay (`timing_post_trial`) has not yet been reached, then the experiment will not continue until the delay is finished. For example, if `timing_post_trial` was 10,000ms and `jsPsych.resumeExperiment()` was called 6,000ms after the previous trial finished, then the experiment would not continue for another 4,000ms.
### Example
```javascript
var trial = {
type: 'single-stim',
stimulus: 'Press p to take a 30 second break. Otherwise, press c to continue immediately.',
is_html: true,
choices: ['p','c'],
on_finish: function(data){
if(data.key_press == 80) { // 80 = p
jsPsych.pauseExperiment();
setTimeout(jsPsych.resumeExperiment, 30000);
}
}
}
```
---
## jsPsych.startTime

View File

@ -14,8 +14,10 @@ Every jsPsych experiment utilizes the core library (contained in the `jspsych.js
* [jsPsych.finishTrial](jspsych-core.md#jspsychfinishtrial)
* [jsPsych.getDisplayElement](jspsych-core.md#jspsychgetdisplayelement)
* [jsPsych.init](jspsych-core.md#jspsychinit)
* [jsPsych.initSettings](jspsych-core.md#jspsychinitSettings)
* [jsPsych.initSettings](jspsych-core.md#jspsychinitsettings)
* [jsPsych.pauseExperiment](jspsych-core.md#jspsychpauseexperiment)
* [jsPsych.progress](jspsych-core.md#jspsychprogress)
* [jsPsych.resumeExperiment](jspsych-core.md#jspsychresumeexperiment)
* [jsPsych.startTime](jspsych-core.md#jspsychstarttime)
* [jsPsych.totalTime](jspsych-core.md#jspsychtotaltime)