Preserving state choices

Hi bubblers,

I’ve been stuck on an issue for about three days now and my small brain just can’t comprehend what I’m doing wrong, or if indeed I’m even going about things correctly.

I’m building a school app where students can have many subjects and subjects can have many students. I have set up a list that uses a custom state to retrieve all of the subjects I (the teacher) have created and, when I’m on a students profile, I can add all of the subjects I have created by clicking on some or all of the subjects I have created, using my custom state list along with a recursive workflow that adds the subject/s to that student. That’s all working great.

However, when I click to run the workflow again, it re-adds the exact same subjects again and when I navigate to another page, and then come back, the selections in my custom state list are no longer selected.

Now I know custom states are a temporary thing and this behaviour is actually correct but can someone point me in the right direction as to how I should solve this? Is a custom state list the right approach? Should I be using something else? If anyone can shed any light on this I’d be eternally grateful!

1 Like

Hi! What do you teach if my I? I work with professors a lot :slight_smile:

Nevertheless, so you have two data types, one list of subjects, and other list of students (users)?

And you want to make students to add their own list of subjects (from the subject data type)?

Student select subject to add from the list (in the states), and then you would like to add only subjects that are not on the students list?

But duplicates are added? Is this all right, or I am missing something?


Hi @another , thanks for replying! I’m not a teacher unfortunately but I’m helping a friend who is :smiley:

In terms of my DB set up - (simplified) it looks like so

User (teacher)
Student - list of students
Subject - list of subjects

Student - list of students

Subjects - list of subjects

I hope that gives you an idea of how everything structured. Let me know if not! Is that even the correct way to set up my approach?

1 Like

Okay, I see now :slight_smile: Thanks for the clarification!

Your data structure is ok, if you would provide this to smaller number of users, let’s say up to 100 or 1000, and I would not go more than that, for example if an user (student) has 50 subjects, that is already too much for me and my personal taste.

If you think long term, you can try structuring (if not late or to much work for you), by having three data types similar to what you have:

Data types:
Student (where list of students will be)
Subject (where list of subjects will be)
Teacher (where list of teacher, and maybe later teachers will be) [Let us know if you will have only one teacher throughout the time]

If a student will not have more than 20-30 subjects (per user), you can that add a list of subjects in the Student’s data type, otherwise I would already think to create a separate data type (4th here), naming it perhaps as “Taken_subjects”, where you will create a new data input each time user (student) adds a new subject to their profile, so you will have a separate (4th) data type where all the chosen subjects will be by the students, and from where you can easily delete and add new with a search, when each student (user) adds or removes a subject.

NOTE: This approach is not sustainable with new regulations in the Bubble and pricing model, where you will be charged by each workload unites, and in this case to search each time when user (Student) add the subject or want to delete, so you make the search in the backend, it would take to much of “workload unit”.

Not sure how long you are in the bubble, and maybe this is too much for you, bit advanced. If you are a beginner, and this app is just for a class. I think you don’t need to worry for a long term yet, and try to make it simple (small, and less complex for yourself) as possible.

If this is the case, I think you started on the right path:

You have three data types: List us teachers, subjects and students.

Each student has a field (list of subjects) where you can actually show a mark on a repeating group where all subjects are listed for user (student), if student has already data subject on their list or not, and if yes, you can showcase as checkbox “checked”, and if user want to remove, user “uncheck” the checkbox.

You can add the workflow triggered with “save button”, to change the list of user’s subjects, and in this case it would be easy for you, as you will have a “Current user” already there, and then if user contains this subject already to remove from the list, and if doesn’t then to add the subject.

How you got bit of a big picture here. Please let me know if you need still help, and perhaps if you can try to explain bit more about the app, so that I can make a shorter and more specific answer for you. Thanks!

1 Like

Thanks for replying @another - I really do appreciate it.

Let me see if I can implement what you said. I’m sure I’ll have further questions :sweat_smile:

1 Like

Oh, glad you find it well. Although I wrote it quick and quite on the fly, flow if you will.

Would you like to answer few questions before you start making changes, or at least share the approach what you will take and why? Just to be sure you don’t do a “double work”. Thanks!

@another So I’m trying to work through this step - however my repeating group is showing the subjects that the teacher has created (as every teacher will have different subjects) i.e - Type of content = Subjects - Data source = Current User (teachers) Subjects.

So in my repeating group I have checkboxes that say - Maths, Science, English, etc.

So how can I check a checkbox of a subject for my current student when the data source is set to Subject? I hope that makes sense. This is the part I can’t get my head around. It’s almost as if I need two data sources on a repeating group. One to know about the subjects that the teacher has created and the other is to know which student I’m working with.

@another - I’ve just come across this really helpful youtube video - How to check a checkbox by clicking on a group - - YouTube - that breaks down how to use the checkbox correctly. However, I still have the problem above. My repeating group is referencing the users (teachers) created subjects (which is what I want) but I then can’t check those against the current student I’m on because the data source is different. Do you know how I can have access to the current student I’m trying to add the subjects to?

I’ve admittedly just skimmed this post, but you can put repeating groups inside repeating groups.

If I understand correctly, you may be best served by having the outermost repeating group be “data source = students” so you get the big list of students, and then within the cell of that repeating group, you’d create another repeating group that is “data source = current teacher’s subjects”. Then your checkboxes go in there.

EDIT: Or actually it sounds like you’re on a student’s profile in this situation, so you’d probably just have the one repeating group of subjects. When you want to add a subject to the student and vice versa, you’d access the student data through wherever it is you’re currently storing it to display their profile.

For example, if the whole page is of the type “student” then your data source to manipulate would be “[current page name]'s student”.

If the page doesn’t have a type, and it’s just one group on the page that is associated with the student, then the data to manipulate would be “[group name]'s student”.

Hi again,

Nice to see we are moving forward here.

In this case, if you will have multiple teachers as well, I see this case in this way.

If there will be around 10-20 subjects per teachers, you can definitely save this in a list of the teacher’s data type, just to make it easier for you later on to fetch, but still in this case even I would create another data type named “Choosen subjects”, with fields: Teacher, Subject and User(Student), so that I have separate data base for each record, due to the long term.

In this case you have both, “personal list” for a teacher, and long term data base of each record, linked to each teacher, subject and user. [Bad thing about this is that each time student or teacher changes own subject, is that you will need to do a search (hopefully in the backend), and you then delete the record or add a new one, to keep your data type clean.

Or if you will, to make it even more for the long term, and simpler, you can separate those two data types, list of subjects, and choosen subjects by users (students).

Than for each student when teacher is selected, you can search for those subjects, and when saved, you can work with another data type.

Hope this helps. Once again, you can make this very simple by having a list in each teacher and student entry and add or remove from the list.

I am having similar case, and I am using both ways, separate data type and lists, so that I can quickly say if in this case student has this subject or not, rather than searching each time the data type with the all “choosen subjects”, which might take a while if you have a larger data base.

Once again, hope this helps. Looking forward!

1 Like

Thanks @melbournemarsden - that’s exactly what I was wanting to do. For some reason I completely forgot that I could reference the student above my repeating group by targeting the page. I’ve got a million other issues but that solves something I’ve been stuck on for days! Thanks again :beers:

1 Like

This topic was automatically closed after 70 days. New replies are no longer allowed.