This commit is contained in:
Ross
2021-05-04 21:59:21 +01:00
parent a17f63b510
commit 975c13977e
3 changed files with 19 additions and 6 deletions
+6 -1
View File
@@ -9,7 +9,7 @@ from django.forms import (
from django.forms import inlineformset_factory from django.forms import inlineformset_factory
from generic.models import ( from generic.models import (
Examination Examination, QuestionNote
) )
from django.contrib.admin.widgets import FilteredSelectMultiple from django.contrib.admin.widgets import FilteredSelectMultiple
@@ -20,3 +20,8 @@ class ExaminationForm(ModelForm):
class Meta: class Meta:
model = Examination model = Examination
fields = ["examination"] fields = ["examination"]
class QuestionNoteForm(ModelForm):
class Meta:
model = QuestionNote()
fields = ["question", "author", "note_type", "note"]
+1
View File
@@ -56,6 +56,7 @@ urlpatterns = [
path("exam/submit", views.exam_submit, name="global_exam_answers_submit"), path("exam/submit", views.exam_submit, name="global_exam_answers_submit"),
#path('', include('generic.urls')), #path('', include('generic.urls')),
path("feedback/<str:question_type>/<int:pk>", views.feedback_create, name="feedback_create"), path("feedback/<str:question_type>/<int:pk>", views.feedback_create, name="feedback_create"),
path("feedback/", views.AddQuestionNote().as_view(), name="feedback"),
path('api/', include(router.urls)), path('api/', include(router.urls)),
+10 -3
View File
@@ -41,6 +41,9 @@ from anatomy.views import AnatomyExamViews
from rapids.views import RapidExamViews from rapids.views import RapidExamViews
from longs.views import LongExamViews from longs.views import LongExamViews
from generic.forms import QuestionNoteForm
from generic.models import QuestionNote
@login_required @login_required
def profile(request): def profile(request):
@@ -147,10 +150,14 @@ def exam_submit(request):
def feedback_create(request, question_type, pk): def feedback_create(request, question_type, pk):
if question_type == "anatomy": if question_type == "anatomy":
content_type = ContentType.objects.get(model="AnatomyQuestion") question = AnatomyQuestion
elif question_type == "rapid": elif question_type == "rapid":
content_type = ContentType.objects.get(model="Rapid") question = Rapid
elif question_type == "long": elif question_type == "long":
content_type = ContentType.objects.get(model="Long") question = Long
return JsonResponse({"success": False, "error": "Invalid exam type"}) return JsonResponse({"success": False, "error": "Invalid exam type"})
class AddQuestionNote(LoginRequiredMixin, CreateView):
model = QuestionNote
form_class = QuestionNoteForm