@bdelab/roar-levante-tasks 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md ADDED
@@ -0,0 +1,121 @@
1
+ # Description
2
+
3
+ The tasks are all housed in this single repo using a monorepo like-structure. Which task is run is selected at run time based on the passed in parameters (e.g. `?task=egma-math`). This can be run standalone as a web app or as an npm package (in ROAD for example). The 'Task Launcher' is simply the name of the class that runs the whole app code.
4
+
5
+ ## App code flow
6
+
7
+ _As a Standalone web app_
8
+
9
+ serve.js -> index.js -> taskConfig.js -> load assets, corpus, setup store -> jsPsych timeline is ran
10
+
11
+ _As a npm package_
12
+
13
+ wherever the package is used -> index.js -> taskConfig.js -> load assets, corpus, setup store -> jsPsych timeline is ran
14
+
15
+ ## How the task launcher works
16
+
17
+ The app can run in two different modes, and as such uses two different build processes. For standalone, the code is built with Webpack. As an `npm` package, the code is built with [Rollup](https://rollupjs.org/). They work fundamentally the same regardless of where they are run.
18
+
19
+ The TaskLauncher class takes in 4 parameters, 1 being optional. firekit, game params, user params, and the display element to attach the jsPsych code to. The display element is optional.
20
+
21
+ **As a Standalone web app**
22
+
23
+ As a standlone web app, the built code includes the `serve` folder. The entry point is in `serve.js`.
24
+ This folder also includes the config for Firestore.
25
+ `serve.js` includes some additional hooks (functions) from Firebase to check authentication.
26
+ In this mode, however, we do not use any authentication but treat the user as a guest.
27
+ The TaskLauncher class requires 3 things to run: firekit, user params, and game params. In standalone, we get all the parameters we need for the game from query strings.
28
+
29
+ **As a npm package (In development)**
30
+
31
+ As an npm package the packaged code does not include the serve folder.
32
+ You use it as you would any typical `npm` package:
33
+ Install it, import it, and run the code.
34
+ As with standalone deployment, it requires a firekit instance, game params, and user params.
35
+
36
+ ```
37
+ Import TaskLauncher from 'core-tasks'
38
+
39
+ const task = new TaskLauncher(firekit, gameParams, userParams);
40
+ task.run();
41
+ ```
42
+
43
+ ### What is firekit?
44
+
45
+ [Firekit](https://github.com/yeatmanlab/roar-firekit) is an SDK developed by the ROAR team that allows for a streamlined interaction with Firestore and Firebase. It provides useful functions and tools for task development.
46
+
47
+ ## Project structure
48
+
49
+ _Currently under development_
50
+
51
+ The overarching goal of this project is to simplify task developent, improve productivity, and decrease task development time. Previously, each task was in its own separate repo which led to a ton of WET ("Write Everything Twice" or in this case X times the amount of tasks) code.
52
+
53
+ Task specifc code lives in the task folder. Each child folder is named after it's respective task name.
54
+ Within that there is a `trials` folder containing `timeline.js`.
55
+ There may be additional helper functions in a `helper` directory.
56
+ Common code that is used throughout multiple tasks is in the `shared` directory.
57
+ This also has a `helpers` and a `trials` folder.
58
+ `taskSetup.js` defines global instances / variables that we need to pass all throughout the tasks.
59
+ `taskConfig.js` is where everything comes together for a task. There are 5 main parts to a task, the config, the store (you can think of this as global state), how to load the corpus (if the task needs it), where to get translations (TBD), and how to build the task timeline.
60
+
61
+ All of these parts in the task config file are ran after recieving the corresponding task name.
62
+
63
+ ## Current Tasks & Parameters
64
+
65
+ In standalone web app mode, tasks and parameters can be changes through query strings. These query string parameters are listed below.
66
+
67
+ ### Common Parameters
68
+
69
+ \_Note: All tasks are timed. The default is listed below.
70
+
71
+ ```
72
+ task: 'egma-math' | 'matrix-reasoning' | 'mental-rotation' | 'hearts-and-flowers' | 'memory-game' | 'same-different-selection' | 'theory-of-mind' | 'trog' [string] (optional)
73
+ age: [number] (optional) ,
74
+ audioFeedback: "neutral" ['string'] (optional) {Default: "neutral"},
75
+ skipInstructions: [boolean] (optional) {Default: true},
76
+ sequentialPractice: [boolean] (optional) {Default: true},
77
+ sequentialStimulus: [boolean] (optional) {Default: true},
78
+ corpus: "*task-name-here*-item-bank" [string] (optional) {Default: math-item-bank},
79
+ buttonLayout: "default" | "diamond" [string] (optional) {Default: "default"},
80
+ trials: [number] (optional),
81
+ stimulusBlocks: [number] (optional) {Default: 3},
82
+ numOfPracticeTrials: [number] (optional) {Default: 2},
83
+ maxIncorrect: [number] (optional) {Default: 3},
84
+ maxTime (minutes): [number] (optional) {Default: 100},
85
+ keyHelpers: [boolean] (optional) {Default: true},
86
+ storeItemId: [boolean] (optional) {Default: false},
87
+ pid: [string] (optional) {Default: random generated string}
88
+
89
+ ```
90
+
91
+ ### Math (includes Number Line) - Default
92
+
93
+ ### Matrix Reasoning
94
+
95
+ ### Mental Rotation
96
+
97
+ ### Hearts and Flowers
98
+
99
+ ### Memory Game
100
+
101
+ ### Same Different Selection
102
+
103
+ ### TROG
104
+
105
+ ## Theory of Mind
106
+
107
+ ## How ROAR / LEVANTE Tasks work within the greater ROAD infrastructure
108
+
109
+ [Data flow diagram](https://miro.com/app/board/uXjVNY-_qDA=/?share_link_id=967374624080)
110
+
111
+ # End to End Testing
112
+
113
+ We leverage the cypress framework for end to end testing. The tests are located in the `cypress` directory. To run the tests, you can use the following command:
114
+
115
+ ```shell
116
+ # Ensure dependencies are installed
117
+ npm install
118
+
119
+ # Run the tests
120
+ npx cypress open
121
+ ```