Documentation

Addon-Events

Event

Events can be sent and received via the Event Bus. You can access the Event Bus via PlayerController.

Events are predefined and currently have four types:
ItemConsumed
ItemReceived
ItemSelected
ValueChanged

There are no custom events at the moment.

Because of the nature of the event bus used for sending and receiving events, each field in the eventData object (more information about it can be found on PlayerController page) must be a string value. Otherwise, difficult-to-diagnose problems with conversion may occur.

Definition

This event is used to notify other modules that the link with the definition has been clicked. Usually, there is another module on the page that will show this definition inline or as a popup.

Event name Params Description
Definition
  • word - show definition for this word
Sent when a definition link with the word is clicked.

Drag and drop implementations

The communication between the drag source and the drag destination is implemented by sending and receiving events. Events are sent via the Event Bus.

Simple scenario

When the user clicks the item in the Source List module, then this Source List sends the ItemSelected event. The Cloze module is listening to this event and saves the Item ID. When the user clicks a cloze gap, then the cloze activity inserts the saved item and sends the ItemConsumed event. The Source List may remove the item when receiving this event. When the user clicks again the gap in the cloze, then the item is removed from the gap and the RemoveItem event is sent.

Events

Event name Params Description
ItemConsumed
  • type - 'string' or 'image'
  • item - item's ID
  • value - item's value. Text for 'string' and URL for 'image'.
Sent by the consumer of the draggable item when the item is put into a module. It notifies the provider (like the Source List) that the item should be removed from the list.
Event name Params Description
ItemReturned
  • type - 'string' or 'image'
  • item - item's ID
  • value - item's value. Text for 'string' and URL for 'image'.
Sent by the consumer of a draggable item when the item is removed from a module. It notifies the provider (like the Source List), that the item should be put back into the list.
Event name Params Description
ItemSelected
  • type - 'string' or 'image'
  • item - item's ID
  • value - item's value. Text for 'string' and URL for 'image'.
Sent by the provider of a draggable item when the item is selected in the module.

Feedbacks

Interactive modules can notify via event other modules about a new value entered by the user. This can be used to provide some visual or audio feedback to the answer given by the user. For example, it is possible to show some text when the user puts an image into the gap.

Event name Params Description
ValueChanged
  • source - module's ID
  • item - ID of the item that changed value
  • value - new value
  • score - item's score
Sent by the interaction when the user changes state (enters new text, inserts an image, etc.)

All OK event

There is a special format of feedback event with which interactive modules can notify other modules when the module's score changes to 100%.

Event name Params Description
ValueChanged
  • source - module's ID
  • item - "all"
  • value - empty string ("")
  • score - empty string ("")
Sent by the interaction when the user changes state and the score of the module is 100%.

Showing and hiding answers

Two special types of events should be handled by all addons and modules working as activities.

Event name Params Description
ShowAnswers
  • source - module's ID
Informs all the activity modules and addons on a page to show the correct answers.
HideAnswers
  • source - module's ID
Informs all activity modules and addons on a page to hide the previously shown correct answers.

While working with both events, the developers should follow a few simple rules:

  1. Showing the correct answers should not change the module's state and its response to the isAttemped() command.
  2. The user's answer should be preserved and displayed again when the HideAnswers event is fired.
  3. The user's answer should be preserved and displayed instead of the correct answer when the user goes back to the page.
  4. If the Check Answers button is selected while the correct answers are being displayed, they should be hidden and the user's answers should be displayed and evaluated (both scoring and marking as correct/incorrect).
  5. If the Show Answers button is selected while the check answers are displayed, they should be hidden and the correct answers should be displayed.
  6. For correct answers, the module should use different CSS classes than for marking as correct in error mode.
  7. Showing the correct answer should not cause sending the events.
  8. Showing the correct answer should not cause the counting of the score.
  9. The module should be blocked.