.
This commit is contained in:
+28
-1
@@ -775,6 +775,17 @@ class CidUserAnswer(models.Model):
|
||||
blank=True,
|
||||
)
|
||||
|
||||
class CallStateOptions(models.TextChoices):
|
||||
CORRECT = "C", _("Correct Call")
|
||||
OVERCALL = "O", _("Overcall")
|
||||
UNDERCALL = "U", _("Undercall")
|
||||
INCORRECTCALL = "W", _("Incorrect Call")
|
||||
PARTIALCALL = "P", _("Partial Call")
|
||||
|
||||
callstate = models.CharField(
|
||||
max_length=1, choices=CallStateOptions.choices, blank=True, null=True
|
||||
)
|
||||
|
||||
def __str__(self):
|
||||
|
||||
name = self.cid
|
||||
@@ -823,6 +834,9 @@ class CidUserAnswer(models.Model):
|
||||
def get_absolute_url(self):
|
||||
return reverse("rapids:user_answer_view", kwargs={"pk": self.pk})
|
||||
|
||||
def get_answer_callstate(self):
|
||||
return self.callstate.label
|
||||
|
||||
def get_answer_score(self, cached=True):
|
||||
if cached and self.score:
|
||||
print("CACHED")
|
||||
@@ -840,10 +854,20 @@ class CidUserAnswer(models.Model):
|
||||
|
||||
# First step we check that the normal/abnormal states match
|
||||
if q.normal != self.normal:
|
||||
if q.normal:
|
||||
self.callstate = CidUserAnswer.CallStateOptions.OVERCALL
|
||||
else:
|
||||
self.callstate = CidUserAnswer.CallStateOptions.UNDERCALL
|
||||
|
||||
self.score = Answer.MarkOptions.INCORRECT
|
||||
self.save()
|
||||
# If they don't match the answer is wrong (score is 0)
|
||||
return 0
|
||||
# If both are normal full marks
|
||||
elif q.normal and self.normal:
|
||||
self.callstate = CidUserAnswer.CallStateOptions.CORRECT
|
||||
self.score = Answer.MarkOptions.CORRECT
|
||||
self.save()
|
||||
return 2
|
||||
|
||||
# Then compare answer strings (as per anatomy questions)
|
||||
@@ -864,13 +888,16 @@ class CidUserAnswer(models.Model):
|
||||
mark = "unmarked"
|
||||
if marked_ans is not None:
|
||||
self.score = marked_ans.status
|
||||
self.save()
|
||||
|
||||
if marked_ans.status == Answer.MarkOptions.CORRECT:
|
||||
self.callstate = CidUserAnswer.CallStateOptions.CORRECT
|
||||
mark = 2
|
||||
elif marked_ans.status == Answer.MarkOptions.HALF_MARK:
|
||||
self.callstate = CidUserAnswer.CallStateOptions.PARTIALCALL
|
||||
mark = 1
|
||||
elif marked_ans.status == Answer.MarkOptions.INCORRECT:
|
||||
self.callstate = CidUserAnswer.CallStateOptions.INCORRECTCALL
|
||||
mark = 0
|
||||
self.save()
|
||||
|
||||
return mark
|
||||
|
||||
Reference in New Issue
Block a user