.
This commit is contained in:
+11
-1
@@ -425,6 +425,10 @@ class CidUserAnswer(models.Model):
|
|||||||
created = models.DateTimeField(auto_now_add=True)
|
created = models.DateTimeField(auto_now_add=True)
|
||||||
updated = models.DateTimeField(auto_now=True)
|
updated = models.DateTimeField(auto_now=True)
|
||||||
|
|
||||||
|
score = models.CharField(
|
||||||
|
max_length=1, choices=Answer.MarkOptions.choices, default=Answer.MarkOptions.UNMARKED
|
||||||
|
)
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
try:
|
try:
|
||||||
exam = self.exam
|
exam = self.exam
|
||||||
@@ -456,11 +460,17 @@ class CidUserAnswer(models.Model):
|
|||||||
# s = s.translate(str.maketrans('', '', string.punctuation))
|
# s = s.translate(str.maketrans('', '', string.punctuation))
|
||||||
# return s
|
# return s
|
||||||
|
|
||||||
def get_answer_score(self):
|
def get_answer_score(self, cached=True):
|
||||||
|
if cached and self.score:
|
||||||
|
marked_ans = self.score
|
||||||
|
else:
|
||||||
q = self.question
|
q = self.question
|
||||||
ans = self.answer_compare
|
ans = self.answer_compare
|
||||||
marked_ans = q.answers.filter(answer_compare__iexact=ans).first()
|
marked_ans = q.answers.filter(answer_compare__iexact=ans).first()
|
||||||
|
|
||||||
|
self.score = marked_ans
|
||||||
|
self.save()
|
||||||
|
|
||||||
mark = "unmarked"
|
mark = "unmarked"
|
||||||
if marked_ans is not None:
|
if marked_ans is not None:
|
||||||
if marked_ans.status == Answer.MarkOptions.CORRECT:
|
if marked_ans.status == Answer.MarkOptions.CORRECT:
|
||||||
|
|||||||
Reference in New Issue
Block a user