-
Notifications
You must be signed in to change notification settings - Fork 2
Lesson Plan API
Sarah Xu edited this page Mar 29, 2023
·
14 revisions
Psst: here's how to test your local storage calls!
- Store a lesson plan on the app’s local backend
- Saves object to JSON structure as "LESSON_NAME.json" using RNFS.writeFile:
{
"name": "lesson_name",
"warmUp": [
{
"type": "text",
"name": "text",
"content": "warmup1"
},
{
"type": "activity",
"name": "C Sharp",
"content": "dir/path/to/card"
}
],
"mainLesson": [],
"coolDown": [],
"notes": ["note1", "note2"]
}
static saveLessonPlan(lesson: LessonPlan): none
- Returns none
- Creates and returns a LessonPlan object
- Check for JSON using RNFS.exists and RNFS.readFile, destructure into new object, store into local storage
- If the name/file does not exist, then error is thrown
static getLessonPlan(name: str): lesson
- Returns LessonPlan object
- Returns an array of LessonPlan names. Does not require the content of each LessonPlan
- Reads each LessonPlan name using RNFS.readFile
- If no LessonPlans exist, error is thrown
static getAllLessonPlanNames(): string []
- Returns array
- Rename a lesson plan. Throws an error if the lesson plan doesn’t exist or if renamed to an existing name
- Uses RNFS.moveFile() with the original filename and the new filename
static setLessonPlanName(old_name: str, new_name: str): none
- Returns none
- Delete a lesson plan using the lesson plan name
- Uses RNFS.unlink() with the filepath and lesson name
static deleteLessonPlan(name: str): none
- Returns none
- Move a given lesson plan from the
Default
directory into theFavourited
directory - Uses RNFS.moveFile()
- Make sure to check the lesson plan already exists first!
static favouriteLessonPlan(name: str): none
- Returns none
- Move a given lesson plan from the
Favourited
directory into theDefault
directory - Uses RNFS.moveFile()
- Make sure to check the lesson plan already exists first!
static unFavouriteLessonPlan(name: str): none
- Returns none