diff --git a/server/cgi/db/question.py b/server/cgi/db/question.py index 2b389c5..b01be16 100644 --- a/server/cgi/db/question.py +++ b/server/cgi/db/question.py @@ -57,14 +57,22 @@ class Question: def get_correct_response_percentage(self, cur): rop = ResponseOptionPool(cur) response_options = rop.select_by_question_id(self.id) - return sum([int(i.get_correctness()) for i in response_options]) / len(response_options) * 100 + if len(response_options) == 0: + return None + else: + return sum([int(i.get_correctness()) for i in response_options]) / len(response_options) * 100 def render_short(self, cur): time_label = self.get_time_label() response_options = self.get_response_option_short_list(cur) - correct_percentage = round(self.get_correct_response_percentage(cur)) + correct_percentage = self.get_correct_response_percentage(cur) - return f'
' + if correct_percentage != None: + sub_label = f"{time_label}