.
This commit is contained in:
+26
-2
@@ -24,7 +24,7 @@ from .forms import (
|
|||||||
ExaminationForm,
|
ExaminationForm,
|
||||||
)
|
)
|
||||||
|
|
||||||
from .models import Examination
|
from .models import Examination, QuestionNote
|
||||||
|
|
||||||
from rapids.models import Rapid as RapidQuestion
|
from rapids.models import Rapid as RapidQuestion
|
||||||
from rapids.models import Exam as RapidExam
|
from rapids.models import Exam as RapidExam
|
||||||
@@ -39,6 +39,8 @@ from django.conf import settings
|
|||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
import os
|
import os
|
||||||
|
|
||||||
|
from rad.views import get_question_and_content_type
|
||||||
|
|
||||||
|
|
||||||
# Create your views here.
|
# Create your views here.
|
||||||
@login_required
|
@login_required
|
||||||
@@ -286,6 +288,10 @@ class ExamViews(View, LoginRequiredMixin):
|
|||||||
|
|
||||||
can_edit = self.check_user_edit_access(request.user) | request.user.is_superuser
|
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()
|
questions = exam.exam_questions.all()
|
||||||
|
|
||||||
question_number = len(questions)
|
question_number = len(questions)
|
||||||
@@ -293,9 +299,27 @@ class ExamViews(View, LoginRequiredMixin):
|
|||||||
return render(
|
return render(
|
||||||
request,
|
request,
|
||||||
"{}/exam_overview.html".format(self.app_name),
|
"{}/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)
|
@method_decorator(login_required)
|
||||||
def exam_json_edit(self, request, pk):
|
def exam_json_edit(self, request, pk):
|
||||||
if request.is_ajax() and request.method == "POST":
|
if request.is_ajax() and request.method == "POST":
|
||||||
|
|||||||
+2
-2
@@ -185,7 +185,7 @@ def feedback_create(request, question_type, pk):
|
|||||||
|
|
||||||
return JsonResponse({"success": False, "error": "Invalid exam type"})
|
return JsonResponse({"success": False, "error": "Invalid exam type"})
|
||||||
|
|
||||||
def get_question_and_content_type(pk, question_type):
|
def get_question_and_content_type(question_type):
|
||||||
if question_type == "rapid":
|
if question_type == "rapid":
|
||||||
question = Rapid
|
question = Rapid
|
||||||
content_type = ContentType.objects.get(model="rapid")
|
content_type = ContentType.objects.get(model="rapid")
|
||||||
@@ -219,7 +219,7 @@ class AddQuestionNote(CreateView):
|
|||||||
pk = self.kwargs["pk"]
|
pk = self.kwargs["pk"]
|
||||||
question_type = self.kwargs["question_type"]
|
question_type = self.kwargs["question_type"]
|
||||||
|
|
||||||
question, content_type = get_question_and_content_type(pk, question_type)
|
question, content_type = get_question_and_content_type(question_type)
|
||||||
|
|
||||||
get_object_or_404(question, pk=pk)
|
get_object_or_404(question, pk=pk)
|
||||||
return { "content_type" : content_type,
|
return { "content_type" : content_type,
|
||||||
|
|||||||
@@ -9,6 +9,17 @@
|
|||||||
<a href="{% url 'admin:rapids_exam_change' exam.id %}" title="Edit the Exam using the admin interface">Admin
|
<a href="{% url 'admin:rapids_exam_change' exam.id %}" title="Edit the Exam using the admin interface">Admin
|
||||||
Edit</a>
|
Edit</a>
|
||||||
<h1>Exam: {{ exam.name }}</h1>
|
<h1>Exam: {{ exam.name }}</h1>
|
||||||
|
|
||||||
|
{% if notes %}
|
||||||
|
<div class="alert alert-warning" role="alert">
|
||||||
|
The following questions have active notes
|
||||||
|
{% for note in notes %}
|
||||||
|
{{note}}
|
||||||
|
{% endfor %}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
This exam has {{question_number}} questions. Time limit: {{exam.time_limit}} seconds.<br />
|
This exam has {{question_number}} questions. Time limit: {{exam.time_limit}} seconds.<br />
|
||||||
<div class="parent-help" title="">
|
<div class="parent-help" title="">
|
||||||
Normal count: {{ exam.get_normal_abnormal_breakdown }}<span class="help-text">[Number of normal questions within
|
Normal count: {{ exam.get_normal_abnormal_breakdown }}<span class="help-text">[Number of normal questions within
|
||||||
@@ -196,7 +207,9 @@
|
|||||||
}));
|
}));
|
||||||
})
|
})
|
||||||
|
|
||||||
$("#full-question-list").append($("<button title='click and drag questions to change order'>Save exam order</button>").click(() => {
|
$("#full-question-list").append($(
|
||||||
|
"<button title='click and drag questions to change order'>Save exam order</button>"
|
||||||
|
).click(() => {
|
||||||
new_order = [];
|
new_order = [];
|
||||||
$("#full-question-list li").each((n, el) => {
|
$("#full-question-list li").each((n, el) => {
|
||||||
new_order.push(el.dataset.question_pk)
|
new_order.push(el.dataset.question_pk)
|
||||||
|
|||||||
Reference in New Issue
Block a user