File tree 2 files changed +8
-7
lines changed
2 files changed +8
-7
lines changed Original file line number Diff line number Diff line change @@ -57,26 +57,27 @@ def extract_answers(cls, values):
57
57
# submission questions.
58
58
is_submission_question = answer ["submission" ] is not None
59
59
60
- if is_submission_question and cls .is_answer_to (answer , cls .Questions .level ):
60
+ if is_submission_question and cls .matches_question (answer , cls .Questions .level ):
61
61
values ["level" ] = answer ["answer" ]
62
62
63
- if is_submission_question and cls .is_answer_to (
64
- answer , cls .Questions .outline
65
- ):
63
+ if is_submission_question and cls .matches_question (answer , cls .Questions .outline ):
66
64
values ["outline" ] = answer ["answer" ]
67
65
68
66
return values
69
67
70
68
@staticmethod
71
- def is_answer_to (answer : dict , question : str ) -> bool :
69
+ def matches_question (answer : dict , question : str ) -> bool :
72
70
"""
73
71
Returns True if the answer corresponds to the question passed as the second
74
72
argument.
75
73
76
74
Answers come in a nested structure that includes localised question
77
75
text. This function is a small wrapper to encapsulate that behaviour.
78
76
"""
79
- return answer .get ("question" , {}).get ("question" , {}).get ("en" ) == question
77
+ # Explicit if to make it clear it's a comparison
78
+ if question == answer .get ("question" , {}).get ("question" , {}).get ("en" ):
79
+ return True
80
+ return False
80
81
81
82
82
83
def get_latest_submissions_data () -> PretalxData :
Original file line number Diff line number Diff line change @@ -86,7 +86,7 @@ def test_submission_is_answer_to():
86
86
]
87
87
88
88
if answers [0 ]["question" ]["question" ]["en" ] == "Outline" :
89
- assert Submission .is_answer_to (answers [0 ], "Outline" )
89
+ assert Submission .matches_question (answers [0 ], "Outline" )
90
90
91
91
92
92
@pytest .mark .django_db
You can’t perform that action at this time.
0 commit comments