fix some collection issues

This commit is contained in:
Ross
2024-07-22 11:35:37 +01:00
parent fe8c5b208b
commit 07d766cb30
5 changed files with 66 additions and 2 deletions
+15 -2
View File
@@ -1028,6 +1028,12 @@ class SeriesDetail(models.Model):
class CaseDetail(models.Model):
"""A through table that stores the relationship between a case and a collection.
This is what user answers are linked to (as there be different questions for the same case in a different collection)
The collection questions and answers are also defined here.
"""
case = models.ForeignKey(Case, on_delete=models.CASCADE)
collection = models.ForeignKey(CaseCollection, on_delete=models.CASCADE)
@@ -1109,8 +1115,15 @@ class BaseReportAnswer(models.Model):
for name, value in self.question.question_schema["properties"].items():
print(name, value)
user_answer = self.json_answer[name]
correct_answer = self.question.question_answers[name]
try:
user_answer = self.json_answer[name]
except KeyError: # If the schema has changed?
user_answer = ""
try:
correct_answer = self.question.question_answers[name]
except KeyError: # If the schema has changed?
correct_answer = ""
print(correct_answer)
match value: