.
This commit is contained in:
+22
-15
@@ -30,12 +30,14 @@ from anatomy.models import Exam as AnatomyExam
|
||||
from rapids.models import CidUserAnswer as RapidsCidUserAnswer
|
||||
from rapids.models import Exam as RapidsExam
|
||||
|
||||
from longs.models import CidUserAnswer as LongsCidUserAnswer
|
||||
from longs.models import Exam as LongsExam
|
||||
|
||||
from anatomy.views import AnatomyExamViews
|
||||
from rapids.views import RapidExamViews
|
||||
from longs.views import LongExamViews
|
||||
|
||||
|
||||
|
||||
@login_required
|
||||
def profile(request):
|
||||
user = request.user
|
||||
@@ -50,32 +52,36 @@ def cid_selector(request):
|
||||
|
||||
|
||||
def cid_scores(request, pk):
|
||||
#exam = get_object_or_404(Exam, pk=pk)
|
||||
# exam = get_object_or_404(Exam, pk=pk)
|
||||
|
||||
# TODO:Need some kind of test for cid
|
||||
cid = pk
|
||||
|
||||
#questions = exam.exam_questions.all()
|
||||
physics_answers = PhysicsCidUserAnswer.objects.filter(
|
||||
cid=cid)
|
||||
anatomy_answers = AnatomyCidUserAnswer.objects.filter(
|
||||
cid=cid)
|
||||
rapids_answers = RapidsCidUserAnswer.objects.filter(
|
||||
cid=cid)
|
||||
# questions = exam.exam_questions.all()
|
||||
physics_answers = PhysicsCidUserAnswer.objects.filter(cid=cid)
|
||||
anatomy_answers = AnatomyCidUserAnswer.objects.filter(cid=cid)
|
||||
rapids_answers = RapidsCidUserAnswer.objects.filter(cid=cid)
|
||||
longs_answers = LongsCidUserAnswer.objects.filter(cid=cid)
|
||||
|
||||
|
||||
if not physics_answers and not anatomy_answers and not rapids_answers:
|
||||
if (
|
||||
not physics_answers
|
||||
and not anatomy_answers
|
||||
and not rapids_answers
|
||||
and not longs_answers
|
||||
):
|
||||
raise Http404("cid not found")
|
||||
|
||||
physics_exam_ids = physics_answers.values_list("exam").distinct()
|
||||
physics_exam_ids = physics_answers.values_list("exam").distinct()
|
||||
physics_exams = PhysicsExam.objects.filter(id__in=physics_exam_ids)
|
||||
|
||||
anatomy_exam_ids = anatomy_answers.values_list("exam").distinct()
|
||||
anatomy_exam_ids = anatomy_answers.values_list("exam").distinct()
|
||||
anatomy_exams = AnatomyExam.objects.filter(id__in=anatomy_exam_ids)
|
||||
|
||||
rapids_exam_ids = rapids_answers.values_list("exam").distinct()
|
||||
rapids_exam_ids = rapids_answers.values_list("exam").distinct()
|
||||
rapids_exams = RapidsExam.objects.filter(id__in=rapids_exam_ids)
|
||||
|
||||
longs_exam_ids = longs_answers.values_list("exam").distinct()
|
||||
longs_exams = LongsExam.objects.filter(id__in=longs_exam_ids)
|
||||
|
||||
return render(
|
||||
request,
|
||||
@@ -84,10 +90,12 @@ def cid_scores(request, pk):
|
||||
"physics_exams": physics_exams,
|
||||
"anatomy_exams": anatomy_exams,
|
||||
"rapids_exams": rapids_exams,
|
||||
"longs_exams": longs_exams,
|
||||
"cid": cid,
|
||||
},
|
||||
)
|
||||
|
||||
|
||||
def active_exams(request):
|
||||
anatomy_exams = AnatomyExamViews.active_exams(request, False)
|
||||
rapid_exams = RapidExamViews.active_exams(request, False)
|
||||
@@ -100,7 +108,6 @@ def active_exams(request):
|
||||
|
||||
active_exams = {"exams": exams}
|
||||
|
||||
|
||||
return JsonResponse(active_exams)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user