Question utils
question.utils:#
copy_shuffle(questions)
#
Makes a shuffled copy of a sequence of questions.
Args: questions (list[Question]): A list of questions
Returns: A shuffled copy of questions
Source code in question/utils.py
question_by_key(key, questions, is_skippable=None, drop_choices=[])
#
Return a copy of question with given key
Parameters:
Name | Type | Description | Default |
---|---|---|---|
key |
str
|
Key of question |
required |
questions |
list[Question]
|
List of questions |
required |
is_skippable |
bool
|
True will make the returned questions skippable |
None
|
drop_choices |
list[str]
|
Choices in the question to be removed (if applicable) |
[]
|
Returns:
Type | Description |
---|---|
A copy of question |
Source code in question/utils.py
total_unanswered_questions(participant, questions)
#
Return how many questions have not been answered yet by the participant
Parameters:
Name | Type | Description | Default |
---|---|---|---|
participant |
Participant
|
Participant who answer questions |
required |
questions |
list[Question]
|
List of questions |
required |
Returns:
Type | Description |
---|---|
Number of unanswered questions |
Source code in question/utils.py
unanswered_questions(participant, questions, randomize=False, cutoff_index=None)
#
Generator to give next unasked profile question and prepare its result
Parameters:
Name | Type | Description | Default |
---|---|---|---|
participant |
Participant
|
participant who will be checked for unanswered questions |
required |
questions |
list[Questions]
|
list of questions from which to select an unanswered question |
required |
randomize |
bool
|
optionally, randomize order of questions |
False
|
cutoff_index |
int
|
Maximal index in a questions sequence to consider questions |
None
|
Yields:
Type | Description |
---|---|
Next unasked profile question |