.
This commit is contained in:
+6
-1
@@ -36,11 +36,16 @@ class LongAnswerForm(ModelForm):
|
|||||||
fields = ("answer_observations","answer_interpretation","answer_principle_diagnosis","answer_differential_diagnosis","answer_management",)
|
fields = ("answer_observations","answer_interpretation","answer_principle_diagnosis","answer_differential_diagnosis","answer_management",)
|
||||||
|
|
||||||
|
|
||||||
class MarkLongQuestionForm(ModelForm):
|
class MarkLongQuestionSingleForm(ModelForm):
|
||||||
class Meta:
|
class Meta:
|
||||||
model = CidUserAnswer
|
model = CidUserAnswer
|
||||||
fields = ["score"]
|
fields = ["score"]
|
||||||
|
|
||||||
|
class MarkLongQuestionDoubleForm(ModelForm):
|
||||||
|
class Meta:
|
||||||
|
model = CidUserAnswer
|
||||||
|
fields = ["score", "mark_reason", "candidate_feedback"]
|
||||||
|
|
||||||
|
|
||||||
class ExaminationForm(ModelForm):
|
class ExaminationForm(ModelForm):
|
||||||
class Meta:
|
class Meta:
|
||||||
|
|||||||
+50
-19
@@ -23,13 +23,14 @@ from django.http import HttpResponseRedirect, HttpResponse
|
|||||||
from .forms import (
|
from .forms import (
|
||||||
LongForm,
|
LongForm,
|
||||||
LongSeriesForm, LongSeriesImageFormSet,
|
LongSeriesForm, LongSeriesImageFormSet,
|
||||||
MarkLongQuestionForm,
|
MarkLongQuestionDoubleForm,
|
||||||
|
MarkLongQuestionSingleForm,
|
||||||
SeriesFormSet,
|
SeriesFormSet,
|
||||||
ExaminationForm,
|
ExaminationForm,
|
||||||
ExamForm,
|
ExamForm,
|
||||||
)
|
)
|
||||||
from .models import (
|
from .models import (
|
||||||
Long, LongSeries,
|
AnswerMarks, Long, LongSeries,
|
||||||
Examination,
|
Examination,
|
||||||
Exam,
|
Exam,
|
||||||
CidUserAnswer,
|
CidUserAnswer,
|
||||||
@@ -678,30 +679,60 @@ def mark_answer(request, exam_id, question_number, cid):
|
|||||||
except IndexError:
|
except IndexError:
|
||||||
next_unmarked_id = False
|
next_unmarked_id = False
|
||||||
|
|
||||||
if request.method == "POST":
|
# We use different forms if the exam should be single or double marked
|
||||||
|
|
||||||
form = MarkLongQuestionForm(request.POST)
|
if not exam.double_mark:
|
||||||
|
if request.method == "POST":
|
||||||
|
form = MarkLongQuestionSingleForm(request.POST)
|
||||||
|
|
||||||
if form.is_valid():
|
if form.is_valid():
|
||||||
# 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=exam_id, sk=question_number, 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", exam_id=exam_id, question_number=question_number, 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", exam_id=exam_id, question_number=question_number, 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_question_overview", pk=exam_id, sk=n - 1)
|
# return redirect("longs:mark_question_overview", pk=exam_id, sk=n - 1)
|
||||||
|
|
||||||
|
else:
|
||||||
|
form = MarkLongQuestionSingleForm(initial={'score': answer.score})
|
||||||
|
|
||||||
else:
|
else:
|
||||||
form = MarkLongQuestionForm(initial={'score': answer.score})
|
mark_object = AnswerMarks.objects.get_or_create(user_answer=answer, marker=request.user)
|
||||||
|
if request.method == "POST":
|
||||||
|
form = MarkLongQuestionDoubleForm(request.POST)
|
||||||
|
|
||||||
|
if form.is_valid():
|
||||||
|
# If skip button is pressed skip the question without marking
|
||||||
|
# Skip is problematic if we skip to the next unmarked answer
|
||||||
|
#if "skip" in request.POST:
|
||||||
|
# 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
|
||||||
|
mark_object.score = form.cleaned_data["score"]
|
||||||
|
mark_object.mark_reason = form.cleaned_data["mark_reason"]
|
||||||
|
mark_object.candidate_feedback = form.cleaned_data["candidate_feedback"]
|
||||||
|
mark_object.marker = request.user
|
||||||
|
mark_object.save()
|
||||||
|
|
||||||
|
if "next" in request.POST:
|
||||||
|
return redirect("longs:mark_answer", exam_id=exam_id, question_number=question_number, cid=next_unmarked_id)
|
||||||
|
if "save" in request.POST:
|
||||||
|
return redirect("longs:mark_answer", exam_id=exam_id, question_number=question_number, cid=cid)
|
||||||
|
#elif "previous" in request.POST:
|
||||||
|
# return redirect("longs:mark_question_overview", pk=exam_id, sk=n - 1)
|
||||||
|
|
||||||
|
else:
|
||||||
|
form = MarkLongQuestionDoubleForm(initial={'score': mark_object.score,'mark_reason': mark_object.mark_reason,'candidate_feedback': mark_object.candidate_feedback, })
|
||||||
|
|
||||||
return render(
|
return render(
|
||||||
request,
|
request,
|
||||||
|
|||||||
Reference in New Issue
Block a user