Hi guys! Long time reader, first-time poster!
I’m building a simple educational course. I’d like to have the ability for users to mark each of the completed courses as done. Marking a course as done would change it’s color.
I’ve managed to change the color via states. However, my challenges are the following:
- How do I manage / organize the database to store what each user has completed?
- How can I revert the state back if the user “unchecks” the task?
- What’s the fastest way to apply a checkbox that does the state change, saving to database etc, to each course? There are 10 courses, so creating complex workflows for each doesn’t seem like the best way to go about it.
Really appreciate the help guys! I’m loving Bubble, but still quite a newbie.
Hi there, @despega… as with most things in Bubble, I am sure there are a number of ways to accomplish what you have described, and all of those ways are going to have their pros and cons. I certainly can’t say whether or not the following suggestion is the “best” way to do it, but I offer it up as food for thought.
I think a simple list on either the
User data type or the
Course data type would get you what you need from a db perspective. If you put the list on the
User data type, it is a list of the courses the user has completed. If you put it on the
Course data type, then it’s a list of the users who have completed that course.
With that structure in place, you wouldn’t need a state change in order to change the color of a completed course for a user. You could use a condition to change the color when the user’s list of completed courses contains the current course or the course’s list of users who have completed it contains the current user.
If you went down this path, maybe you’d have a button (as opposed to a checkbox) that lets a user mark a course as complete. The associated workflow would be super simple in that it would just add the course to the user’s list of completed courses or add the user to the course’s list of users who have completed it. Marking the course back to incomplete would work the same way but the course or user would be removed from the list when a button is clicked.
Anyway, like I said, this suggestion is just food for thought, but I think it is how I might approach it… well, until someone comes along and says it’s the worst idea ever, that is.
First, thank you so much for your guidance and the time you took to help! I managed to get it working. I created a database for each course, then generate an entry for each user who marks it as complete. I figured this would be the best way to then generate stats on courses, ie, total # of people who have completed each course.
I have a question on deleting the entry, though. In the workflows, my search for the entry looks like this:
I added the :first item on to delete as otherwise it didn’t work.
I search for current users’s email under the respective course database.
Does this make sense to you?
Thank you so much! Hope someday not to be such a newbie so I can help others!
No problem at all, @despega… always happy to try to help.
So each course is its own data type, right? And you add a record to a course’s data type when a user completes that course? If that is correct, then I think the way you are going about marking a course as incomplete for a user (i.e., deleting the user’s record from the course’s data type) makes sense.
For what it’s worth, if you had gone with the list idea, getting the total number of users who have completed a course would be simple count of the number of items in the list. Again, just food for thought.
Nutritious food for thought!
Ok, awesome, good to know that what I did makes sense. Inserting the course completed data into each user also felt natural. I’ll try that with other projects. I’m already getting the itch of working on more complex stuff!
Thanks again for your help!!