PricingBlog

Show User Progress in a Course

  • vaughtton-1268123795986583602

    Vaughtton

    1 year ago

    ¡Hey!

    Having a little bit of trouble figuring out how to showcase if a user has completed a lesson or not. Right now I have a table containing the Progress, which saves the user_id and lesson_id and an Endpoint that returns me all the completed lessons for a specific user.

    What I'm finding difiicult to do is a formula that for each lesson of the course shows a value of "Completed" if the user has completed the lesson - so the lesson_id is in the Get_Progress API Call or "Not completed" if not in there.

    Maybe I'm missing something in my planning as well!

    Thanks!

    P.D. ¿Are there Checkboxes native in Toddle?
  • mighty.13-1268128810440855563

    Mighty

    1 year ago

    You can have a native html checkbox. Add input and then if not present, add an attribute "type" to it. Change it to checkbox.

    As for your main problem, I think you need to have two queries. One to get all the possible lessons, and another that returns the completed lessons from the authenticated user. Then you match them. If lessons.lesson_id exists in progress.lesson_id then show completed, otherwise not completed. I hope this helps.
  • vaughtton-1268129279669964893

    Vaughtton

    1 year ago

    ¡Yep! That sounds right, thanks for the input 😄 Great way to do that.

    For the second part is where I'm having the trouble getting a formula in Toddle that does that :/
  • mighty.13-1268130148084092929

    Mighty

    1 year ago

    Ah, I see. Sorry, I can't help there. I'm just a toddle newbie.
    ❤️1
  • yoelfdz-1268154987234594877

    yoelfdz

    1 year ago

    Hey @Vaughtton I've done that before. You should be able to accomplish that with a formula like:

    {completed_lessons} -> Size -> multiply by 100 -> divide by ({all_lessons} -> Size)

    It may vary or might need to do it in another way depending on how you are receiving the data. Reach me out through DM with a branch url and I'll have a look if you want.
    1
  • yoelfdz-1268156418813329520

    yoelfdz

    1 year ago

    And if you want to know specifically which lesson has been completed, assuming you have an uuid of the lesson on both {completed_lessons} and {all_lessons} you could use the map formula and the uuid to check if {completed_lessons} includes item.uuid and set the completed boolean