I have a learning platform where all the learning resources are nested inside sections
Both the sections and the resources are sorted by a number field “position”.
The “user” data type has a list of data type “resource_done” that host all the learning resources they finished
I’m adding a button “next resource” that will direct the user to the next resource they need to learn, and I wanted to hear your thoughts on how I wanted to do it and if there is a more efficient way?
My idea on how to do it:
Creating a data type “Last_Resource” that will update each time the user finishes a learning resource
it will have the following fields:
Resource - type resource
Section - type section
(1) When the user clicks on the “next resource” button it will search for a resource that has a “position” + 1 inside the current section, and if this resource is not inside the user’s “resource_done” list it will direct them to it.
(2) If the resource is on the “resource_done” list it will repeat the process when the position + 1 is the of the resource in the “resource_done” list
(3) If the isn’t a resource of that position inside the section, a new search will happen just like in (1) when the section position is +1 and repeat the entire process
(4) if there isn’t a section + 1 in (3) the system will look for a resource that isn’t finished in past sections starting with the section in position 1
It’s all sounds very inefficient to me, and this action needs to happen fast otherwise the user experience will be greatly damaged, do you have a better way to do it?