.
This commit is contained in:
+1
-1
@@ -202,4 +202,4 @@ LongSeriesImageFormSet = inlineformset_factory(
|
|||||||
class ExamForm(ModelForm):
|
class ExamForm(ModelForm):
|
||||||
class Meta:
|
class Meta:
|
||||||
model = Exam
|
model = Exam
|
||||||
fields = ["name", "time_limit", "exam_mode", "active", "archive"]
|
fields = ["name", "time_limit", "exam_mode", "active", "double_mark", "archive"]
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
# Generated by Django 3.2.6 on 2021-09-11 17:25
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('longs', '0050_auto_20210911_1818'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='exam',
|
||||||
|
name='double_mark',
|
||||||
|
field=models.BooleanField(default=True),
|
||||||
|
),
|
||||||
|
]
|
||||||
@@ -585,6 +585,8 @@ class Exam(ExamBase):
|
|||||||
help_text='Author of exam',
|
help_text='Author of exam',
|
||||||
related_name="long_exam_author")
|
related_name="long_exam_author")
|
||||||
|
|
||||||
|
double_mark = models.BooleanField(default=True, help_text="Defines if an exam is expected to be double marked")
|
||||||
|
|
||||||
def get_exam_question_json(self, question_id):
|
def get_exam_question_json(self, question_id):
|
||||||
q = get_object_or_404(Long, pk=question_id)
|
q = get_object_or_404(Long, pk=question_id)
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -66,7 +66,7 @@ urlpatterns = [
|
|||||||
views.question_review,
|
views.question_review,
|
||||||
name="question_review",
|
name="question_review",
|
||||||
),
|
),
|
||||||
path("exam/<int:pk>/<int:sk>/<int:cid>/mark", views.mark_answer, name="mark_answer"),
|
path("exam/<int:exam_id>/<int:question_number>/<int:cid>/mark", views.mark_answer, name="mark_answer"),
|
||||||
path("exam/<int:pk>/<int:sk>/mark", views.mark, name="mark"),
|
path("exam/<int:pk>/<int:sk>/mark", views.mark, name="mark"),
|
||||||
path("exam/<int:pk>/mark", views.LongExamViews.mark_overview, name="mark_overview"),
|
path("exam/<int:pk>/mark", views.LongExamViews.mark_overview, name="mark_overview"),
|
||||||
# path("exam/<int:pk>/<int:sk>/", views.exam_take, name="exam_take"),
|
# path("exam/<int:pk>/<int:sk>/", views.exam_take, name="exam_take"),
|
||||||
|
|||||||
+10
-10
@@ -635,12 +635,12 @@ def loadJsonAnswer(answer):
|
|||||||
@login_required
|
@login_required
|
||||||
@user_is_long_marker
|
@user_is_long_marker
|
||||||
@reversion.create_revision()
|
@reversion.create_revision()
|
||||||
def mark_answer(request, pk, sk, cid):
|
def mark_answer(request, exam_id, question_number, cid):
|
||||||
exam = get_object_or_404(Exam, pk=pk)
|
exam = get_object_or_404(Exam, pk=exam_id)
|
||||||
|
|
||||||
questions = exam.exam_questions.all()
|
questions = exam.exam_questions.all()
|
||||||
|
|
||||||
n = sk
|
n = question_number
|
||||||
|
|
||||||
question_details = {
|
question_details = {
|
||||||
"total": len(questions),
|
"total": len(questions),
|
||||||
@@ -648,16 +648,16 @@ def mark_answer(request, pk, sk, cid):
|
|||||||
}
|
}
|
||||||
|
|
||||||
try:
|
try:
|
||||||
question = questions[sk]
|
question = questions[question_number]
|
||||||
except IndexError:
|
except IndexError:
|
||||||
raise Http404("Exam question does not exist")
|
raise Http404("Exam question does not exist")
|
||||||
|
|
||||||
try:
|
try:
|
||||||
answer = question.cid_user_answers.get(cid=cid, exam__id=pk)
|
answer = question.cid_user_answers.get(cid=cid, exam__id=exam_id)
|
||||||
except ObjectDoesNotExist:
|
except ObjectDoesNotExist:
|
||||||
raise Http404("User answer does not exist")
|
raise Http404("User answer does not exist")
|
||||||
|
|
||||||
cid_list = list(question.cid_user_answers.filter(exam__id=pk).values_list("cid", flat=True))
|
cid_list = list(question.cid_user_answers.filter(exam__id=exam_id).values_list("cid", flat=True))
|
||||||
|
|
||||||
previous_cid = False
|
previous_cid = False
|
||||||
next_cid = False
|
next_cid = False
|
||||||
@@ -686,18 +686,18 @@ def mark_answer(request, pk, sk, cid):
|
|||||||
# If skip button is pressed skip the question without marking
|
# If skip button is pressed skip the question without marking
|
||||||
# Skip is problematic if we skip to the next unmarked answer
|
# Skip is problematic if we skip to the next unmarked answer
|
||||||
#if "skip" in request.POST:
|
#if "skip" in request.POST:
|
||||||
# return redirect("longs:mark_answer", pk=pk, sk=sk, cid=next_unmarked_id)
|
# return redirect("longs:mark_answer", pk=exam_id, sk=question_number, cid=next_unmarked_id)
|
||||||
|
|
||||||
# Extract score from form and save it to the object
|
# Extract score from form and save it to the object
|
||||||
answer.score = form.cleaned_data["score"]
|
answer.score = form.cleaned_data["score"]
|
||||||
answer.save()
|
answer.save()
|
||||||
|
|
||||||
if "next" in request.POST:
|
if "next" in request.POST:
|
||||||
return redirect("longs:mark_answer", pk=pk, sk=sk, cid=next_unmarked_id)
|
return redirect("longs:mark_answer", exam_id=exam_id, question_number=question_number, cid=next_unmarked_id)
|
||||||
if "save" in request.POST:
|
if "save" in request.POST:
|
||||||
return redirect("longs:mark_answer", pk=pk, sk=sk, cid=cid)
|
return redirect("longs:mark_answer", exam_id=exam_id, question_number=question_number, cid=cid)
|
||||||
#elif "previous" in request.POST:
|
#elif "previous" in request.POST:
|
||||||
# return redirect("longs:mark", pk=pk, sk=n - 1)
|
# return redirect("longs:mark", pk=exam_id, sk=n - 1)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
form = MarkLongQuestionForm(initial={'score': answer.score})
|
form = MarkLongQuestionForm(initial={'score': answer.score})
|
||||||
|
|||||||
Reference in New Issue
Block a user