many Longs fixes
This commit is contained in:
+36
-20
@@ -32,8 +32,8 @@ from generic.models import (
|
||||
CidUserGroup,
|
||||
ExamUserStatus,
|
||||
Examination,
|
||||
#Condition,
|
||||
#Sign,
|
||||
# Condition,
|
||||
# Sign,
|
||||
ExamBase,
|
||||
Plane,
|
||||
Contrast,
|
||||
@@ -90,15 +90,15 @@ class Long(models.Model):
|
||||
feedback = models.TextField(null=True, blank=True)
|
||||
|
||||
# TODO: merge with atlas condition / signs / finding
|
||||
#condition = tagulous.models.TagField(
|
||||
# condition = tagulous.models.TagField(
|
||||
# to=Condition,
|
||||
# blank=True,
|
||||
# help_text='Associated condition. Will allow searching / filtering and tips / hints to be displayed. Conditions with spaces must be enclosed in quotes "..."',
|
||||
#)
|
||||
# )
|
||||
|
||||
#sign = tagulous.models.TagField(
|
||||
# sign = tagulous.models.TagField(
|
||||
# to=Sign, blank=True, help_text="Radiological signs in the question"
|
||||
#)
|
||||
# )
|
||||
|
||||
# Model answers
|
||||
model_observations = models.TextField(null=True, blank=True)
|
||||
@@ -224,16 +224,17 @@ class Long(models.Model):
|
||||
"management": self.model_management,
|
||||
}
|
||||
|
||||
|
||||
def get_question_json(self, based: bool=True, answers: bool=True, feedback: bool=False):
|
||||
def get_question_json(
|
||||
self, based: bool = True, answers: bool = True, feedback: bool = False
|
||||
):
|
||||
"""Returns a json representation of the question
|
||||
|
||||
|
||||
if based = False return is a dict
|
||||
otherwise a url to the json file
|
||||
|
||||
answers arg is only parsed if based = False
|
||||
"""
|
||||
|
||||
|
||||
question_id = self.pk
|
||||
|
||||
if not based:
|
||||
@@ -285,7 +286,6 @@ class Long(models.Model):
|
||||
Path(path).parents[0].mkdir(parents=True, exist_ok=True)
|
||||
|
||||
with open(path, "w+") as f:
|
||||
|
||||
print("start writing file")
|
||||
# We manually create the json for long questions to reducem memroy usade
|
||||
f.write(
|
||||
@@ -431,13 +431,13 @@ class LongSeries(models.Model):
|
||||
)
|
||||
|
||||
def __str__(self):
|
||||
if self.long:
|
||||
long_id = ", ".format([long.pk for long in self.long.all()])
|
||||
# long_id = self.long.pk
|
||||
else:
|
||||
long_id = "None"
|
||||
return "{}/{} : {} [{}]".format(
|
||||
self.pk, self.get_examination(), self.description, long_id
|
||||
#if self.long:
|
||||
# long_id = ", ".format([long.pk for long in self.long.all()])
|
||||
# # long_id = self.long.pk
|
||||
#else:
|
||||
# long_id = "None"
|
||||
return "{}/{} : {}".format(
|
||||
self.pk, self.get_examination(), self.description
|
||||
)
|
||||
|
||||
def get_author_objects(self):
|
||||
@@ -695,7 +695,6 @@ class Exam(ExamBase):
|
||||
for q in questions:
|
||||
exam_order.append(q.id)
|
||||
if based:
|
||||
|
||||
# If it is a new question we need to for a question json refresh
|
||||
if q.json_creation_time is None:
|
||||
q.get_question_json()
|
||||
@@ -755,6 +754,7 @@ class Exam(ExamBase):
|
||||
@reversion.register
|
||||
class UserAnswer(UserAnswerBase):
|
||||
"""User answers by candidate"""
|
||||
|
||||
app_name = "longs"
|
||||
|
||||
question = models.ForeignKey(
|
||||
@@ -869,7 +869,7 @@ class UserAnswer(UserAnswerBase):
|
||||
|
||||
def get_answer_score(self):
|
||||
if self.score == "":
|
||||
return ""
|
||||
return "unmarked"
|
||||
return float(self.score)
|
||||
|
||||
def discrepant_answers(self):
|
||||
@@ -878,7 +878,23 @@ class UserAnswer(UserAnswerBase):
|
||||
return True
|
||||
return False
|
||||
|
||||
def get_answer_string(self) -> str:
|
||||
return f"""
|
||||
Observations:
|
||||
{self.answer_observations},
|
||||
|
||||
Interpretation:
|
||||
{self.answer_interpretation},
|
||||
|
||||
Principle Diagnosis:
|
||||
{self.answer_principle_diagnosis},
|
||||
|
||||
Differential:
|
||||
{self.answer_differential_diagnosis},
|
||||
|
||||
Management:
|
||||
{self.answer_management},
|
||||
"""
|
||||
|
||||
|
||||
@reversion.register
|
||||
|
||||
Reference in New Issue
Block a user