File tree Expand file tree Collapse file tree 2 files changed +8
-7
lines changed Expand file tree Collapse file tree 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):
5757 # submission questions.
5858 is_submission_question = answer ["submission" ] is not None
5959
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 ):
6161 values ["level" ] = answer ["answer" ]
6262
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 ):
6664 values ["outline" ] = answer ["answer" ]
6765
6866 return values
6967
7068 @staticmethod
71- def is_answer_to (answer : dict , question : str ) -> bool :
69+ def matches_question (answer : dict , question : str ) -> bool :
7270 """
7371 Returns True if the answer corresponds to the question passed as the second
7472 argument.
7573
7674 Answers come in a nested structure that includes localised question
7775 text. This function is a small wrapper to encapsulate that behaviour.
7876 """
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
8081
8182
8283def 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():
8686 ]
8787
8888 if answers [0 ]["question" ]["question" ]["en" ] == "Outline" :
89- assert Submission .is_answer_to (answers [0 ], "Outline" )
89+ assert Submission .matches_question (answers [0 ], "Outline" )
9090
9191
9292@pytest .mark .django_db
You can’t perform that action at this time.
0 commit comments