generalise a QuestionBase
This commit is contained in:
+91
-91
@@ -978,97 +978,97 @@ def mark(request, exam_id, sk):
|
||||
# )
|
||||
|
||||
|
||||
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,
|
||||
},
|
||||
)
|
||||
#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
|
||||
|
||||
Reference in New Issue
Block a user