/datum/poll_question
Datum which holds details of a running poll loaded from the database and supplementary info.
Used to minimize the need for querying this data every time it's needed.
Vars | |
admin_only | Hides the poll from any client without a holder datum. |
---|---|
allow_revoting | Allows a player to change their vote to a poll they've already voted on, off by default. |
created_by | Ckey of the poll's original author |
dont_show | Hint for statbus, not used by the game; Stops the results of a poll from being displayed until the end_datetime is reached. |
duration | Holds duration data when creating or editing a poll and refreshing the poll creation window. |
edit_ready | Indicates if a poll has been submitted or loaded from the DB so the management panel will open with edit functions. |
end_datetime | Date and time the poll will run until, timestamp format is YYYY-MM-DD HH:MM:SS. |
future_poll | Indicates a poll is set to not start in the future, still visible for editing but not voting on. |
interval | Holds interval data when creating or editing a poll and refreshing the poll creation window. |
options | Reference list of the options for this poll, not used by text response polls. |
options_allowed | The number of responses allowed in a multiple-choice poll, more can be selected but won't be recorded. |
poll_id | Table id of this poll, will be null until poll has been created. |
poll_type | The type of poll to be created, must be POLLTYPE_OPTION, POLLTYPE_TEXT, POLLTYPE_RATING, POLLTYPE_MULTI or POLLTYPE_IRV. |
poll_votes | Count of how many players have voted or responded to this poll. |
question | The title text of the poll, shows up on the list of polls. |
start_datetime | Date and time the poll opens, timestamp format is YYYY-MM-DD HH:MM:SS. |
subtitle | Supplementary text displayed only when responding to a poll. |
Procs | |
clear_poll_votes | Deletes all votes or text replies for this poll, depending on its type. |
delete_poll | Sets a poll and its associated data as deleted in the database. |
save_all_options | Saves all options of a poll to the database. |
save_poll_data | Inserts or updates a poll question to the database. |
Var Details
admin_only
Hides the poll from any client without a holder datum.
allow_revoting
Allows a player to change their vote to a poll they've already voted on, off by default.
created_by
Ckey of the poll's original author
dont_show
Hint for statbus, not used by the game; Stops the results of a poll from being displayed until the end_datetime is reached.
duration
Holds duration data when creating or editing a poll and refreshing the poll creation window.
edit_ready
Indicates if a poll has been submitted or loaded from the DB so the management panel will open with edit functions.
end_datetime
Date and time the poll will run until, timestamp format is YYYY-MM-DD HH:MM:SS.
future_poll
Indicates a poll is set to not start in the future, still visible for editing but not voting on.
interval
Holds interval data when creating or editing a poll and refreshing the poll creation window.
options
Reference list of the options for this poll, not used by text response polls.
options_allowed
The number of responses allowed in a multiple-choice poll, more can be selected but won't be recorded.
poll_id
Table id of this poll, will be null until poll has been created.
poll_type
The type of poll to be created, must be POLLTYPE_OPTION, POLLTYPE_TEXT, POLLTYPE_RATING, POLLTYPE_MULTI or POLLTYPE_IRV.
poll_votes
Count of how many players have voted or responded to this poll.
question
The title text of the poll, shows up on the list of polls.
start_datetime
Date and time the poll opens, timestamp format is YYYY-MM-DD HH:MM:SS.
subtitle
Supplementary text displayed only when responding to a poll.
Proc Details
clear_poll_votes
Deletes all votes or text replies for this poll, depending on its type.
delete_poll
Sets a poll and its associated data as deleted in the database.
Calls the procedure set_poll_deleted to set the deleted column to 1 for each row in the poll_ tables matching the poll id used. Then deletes each option datum and finally the poll itself.
save_all_options
Saves all options of a poll to the database.
Saves all the created options for a poll when it's submitted to the DB for the first time and associated an id with the options. Insertion and id querying for each option is done separately to ensure data integrity; this is less performant, but not significantly. Using MassInsert() would mean having to query a list of rows by poll_id or matching by fields afterwards, which doesn't guarantee accuracy.
save_poll_data
Inserts or updates a poll question to the database.
Uses INSERT ON DUPLICATE KEY UPDATE to handle both inserting and updating at once. The start and end datetimes and poll id for new polls is then retrieved for the poll datum. Arguments:
- clear_votes - When true will call clear_poll_votes() to delete all votes matching this poll id.