Actions when Progress Bar reaches max

I'm working a page where a learner has a specified number of clicks to complete at a task and find certain items on the page. I'm using a progress bar so that the learner knows roughly how many clicks they have used along with providing feedback when they find each item.

My goal is two fold:

  1. A text box that displays the number of clicks used based off the value on the progress bar
  2. All clickable options are disabled when the learner has reached the maximum clicks
  3. Once the max has been reached, a text box with some information such as results, next steps, etc.

I realize I could set up an action on each clickable item to change contents on a text box to match the variable and actions that trigger if the progress bar variable has reached 20. However, the has approximately 80-ish clickable items. However, I was hoping there may be a much cleaner and more efficient way to accomplish this. I've attached what I have so far and hoping I can get some insight on this idea.


Discussion (6)

I'd create an action group with all actions related to your progress bar and the maximum number of click:

  1. Action: Modify variable

    Target: used_clicks

    Type: Add

    Value: 1

  2. Action: Set progress bar position

    Target: Clicks used indicator

    Position: VAR(used_clicks)

    Only if: used_clicks less than or equal "20"

  3. Action: Set state

    Target: Open File Menu

    State: Disable

    Only if: used_clicks greater than or equal "20"

    Repeat for each of your Main menu buttons, (6 buttons). All other buttons cannot be shown if the 6 main buttons are disabled.

  4. Action: Show

    Target: Your feedback elements

    Only if: used_clicks greater than or equal "20"

Add an action to "Run action group" to each of your buttons of that you want to count the clicks.

This worked really well and was also applicable to the process if the learner correctly selected all the options before reaching the maximum clicks.

I am running into a new issue that happens when if the learner goes on from this page, but then returns to it after working on the task. I want to reset the progress bar to 0 when the page loads if they've already visited the page, regardless of whether they "passed" or not. The progress bar position resets, but the variable for the progress bar will not (ProgressBar_0001). I have an action set on page show that says to modify the variable to equal 0, but to no avail. It seems like this should work since it's the action right after setting the progress bar position to 0.

Also, I do not have the "retain value" checked on the progress bar properties.

You'll have to reset anything that takes influence on the progress bar. Set the progress bar position to "0". The progress bar variable always contains the progress bar position, so there should be no need to modify the variable separately.

If you followed my sample, you'd have to modify "used_clicks" to "0" as this is the value that controls the progress bar. It's not directly related to the progress bar so it will keep its value throughout the session. This means, when the user returns to the page the progress bar may be "0" again, but on the first click, "1" is added to "used_clicks" and the progress bar is set to the new value, that is 1 + current value of the variable which is the number of clicks from the last visit of the page.

If you wanted the learner to continue with the number of clicks from the last visit, you could add an action On: Show on page level to set the progress bar to "used_clicks" again.

"Retain value between sessions" won't influence the value of a variable while in the same session (while the window is open). When checked, Lectora will store the value in a cookie or in the LMS when the user closes the window and retrieve the value when the next session is started. If unchecked, the variable will have its initial value again.

You know what? I've been looking at this course WAYYYY too long. There is a very simple answer to this scenario. Add an OnPageShow that changes the state of the text box to reflect the number of clicks. So if I reset the progress bar position then do the change contents, it resets the whole thing to 0 again.

Consider this a "head-desk" moment.

This seems somewhat counterintuitive. There is a variable attached to the progress bar (ProgressBar_0001) by default attached to the progress bar. Theoretically, I would think that setting the progress bar position to 0 would set the variable to 0 as well OR the value could be manually set with a Modify Variable action. Having to create a separate variable to "count clicks" when one already exists creates more work and seems redundant.

This would mean that I would have to add the variable and the action to all the buttons on the page. An action group doesn't work as well, since on some buttons, the action needs to update the score for the page as well as count a click.

You're right of course, it is a bit redundant, only it's easier to control the unrelated variable as it can be modified in all ways. The progress bar variable can be modified but should not, as this variable and the progress bar itself is controlled by Lectoras progress bar actions "Set progress bar position" or "Step progress bar position".In most cases it's better not to interfere with Lectoras native actions, unless you know exactly what the action does.

Setting the progress bar position to "0" will / should also set the variable to "0". A "Modify variable" action will modify the variable but won't update the progress bar position. It seems that the "Step" action checks the current position of the progress bar before calculating the new position and as the position hasn't been updated it won't recognize the modified value of the variable, as it seems to modify the variable after changing the position.

The action group only controls the progress bar by counting the clicks on certain buttons. I didn't know it should do more ;-) If you want to react to the new value, calculated in the action group, you can either add these actions to the action group under suitable conditions or add them to the buttons. It may be necessary to add a short delay to the actions to make sure it's run after the action group. Also mind that these action should be under the "Run action group" action in the title explorer.

Discussions have been disabled for this post