generic score pages
This commit is contained in:
@@ -21,9 +21,56 @@ from django.http import Http404, JsonResponse
|
||||
|
||||
from django.http import HttpResponseRedirect, HttpResponse
|
||||
|
||||
from physics.models import CidUserAnswer as PhysicsCidUserAnswer
|
||||
from physics.models import Exam as PhysicsExam
|
||||
|
||||
from anatomy.models import CidUserAnswer as AnatomyCidUserAnswer
|
||||
from anatomy.models import Exam as AnatomyExam
|
||||
|
||||
|
||||
|
||||
@login_required
|
||||
def profile(request):
|
||||
user = request.user
|
||||
return render(request, "profile.html", {"user": user})
|
||||
|
||||
|
||||
def cid_selector(request):
|
||||
return render(
|
||||
request,
|
||||
"cid_selector.html",
|
||||
)
|
||||
|
||||
|
||||
def cid_scores(request, 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)
|
||||
|
||||
|
||||
if not physics_answers and not anatomy_answers:
|
||||
raise Http404("cid not found")
|
||||
|
||||
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_exams = AnatomyExam.objects.filter(id__in=anatomy_exam_ids)
|
||||
|
||||
|
||||
return render(
|
||||
request,
|
||||
"cid_scores.html",
|
||||
{
|
||||
"physics_exams": physics_exams,
|
||||
"anatomy_exams": anatomy_exams,
|
||||
"cid": cid,
|
||||
},
|
||||
)
|
||||
Reference in New Issue
Block a user