The Art of e-Learning

Frequently Asked Questions

Scripts

How to open MS Word document in a new window from the course?

Version: 4.0

At the beggining you have to copy this document into Resources directory (which is placed in main directory of the course). To open a document after button click you need to add action to it:
  • When acction appears: Click
  • Target object: page01
  • Execute action: Run script
And enter script command:

window.open("../resources/document_name.doc");

Where document_name is your document.

Warning: In Button Properties uncheck option "Button that confirms the answer".



After checking Student's answers in inputs incorrect answers will be changed to correct ones and the background colour in this elements will be changed.

Version: 4.2.9

Please open Page actions (Click with right button on the page->Page actions) and create the action as follows:
- When action appears: After page incorrect answer
- Target object: <self>
- Execute action: Run script.
Now we have to write a script, which will search for all input components ('componentInput') to check, if their answers are correct. If not, then the answer given by a Student will be changed for the correct one (or if there are multiple answers - for the list of answers separated by a comma character - line 4 of the script). At the end we are finding an 'input' field (line 5) and changing its color (line 6).

This script solves such situation:
for (var i=0; i < page.children.length; i++) {
 var obj = page.children[i];
 if (obj.type == "componentInput" && !obj.checkAnswer()) {
  obj.setAnswer(obj.correctAnswer.split('||').join(','));
  var elem = document.getElementsByName(obj.id+"Form")[0];
  elem.elements[0].style.background = 'red';
 }
}

If you would like to change a background for incorrect elements, please change value of .style.background (line 6 of the script), by giving it as a word or as a hexadecimal value (at the beginning should be hash(#) character placed, e.g. "#AAAAAA").

The script will work only with "Input" elements. To make it work with another elements, the line 3 should be modified and "componentInput" should be exchanged for proper type of the component.



I want to inform a Student, that they are leaving the page, which hasn't been seen completely.

Version: 4.2.9

The easiest and the quickest way is to use User variables in WBTExpress. To make your own variable, please choose option "Project" and "User Variables" (Project->User Variables). In the window enter your variable - lets call it 'next1' and set its value at 0.
At the beginning, on each element on the page, which will be revealed to a Student, we put an action (Click with right button on an object->Actions):
- When action appears: Show
- Target object: self
- Execute action: Run script
And please enter a script, which allows to count amount of elements shown to a Student:
me.next1 += parseInt(me.next1)+1;

Next, in Page actions (Click with right button on the page->Page actions) create the following action:
- When action appears: Load
- Target object: self
- Run action: Set User Value.
And set the value of the 'next1' variable to 0.

At the end we have to write a script for a button, which will be moving a Student to the next page. So, we call the action editor (Click with right button on the object->Actions) and create the following action:
- When action appears: Click
- Target object: self
- Run action: Run script
And enter the following script:
if ((parseInt(me.next11) < 4) && (!page.all["flash1"].visible)) {
 page.all["flash1"].actionShowObject();
} else {
 page.nextPage();
}

Where, in this case:
- 4 is the number of elements on the page,
- flash1 is an element, which will be the 'warning' for a Student. Its status is set to "Hidden".

Of course you can change this parameters to your needs - depending on the amount of objects on the page, which should be seen by a Student and on elements, which will be shown, when a Student tries to leave a page. Besides there is a function to move to the next page, so you don't have to create a separate action for this.

Information: For each page the variable should be set to 0 at the action "Load".



I want to inform a Student, that they are trying to leave a page without seeing it completely, but only if a Student sees this page for a first time.

Version: 4.2.9

To see, if a page has been visited by a Student we should check its open status and, if they haven't seen everything on a page, show some warning or information. To do such action, we have to modify a script from a previous example adding at the beginning a line to check page's open status:
if (page.openStatus == lms.STATUS_NOT_ATTEMPTED)

Such solution will guarantee, that if a Student visites a page for a first time and won't see it completely, defined warning or information will be revealed.



How make the Graphics visible on the page, but only if the Student has entered on this page from specified page (for example: from page 1 we go to page 3 and the Graphics is displayed. But if we go from another page to page 3, the Graphics will be hidden).

Version: 4.2.9

We have to define an action in the element responsible for the Goto Page activity (for example it'll be Button). The action will help us in marking whether the jump was from the correct page or not.

First we have to define single user variable. Please choose menu "Project" and "User variables" option. Add new variable by clicking on the "Add" button, enter its name (for example "jump") and set its value on 0.

Next, click right mouse button on the Button responsible for going to the defined page and select "Actions" option. Please create the following action:
- When action appears: Click,
- Target object: page01,
- Execute action: Set User Value.
And set the value of variable "jump" as 1.

Information: The action setting value of the user variable should be declared earlier than action, that executes jumping to another page.

Next, on the target page please define the following action:
- When action appears: Unload,
- Target object: page01,
- Execute action: Set User Value.
And set the value of variable "jump" as 1. Such action will prevent displaying the Graphics, when the Student enters the page multiple times from different pages.

Please click left mouse button on the Graphics, which should be displayed, while holding Ctrl+Shift keys. In the dialogue window, which will appear, please find "Visible If" option and enter there the following line:
me.jump == 1
And confirm it by clicking the Ok button.