Skip to content

Commit

Permalink
fix circular import
Browse files Browse the repository at this point in the history
  • Loading branch information
BeritJanssen committed Jun 10, 2024
1 parent 9270bd3 commit 2c08c0c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
13 changes: 8 additions & 5 deletions backend/question/demographics.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
from experiment.standards.iso_countries import ISO_COUNTRIES
from experiment.standards.iso_languages import ISO_LANGUAGES
from experiment.standards.isced_education import ISCED_EDUCATION_LEVELS
from .utils import question_by_key


ATTAINED_EDUCATION_CHOICES = dict(
ISCED_EDUCATION_LEVELS,
Expand Down Expand Up @@ -148,19 +150,20 @@


def demographics_other():
from .utils import question_by_key

questions = []

question = question_by_key('dgf_education', drop_choices=['isced-2', 'isced-5'])
question = question_by_key('dgf_education', DEMOGRAPHICS, drop_choices=[
'isced-2', 'isced-5'])
question.key = 'dgf_education_matching_pairs'
questions.append(question)

question = question_by_key('dgf_education', drop_choices=['isced-1'])
question = question_by_key(
'dgf_education', DEMOGRAPHICS, drop_choices=['isced-1'])
question.key = 'dgf_education_gold_msi'
questions.append(question)

question = question_by_key('dgf_education', drop_choices=['isced-5'])
question = question_by_key(
'dgf_education', DEMOGRAPHICS, drop_choices=['isced-5'])
question.key = 'dgf_education_huang_2022'
questions.append(question)

Expand Down
6 changes: 2 additions & 4 deletions backend/question/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,20 @@

from result.utils import prepare_profile_result

from .demographics import DEMOGRAPHICS


def copy_shuffle(questions):
qcopy = deepcopy(questions)
random.shuffle(qcopy)
return qcopy


def total_unanswered_questions(participant, questions=DEMOGRAPHICS):
def total_unanswered_questions(participant, questions):
""" Return how many questions have not been answered yet by the participant"""
profile_questions = participant.profile().values_list('question_key', flat=True)
return len([question for question in questions if question.key not in profile_questions])


def question_by_key(key, questions=DEMOGRAPHICS, is_skippable=None, drop_choices=[]):
def question_by_key(key, questions, is_skippable=None, drop_choices=[]):
"""Return question by given key"""
for question in questions:
if question.key == key:
Expand Down

0 comments on commit 2c08c0c

Please sign in to comment.