This commit is contained in:
Ross
2022-08-04 09:58:29 +01:00
parent be70054cf7
commit a2759908c4
4 changed files with 69 additions and 8 deletions
+9 -3
View File
@@ -1,3 +1,4 @@
from __future__ import annotations
import json
from django.contrib.contenttypes.fields import GenericRelation
from django.db import models
@@ -256,7 +257,7 @@ class AnatomyQuestion(models.Model):
]
)
def get_question_json(self, based=True, feedback=False):
def get_question_json(self, based=True, feedback=False, answers=True):
"""Returns a json representation of the question"""
# Loop through rapidimage associations
@@ -281,7 +282,8 @@ class AnatomyQuestion(models.Model):
"question": str(self.question_type),
}
json["answers"] = list(self.get_correct_unstripped_answers())
if answers:
json["answers"] = list(self.get_correct_unstripped_answers())
return json
@@ -420,11 +422,15 @@ class Exam(ExamBase):
else:
image = q.image.url
annotations = []
if str(q.image_annotations):
annotations = [str(q.image_annotations)]
exam_questions[q.id] = {
"title": q.get_title(),
"question": str(q.question_type),
"images": [image],
"annotations": [str(q.image_annotations)],
"annotations": annotations,
"type": "anatomy",
}