Documentation
Addon-Events
Event
Events can be sent and received via Event Bus. You can access Event Bus via PlayerController.
Events are predefined and currently there are 4 types:
* ItemConsumed
* ItemReceived
* ItemSelected
* ValueChanged
There are no custom events at the moment.
Because of the nature of event bus used for sending and receiving events, each field in eventData object (more information about it can be found on PlayerController page) has to be string value. Otherwise, difficult to diagnose problems with conversion may occur.
Definition
This event is used to notify other modules that the link with definition has been clicked. Usually there is another module on the page which will show this definition inline or as a popup.
Event name | Params | Description |
---|---|---|
Definition |
|
Sent when a definition link with word is clicked. |
Drag and drop implementations
The communication between drag source and drag destination is implemented by sending and receiving events. Events are sent via Event Bus.
Simple scenario
When a user clicks on the item in source list, then this source list sends ItemSelected event. Cloze module is listening to this event and save Item id. When a user clicks on a cloze gap, then a cloze activity inserts a saved item and sends event ItemConsumed. Source list may remove the item when receiving this event. When a user clicks again on a gap in cloze, then item is removed from the gap and RemoveItem event is sent.
Events
Event name | Params | Description |
---|---|---|
ItemConsumed |
|
Sent by consumer of the draggable item when the item is put into a module. It notifies the provider (like a source list) that the item should be removed from the list. |
Event name | Params | Description |
---|---|---|
ItemReturned |
|
Sent by consumer of a draggable item when the item is removed from a module. It notifies the provider (like a source list), that the item should be put back to the list. |
Event name | Params | Description |
---|---|---|
ItemSelected |
|
Sent by 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 user. This can be used to provide some visual or audio feedback in the answer given by a user. For example, it is possible to show some text when a user puts an image to the gap.
Event name | Params | Description |
---|---|---|
ValueChanged |
|
Sent by interaction when a user changes state (enters new text, or inserts 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 |
|
Sent by interaction when a user changes state and the score of the module is 100% |
Showing and hiding answers
There are two special types of events which should be handled by all addons and modules working as activities.
Event name | Params | Description |
---|---|---|
ShowAnswers |
|
Informs all activity modules and addons on a page to show the correct answers. |
HideAnswers |
|
Informs all activity modules and addons on a page to hide the previously shown correct answers. |
While working with both events, developers should follow a few simple rules:
- Showing the correct answers should not change module's state and its response to isAttemped() command
- The user's answer should be preserved and displayed again when HideAnswers event is fired
- The user's answer should be preserved and displayed instead of the correct answer when the user goes back to the page
- If Check Answers button is selected while the correct answers are displayed, they should be hidden and the user's answers should be displayed and evaluated (both scoring and marking as correct/incorrect)
- If Show Answers button is selected while the check answers are displayed, they should be hidden and the correct answers should be displayed
- For correct answers, the module should use different CSS classes than for marking as correct in error mode
- Showing the correct answer should not cause sending the events
- Showing the correct answer should not cause counting score
- Module should be blocked