For example, your quiz has an essay question with both minimum and maximum word limits. You want to count the number of words and display them to your learners so that they know whether they respect the limit. The essay question may look like this:
Step 1: Create a number variable “wordCount”. (Home tab > Variables > add a new variable). For more information, see How to use number variables.
Step 2: Add an On Click event to the Count button. (In the Properties pane > Events – Actions > Add the On Click event.)
Write the script like the below image. Briefly, the script gets the text typed in the Essay_Question text box, calculates the words, and then sets the value of the wordCount variable with the number of words.
Note: You must write the question name (see it in the General tab > Name section of the answer area) as well as the name of the variable created above exactly.
Step 5: Click OK to finish. Next, you need to create a reference to display the number of words. (Insert a shape > click the text area of it > Home tab > Reference > wordCount > OK.)
Step 6: In the Home tab or Export tab, click HTML5 Preview to preview your project in a browser. Type some text in the text box and count the number of words.
If you want to run a script when the project loads, perform the following:
Step 1: Click the ActivePresenter button > Project > Properties.
Step 2: In the Project Properties dialog, switch to the Event tab and write your code.
The script above checks if a learner fails the lesson. If so, the lesson will be marked incomplete instead of completed even when it’s finished. By default, ActivePresenter marks a lesson completed when learners finish it, even if they fail. If you want the lesson to be marked incomplete when learners fail, run the script.
Customizing the Script Editor
If your experiments go haywire, you can always restore to the defaults by clicking the Restore Defaults button (2).
- Change the color of the editor components (3): Click the color rectangle next to the component in the component list, and then select a color in the Color Picker.
- Change the code view options: Select the check boxes to show line numbers (4), show dots in place of white space (5), and insert matching closing brackets to the code (6).
That’s how to add custom scripts in ActivePresenter 8. Try it out to extend the functionality of your course.