The current project I am working on is a on-boarding/training app. The app will allow administrative users to create courses, break up the courses into modules that consist of a single video, create quizzes per course that consist of a series of questions with multiple choice answers. Normal users will have the ability to “register” for these courses and ultimately take the quiz for each course that they register for.
I ran into some trouble while creating the processes that create the registered course, its modules, the courses quiz, the quiz’s questions, and the possible answers to the questions.
I envisioned the following steps:
- Based on user Course selection, create the User Course
- Iterate through the selected Course’s Modules and create User Modules
- Take the Course’s Quiz and create a User Quiz
- Iterate through the Course’s Quiz’s Questions and create a User Question
- and finally, iterate through each Quiz Question’s Answers and create corresponding User Question Answers
Goals:
- Stay within the Hobby plan. (I wanted to have a pilot to demo first before having the client dish out $$)
- Seamless UX
I hope to explain the problems I came across, how I resolved my issues, and hopefully get some feedback on how others have solved a similar problem or how they may go about this differently.
Problem #1:
No out of the box bubble action exists that allows you to loop through a list. I worked with other rapid application development platforms like Mendix whose visual workflow/logic builder has this feature.
(It would be a great feature to have in bubble. Just putting it out to the universe in hopes that the bubble gods here my plea It’s all love for bubble from me).
I then I found a video about running a scheduled api event on a list by @romanmg Big shout out to you btw. Extremely resourceful with the information you have put out there.
Thinking that this may solve my problem, I whipped up the workflows to handle:
- Iterating through the selected Course’s Modules
- Iterating through the Quiz’s Questions,
- and iterating through the Question’s Answers
Problem #2:
It seemed like it would all work, but I didn’t realize that you have to be on a paid plan to access the scheduled api features. Given that my goal was to stay on the hobby plan for the time being, it was time to move on.
I then opted to program a way using the Toolbox plugin’s javascript to bubble’s feature to iterate through my lists.
On my Course page, where users can register for Courses, is set up with the following:
-
A repeating group to display available courses to register for
-
A button within each Repeating Group cell allowing the User to Register for the given course
-
A custom state for the following
Module list to iterate on
Questions to iterate on
Answers to iterate on
The created User Course
The created User Quiz
The current Question
The current User Question -
Javascript to Bubble Elements to iterate on for the following:
Modules
Questions
Answers
(3 total JB elements)
The Register button kicks off the following workflow
The jist here is that I create the User Course, set the created User Course as User Course custom state so I may access it in other workflows, set the Module list custom state to the list of Modules belonging to the Course, run a javascript action passing the Module list custom state’s count into the javascript to bubble’s element I set up for the Modules, and finally creates the user quiz portion of the user course.
In my use case, my function in the JB element for my modules is bubble_fn_userModule. This JB element is set to trigger an event. In the Workflows, I have an event set up to run for that JB element only when its value is greater than 0.
The javascript action in the workflow behind the Register button passes the count of the custom state module list to the jb element like so: bubble_fn_userModule(course_page’s ModuleList’s:count). Because the count is a value greater than 0, the javascript event for the JB element is kicked off.
This workflow iterates through the list of Modules and for every module, creates a User Module and associates it to the User Course custom State that I use to store the User Course created in the first workflow. The last action decrements the javascript to bubble’s module’s value by 1.
To access the data I need to pass to each created User Module, I set each field equal to course_page’s ModuleList’s:item#This JavascripttoBubble’s value’s(corresponding field I need to “copy”).
The break down:
Essentially you access the current iteration’s “thing” through the stored list’s item number that’s equal to the Javascript to Bubble’s current value.
For example if my list of modules consists of 4, when my javascript to bubble event is kicked off, the starting value is 4. So the stored list’s item # when I start is 4. Thus, the workflow will execute on the 4 item in my list. When the javascript to bubble’s module value is decremented, the workflow kicks off again only this time on the 3 item all the way down till there are no more.
@keith explains iterating using these javascript to bubble elements in a much more concise manner than I am in this post. I am trying to add a use case scenario here with my explanation.
The last step in my first workflow creates the user quiz, user questions, and user answer components of the registered course.
The Questions are iterated in a similar fashion where I have a JB element set to trigger an event only when its value is greater than 0.
In a run javascript action within the Create quiz workflow, I pass the Question count of a custom state list to the JB element for Questions thereby kicking off its workflow event that creates a User Question for each Question in the stored list.
I happen to store the current User Question in another custom state to associate it as the parent of User Answers created in a separate Javascript event workflow.
Problem #3:
In my create question javascript event workflow, I pass the Answer count’s value of the current Question to the JB element for Answers. The very next action I have is a Run Javascript action that decrements the javascript to bubble’s questions value by 1.
However, I didn’t necessarily want to decrease the Javascript to Bubble’s Question’s value until all the User Answers have been created for the current question at hand.
I thought that setting up a Only when statement would satisfy this requirement. So I set the Run javascript action to Only run when the Javascript to Bubble’s Answer’s value is 0. This didn’t work.
The workflow processed only once and my end result was everything I needed except that only one question was created and its corresponding answers.
I tried setting an “Imported” attribute on my Answers that would tell me if an Answer had been processed or not. I then tried to set the Only statement to run when all Answers had a “true” value set on Imported. My end result was the same as before with only one question and its corresponding answers created.
The remedy:
I created a Fourth Javascript to bubble element on the Course page set to Trigger an event. The event would only trigger when its value was set to 0.
In my create Questions workflow, I used a Run javascript action to set the value of the fourth javascript to bubble element to the Answer count of the current question. In my create Answers workflow, I decremented both the JB element Answer’s value and the newly created javascript to bubble elements value.
When this new JB element reached zero, it executed a run javascript action that decremented the javascript to bubble’s Question’s value by 1 thereby kicking off the next Question and Answer set.
This worked exactly as I expected except that it takes about 25 seconds!!! No bueno…
So, I achieved my goal in not switching away from the Hobby plan, however my second goal is compromised in that the UX isn’t as seamless as I’d like it to be.
I thought of scheduling a custom event sometime in the future however, I don’t know of a way to easily store the many parameters I am using to make the proper associations within each workflow.
I know that this project will move forward to a paid plan at some point and maybe the scheduled API workflows will work out better for me.
All in all, I hope this really long post may help someone in some fashion.
Again shout out to @romanmg and @keith for all the useful content out there.
Anyone have any similar experience?
How about them scheduled API workflows?
Thanks,