fix some useranswer compare issuses

This commit is contained in:
Ross
2024-01-10 21:06:49 +00:00
parent 76b4746b13
commit 8d0ffbba06
12 changed files with 86 additions and 96 deletions
+3 -9
View File
@@ -76,8 +76,8 @@ def image_directory_path(instance, filename):
def get_answer_compare(s):
s = s.strip().lower()
s = s.translate(str.maketrans("", "", string.punctuation.replace("#", "")))
s = s.strip().translate(str.maketrans("", "", string.punctuation.replace("#", ""))).lower()
s = " ".join(s.split())
return s
@@ -804,13 +804,7 @@ class UserAnswer(UserAnswerBase):
self.score = Answer.MarkOptions.UNMARKED
if self.answer:
self.answer = self.answer.strip()
s = self.answer.lower()
s = s.translate(
str.maketrans("", "", string.punctuation.replace("#", ""))
).strip()
self.answer_compare = s
self.answer_compare = get_answer_compare(self.answer)
else:
self.answer = ""
self.answer_compare = ""