.
This commit is contained in:
@@ -23,6 +23,7 @@ from django.views.generic import TemplateView
|
|||||||
from . import views
|
from . import views
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
from rapids import views as rapid_views
|
from rapids import views as rapid_views
|
||||||
from anatomy import views as anatomy_views
|
from anatomy import views as anatomy_views
|
||||||
from longs import views as long_views
|
from longs import views as long_views
|
||||||
@@ -58,6 +59,7 @@ urlpatterns = [
|
|||||||
path("feedback/<str:question_type>/<int:pk>", views.AddQuestionNote.as_view(), name="feedback_create"),
|
path("feedback/<str:question_type>/<int:pk>", views.AddQuestionNote.as_view(), name="feedback_create"),
|
||||||
#path("feedback/", views.AddQuestionNote.as_view(), name="feedback"),
|
#path("feedback/", views.AddQuestionNote.as_view(), name="feedback"),
|
||||||
path("feedback/answer", views.answer_suggestion_submit, name="answer_suggestion_submit"),
|
path("feedback/answer", views.answer_suggestion_submit, name="answer_suggestion_submit"),
|
||||||
|
path("feedback/answer/confirm", views.answer_suggestion_confirm, name="answer_suggestion_confirm"),
|
||||||
|
|
||||||
|
|
||||||
path('api/', include(router.urls)),
|
path('api/', include(router.urls)),
|
||||||
|
|||||||
+22
-1
@@ -224,4 +224,25 @@ def answer_suggestion_submit(request):
|
|||||||
return JsonResponse({"success": True, "error": "Answer submited"})
|
return JsonResponse({"success": True, "error": "Answer submited"})
|
||||||
|
|
||||||
# postExamAnswers
|
# postExamAnswers
|
||||||
return JsonResponse({"success": False, "error": "Invalid data"})
|
return JsonResponse({"success": False, "error": "Invalid data"})
|
||||||
|
|
||||||
|
@login_required
|
||||||
|
def answer_suggestion_confirm(request):
|
||||||
|
if request.is_ajax and request.method == "POST":
|
||||||
|
j = json.loads(request.body.decode())
|
||||||
|
question_type = j["question_type"]
|
||||||
|
aid = j["aid"]
|
||||||
|
|
||||||
|
if question_type == "anatomy":
|
||||||
|
AnswerModel = AnatomyAnswer
|
||||||
|
question = AnatomyQuestion
|
||||||
|
elif question_type == "rapid":
|
||||||
|
AnswerModel = RapidAnswer
|
||||||
|
question = Rapid
|
||||||
|
else:
|
||||||
|
return JsonResponse({"success": False, "error": "Invalid question type"})
|
||||||
|
|
||||||
|
answer = get_object_or_404(AnswerModel, pk=qid)
|
||||||
|
answer.proposed = False
|
||||||
|
answer.save()
|
||||||
|
return JsonResponse({"success": True, "error": "Answer changed"})
|
||||||
|
|||||||
@@ -30,7 +30,7 @@
|
|||||||
<p><b>Scrapped:</b> {{ question.scrapped }} <a href="{% url 'rapids:rapid_scrap' pk=question.pk %}">(toggle)</a>
|
<p><b>Scrapped:</b> {{ question.scrapped }} <a href="{% url 'rapids:rapid_scrap' pk=question.pk %}">(toggle)</a>
|
||||||
<p class="pre-whitespace">
|
<p class="pre-whitespace">
|
||||||
Answers (score): {% for answer in question.answers.all %}
|
Answers (score): {% for answer in question.answers.all %}
|
||||||
<span {% if answer.proposed %}class="proposed-answer"{% endif %}>
|
<span {% if answer.proposed %}class="proposed-answer" data-aid="{{answer.pk}}" data-question-type="rapid" {% endif %}>
|
||||||
{{ answer }} ({{answer.status}}),
|
{{ answer }} ({{answer.status}}),
|
||||||
</span>
|
</span>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
@@ -55,4 +55,39 @@
|
|||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
<div id="single-dicom-viewer" class="dicom-viewer" data-images="{{ question.GetImageUrls }}" data-annotations=''></div>
|
<div id="single-dicom-viewer" class="dicom-viewer" data-images="{{ question.GetImageUrls }}" data-annotations=''></div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
$(document).ready(function () {
|
||||||
|
// send request to change the is_private state on customSwitches toggle
|
||||||
|
$(".proposed-answer").each((n, el) => {
|
||||||
|
|
||||||
|
$(el).append("<span>SAVE</span>").on("click", function () {
|
||||||
|
$.ajax({
|
||||||
|
url: "{% url 'answer_suggestion_confirm' %}",
|
||||||
|
data: {
|
||||||
|
csrfmiddlewaretoken: "{{ csrf_token }}",
|
||||||
|
//active: this.checked // true if checked else false
|
||||||
|
},
|
||||||
|
body: { question_type: "rapid", aid: el.dataset.aid},
|
||||||
|
type: "POST",
|
||||||
|
dataType: "json",
|
||||||
|
})
|
||||||
|
// $.ajax().done(), $.ajax().fail(), $ajax().always() are upto you. Add/change accordingly
|
||||||
|
.done(function (data) {
|
||||||
|
console.log(data);
|
||||||
|
|
||||||
|
if (data.status == "success") {
|
||||||
|
toastr.info('Exam state changed.')
|
||||||
|
}
|
||||||
|
// show some message according to the response.
|
||||||
|
// For eg. A message box showing that the status has been changed
|
||||||
|
})
|
||||||
|
.always(function () {
|
||||||
|
console.log('[Done]');
|
||||||
|
})
|
||||||
|
})
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
</script>
|
||||||
Reference in New Issue
Block a user