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
+7 -2
View File
@@ -9,7 +9,7 @@ from django.forms import (
from django.forms import inlineformset_factory
from generic.models import (
Examination
Examination, QuestionNote
)
from django.contrib.admin.widgets import FilteredSelectMultiple
@@ -19,4 +19,9 @@ from django.forms.widgets import RadioSelect, TextInput, Textarea
class ExaminationForm(ModelForm):
class Meta:
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('', include('generic.urls')),
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)),
+11 -4
View File
@@ -41,6 +41,9 @@ from anatomy.views import AnatomyExamViews
from rapids.views import RapidExamViews
from longs.views import LongExamViews
from generic.forms import QuestionNoteForm
from generic.models import QuestionNote
@login_required
def profile(request):
@@ -147,10 +150,14 @@ def exam_submit(request):
def feedback_create(request, question_type, pk):
if question_type == "anatomy":
content_type = ContentType.objects.get(model="AnatomyQuestion")
question = AnatomyQuestion
elif question_type == "rapid":
content_type = ContentType.objects.get(model="Rapid")
question = Rapid
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