Element

@Serializable
class Element

Represents a single content item within an Event, such as a poll, quiz, or informational card.

This class provides access to the element's state, its custom fields, and methods for interaction (e.g., answering a poll). To receive live updates for an element, attach a listener using add.

Properties

Link copied to clipboard

The list of possible answer options for a votable element. Returns null if the element is not votable.

Link copied to clipboard
@Transient
var canShowResults: Boolean

Indicates if the voting results for this element can currently be shown to the user.

Link copied to clipboard
@SerialName(value = "content_type")
val contentType: String

The specific content type of a custom element, as defined in the App Spec.

Link copied to clipboard
@Transient
var correctOption: Int?

The index of the correct answer option. Returns null if the correct option has not been revealed.

Link copied to clipboard

The total active duration of the element in seconds. Returns 0 if the element has no duration.

Link copied to clipboard

Custom field data for this element, localised to the current project locale. Keys and value types are defined in the project's App Spec.

Link copied to clipboard

true if the user has answered this element, false otherwise.

Link copied to clipboard
val id: String

The unique identifier of the element.

Link copied to clipboard

true if the correct option has been revealed, false otherwise.

Link copied to clipboard

true if the element is an interactive poll or quiz, false otherwise.

Link copied to clipboard

The maximum number of options a user can select when answering.

Link copied to clipboard

The maximum number of votes a user can assign to a single option.

Link copied to clipboard

The maximum number of votes a user can distribute among options.

Link copied to clipboard

The minimum number of options a user must select when answering.

Link copied to clipboard
@SerialName(value = "published_at")
val publishedAt: Long

The timestamp (in seconds) when the element was published.

Link copied to clipboard

The question text for a votable element. Returns null if the element is not votable.

Link copied to clipboard

Whether the platform counts votes on this element only from validated users, or null when the element is not a poll.

Link copied to clipboard

The voting results for a votable element. Returns null if results are not yet revealed or available.

Link copied to clipboard

The mode that determines when results should be shown.

Link copied to clipboard
@Transient
var state: ElementState

The current state of the element, e.g., OPENED or CLOSED.

Link copied to clipboard

The type of the element, e.g., "poll-element".

Link copied to clipboard

The timestamp (in seconds) when the element was last updated.

Link copied to clipboard
@Transient
var userAnswer: Answer?

The user's previously submitted answer for this element. Returns null if the user has not answered.

Functions

Link copied to clipboard
fun add(listener: ElementUpdateListener)

Adds a listener to receive updates for this element, such as state changes or new results.

Link copied to clipboard
fun answer(answer: Answer)

Submits a detailed answer for an interactive element, allowing for multiple votes per option.

fun answer(options: IntArray)
fun answer(vararg options: Int)

Submits an answer for an interactive element. Each selected option receives one vote.

Link copied to clipboard
open operator override fun equals(other: Any?): Boolean
Link copied to clipboard
open override fun hashCode(): Int
Link copied to clipboard

Removes a previously added listener.