Class checklistItem
Acts as an interface for a checklist item implementation.
A checklist item can have a challenge and resposne text, which are displayed in the UI. These are optional, however if the checklist item has a response, the challenge and response texts are required.
The challenge and response sounds are referenced by a key. The challenge sound key is required for each checklist item. The response sound key is only required if the checklist item provides a response text.
If a checklist item does not have a response, it is not displayed in the UI. Instead, only the challenge sound is played and then it is completed automatically.
A checklist item can either evaluate itself if its conditions are met or it can indicate that it needs to be completed manually (e.g. by the user or by some external trigger).
Callbacks can be added to react to the checklist item getting started, failed and completed.
Info:
- Copyright: 2022 Patrick Lang
- Author: Patrick Lang
Methods
| checklistItem:new () | Creates a new checklist item. |
| checklistItem:getChallengeText () | Gets the challenge text of the checklist item. |
| checklistItem:getResponseText () | Gets the response text of the checklist item. |
| checklistItem:getChallengeKey () | Gets the key of the challenge sound. |
| checklistItem:getResponseKey () | Gets the key of the response sound. |
| checklistItem:hasResponse () | Checks whether the checklist item has a response This function can be implemented in a derived checklist item class. |
| checklistItem:isManualItem () | Checks whether the checklist item needs to be completed manually. |
| checklistItem:evaluate () | Checks whether the conditions of the checklist items are met. |
| checklistItem:setState (state) | Sets the state of the checklist item. |
| checklistItem:getState () | Gets the current state of the checklist item. |
| checklistItem:reset () | Resets the state of the checklist item. |
| checklistItem:addStartedCallback (callback) | Adds a callback which is executed if the checklist item is started. |
| checklistItem:addFailedCallback (callback) | Adds a callback which is executed if the checklist item has failed. |
| checklistItem:addCompletedCallback (callback) | Adds a callback which is executed if the checklist item is completed. |
| checklistItem:onStarted () | Executes the started callbacks. |
| checklistItem:onFailed () | Executes the failed callbacks. |
| checklistItem:onCompleted () | Executes the completed callbacks. |
Methods
- checklistItem:new ()
-
Creates a new checklist item.
Returns:
-
checklistItem
The created checklist item.
- checklistItem:getChallengeText ()
-
Gets the challenge text of the checklist item.
This function can be implemented in a derived checklist item class.
Returns:
-
optional string
Always
nil. - checklistItem:getResponseText ()
-
Gets the response text of the checklist item.
This function can be implemented in a derived checklist item class.
Returns:
-
optional string
Always
nil. - checklistItem:getChallengeKey ()
-
Gets the key of the challenge sound.
This function can be implemented in a derived checklist item class.
Returns:
-
optional string
Always
nil. - checklistItem:getResponseKey ()
-
Gets the key of the response sound.
This function can be implemented in a derived checklist item class.
Returns:
-
optional string
Always
nil. - checklistItem:hasResponse ()
-
Checks whether the checklist item has a response
This function can be implemented in a derived checklist item class.
Returns:
-
bool
Always
false. - checklistItem:isManualItem ()
-
Checks whether the checklist item needs to be completed manually.
This function can be implemented in a derived checklist item class.
Returns:
-
bool
Always
false. - checklistItem:evaluate ()
-
Checks whether the conditions of the checklist items are met.
This function can be implemented in a derived checklist item class.
Returns:
-
bool
Always
true. - checklistItem:setState (state)
-
Sets the state of the checklist item.
Parameters:
- state number The new state.
- checklistItem:getState ()
-
Gets the current state of the checklist item.
Returns:
-
number
The current state.
- checklistItem:reset ()
- Resets the state of the checklist item.
- checklistItem:addStartedCallback (callback)
-
Adds a callback which is executed if the checklist item is started.
Parameters:
- callback func The callback to add.
Usage:
myChecklistItem:addStartedCallback(function() end)
- checklistItem:addFailedCallback (callback)
-
Adds a callback which is executed if the checklist item has failed.
Parameters:
- callback func The callback to add.
Usage:
myChecklistItem:addFailedCallback(function() end)
- checklistItem:addCompletedCallback (callback)
-
Adds a callback which is executed if the checklist item is completed.
Parameters:
- callback func The callback to add.
Usage:
myChecklistItem:addCompletedCallback(function() end)
- checklistItem:onStarted ()
- Executes the started callbacks.
- checklistItem:onFailed ()
- Executes the failed callbacks.
- checklistItem:onCompleted ()
- Executes the completed callbacks.