@@ -7,19 +7,20 @@ including Vite, Vue, Bulma, and Google Firebase. However it also provide an
77that goes beyond basic Vue components.
88
99The first concept to introduce is the notion of a [ View] ( ./views.md ) . A View is
10- a component that represents a single "phase" or part of an experiment. For
11- example, the part of your experiment that collects informed consent might be one
12- View. Another View might be the debriefing form. Below we will describe how you
13- define the sequence of Views in your experiment.
10+ a self-contained bit of code that represents a single "phase" or part of an
11+ experiment. For example, the part of your experiment that collects informed
12+ consent might be one View. Another View might be the debriefing form. Below we
13+ will describe how you define the sequence of Views in your experiment.
1414
1515<img src =" /images/viewstimeline.png " width =" 800 " alt =" timeline example " style =" margin : auto ;" >
1616
17- Each View is minimally a Vue component which can be written in whatever way you
18- please. However, Smile provides a custom API for building views. The key idea
19- behind this API is the concept of 'steps'. A [ step] ( ./steps.md ) is a sequenced
20- event that occurs _ within_ a view. For example, a view might have a step that
21- presents a question to the participant, a step that collects a response, and a
22- step that displays the results.
17+ Each View is minimally a Vue component (a special type of web development file)
18+ which can be written in whatever way you please. However, Smile provides a
19+ custom API for building Views. The key idea behind this API is the concept of
20+ 'steps'. A [ step] ( ./steps.md ) is a sequenced event that occurs _ within_ a view.
21+ For example, a View might have a step that presents a question to the
22+ participant, a step that collects a response, and a step that displays the
23+ results.
2324
2425<img src =" /images/steps.png " width =" 600 " alt =" steps example " style =" margin : auto ;" >
2526
@@ -123,10 +124,10 @@ api.onKeyDown(' ', () => {
123124<style scoped></style>
124125```
125126
126- This uses on the ` api.onKeyDown ` method to listen for the spacebar key press and
127+ This uses the ` api.onKeyDown ` method to listen for the spacebar key press and
127128advance to the next step. You can also go to the previous step with
128129` api.goPrevStep() ` or jump to a specific step with ` api.goToStep(pathname) ` . We
129- will talk about paths later.
130+ will talk about paths in a later section of the documentation .
130131
131132Now we actually need to display the word to the user. We can do this by updating
132133the template part of the component.
@@ -227,9 +228,9 @@ need to check if it is already started since the `<script setup>` section only
227228runs once. The reason is that Smile _ persists_ information across page reloads.
228229This way if your participant reloads the page in their browser, Smile will
229230detect the timer was already started and continue measuring time with respect to
230- first time it was started. Of course, if you don't want that more fancy behavior
231- you can just call ` api.startTimer() ` without checking if it was already started,
232- which will restart it to measure "from the last page load."
231+ the first time it was started. Of course, if you don't want that more fancy
232+ behavior you can just call ` api.startTimer() ` without checking if it was already
233+ started, which will restart it to measure "from the last page load."
233234
234235This example shows another aspect of Smile's API. We use ` api.elapsedTime() ` to
235236measure the time it took the user to press the spacebar. Then we _ write_ the
@@ -240,16 +241,22 @@ resulting data to a new property in the `api.stepData` object called
240241Then we called ` api.recordStep() ` to record the step data. This persists the
241242data so that it will be written to the database record for this participant.
242243It's worth mentioning here that this doesn't mean the data will be immediately
243- stored in Firebase -- firebase limits the frequency by which we can write to
244- documents but rest assured ` api.recordStep() ` will buffer your participants
245- trial data so that on the next opportunity it is safely written to the database.
246- In addition even if the subject reloads the browser at this point the data for
247- that trial will be restored for later syncing to Firebase, limiting data loss.
244+ stored in our database -- for example Firebase (the recommended database for
245+ Smile) limits the frequency by which we can write to documents but rest assured
246+ ` api.recordStep() ` will buffer your participants trial data so that on the next
247+ opportunity it is safely written to the database. In addition even if the
248+ subject reloads the browser at this point, the data for that trial will be
249+ restored for later syncing, limiting data loss.
248250
249251** What this section reveals it that Smile's API goes beyond basic Vue components
250- to provide ways to save data to a database, persist data across page loads, and
251- provides convenient ways to record data typically needed in behavioral
252- experiments.**
252+ to provide ways to define steps or trials in an experiment, save data to a
253+ database, persist data across page loads, and provides convenient ways to record
254+ data typically needed in behavioral experiments.**
255+
256+ It gets much more fancy and powerful from there. For example
257+ [ here] ( https://github.com/NYUCCL/smile/blob/main/src/user/components/stroop_exp/StroopView.vue )
258+ is a more complex example of a Stroop experiment which uses heriachically nested
259+ steps, randomization, and more.
253260
254261### Transitioning to the next View
255262
0 commit comments