4.12, 4.13-Saving User Progress on a Screen

One of my teams is developing an app where they want to be able save the users progress so that the user can start where they left off the next time they return to the app. Does App Lab have the ability to do this? If so, how?

This is something that App Lab can do, but it’s pretty far outside the scope of what students are learning in Unit 4. The full version of App Lab includes a set of data tools that allow a program to record either simple key-value pairs, or to use a table of data as a database. Students can access full App Lab by clicking “Remix” on any of their project levels.

The simplest (though kinda hacky) way to do this would be to record a key-value pair for each user, where they key is the user’s id (which you can find with getUserId()) and the value is the ID of the last screen they visited, using something like this example app https://studio.code.org/projects/applab/DbtLTRJpwBwUYTDVzr5Q1w/view

The more correct approach would be to record the data in tables, but it requires a lot of concepts that students haven’t learned yet (including arrays and objects). For the sake of comparison, here’s a version using tables https://studio.code.org/projects/applab/WknCxGnA5V9oegM2QgXFEg/view

All that said, unless the students are super gung ho about exploring these extra functions, I’d redirect them towards working on making their prototype clearly communicate their design goals. Remember that the point of this project isn’t to create a fully functional app, but to do some quick iteration to get feedback on an idea, which probably doesn’t require that the app remembers where you left off.

2 Likes

I tried your more correct approach. Inside Code studio works fine. However, i shared it to my phone, tried to run it and it is not saving the last number. When I restart the app it is always in number 1. Please advise. Thank you

There is a verified solution I have checked myself! You can create a record in a single table that stores a user’s ID, or create a login system. Then, for each click to a different screen, first put readRecords, then inside the for loop do if(getUserID == records[i].TheUserIDColumn), update record of records[i].ScreenSaveColumn. That way, it will update once the user clicks something.
If you’re wondering how to make a login system, I made 2 videos, yet there are 2-3 to come, which will work. I have tested them already and created an app myself with it. See the code here: App Lab - Code.org.
See the two videos on my channel.https://www.youtube.com/channel/UCuO0NCqfd9OYm2AaP3G9kog?app=desktop