.
This commit is contained in:
+26
-2
@@ -24,7 +24,7 @@ from .forms import (
|
||||
ExaminationForm,
|
||||
)
|
||||
|
||||
from .models import Examination
|
||||
from .models import Examination, QuestionNote
|
||||
|
||||
from rapids.models import Rapid as RapidQuestion
|
||||
from rapids.models import Exam as RapidExam
|
||||
@@ -39,6 +39,8 @@ from django.conf import settings
|
||||
from datetime import datetime
|
||||
import os
|
||||
|
||||
from rad.views import get_question_and_content_type
|
||||
|
||||
|
||||
# Create your views here.
|
||||
@login_required
|
||||
@@ -286,6 +288,10 @@ class ExamViews(View, LoginRequiredMixin):
|
||||
|
||||
can_edit = self.check_user_edit_access(request.user) | request.user.is_superuser
|
||||
|
||||
notes = []
|
||||
if can_edit:
|
||||
notes = self.exam_notes(request, pk)
|
||||
|
||||
questions = exam.exam_questions.all()
|
||||
|
||||
question_number = len(questions)
|
||||
@@ -293,9 +299,27 @@ class ExamViews(View, LoginRequiredMixin):
|
||||
return render(
|
||||
request,
|
||||
"{}/exam_overview.html".format(self.app_name),
|
||||
{"exam": exam, "questions": questions, "question_number": question_number, "can_edit": can_edit},
|
||||
{"exam": exam, "questions": questions, "question_number": question_number, "can_edit": can_edit, "notes": notes},
|
||||
)
|
||||
|
||||
#@method_decorator(login_required)
|
||||
def exam_notes(self, request, pk):
|
||||
exam = get_object_or_404(self.Exam, pk=pk)
|
||||
|
||||
if request.user not in exam.author.all():
|
||||
if not self.check_user_access(request.user):
|
||||
raise PermissionDenied
|
||||
|
||||
q, content_type = get_question_and_content_type(self.question_type)
|
||||
|
||||
question_pks = exam.exam_questions.values_list("pk", flat=True)
|
||||
|
||||
# Get active notes for type
|
||||
notes = QuestionNote.objects.filter(content_type=content_type, object_id__in=question_pks, complete=False)
|
||||
|
||||
return notes
|
||||
|
||||
|
||||
@method_decorator(login_required)
|
||||
def exam_json_edit(self, request, pk):
|
||||
if request.is_ajax() and request.method == "POST":
|
||||
|
||||
Reference in New Issue
Block a user