Survey¶
Todo
Docstrings (module, models)
Models¶
-
class
indico.modules.events.surveys.models.surveys.
Survey
(**kwargs)¶ Bases:
sqlalchemy.orm.decl_api.Model
A simple constructor that allows initialization from kwargs.
Sets attributes on the constructed instance using the names and values in
kwargs
.Only keys that are present as attributes of the instance’s class are allowed. These could be, for example, any mapped columns or relationships.
-
anonymous
¶ Whether submissions will not be linked to a user
-
can_submit
(user)¶
-
close
()¶
-
end_dt
¶ Datetime when the survey is closed
-
event
¶ The Event containing this survey
-
event_id
¶ The ID of the event
-
has_ended
¶
-
has_started
¶
-
id
¶ The ID of the survey
-
introduction
¶
-
is_active
¶
-
is_deleted
¶ Whether the survey has been marked as deleted
-
is_visible
¶
-
items
¶ The list of items
-
limit_reached
¶
-
locator
¶ Define a smart locator property.
This behaves pretty much like a normal read-only property and the decorated function should return a dict containing the necessary data to build a URL for the object.
This decorator should usually be applied to a method named
locator
as this name is required for get_locator to find it automatically when just passing the object.If you need more than one locator, you can define it like this:
@locator_property def locator(self): return {...} @locator.other def locator(self): return {...}
The
other
locator can then be accessed by passingobj.locator.other
to the code expecting an object with a locator.
-
new_submission_emails
¶ Email addresses to notify about new submissions
-
notifications_enabled
¶ Whether to send survey related notifications to users
-
notify_participants
¶ Whether include Participants / Registrants when sending start notifications
-
open
()¶
-
partial_completion
¶ Whether answers can be saved without submitting the survey
-
private
¶
-
questions
¶ The list of questions
-
require_user
¶ Whether submissions must be done by logged users
-
sections
¶ The list of sections
-
send_start_notification
()¶
-
send_submission_notification
(submission)¶
-
start_dt
¶ Datetime when the survey is open
-
start_notification_emails
¶ Email addresses to notify about the start of a survey
-
start_notification_recipients
¶ Return all recipients of the notifications.
This includes both explicit recipients and, if enabled, participants of the event.
-
start_notification_sent
¶ Whether start notification has been already sent
-
state
¶
-
submission_limit
¶ Maximum number of submissions allowed
-
submissions
¶ The list of submissions
-
title
¶ The title of the survey
-
uuid
¶
-
-
class
indico.modules.events.surveys.models.surveys.
SurveyState
¶ Bases:
indico.util.enum.IndicoEnum
An enumeration.
-
active_and_answered
= 4¶
-
active_and_clean
= 3¶
-
finished
= 5¶
-
limit_reached
= 6¶
-
not_ready
= 1¶
-
ready_to_open
= 2¶
-
-
class
indico.modules.events.surveys.models.items.
SurveyItem
(**kwargs)¶ Bases:
indico.core.db.sqlalchemy.descriptions.DescriptionMixin
,sqlalchemy.orm.decl_api.Model
A simple constructor that allows initialization from kwargs.
Sets attributes on the constructed instance using the names and values in
kwargs
.Only keys that are present as attributes of the instance’s class are allowed. These could be, for example, any mapped columns or relationships.
-
default_render_mode
= 2¶
-
display_as_section
¶ If a section should be rendered as a section
-
field_data
¶ Field-specific data (such as choices for multi-select fields)
-
field_type
¶ The type of the field used for the question
-
id
¶ The ID of the item
-
is_required
¶ If the question must be answered (wtforms DataRequired)
-
parent_id
¶ The ID of the parent section item (NULL for top-level items, i.e. sections)
-
position
¶ The position of the item in the survey form
-
possible_render_modes
= {<RenderMode.markdown: 2>}¶
-
render_mode
= 2¶
-
survey_id
¶ The ID of the survey
-
title
¶ The title of the item
-
to_dict
()¶ Return a json-serializable representation of this object.
Subclasses must add their own data to the dict.
-
type
¶ The type of the survey item
-
-
class
indico.modules.events.surveys.models.items.
SurveyItemType
¶ Bases:
int
,indico.util.enum.IndicoEnum
An enumeration.
-
question
= 1¶
-
section
= 2¶
-
text
= 3¶
-
-
class
indico.modules.events.surveys.models.items.
SurveyQuestion
(**kwargs)¶ Bases:
indico.modules.events.surveys.models.items.SurveyItem
A simple constructor that allows initialization from kwargs.
Sets attributes on the constructed instance using the names and values in
kwargs
.Only keys that are present as attributes of the instance’s class are allowed. These could be, for example, any mapped columns or relationships.
-
display_as_section
¶
-
field
¶
-
field_data
¶
-
field_type
¶
-
get_summary
(**kwargs)¶ Return the summary of answers submitted for this question.
-
id
¶
-
is_required
¶
-
locator
¶
-
not_empty_answers
¶
-
parent_id
¶
-
position
¶
-
render_mode
= 2¶
-
survey_id
¶
-
title
¶
-
to_dict
()¶ Return a json-serializable representation of this object.
Subclasses must add their own data to the dict.
-
type
¶
-
-
class
indico.modules.events.surveys.models.items.
SurveySection
(**kwargs)¶ Bases:
indico.modules.events.surveys.models.items.SurveyItem
A simple constructor that allows initialization from kwargs.
Sets attributes on the constructed instance using the names and values in
kwargs
.Only keys that are present as attributes of the instance’s class are allowed. These could be, for example, any mapped columns or relationships.
-
children
¶ The child items of this section
-
display_as_section
¶
-
field_data
¶
-
field_type
¶
-
id
¶
-
is_required
¶
-
locator
¶
-
parent_id
¶
-
position
¶
-
render_mode
= 2¶
-
survey_id
¶
-
title
¶
-
to_dict
()¶ Return a json-serializable representation of this object.
Subclasses must add their own data to the dict.
-
type
¶
-
-
class
indico.modules.events.surveys.models.items.
SurveyText
(**kwargs)¶ Bases:
indico.modules.events.surveys.models.items.SurveyItem
A simple constructor that allows initialization from kwargs.
Sets attributes on the constructed instance using the names and values in
kwargs
.Only keys that are present as attributes of the instance’s class are allowed. These could be, for example, any mapped columns or relationships.
-
display_as_section
¶
-
field_data
¶
-
field_type
¶
-
id
¶
-
is_required
¶
-
locator
¶
-
parent_id
¶
-
position
¶
-
render_mode
= 2¶
-
survey_id
¶
-
title
¶
-
to_dict
()¶ Return a json-serializable representation of this object.
Subclasses must add their own data to the dict.
-
type
¶
-
-
class
indico.modules.events.surveys.models.submissions.
SurveyAnswer
(**kwargs)¶ Bases:
sqlalchemy.orm.decl_api.Model
A simple constructor that allows initialization from kwargs.
Sets attributes on the constructed instance using the names and values in
kwargs
.Only keys that are present as attributes of the instance’s class are allowed. These could be, for example, any mapped columns or relationships.
-
answer_data
¶
-
data
¶ The user’s answer (no, not 42!) to the question
-
is_empty
¶
-
question
¶ The list of answers
-
question_id
¶ The ID of the question
-
submission_id
¶ The ID of the submission
-
-
class
indico.modules.events.surveys.models.submissions.
SurveySubmission
(**kwargs)¶ Bases:
sqlalchemy.orm.decl_api.Model
A simple constructor that allows initialization from kwargs.
Sets attributes on the constructed instance using the names and values in
kwargs
.Only keys that are present as attributes of the instance’s class are allowed. These could be, for example, any mapped columns or relationships.
-
answers
¶ The list of answers
-
friendly_id
¶ The human-friendly ID of the submission
-
id
¶ The ID of the submission
-
is_anonymous
¶ Whether the survey submission is anonymous
-
is_submitted
¶ Whether the survey was submitted
-
locator
¶
-
pending_answers
¶ List of non-submitted answers
-
submitted_dt
¶ The date/time when the survey was submitted
-
survey_id
¶ The ID of the survey
-
user
¶ The user who submitted the survey
-
user_id
¶ The ID of the user who submitted the survey
-
Operations¶
-
indico.modules.events.surveys.operations.
add_survey_question
(section, field_cls, data)¶ Add a question to a survey.
Parameters: - section – The SurveySection to which the question will be added.
- field_cls – The field class of this question.
- data – The FieldConfigForm.data to populate the question with.
Returns: The added SurveyQuestion.
-
indico.modules.events.surveys.operations.
add_survey_section
(survey, data)¶ Add a section to a survey.
Parameters: - survey – The Survey to which the section will be added.
- data – Attributes of the new SurveySection.
Returns: The added SurveySection.
-
indico.modules.events.surveys.operations.
add_survey_text
(section, data)¶ Add a text item to a survey.
Parameters: - section – The SurveySection to which the question will be added.
- data – The TextForm.data to populate the question with.
Returns: The added SurveyText.
Utilities¶
-
indico.modules.events.surveys.util.
generate_spreadsheet_from_survey
(survey, submission_ids)¶ Generate spreadsheet data from a given survey.
Parameters: - survey – Survey for which the user wants to export submissions
- submission_ids – The list of submissions to include in the file
-
indico.modules.events.surveys.util.
get_events_with_submitted_surveys
(user, dt=None)¶ Get the IDs of events where the user submitted a survey.
Parameters: - user – A User
- dt – Only include events taking place on/after that date
Returns: A set of event ids
-
indico.modules.events.surveys.util.
is_submission_in_progress
(survey)¶ Check whether the current user has a survey submission in progress.
-
indico.modules.events.surveys.util.
make_survey_form
(survey)¶ Create a WTForm from survey questions.
Each question will use a field named
question_ID
.Parameters: survey – The Survey for which to create the form. Returns: An IndicoForm subclass.
-
indico.modules.events.surveys.util.
query_active_surveys
(event)¶
-
indico.modules.events.surveys.util.
save_submitted_survey_to_session
(submission)¶ Save submission of a survey to session for further checks.
-
indico.modules.events.surveys.util.
was_survey_submitted
(survey)¶ Check whether the current user has submitted a survey.