rename CidUserAnswer to UserAnswer
This commit is contained in:
+5
-5
@@ -36,25 +36,25 @@ from django.shortcuts import render, get_object_or_404, redirect
|
||||
from django.contrib.contenttypes.models import ContentType
|
||||
|
||||
|
||||
from physics.models import CidUserAnswer as PhysicsCidUserAnswer, Question
|
||||
from physics.models import UserAnswer as PhysicsUserAnswer, Question
|
||||
from physics.models import Exam as PhysicsExam
|
||||
from physics.models import Question as SbasQuestion
|
||||
|
||||
from anatomy.models import CidUserAnswer as AnatomyCidUserAnswer
|
||||
from anatomy.models import UserAnswer as AnatomyUserAnswer
|
||||
from anatomy.models import Exam as AnatomyExam
|
||||
from anatomy.models import AnatomyQuestion
|
||||
from anatomy.models import Answer as AnatomyAnswer
|
||||
|
||||
from rapids.models import CidUserAnswer as RapidsCidUserAnswer
|
||||
from rapids.models import UserAnswer as RapidsUserAnswer
|
||||
from rapids.models import Exam as RapidsExam
|
||||
from rapids.models import Rapid
|
||||
from rapids.models import Answer as RapidAnswer
|
||||
|
||||
from longs.models import CidUserAnswer as LongsCidUserAnswer
|
||||
from longs.models import UserAnswer as LongsUserAnswer
|
||||
from longs.models import Exam as LongsExam
|
||||
from longs.models import Long
|
||||
|
||||
from sbas.models import CidUserAnswer as SbasCidUserAnswer
|
||||
from sbas.models import UserAnswer as SbasUserAnswer
|
||||
from sbas.models import Exam as SbasExam
|
||||
from sbas.models import Question as SbasQuestion
|
||||
|
||||
|
||||
+1
-1
@@ -394,7 +394,7 @@ class ExamUserStatus(models.Model):
|
||||
return f"{self.datetime}: {user} - {self.status} ({self.extra})"
|
||||
|
||||
|
||||
class CidUserAnswerBase(models.Model):
|
||||
class UserAnswerBase(models.Model):
|
||||
|
||||
cid = models.BigIntegerField(
|
||||
blank=True,
|
||||
|
||||
+17
-17
@@ -311,7 +311,7 @@ class ExamViews(View, LoginRequiredMixin):
|
||||
self.Exam = exam
|
||||
self.Question = question
|
||||
self.Answer = answer
|
||||
self.CidUserAnswer = cid_user_answer
|
||||
self.UserAnswer = cid_user_answer
|
||||
self.app_name = app
|
||||
self.question_type = question_type
|
||||
self.normalise_score = normalise_score
|
||||
@@ -855,7 +855,7 @@ class ExamViews(View, LoginRequiredMixin):
|
||||
|
||||
questions = exam.exam_questions.all()
|
||||
|
||||
cids = self.CidUserAnswer.objects.filter(question__in=questions, exam__id=pk)
|
||||
cids = self.UserAnswer.objects.filter(question__in=questions, exam__id=pk)
|
||||
|
||||
# Force a score update
|
||||
for c in cids:
|
||||
@@ -1186,7 +1186,7 @@ class ExamViews(View, LoginRequiredMixin):
|
||||
),
|
||||
# Prefetch(
|
||||
# "cid_user_answers",
|
||||
# queryset=self.CidUserAnswer.objects.filter(score=self.Answer.MarkOptions.UNMARKED, exam__id=pk),
|
||||
# queryset=self.UserAnswer.objects.filter(score=self.Answer.MarkOptions.UNMARKED, exam__id=pk),
|
||||
# to_attr="prefetched_unmarked_cid_answers"
|
||||
# #queryset=self.Answer.objects.filter(),
|
||||
# ),
|
||||
@@ -1427,11 +1427,11 @@ class ExamViews(View, LoginRequiredMixin):
|
||||
)
|
||||
|
||||
if uid:
|
||||
existing_answers = self.CidUserAnswer.objects.filter(
|
||||
existing_answers = self.UserAnswer.objects.filter(
|
||||
question__id=answer["qid"], exam__id=eid, user__id=uid
|
||||
)
|
||||
else:
|
||||
existing_answers = self.CidUserAnswer.objects.filter(
|
||||
existing_answers = self.UserAnswer.objects.filter(
|
||||
question__id=answer["qid"], exam__id=eid, cid=cid
|
||||
)
|
||||
posted_answer = answer["ans"]
|
||||
@@ -1445,13 +1445,13 @@ class ExamViews(View, LoginRequiredMixin):
|
||||
|
||||
if not existing_answers:
|
||||
if uid:
|
||||
ans = self.CidUserAnswer(
|
||||
ans = self.UserAnswer(
|
||||
answer=posted_answer,
|
||||
normal=normal,
|
||||
user=User.objects.get(id=uid),
|
||||
)
|
||||
else:
|
||||
ans = self.CidUserAnswer(
|
||||
ans = self.UserAnswer(
|
||||
answer=posted_answer, normal=normal, cid=cid
|
||||
)
|
||||
|
||||
@@ -1471,11 +1471,11 @@ class ExamViews(View, LoginRequiredMixin):
|
||||
case "anatomy":
|
||||
if not existing_answers:
|
||||
if uid:
|
||||
ans = self.CidUserAnswer(
|
||||
ans = self.UserAnswer(
|
||||
answer=posted_answer, user=User.objects.get(id=uid)
|
||||
)
|
||||
else:
|
||||
ans = self.CidUserAnswer(answer=posted_answer, cid=cid)
|
||||
ans = self.UserAnswer(answer=posted_answer, cid=cid)
|
||||
|
||||
ans.question_id = answer["qid"]
|
||||
ans.exam_id = eid
|
||||
@@ -1493,9 +1493,9 @@ class ExamViews(View, LoginRequiredMixin):
|
||||
# If the user answer does not exist
|
||||
if not existing_answers:
|
||||
if uid:
|
||||
ans = self.CidUserAnswer(user=User.objects.get(id=uid))
|
||||
ans = self.UserAnswer(user=User.objects.get(id=uid))
|
||||
else:
|
||||
ans = self.CidUserAnswer(cid=cid)
|
||||
ans = self.UserAnswer(cid=cid)
|
||||
ans.question_id = answer["qid"]
|
||||
ans.exam_id = eid
|
||||
|
||||
@@ -1527,7 +1527,7 @@ class ExamViews(View, LoginRequiredMixin):
|
||||
|
||||
n = n + 1
|
||||
|
||||
# print(CidUserAnswer.objects.filter(exam__id=q["eid"]))
|
||||
# print(UserAnswer.objects.filter(exam__id=q["eid"]))
|
||||
# print(request.urlencode())
|
||||
exam_type, exam_id = request.POST.get("eid").split("/")
|
||||
|
||||
@@ -1747,7 +1747,7 @@ class ExamViews(View, LoginRequiredMixin):
|
||||
exam.exam_questions.all()
|
||||
) # .prefetch_related("cid_user_answers", "answers")
|
||||
|
||||
# cid_user_answers = list(CidUserAnswer.objects.filter(cid=cid, exam__id=pk).prefetch_related("question"))
|
||||
# cid_user_answers = list(UserAnswer.objects.filter(cid=cid, exam__id=pk).prefetch_related("question"))
|
||||
|
||||
# cid_user_answers_q_map = {}
|
||||
|
||||
@@ -1874,8 +1874,8 @@ class ExamViews(View, LoginRequiredMixin):
|
||||
else:
|
||||
questions = exam.exam_questions.all().prefetch_related("answers")
|
||||
|
||||
# We could prefect the CidUserAnswers.answers here (if we didn't cache them)
|
||||
cid_user_answers = self.CidUserAnswer.objects.select_related("question").filter(
|
||||
# We could prefect the UserAnswers.answers here (if we didn't cache them)
|
||||
cid_user_answers = self.UserAnswer.objects.select_related("question").filter(
|
||||
question__in=questions, exam__id=pk
|
||||
)
|
||||
|
||||
@@ -2063,9 +2063,9 @@ class ExamViews(View, LoginRequiredMixin):
|
||||
|
||||
|
||||
class GenericViewBase:
|
||||
def __init__(self, app_name, QuestionObject, CidUserAnswerObject, ExamObject):
|
||||
def __init__(self, app_name, QuestionObject, UserAnswerObject, ExamObject):
|
||||
self.question_object = QuestionObject
|
||||
self.cid_user_answer_object = CidUserAnswerObject
|
||||
self.cid_user_answer_object = UserAnswerObject
|
||||
self.exam_object = ExamObject
|
||||
self.app_name = app_name
|
||||
|
||||
|
||||
Reference in New Issue
Block a user