.
This commit is contained in:
+44
-1
@@ -213,6 +213,49 @@ class AnatomyQuestion(models.Model):
|
||||
def get_annotations(self):
|
||||
return self.image_annotations
|
||||
|
||||
def get_title(self):
|
||||
return "{}".format(self.description)
|
||||
|
||||
def get_correct_unstripped_answers(self):
|
||||
return set(
|
||||
[
|
||||
str(i)
|
||||
for i in self.answers.filter(proposed=False)
|
||||
if i.status == i.MarkOptions.CORRECT
|
||||
]
|
||||
)
|
||||
|
||||
def get_question_json(self, based=True):
|
||||
"""Returns a json representation of the question"""
|
||||
|
||||
# Loop through rapidimage associations
|
||||
images = []
|
||||
annotations = []
|
||||
feedback_images = []
|
||||
|
||||
if based:
|
||||
images.append(image_as_base64(self.image))
|
||||
else:
|
||||
images.append("{}/{}".format(settings.REMOTE_URL, self.image.url))
|
||||
|
||||
if self.image_annotations:
|
||||
annotations.append(str(self.image_annotations))
|
||||
|
||||
|
||||
|
||||
json = {
|
||||
"images": images,
|
||||
#"feedback_image": [],
|
||||
"annotations": annotations,
|
||||
"type": "anatomy",
|
||||
"title": self.get_title(),
|
||||
"question": str(self.question_type),
|
||||
}
|
||||
|
||||
json["answers"] = list(self.get_correct_unstripped_answers())
|
||||
|
||||
return json
|
||||
|
||||
|
||||
@reversion.register
|
||||
class Answer(models.Model):
|
||||
@@ -313,7 +356,7 @@ class Exam(ExamBase):
|
||||
exam_order.append(q.id)
|
||||
|
||||
exam_questions[q.id] = {
|
||||
"title": "{}".format(q.description),
|
||||
"title": q.get_title(),
|
||||
"question": str(q.question_type),
|
||||
"images": [image_as_base64(q.image)],
|
||||
"annotations": [str(q.image_annotations)],
|
||||
|
||||
Reference in New Issue
Block a user