This commit is contained in:
Ross
2021-01-30 15:16:18 +00:00
parent 37a2f2d88e
commit d4fa92b220
4 changed files with 75 additions and 8 deletions
+10
View File
@@ -386,6 +386,9 @@ class CidUserAnswer(models.Model):
question = models.ForeignKey(
Rapid, related_name="cid_user_answers", on_delete=models.CASCADE
)
# For rapids the answer can be normal in which case the below field is true
normal = models.BooleanField(default=False)
answer = models.TextField(max_length=500, blank=True)
answer_compare = models.TextField(max_length=500, blank=True)
@@ -430,6 +433,13 @@ class CidUserAnswer(models.Model):
def get_answer_score(self):
q = self.question
# First step we check that the normal/abnormal states match
if q.normal != self.normal:
# If they don't match the answer is wrong (score is 0)
return 0
# Then compare answer strings (as per anatomy questions)
ans = self.answer_compare
if (
q.answers.filter(