This commit is contained in:
Ross
2021-12-12 12:40:15 +00:00
parent 90a2ef78d9
commit 1ecd71d799
14 changed files with 320 additions and 289 deletions
+51 -51
View File
@@ -1,62 +1,62 @@
{% extends 'anatomy/base.html' %}
{% block content %}
<div class="question-display-block">
<div class="hide-show">HIDE/SHOW</div>
<div class="inner-display-block">
Question <span class="question-number">No question loaded</span><br/>
<span id="question-title"></span><br/>
<span id="question-question"></span>
<div id="single-dicom-viewer" class="dicom-viewer" data-images="" data-annotations=''>
</div>
<div class="answers">Answers: </div>
<div class="question-display-block">
<div class="hide-show">HIDE/SHOW</div>
<div class="inner-display-block">
Question <span class="question-number">No question loaded</span><br />
<span id="question-title"></span><br />
<span id="question-question"></span>
<div id="single-dicom-viewer" class="dicom-viewer" data-images="" data-annotations=''>
</div>
<div class="answers">Answers: </div>
</div>
<div class="anatomy">
<h2>Exam: {{ exam.name }}</h2>
<h3>Candidate: {{ cid }}</h3>
Answers:
<ul class="score-answer-list">{% for ans, score, correct_answer in answers_and_marks %}
<li class="user-answer-li">Question {{forloop.counter}} - Correct answer: <span
class="correct-answer">{{ correct_answer }}</span></li>
<span class="user-answer-score user-answer-score-{{score}} physics-ans">
<pre>{{ans}}</pre> ({{score}})
</span>
<span class="view-question-link" data-qn={{forloop.counter0}}>View</span>
</div>
<div class="anatomy">
<h2>Exam: {{ exam.name }}</h2>
<h3>Candidate: {{ cid }}</h3>
Answers:
<ul class="score-answer-list">{% for ans, score, correct_answer in answers_and_marks %}
<li class="user-answer-li">Question {{forloop.counter}} - Correct answer: <span class="correct-answer">{{
correct_answer }}</span></li>
<span class="user-answer-score user-answer-score-{{score}} physics-ans">
<pre>{{ans}}</pre> ({{score}})
</span>
<span class="view-question-link" data-qn={{forloop.counter0}}>View</span>
{% endfor %}
</ul>
<br /> Total mark: {{ total_score }} / {{max_score}}
<div>
<a href="{% url 'cid_scores' cid %}">Other exams</a>
</div>
</ul>
<br /> Total mark: {{ total_score }} / {{max_score}}
<div>
<a href="{% url 'cid_scores' cid passcode %}">Other exams</a>
</div>
</div>
{% endblock %}
{% block js %}
<script>
$(document).ready(function () {
$(".hide-show").click((evt, el) => {
$(".inner-display-block").toggle();
})
<script>
$(document).ready(function () {
$(".hide-show").click((evt, el) => {
$(".inner-display-block").toggle();
})
$(".view-question-link").on("click", function (e) {
console.log("click", e)
question_number = e.currentTarget.dataset.qn;
$("#single-dicom-viewer").empty();
$.ajax({
url: `{% url 'anatomy:question_review' pk=exam.pk %}`,
data: {
csrfmiddlewaretoken: "{{ csrf_token }}",
question_number: question_number
},
type: "POST",
dataType: "json",
})
$(".view-question-link").on("click", function (e) {
console.log("click", e)
question_number = e.currentTarget.dataset.qn;
$("#single-dicom-viewer").empty();
$.ajax({
url: `{% url 'anatomy:question_review' pk=exam.pk %}`,
data: {
csrfmiddlewaretoken: "{{ csrf_token }}",
question_number: question_number
},
type: "POST",
dataType: "json",
})
// $.ajax().done(), $.ajax().fail(), $ajax().always() are upto you. Add/change accordingly
.done(function (data) {
.done(function (data) {
console.log(data);
let event = new CustomEvent('loadDicomViewerUrls', {
"detail": {"images" : data.images, "annotations" : data.annotations}
"detail": { "images": data.images, "annotations": data.annotations }
});
window.dispatchEvent(event);
@@ -67,13 +67,13 @@
$(".question-display-block .question-number").empty().append(n);
$(".inner-display-block").show();
})
.always(function () {
.always(function () {
console.log('[Done]');
})
})
})
$(".view-question-link").first().click();
$(".view-question-link").first().click();
});
</script>
{% endblock %}
});
</script>
{% endblock %}
+1 -1
View File
@@ -76,7 +76,7 @@ urlpatterns = [
name="exam_scores_cid",
),
path(
"exam/<int:pk>/scores/<int:sk>/",
"exam/<int:pk>/scores/<int:sk>/<str:passcode>/",
views.exam_scores_cid_user,
name="exam_scores_cid_user",
),
+93 -91
View File
@@ -134,89 +134,89 @@ def answer_question(request, pk):
)
@login_required
def exam_take(request, pk, sk):
"""
Allows taking of the exam on the django server (when logged in)
No longer used (deprecated in favour of using RTS)
"""
exam = get_object_or_404(Exam, pk=pk)
questions = exam.exam_questions.all()
try:
question = questions[sk]
except IndexError:
raise Http404("Exam question does not exist")
n = sk
question_details = {
"total": len(questions),
"current": n + 1,
}
# Get data for flagged
# answered_questions = UserAnswer.objects.filter(user=request.user).values_list("question__pk", flat=True)
user_answer_data = UserAnswer.objects.filter(user=request.user).values_list(
"question__pk", "answer", "flagged"
)
# flagged_questions = UserAnswer.objects.filter(user=request.user, flagged=True).values_list("question__pk", flat=True)
# flagged_questions I= UserAnswer.filter(user=request.user, ).values_list("question__pk", flat=True)
answered_questions = set()
flagged_questions = set()
for ans_pk, answer, flagged in user_answer_data:
if len(answer.strip()) > 0:
answered_questions.add(ans_pk)
if flagged:
flagged_questions.add(ans_pk)
# u = question.user_answers
answer = question.user_answers.filter(
user=request.user
).first() # .filter(user=User)
if request.method == "POST":
if answer:
form = AnatomyAnswerForm(request.POST, instance=answer)
else:
form = AnatomyAnswerForm(request.POST)
if form.is_valid():
answer = form.save(commit=False)
answer.user = request.user
answer.question = question
# answer.published_date = timezone.now()
answer.save()
if "next" in request.POST:
return redirect("anatomy:exam_take", pk=pk, sk=n + 1)
elif "previous" in request.POST:
return redirect("anatomy:exam_take", pk=pk, sk=n - 1)
else:
form = AnatomyAnswerForm(instance=answer)
return render(
request,
"anatomy/exam.html",
{
"exam": exam,
"form": form,
"question": question,
"question_details": question_details,
"questions": questions,
"flagged_questions": flagged_questions,
"answered_questions": answered_questions,
"answer": answer,
},
)
#@login_required
#def exam_take(request, pk, sk):
# """
# Allows taking of the exam on the django server (when logged in)
#
# No longer used (deprecated in favour of using RTS)
# """
# exam = get_object_or_404(Exam, pk=pk)
#
# questions = exam.exam_questions.all()
#
# try:
# question = questions[sk]
# except IndexError:
# raise Http404("Exam question does not exist")
#
# n = sk
#
# question_details = {
# "total": len(questions),
# "current": n + 1,
# }
#
# # Get data for flagged
# # answered_questions = UserAnswer.objects.filter(user=request.user).values_list("question__pk", flat=True)
# user_answer_data = UserAnswer.objects.filter(user=request.user).values_list(
# "question__pk", "answer", "flagged"
# )
# # flagged_questions = UserAnswer.objects.filter(user=request.user, flagged=True).values_list("question__pk", flat=True)
# # flagged_questions I= UserAnswer.filter(user=request.user, ).values_list("question__pk", flat=True)
#
# answered_questions = set()
# flagged_questions = set()
# for ans_pk, answer, flagged in user_answer_data:
# if len(answer.strip()) > 0:
# answered_questions.add(ans_pk)
# if flagged:
# flagged_questions.add(ans_pk)
#
# # u = question.user_answers
# answer = question.user_answers.filter(
# user=request.user
# ).first() # .filter(user=User)
# if request.method == "POST":
# if answer:
# form = AnatomyAnswerForm(request.POST, instance=answer)
# else:
# form = AnatomyAnswerForm(request.POST)
# if form.is_valid():
# answer = form.save(commit=False)
# answer.user = request.user
# answer.question = question
# # answer.published_date = timezone.now()
# answer.save()
# if "next" in request.POST:
# return redirect("anatomy:exam_take", pk=pk, sk=n + 1)
# elif "previous" in request.POST:
# return redirect("anatomy:exam_take", pk=pk, sk=n - 1)
# else:
# form = AnatomyAnswerForm(instance=answer)
# return render(
# request,
# "anatomy/exam.html",
# {
# "exam": exam,
# "form": form,
# "question": question,
# "question_details": question_details,
# "questions": questions,
# "flagged_questions": flagged_questions,
# "answered_questions": answered_questions,
# "answer": answer,
# },
# )
def flag_question(request):
pk = request.GET.get("pk", None)
ans = UserAnswer.objects.filter(user=request.user, question__pk=pk).first()
ans.flagged = not ans.flagged
ans.save()
data = {"flagged": ans.flagged}
return JsonResponse(data)
#def flag_question(request):
# pk = request.GET.get("pk", None)
# ans = UserAnswer.objects.filter(user=request.user, question__pk=pk).first()
# ans.flagged = not ans.flagged
# ans.save()
# data = {"flagged": ans.flagged}
# return JsonResponse(data)
def loadJsonAnswer(answer):
@@ -329,8 +329,7 @@ def mark(request, exam_pk, sk, unmarked_exam_answers_only=True, review=False):
except IndexError:
raise Http404("Exam question does not exist")
#unmarked_user_answers = question.get_unmarked_user_answers()
# unmarked_user_answers = question.get_unmarked_user_answers()
if request.method == "POST":
@@ -383,9 +382,9 @@ def mark(request, exam_pk, sk, unmarked_exam_answers_only=True, review=False):
else:
form = MarkAnatomyQuestionForm()
#correct_answers = question.answers.filter(status=Answer.MarkOptions.CORRECT)
#half_mark_answers = question.answers.filter(status=Answer.MarkOptions.HALF_MARK)
#incorrect_answers = question.answers.filter(status=Answer.MarkOptions.INCORRECT)
# correct_answers = question.answers.filter(status=Answer.MarkOptions.CORRECT)
# half_mark_answers = question.answers.filter(status=Answer.MarkOptions.HALF_MARK)
# incorrect_answers = question.answers.filter(status=Answer.MarkOptions.INCORRECT)
correct_answers = []
half_mark_answers = []
@@ -395,13 +394,14 @@ def mark(request, exam_pk, sk, unmarked_exam_answers_only=True, review=False):
unmarked_user_answers = []
if review:
unmarked_user_answers = question.get_user_answers(exam_pk=exam_pk, include_normal=False)
unmarked_user_answers = question.get_user_answers(
exam_pk=exam_pk, include_normal=False
)
elif unmarked_exam_answers_only:
unmarked_user_answers = question.get_unmarked_user_answers(exam_pk=exam_pk)
else:
unmarked_user_answers = question.get_unmarked_user_answers()
if not unmarked_exam_answers_only:
correct_answers = question.answers.filter(status=Answer.MarkOptions.CORRECT)
half_mark_answers = question.answers.filter(status=Answer.MarkOptions.HALF_MARK)
@@ -532,6 +532,7 @@ def exam_scores_cid(request, pk):
"anatomy/exam_scores.html",
{
"cids": cids,
"passcode": passcode,
"exam": exam,
"unmarked": unmarked,
"questions": questions,
@@ -551,14 +552,15 @@ def exam_scores_cid(request, pk):
)
def exam_scores_cid_user(request, pk, sk):
def exam_scores_cid_user(request, pk, sk, passcode):
exam = get_object_or_404(Exam, pk=pk)
if not exam.exam_mode:
raise Http404("Packet not in exam mode")
# TODO:Need some kind of test for cid
cid = sk
if not exam.check_cid_user(cid, passcode):
raise Http404("Error accessing exam")
questions = exam.exam_questions.all()
@@ -609,6 +611,7 @@ def exam_scores_cid_user(request, pk, sk):
{
"exam": exam,
"cid": cid,
"passcode": passcode,
"questions": questions,
"answers": answers,
"answers_marks": answers_marks,
@@ -1051,5 +1054,4 @@ class StructureAutocomplete(autocomplete.Select2QuerySetView):
except FieldError:
return Structure.objects.none()
return qs
+72 -71
View File
@@ -1,82 +1,83 @@
{% extends 'longs/base.html' %}
{% block content %}
<div class="question-display-block">
<div class="hide-show">HIDE/SHOW</div>
<div class="inner-display-block">
Question <span class="question-number">1</span><br />
History: <span id="history"></span><br />
Images: <span id="series"></span>
<div id="single-dicom-viewer" class="dicom-viewer" data-images="" data-annotations=''>
</div>
<div class="question-display-block">
<div class="hide-show">HIDE/SHOW</div>
<div class="inner-display-block">
Question <span class="question-number">1</span><br />
History: <span id="history"></span><br />
Images: <span id="series"></span>
<div id="single-dicom-viewer" class="dicom-viewer" data-images="" data-annotations=''>
</div>
</div>
<div class="longs">
<h2>Exam: {{ exam.name }}</h2>
<h3>Candidate: {{ cid }}</h3>
Scores:
<ul>{% for score in answers_marks %}
<li class="user-answer-li">Question {{forloop.counter}}</li>
<span class="user-answer-score user-answer-score-{{score}}">
<pre>{{ans}}</pre> ({{score}})</span>
</div>
<div class="longs">
<h2>Exam: {{ exam.name }}</h2>
<h3>Candidate: {{ cid }}</h3>
Scores:
<ul>{% for score in answers_marks %}
<li class="user-answer-li">Question {{forloop.counter}}</li>
<span class="user-answer-score user-answer-score-{{score}}">
<pre>{{ans}}</pre> ({{score}})
</span>
{% endfor %}
</ul>
<br /> Total mark: {{ total_score }} / {{max_score}}
<br /> Normalised score: {{normalised_score}}
<div>
<h4>Answers</h4>
<ul class="long-answer">{% for a,b,c,d,e in answer_text %}
<li class="user-answer-li"><b>Question {{forloop.counter}}</b> <span class="view-question-link-longs"
</ul>
<br /> Total mark: {{ total_score }} / {{max_score}}
<br /> Normalised score: {{normalised_score}}
<div>
<h4>Answers</h4>
<ul class="long-answer">{% for a,b,c,d,e in answer_text %}
<li class="user-answer-li"><b>Question {{forloop.counter}}</b> <span class="view-question-link-longs"
data-qn={{forloop.counter0}}>View</span></li>
<ul>
<li class="user-answer-li">Observation</br>
<pre>{{a}}</pre>
</li>
<li class="user-answer-li">Interpretation</br>
<pre>{{b}}</pre>
</li>
<li class="user-answer-li">Principle Diagnosis</br>
<pre>{{c}}</pre>
</li>
<li class="user-answer-li">Differential Diagnosis</br>
<pre>{{d}}</pre>
</li>
<li class="user-answer-li">Management</br>
<pre>{{e}}</pre>
</li>
</ul>
{% endfor %}
<ul>
<li class="user-answer-li">Observation</br>
<pre>{{a}}</pre>
</li>
<li class="user-answer-li">Interpretation</br>
<pre>{{b}}</pre>
</li>
<li class="user-answer-li">Principle Diagnosis</br>
<pre>{{c}}</pre>
</li>
<li class="user-answer-li">Differential Diagnosis</br>
<pre>{{d}}</pre>
</li>
<li class="user-answer-li">Management</br>
<pre>{{e}}</pre>
</li>
</ul>
{% endfor %}
</ul>
</div>
<div>
<a href="{% url 'cid_scores' cid %}">Other exams</a>
</div>
</div>
<div>
<a href="{% url 'cid_scores' cid passcode %}">Other exams</a>
</div>
</div>
{% endblock %}
{% block js %}
<script>
$(document).ready(function () {
$(".hide-show").click((evt, el) => {
$(".inner-display-block").toggle();
})
<script>
$(document).ready(function () {
$(".hide-show").click((evt, el) => {
$(".inner-display-block").toggle();
})
$(".view-question-link-longs").on("click", function (e) {
console.log("click", e)
question_number = e.currentTarget.dataset.qn;
$("#single-dicom-viewer").empty();
$.ajax({
url: `{% url 'longs:question_review' pk=exam.pk %}`,
data: {
csrfmiddlewaretoken: "{{ csrf_token }}",
question_number: question_number
},
type: "POST",
dataType: "json",
})
$(".view-question-link-longs").on("click", function (e) {
console.log("click", e)
question_number = e.currentTarget.dataset.qn;
$("#single-dicom-viewer").empty();
$.ajax({
url: `{% url 'longs:question_review' pk=exam.pk %}`,
data: {
csrfmiddlewaretoken: "{{ csrf_token }}",
question_number: question_number
},
type: "POST",
dataType: "json",
})
// $.ajax().done(), $.ajax().fail(), $ajax().always() are upto you. Add/change accordingly
.done(function (data) {
.done(function (data) {
console.log(data);
let event = new CustomEvent('loadDicomViewerUrls', {
@@ -93,7 +94,7 @@
$("#series").empty();
data.image_titles.forEach((element, index) => {
$("#series").append($(
`<span class="image-link" title="click to view">${index+1}: ${element}</span> `
`<span class="image-link" title="click to view">${index + 1}: ${element}</span> `
).click(() => {
$("#single-dicom-viewer").empty();
let event = new CustomEvent('loadDicomViewerUrls', {
@@ -110,13 +111,13 @@
})
$(".inner-display-block").show();
})
.always(function () {
.always(function () {
console.log('[Done]');
})
})
})
$(".view-question-link").first().click();
$(".view-question-link").first().click();
});
</script>
{% endblock %}
});
</script>
{% endblock %}
+16 -4
View File
@@ -66,9 +66,21 @@ urlpatterns = [
views.question_review,
name="question_review",
),
path("exam/<int:exam_id>/<int:question_number>/<int:cid>/mark", views.mark_answer, name="mark_answer"),
path("exam/<int:exam_id>/<int:question_number>/<int:cid>/mark_override", views.mark_answer_override, name="mark_answer_override"),
path("exam/<int:exam_id>/<int:sk>/mark", views.mark_question_overview, name="mark_question_overview"),
path(
"exam/<int:exam_id>/<int:question_number>/<int:cid>/mark",
views.mark_answer,
name="mark_answer",
),
path(
"exam/<int:exam_id>/<int:question_number>/<int:cid>/mark_override",
views.mark_answer_override,
name="mark_answer_override",
),
path(
"exam/<int:exam_id>/<int:sk>/mark",
views.mark_question_overview,
name="mark_question_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(
@@ -89,7 +101,7 @@ urlpatterns = [
),
path("exam/<int:pk>/scores", views.exam_scores_cid, name="exam_scores_cid"),
path(
"exam/<int:pk>/scores/<int:sk>/",
"exam/<int:pk>/scores/<int:sk>/<str:passcode>/",
views.exam_scores_cid_user,
name="exam_scores_cid_user",
),
+2 -1
View File
@@ -1032,7 +1032,7 @@ def exam_scores_cid(request, pk):
)
def exam_scores_cid_user(request, pk, sk):
def exam_scores_cid_user(request, pk, sk, passcode):
exam = get_object_or_404(Exam, pk=pk)
# TODO:Need some kind of test for cid
@@ -1104,6 +1104,7 @@ def exam_scores_cid_user(request, pk, sk):
{
"exam": exam,
"cid": cid,
"passcode" : passcode,
"questions": questions,
# "answers": answers,
"answers_marks": answers_marks,
@@ -10,7 +10,8 @@
<li class="user-answer-li">Question {{forloop.counter}} - {{ question.stem }}</li>
<ol type="a">
{% for q, a, score, correct_answer in ans %}
<li>{{q}}: Correct answer: {{correct_answer}} <br />{{a}} <span class="answer-{{score}}">(Score: {{score}})</span></li>
<li>{{q}}: Correct answer: {{correct_answer}} <br />{{a}} <span class="answer-{{score}}">(Score:
{{score}})</span></li>
{% endfor %}
</ol>
{% endfor %}
+3 -4
View File
@@ -88,7 +88,7 @@ def active_exams(request):
@login_required
def exam_scores_cid(request, pk, passcode):
def exam_scores_cid(request, pk):
exam = get_object_or_404(Exam, pk=pk)
questions = exam.exam_questions.all()
@@ -170,7 +170,6 @@ def exam_scores_cid(request, pk, passcode):
"physics/exam_scores.html",
{
"cids": cids,
"passcode": passcode,
"exam": exam,
"unmarked": unmarked,
"questions": questions,
@@ -281,7 +280,7 @@ def exam_start(request, pk):
)
def exam_finish(request, pk, cid, passcode=None):
def exam_finish(request, pk, cid, passcode):
exam = get_object_or_404(Exam, pk=pk)
if not exam.check_cid_user(cid, passcode):
@@ -322,7 +321,7 @@ def exam_finish(request, pk, cid, passcode=None):
)
def exam_take(request, pk, sk, cid, passcode=None):
def exam_take(request, pk, sk, cid, passcode):
exam = get_object_or_404(Exam, pk=pk)
+50 -50
View File
@@ -1,62 +1,62 @@
{% extends 'rapids/base.html' %}
{% block content %}
<div class="question-display-block">
<div class="hide-show">HIDE/SHOW</div>
<div class="inner-display-block">
Question <span class="question-number">1</span>
<div id="single-dicom-viewer" class="dicom-viewer" data-images="" data-annotations=''>
</div>
<div class="answers">Answers: </div>
<div class="question-display-block">
<div class="hide-show">HIDE/SHOW</div>
<div class="inner-display-block">
Question <span class="question-number">1</span>
<div id="single-dicom-viewer" class="dicom-viewer" data-images="" data-annotations=''>
</div>
<div class="answers">Answers: </div>
</div>
<div class="rapids">
<h2>Exam: {{ exam.name }}</h2>
<h3>Candidate: {{ cid }}</h3>
Answers:
<ul class="score-answer-list">{% for ans, score, correct_answer in answers_and_marks %}
<li class="user-answer-li">Question {{forloop.counter}} - Correct answer: <span
class="correct-answer">{{ correct_answer }}</span></li>
<span class="user-answer-score user-answer-score-{{score}} rapid-ans">
<pre>{{ans}}</pre> ({{score}})
</span>
<span class="view-question-link" data-qn={{forloop.counter0}}>View</span>
</div>
<div class="rapids">
<h2>Exam: {{ exam.name }}</h2>
<h3>Candidate: {{ cid }}</h3>
Answers:
<ul class="score-answer-list">{% for ans, score, correct_answer in answers_and_marks %}
<li class="user-answer-li">Question {{forloop.counter}} - Correct answer: <span class="correct-answer">{{
correct_answer }}</span></li>
<span class="user-answer-score user-answer-score-{{score}} rapid-ans">
<pre>{{ans}}</pre> ({{score}})
</span>
<span class="view-question-link" data-qn={{forloop.counter0}}>View</span>
{% endfor %}
</ul>
<br /> Total mark: {{ total_score }} / {{max_score}}
<br /> Normalised score: {{ normalised_score }}
<div>
<a href="{% url 'cid_scores' cid %}">Other exams</a>
</div>
</ul>
<br /> Total mark: {{ total_score }} / {{max_score}}
<br /> Normalised score: {{ normalised_score }}
<div>
<a href="{% url 'cid_scores' cid passcode %}">Other exams</a>
</div>
</div>
{% endblock %}
{% block js %}
<script>
<script>
$(document).ready(function () {
$(".hide-show").click((evt, el) => {
$(".inner-display-block").toggle();
$(document).ready(function () {
$(".hide-show").click((evt, el) => {
$(".inner-display-block").toggle();
})
$(".view-question-link").on("click", function (e) {
console.log("click", e)
question_number = e.currentTarget.dataset.qn;
$("#single-dicom-viewer").empty();
$.ajax({
url: `{% url 'rapids:question_review' pk=exam.pk %}`,
data: {
csrfmiddlewaretoken: "{{ csrf_token }}",
question_number: question_number
},
type: "POST",
dataType: "json",
})
$(".view-question-link").on("click", function (e) {
console.log("click", e)
question_number = e.currentTarget.dataset.qn;
$("#single-dicom-viewer").empty();
$.ajax({
url: `{% url 'rapids:question_review' pk=exam.pk %}`,
data: {
csrfmiddlewaretoken: "{{ csrf_token }}",
question_number: question_number
},
type: "POST",
dataType: "json",
})
// $.ajax().done(), $.ajax().fail(), $ajax().always() are upto you. Add/change accordingly
.done(function (data) {
.done(function (data) {
console.log(data);
let event = new CustomEvent('loadDicomViewerUrls', {
"detail": {"images" : data.images, "annotations" : data.annotations}
"detail": { "images": data.images, "annotations": data.annotations }
});
window.dispatchEvent(event);
@@ -67,13 +67,13 @@
// For eg. A message box showing that the status has been changed
$(".inner-display-block").show();
})
.always(function () {
.always(function () {
console.log('[Done]');
})
})
})
$(".view-question-link").first().click();
$(".view-question-link").first().click();
});
</script>
{% endblock %}
});
</script>
{% endblock %}
+1 -1
View File
@@ -76,7 +76,7 @@ urlpatterns = [
name="exam_scores_cid",
),
path(
"exam/<int:pk>/scores/<int:cid>/",
"exam/<int:pk>/scores/<int:cid>/<str:passcode>/",
views.exam_scores_cid_user,
name="exam_scores_cid_user",
),
+2 -1
View File
@@ -846,7 +846,7 @@ def exam_scores_cid(request, pk):
)
def exam_scores_cid_user(request, pk, cid):
def exam_scores_cid_user(request, pk, cid, passcode):
exam = get_object_or_404(Exam, pk=pk)
if not exam.exam_mode:
@@ -908,6 +908,7 @@ def exam_scores_cid_user(request, pk, cid):
{
"exam": exam,
"cid": cid,
"passcode" : passcode,
"questions": questions,
"answers": answers,
"answers_marks": answers_marks,
+5 -3
View File
@@ -7,13 +7,15 @@
Answers:
<ul>
{% for question, a, score, correct_answer in answers_and_marks %}
<li class="user-answer-li"><a href="{% url 'sbas:exam_take' exam.pk forloop.counter0 cid %}">Question {{forloop.counter}}</a> - {{ question.stem |safe}}</li>
<span>Correct answer: {{correct_answer|safe}} <br />{{a}} <span class="answer-{{score}}">(Score: {{score}})</span></span>
<li class="user-answer-li"><a href="{% url 'sbas:exam_take' exam.pk forloop.counter0 cid %}">Question
{{forloop.counter}}</a> - {{ question.stem |safe}}</li>
<span>Correct answer: {{correct_answer|safe}} <br />{{a}} <span class="answer-{{score}}">(Score:
{{score}})</span></span>
{% endfor %}
</ul>
<br /> Total mark: {{ total_score }} / {{max_score}}
<div>
<a href="{% url 'cid_scores' cid %}">Other exams</a>
<a href="{% url 'cid_scores' cid passcode %}">Other exams</a>
</div>
</div>
{% endblock %}
+3 -3
View File
@@ -14,9 +14,9 @@ urlpatterns = [
# path("question/<int:pk>/update", views.QuestionUpdate.as_view(), name="anatomy_question_update"),
# path("exam/<int:pk>/<int:sk>/mark", views.mark, name="mark"),
# path("exam/<int:pk>/mark", views.mark_overview, name="mark_overview"),
path("exam/<int:pk>/<int:sk>/<str:cid>/take", views.exam_take, name="exam_take"),
path("exam/<int:pk>/<int:sk>/<str:cid>/<str:passcode>/take", views.exam_take, name="exam_take"),
path("exam/<int:pk>/start", views.exam_start, name="exam_start"),
path("exam/<int:pk>/<str:cid>/finish", views.exam_finish, name="exam_finish"),
path("exam/<int:pk>/<str:cid>/<str:passcode>/finish", views.exam_finish, name="exam_finish"),
path("exam/<int:pk>/", views.SbasExamViews.exam_overview, name="exam_overview"),
path(
"exam/<int:pk>/scores",
@@ -24,7 +24,7 @@ urlpatterns = [
name="exam_scores_cid",
),
path(
"exam/<int:pk>/scores/<int:sk>/",
"exam/<int:pk>/scores/<int:sk>/<str:passcode>/",
views.exam_scores_cid_user,
name="exam_scores_cid_user",
),
+19 -7
View File
@@ -179,7 +179,7 @@ def exam_scores_cid(request, pk):
)
def exam_scores_cid_user(request, pk, sk):
def exam_scores_cid_user(request, pk, sk, passcode):
exam = get_object_or_404(Exam, pk=pk)
# TODO:Need some kind of test for cid
@@ -229,6 +229,7 @@ def exam_scores_cid_user(request, pk, sk):
{
"exam": exam,
"cid": cid,
"passcode" : passcode,
"questions": questions,
"answers": answers,
"answers_marks": answers_marks,
@@ -253,9 +254,12 @@ def exam_start(request, pk):
},
)
def exam_finish(request, pk, cid):
def exam_finish(request, pk, cid, passcode):
exam = get_object_or_404(Exam, pk=pk)
if not exam.check_cid_user(cid, passcode):
raise Http404("Error accessing exam")
questions = exam.exam_questions.all()
answers = CidUserAnswer.objects.filter(
@@ -286,17 +290,21 @@ def exam_finish(request, pk, cid):
"question_answer_tuples": question_answer_tuples,
"answer_count": answer_count,
"exam_length": len(questions),
"passcode": passcode,
},
)
def exam_take(request, pk, sk, cid):
def exam_take(request, pk, sk, cid, passcode):
exam = get_object_or_404(Exam, pk=pk)
if not exam.active:
raise Http404("Exam not found")
if not exam.check_cid_user(cid, passcode):
raise Http404("Error accessing exam")
question = exam.exam_questions.all()[sk]
exam_length = len(exam.exam_questions.all())
@@ -318,14 +326,17 @@ def exam_take(request, pk, sk, cid):
answer.exam = exam
# answer.published_date = timezone.now()
answer.save()
kwargs = {"pk": pk, "cid": cid, "passcode": passcode}
if "next" in request.POST:
return redirect("sbas:exam_take", pk=pk, sk=pos + 1, cid=cid)
return redirect("sbas:exam_take", sk=pos + 1, **kwargs)
elif "previous" in request.POST:
return redirect("sbas:exam_take", pk=pk, sk=pos - 1, cid=cid)
return redirect("sbas:exam_take", sk=pos - 1, **kwargs)
elif "finish" in request.POST:
return redirect("sbas:exam_finish", pk=pk, cid=cid)
return redirect("sbas:exam_finish", **kwargs)
elif "goto" in request.POST:
return redirect("sbas:exam_take", pk=pk, sk=int(request.POST.get("goto")), cid=cid)
return redirect("sbas:exam_take", sk=int(request.POST.get("goto")), **kwargs)
else:
form = CidUserAnswerForm(instance=answer)
@@ -354,6 +365,7 @@ def exam_take(request, pk, sk, cid):
"exam_length": exam_length,
"pos": pos,
"saved_answer": saved_answer,
"passcode": passcode,
},
)