Downright Sneaky Lectora Tricks Part 2: Create a “Hidden Entrance” to devMode

blog_SneakyPt2

In the previous Downright Sneaky Lectora® Tricks tutorial, we created the devMode variable in Lectora®. Today, we’re going to provide a way to turn it ON and OFF. Turning devMode ON and OFFNow that you have created your devMode variable, you need a way to toggle it ON and OFF. My own methods for toggling devMode have evolved significantly over time.Initially, I just set the Initial Value of the devMode variable to 1 so that it was ALWAYS ON during course development. When development was over, I changed the initial value to 0 to turn it off and republish. After a couple of close calls, I decided to make the entrance to devMode hidden so that if I forgot to turn it off, it wouldn’t be noticeable to students.We’ll do the same: we’ll use a transparent button to turn devMode ON and OFF.How to add a transparent button to toggle devMode

  1. On the Insert ribbon, click the Button drop-down list and select Transparent to add a transparent button to the page. Rename the button devEntrance.
pt2_img1_transparentBtn

Position the button out of the way but in a spot where you can find it without trouble.

pt2_img2_screenshot
  1. Select the action for devEntrance button and, in the Properties ribbon, apply the following settings:

Trigger: Mouse Click Action: Modify Variable Target: devMode Type: Set equal to Value: 1

pt2_img3_devModeOn-tbr

Now your invisible button can turn devMode ON!Make the button turn devMode OFF tooRight now, the devEntrance button turns devMode on, but what if you want to be able to go back to the regular mode? You should be able to turn the variable OFF too. How do you do it?You COULD make a second button to turn devMode off (I did at one point), but tell me... do you use ONE LIGHT SWITCH to turn your lights ON and ANOTHER to turn them OFF? No, you use a single switch that toggles between ON and OFF.What we need is for our button to do DIFFERENT THINGS in DIFFERENT situations (turn OFF or turn ON). This is where you apply CONDITIONAL logic, which means adding an IF to your action. Here’s how the logic works...

When you click the devEntrance button, IF devMode is OFF, turn it ON. Otherwise, IF devMode is ON, turn it OFF.

Still with me? Here’s how we program that logic into the action.

  1. Select the action for the devEntrance button and, on the Properties ribbon, click the Conditions button (which currently displays the word Always).
onClck devmode on

The Set Action Conditions dialog box is displayed.

pt2_img4_set conditions
  1. Select the following settings in the Set Action Conditions dialog box:
  • Variable: devMode
  • Relationship: Equal To
  • Value : 0

What we are saying is that IF devMode is OFF (0), then run the action. The action, of course, will be to turn it ON (1).

Click OK to close the Set Action Conditions dialog box.

The Conditions button now displays IF (instead of Always) because you have made this action conditional.

pt2_img5_set conditionsIF

The final step is to specify what happens when our IF condition (devMode = 0) is NOT in effect. The only way our condition can’t be met is if devMode is already ON (devMode=1). In that case, the action we want is to turn devMode OFF (change devMode = 0).

pt2_img6_set conditionsELSE
  1. Click the Else Action button (which currently shows No Action) and select Modify Variable from the drop-down list and enter the following settings in the Properties ribbon:
  • Target: devMode
  • Type: Set Equal To
  • Value: 0
pt2_img7_conditionsFull

Now your button turns devMode on AND off. Make sense? Feel free to test it out… the only problem is that devMode doesn’t DO anything just yet, so you won’t see any difference.This is plenty for today. In part 3 of this Downright Sneaky Lectora Tricks tutorial, we’ll add a devMode indicator to make sure it’s working.Download the Lectora and Lectora Online files for this course in the Trivantis® Community.John Mortenson is the Online Learning Manager for The Fresh Market. He has been developing online courses for over 10 years and is a member of the Lectora Advisory Board. He is also an Adobe Creative Suite Guru and cartoonist. You can contact him onLinkedIn andTwitter.

Previous Tutorial

Next Tutorial