Skip to content

Question utils

backend.question.utils:#

get_unanswered_questions(participant, question_set) #

Return next unasked profile question and prepare its result

Parameters:

Name Type Description Default
participant Participant

participant who will be checked for unanswered questions

required
question_set QuerySet

set of question objects for which status is checked

required

Yields:

Type Description
Generator

Next unasked profile question

Source code in backend/question/utils.py
def get_unanswered_questions(participant: Model, question_set: QuerySet) -> Generator:
    """Return next unasked profile question and prepare its result

    Args:
        participant (Participant): participant who will be checked for unanswered questions
        question_set (QuerySet): set of question objects for which status is checked

    Yields:
        Next unasked profile question

    """
    keys_answered = participant.profile_results().values_list('question_key', flat=True)
    for question_obj in question_set:
        if question_obj.key in keys_answered:
            continue
        yield question_obj