fix question ordering through mark systems
This commit is contained in:
@@ -1,10 +1,15 @@
|
||||
|
||||
{% extends 'generic/exam_scores_base.html' %}
|
||||
|
||||
{% block navigation %}
|
||||
{{ block.super }}
|
||||
{% include 'generic/exam_link_headers.html' %}
|
||||
{% endblock navigation %}
|
||||
|
||||
{% block table_answers %}
|
||||
{% for question in questions %}
|
||||
<tr>
|
||||
<td><a href="{% url 'anatomy:mark' exam_pk=exam.pk sk=forloop.counter0 %}">Question {{forloop.counter}}</a>
|
||||
<td><a href="{% url 'longs:mark' exam_id=exam.pk sk=forloop.counter0 %}">Question {{forloop.counter}}</a>
|
||||
</td>
|
||||
{% comment %} {% for cid in cids %}
|
||||
<td class="anatomy-ans user-answer-score-{{score_by_question|get_item:question|get_item:cid}}" title="answer score: {{score_by_question|get_item:question|get_item:cid}}">{{ans_by_question|get_item:question|get_item:cid}}</td>
|
||||
|
||||
@@ -39,7 +39,12 @@
|
||||
|
||||
{% if not next_unmarked_id and not unmarked %}
|
||||
<div class="alert alert-info sticky-alert" role="alert">Success! Marking question complete. <br />
|
||||
<a href="{% url 'longs:mark_answer_override' exam_id=exam.pk question_number=question_details.current|add:'-1' answer_id=answer.id %}">Set final score</a><br/>
|
||||
|
||||
|
||||
{% if exam.double_mark %}
|
||||
<a href="{% url 'longs:mark_answer_override' exam_id=exam.pk question_number=question_details.current|add:'-1' answer_id=answer.id %}">Set final score</a><br/>
|
||||
{% endif %}
|
||||
|
||||
Return to <a href="{% url 'longs:mark' exam.id question_details.current|add:'-1' %}">question
|
||||
overview</a>, <a href="{% url 'longs:mark_overview' pk=exam.pk %}">marking
|
||||
overview</a><br />
|
||||
|
||||
@@ -543,6 +543,7 @@ def test_exams(db, client):
|
||||
cid_exam_scores_soup.find("div", {"class": "score-overview"}) is None
|
||||
) # check we hide the score overview if not published
|
||||
|
||||
|
||||
# Add another question to the exam
|
||||
create_question(exam)
|
||||
|
||||
|
||||
+5
-204
@@ -526,8 +526,9 @@ class LongUpdate(
|
||||
def form_valid(self, form):
|
||||
# save exam orders (there must be a better way to do this)
|
||||
exam_orders = {}
|
||||
exam: Exam
|
||||
for exam in self.object.exams.all():
|
||||
exam_orders[exam] = list(exam.exam_questions.all())
|
||||
exam_orders[exam] = list(exam.get_questions())
|
||||
|
||||
self.object = form.save(commit=False)
|
||||
self.object.save()
|
||||
@@ -650,7 +651,7 @@ def mark_answer_override(request, exam_id, question_number, cid):
|
||||
def mark_answer(request, exam_id, question_number, answer_id, override=False):
|
||||
exam = get_object_or_404(Exam, pk=exam_id)
|
||||
|
||||
questions = exam.exam_questions.all()
|
||||
questions = exam.get_questions()
|
||||
|
||||
n = question_number
|
||||
|
||||
@@ -845,7 +846,7 @@ def mark_answer(request, exam_id, question_number, answer_id, override=False):
|
||||
def mark(request, exam_id, sk):
|
||||
exam = get_object_or_404(Exam, pk=exam_id)
|
||||
|
||||
questions = exam.exam_questions.all()
|
||||
questions = exam.get_questions()
|
||||
|
||||
n = sk
|
||||
|
||||
@@ -893,206 +894,6 @@ def mark(request, exam_id, sk):
|
||||
)
|
||||
|
||||
|
||||
# @login_required
|
||||
# @user_is_long_marker
|
||||
# def exam_scores_all(request, pk):
|
||||
# exam = get_object_or_404(Exam, pk=pk)
|
||||
#
|
||||
# questions = exam.exam_questions.all()
|
||||
#
|
||||
# cids = (
|
||||
# UserAnswer.objects.filter(question__in=questions, exam__id=pk)
|
||||
# .order_by("cid")
|
||||
# .values_list("cid", flat=True)
|
||||
# .distinct()
|
||||
# )
|
||||
#
|
||||
# user_answers_and_marks = defaultdict(list)
|
||||
# user_answers_marks = defaultdict(list)
|
||||
# user_answers = defaultdict(list)
|
||||
# user_names = {}
|
||||
#
|
||||
# by_question = defaultdict(list)
|
||||
# unmarked = set()
|
||||
#
|
||||
# # Loop through all candidates
|
||||
# for cid in cids:
|
||||
# # Convoluted (probably...)
|
||||
# user_names[cid] = cid
|
||||
# for q in questions:
|
||||
# # Get user answer
|
||||
# s = q.cid_user_answers.filter(cid=cid, exam__id=pk).first()
|
||||
#
|
||||
# if not s:
|
||||
# # skip if no answer, (score 4)
|
||||
# user_answers_marks[cid].append(4)
|
||||
# # user_answers[cid].append("")
|
||||
# by_question[q].append(("", 4))
|
||||
# continue
|
||||
# else:
|
||||
# ans = ""
|
||||
# answer_score = s.get_answer_score()
|
||||
# if answer_score == "":
|
||||
# index = exam.get_question_index(q)
|
||||
# unmarked.add(index)
|
||||
# # user_answers[cid].append(ans)
|
||||
# user_answers_marks[cid].append(answer_score)
|
||||
# # user_answers_and_marks[cid].append((ans, answer_score))
|
||||
#
|
||||
# by_question[q].append((ans, answer_score))
|
||||
#
|
||||
# user_scores = {}
|
||||
# user_scores_normalised = {}
|
||||
# for user in user_answers_marks:
|
||||
# user_scores[user] = sum([i for i in user_answers_marks[user] if i != ""])
|
||||
# user_scores_normalised[user] = normaliseScore(
|
||||
# sum([i for i in user_answers_marks[user] if i != ""])
|
||||
# )
|
||||
#
|
||||
# user_scores_list = list(user_scores.values())
|
||||
#
|
||||
# if len(user_scores_list) < 1:
|
||||
# mean = 0
|
||||
# median = 0
|
||||
# mode = 0
|
||||
# fig_html = ""
|
||||
# else:
|
||||
# mean = statistics.mean(user_scores_list)
|
||||
# median = statistics.median(user_scores_list)
|
||||
# try:
|
||||
# mode = statistics.mode(user_scores_list)
|
||||
# except statistics.StatisticsError:
|
||||
# mode = "No unique mode"
|
||||
#
|
||||
# df = user_scores_list
|
||||
# fig = px.histogram(
|
||||
# df,
|
||||
# x=0,
|
||||
# title="{}: distribution of scores".format(exam),
|
||||
# labels={"0": "Score"},
|
||||
# height=400,
|
||||
# width=600,
|
||||
# )
|
||||
# fig_html = fig.to_html()
|
||||
#
|
||||
# max_score = len(questions) * 2
|
||||
#
|
||||
# return render(
|
||||
# request,
|
||||
# "longs/exam_scores.html",
|
||||
# {
|
||||
# "cids": cids,
|
||||
# "exam": exam,
|
||||
# "unmarked": unmarked,
|
||||
# "questions": questions,
|
||||
# "by_question": by_question,
|
||||
# # "user_answers": dict(user_answers),
|
||||
# "user_answers_marks": dict(user_answers_marks),
|
||||
# "user_scores": user_scores,
|
||||
# "user_scores_normalised": user_scores_normalised,
|
||||
# "user_scores_list": user_scores_list,
|
||||
# "user_names": user_names,
|
||||
# # "user_answers_and_marks": user_answers_and_marks,
|
||||
# "max_score": max_score,
|
||||
# "mean": mean,
|
||||
# "median": median,
|
||||
# "mode": mode,
|
||||
# "plot": fig_html,
|
||||
# },
|
||||
# )
|
||||
|
||||
|
||||
# def exam_scores_cid_user(request, pk, cid, passcode):
|
||||
# exam = get_object_or_404(Exam, pk=pk)
|
||||
#
|
||||
# # TODO:Need some kind of test for cid
|
||||
#
|
||||
# if not exam.exam_mode:
|
||||
# raise Http404("Packet not in exam mode")
|
||||
#
|
||||
# if not exam.check_cid_user(cid, passcode, request):
|
||||
# raise Http404("Error accessing exam")
|
||||
#
|
||||
#
|
||||
# questions = exam.exam_questions.all()
|
||||
#
|
||||
# # answers_and_marks = []
|
||||
# answers_marks = []
|
||||
# # answers = []
|
||||
# answer_text = []
|
||||
#
|
||||
# view_all_results = False
|
||||
# if request.user.groups.filter(name="view_all_results").exists():
|
||||
# view_all_results = True
|
||||
#
|
||||
# for q in questions:
|
||||
# # Get user answer
|
||||
# user_answer = q.cid_user_answers.filter(cid=cid, exam__id=pk).first()
|
||||
#
|
||||
# if not user_answer or user_answer is None:
|
||||
# # skip if no answer
|
||||
# # answers_marks.append("")
|
||||
# # answers.append("")
|
||||
# answer_score = 4
|
||||
# # ans = "Not answered"
|
||||
# answer_text.append(
|
||||
# (
|
||||
# ("Not answered"),
|
||||
# ("Not answered"),
|
||||
# ("Not answered"),
|
||||
# ("Not answered"),
|
||||
# ("Not answered"),
|
||||
# )
|
||||
# )
|
||||
# else:
|
||||
# answer_score = user_answer.get_answer_score()
|
||||
#
|
||||
# answer_text.append(
|
||||
# (
|
||||
# user_answer.answer_observations,
|
||||
# user_answer.answer_interpretation,
|
||||
# user_answer.answer_principle_diagnosis,
|
||||
# user_answer.answer_differential_diagnosis,
|
||||
# user_answer.answer_management,
|
||||
# )
|
||||
# )
|
||||
#
|
||||
# if not exam.publish_results and not view_all_results:
|
||||
# answer_score = 0
|
||||
# # answers.append(ans)
|
||||
# answers_marks.append(answer_score)
|
||||
# # answers_and_marks.append((ans, answer_score, correct_answer))
|
||||
#
|
||||
# answered = [i for i in answers_marks if i != ""]
|
||||
# if "" in answers_marks:
|
||||
# total_score = sum(answered)
|
||||
# unmarked_number = len(answers_marks) - len(answered)
|
||||
# total_score = "{} ({} unmarked)".format(total_score, unmarked_number)
|
||||
# normalised_score = "Not available"
|
||||
# else:
|
||||
# total_score = sum(answered)
|
||||
# normalised_score = normaliseScore(total_score)
|
||||
#
|
||||
# max_score = len(questions) * 8
|
||||
#
|
||||
# return render(
|
||||
# request,
|
||||
# "longs/exam_scores_user.html",
|
||||
# {
|
||||
# "exam": exam,
|
||||
# "cid": cid,
|
||||
# "passcode": passcode,
|
||||
# "questions": questions,
|
||||
# # "answers": answers,
|
||||
# "answers_marks": answers_marks,
|
||||
# "total_score": total_score,
|
||||
# "normalised_score": normalised_score,
|
||||
# "max_score": max_score,
|
||||
# "answer_text": answer_text,
|
||||
# # "answers_and_marks": answers_and_marks,
|
||||
# "view_all_results": view_all_results,
|
||||
# },
|
||||
# )
|
||||
|
||||
|
||||
@login_required
|
||||
@@ -1288,7 +1089,7 @@ def question_review(request, pk):
|
||||
if not exam.publish_results:
|
||||
raise Http404
|
||||
|
||||
question = exam.exam_questions.all()[int(request.POST["question_number"])]
|
||||
question = exam.get_questions()[int(request.POST["question_number"])]
|
||||
|
||||
question_json = question.get_question_json(based=False)
|
||||
return JsonResponse(question_json)
|
||||
|
||||
Reference in New Issue
Block a user